customize.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. {% extends '../layout/admin.html' %}
  2. {% block html_title %}{{ customTitle(t('Customize')) }} {% endblock %}
  3. {% block style_css_block %}
  4. <link rel="stylesheet" href="{{ webpack_asset('style').css }}">
  5. <link rel="stylesheet" id="jssDefault" {# append id for theme selector #} href="{{ webpack_asset('style-theme-' + theme()).css }}">
  6. {% endblock %}
  7. {% block html_additional_headers %}
  8. {% parent %}
  9. <!-- CodeMirror -->
  10. <link rel="stylesheet" href="https://cdn.jsdelivr.net/jquery.ui/1.11.4/jquery-ui.min.css">
  11. <style>
  12. .CodeMirror {
  13. border: 1px solid #eee;
  14. }
  15. </style>
  16. {% endblock %}
  17. {% block content_header %}
  18. <div class="header-wrap">
  19. <header id="page-header">
  20. <h1 class="title" id="">{{ t('Customize') }} </h1>
  21. </header>
  22. </div>
  23. {% endblock %}
  24. {% block content_main %}
  25. <div class="content-main admin-customize">
  26. {% set smessage = req.flash('successMessage') %}
  27. {% if smessage.length %}
  28. <div class="alert alert-success">
  29. {{ smessage }}
  30. </div>
  31. {% endif %}
  32. {% set emessage = req.flash('errorMessage') %}
  33. {% if emessage.length %}
  34. <div class="alert alert-danger">
  35. {{ emessage }}
  36. </div>
  37. {% endif %}
  38. <div class="row">
  39. <div class="col-md-3">
  40. {% include './widget/menu.html' with {current: 'customize'} %}
  41. </div>
  42. <div class="col-md-9">
  43. <form action="/_api/admin/customize/theme" method="post" class="form-horizontal" id="customthemeSettingForm" role="form">
  44. <fieldset>
  45. <legend>{{ t('customize_page.Theme') }}</legend>
  46. <div id="themeOptions" class="d-flex">
  47. <a id="theme-option-default" href="#"
  48. class="default {% if 'default' === settingForm['customize:theme'] %}active{% endif %}"
  49. onclick="selectTheme('default')"
  50. data-theme="{{ webpack_asset('style-theme-default').css }}">
  51. {% include 'widget/theme-colorbox.html' %}
  52. </a>
  53. <a id="theme-option-default-dark" href="#"
  54. class="default-dark {% if 'default-dark' === settingForm['customize:theme'] %}active{% endif %}"
  55. onclick="selectTheme('default-dark')"
  56. data-theme="{{ webpack_asset('style-theme-default-dark').css }}">
  57. {% include 'widget/theme-colorbox.html' %}
  58. </a>
  59. <a id="theme-option-nature"
  60. class="nature"
  61. data-theme="{{ webpack_asset('style-theme-nature').css }}">
  62. {% include 'widget/theme-colorbox.html' %}
  63. </a>
  64. </div>
  65. <div class="form-group">
  66. <div class="col-xs-offset-5 col-xs-6">
  67. <input type="hidden" id="hiddenInputTheme" name="settingForm[customize:theme]" value="{{ settingForm['customize:theme'] }}">
  68. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  69. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  70. </div>
  71. </div>
  72. </fieldset>
  73. </form>
  74. <form action="/_api/admin/customize/behavior" method="post" class="form-horizontal" id="cutombehaviorSettingForm" role="form">
  75. <fieldset>
  76. <legend>{{ t('customize_page.Behavior') }}</legend>
  77. {% set isBehaviorGrowi = 'growi' === settingForm['customize:behavior'] || 'crowi-plus' === settingForm['customize:behavior'] %}
  78. <div class="form-group">
  79. <div class="col-xs-6">
  80. <h4>
  81. <div class="radio radio-primary">
  82. <input type="radio" id="radioBehaviorGrowi" name="settingForm[customize:behavior]" value="growi"
  83. {% if isBehaviorGrowi %}checked="checked"{% endif %}>
  84. <label for="radioBehaviorGrowi">
  85. GROWI Simplified Behavior <small class="text-success">(Recommended)</small>
  86. </label>
  87. </div>
  88. </h4>
  89. <ul>
  90. <li>Both of <code>/page</code> and <code>/page/</code> shows the same page</li>
  91. <li><code>/nonexistent_page</code> shows editing form</li>
  92. <li>All pages shows the list of sub pages <b>if using GROWI Enhanced Layout</b></li>
  93. </ul>
  94. </div>
  95. <div class="col-xs-6">
  96. <h4>
  97. <div class="radio radio-primary">
  98. <input type="radio" id="radioBehaviorCrowi" name="settingForm[customize:behavior]" value="crowi"
  99. {% if !isBehaviorGrowi %}checked="checked"{% endif %}>
  100. <label for="radioBehaviorCrowi">
  101. Crowi Classic Behavior
  102. </label>
  103. </div>
  104. </h4>
  105. <ul>
  106. <li><code>/page</code> shows the page</li>
  107. <li><code>/page/</code> shows the list of sub pages</li>
  108. <ul>
  109. <li>If portal is applied to <code>/page/</code> , the portal and the list of sub pages are shown</li>
  110. </ul>
  111. <li><code>/nonexistent_page</code> shows editing form</li>
  112. <li><code>/nonexistent_page/</code> the list of sub pages</li>
  113. </ul>
  114. </div>
  115. </div>
  116. <div class="form-group">
  117. <div class="col-xs-offset-5 col-xs-6">
  118. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  119. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  120. </div>
  121. </div>
  122. </fieldset>
  123. </form>
  124. <form action="/_api/admin/customize/layout" method="post" class="form-horizontal" id="cutomlayoutSettingForm" role="form">
  125. <fieldset>
  126. <legend>{{ t('customize_page.Layout') }}</legend>
  127. {% set isLayoutGrowi = 'growi' === settingForm['customize:layout'] || 'crowi-plus' === settingForm['customize:layout'] %}
  128. <div class="form-group">
  129. <div class="col-xs-6">
  130. <h4>
  131. <div class="radio radio-primary">
  132. <input type="radio" id="radioLayoutGrowi" name="settingForm[customize:layout]" value="growi"
  133. {% if isLayoutGrowi %}checked="checked"{% endif %}>
  134. <label for="radioLayoutGrowi">
  135. GROWI Enhanced Layout <small class="text-success">(Recommended)</small>
  136. </label>
  137. </div>
  138. </h4>
  139. <a href="/images/admin/customize/layout-crowi-plus.gif" class="ss-container">
  140. <img src="/images/admin/customize/layout-crowi-plus-thumb.gif" width="240px">
  141. </a>
  142. <ul>
  143. <li>Simple and Clear</li>
  144. <ul>
  145. <li>Show and post comments from the bottom of the page</li>
  146. <li>Affix Table-of-contents</li>
  147. </ul>
  148. </ul>
  149. </div>
  150. <div class="col-xs-6">
  151. <h4>
  152. <div class="radio radio-primary">
  153. <input type="radio" id="radioLayoutCrowi" name="settingForm[customize:layout]" value="crowi"
  154. {% if !isLayoutGrowi %}checked="checked"{% endif %}>
  155. <label for="radioLayoutCrowi">
  156. Crowi Classic Layout
  157. </label>
  158. </div>
  159. </h4>
  160. <a href="/images/admin/customize/layout-classic.gif" class="ss-container">
  161. <img src="/images/admin/customize/layout-classic-thumb.gif" width="240px">
  162. </a>
  163. <ul>
  164. <li>Functional</li>
  165. <ul>
  166. <li>Collapsible Sidebar</li>
  167. <li>Show and post comments in Sidebar</li>
  168. <li>Collapsible Table-of-contents</li>
  169. </ul>
  170. </ul>
  171. </div>
  172. </div>
  173. <div class="form-group">
  174. <div class="col-xs-offset-5 col-xs-6">
  175. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  176. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  177. </div>
  178. </div>
  179. </fieldset>
  180. </form>
  181. <form action="/_api/admin/customize/features" method="post" class="form-horizontal" id="customfeaturesSettingForm" role="form">
  182. <fieldset>
  183. <legend>{{ t('customize_page.Function') }}</legend>
  184. <p class="well">{{ t("customize_page.function_choose") }}</p>
  185. <div class="form-group">
  186. <label for="settingForm[customize:isEnabledTimeline]" class="col-xs-3 control-label">{{ t('customize_page.Timeline function') }}</label>
  187. <div class="col-xs-9">
  188. <div class="btn-group btn-toggle" data-toggle="buttons">
  189. <label class="btn btn-default btn-rounded btn-outline {% if settingForm['customize:isEnabledTimeline'] %}active{% endif %}" data-active-class="primary">
  190. <input name="settingForm[customize:isEnabledTimeline]" value="true" type="radio"
  191. {% if true === settingForm['customize:isEnabledTimeline'] %}checked{% endif %}> ON
  192. </label>
  193. <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:isEnabledTimeline'] %}active{% endif %}" data-active-class="default">
  194. <input name="settingForm[customize:isEnabledTimeline]" value="false" type="radio"
  195. {% if !settingForm['customize:isEnabledTimeline'] %}checked{% endif %}> OFF
  196. </label>
  197. </div>
  198. <p class="help-block">
  199. {{ t("customize_page.subpage_display") }}
  200. </p>
  201. <p class="help-block">
  202. {{ t("customize_page.performance_decrease") }}<br>
  203. {{ t("customize_page.list_page_display") }}
  204. </p>
  205. </div>
  206. </div>
  207. <div class="form-group">
  208. <label for="settingForm[customize:isSavedStatesOfTabChanges]" class="col-xs-3 control-label">{{ t("customize_page.tab_switch") }}</label>
  209. <div class="col-xs-9">
  210. <div class="btn-group btn-toggle" data-toggle="buttons">
  211. <label class="btn btn-default btn-rounded btn-outline {% if settingForm['customize:isSavedStatesOfTabChanges'] %}active{% endif %}" data-active-class="primary">
  212. <input name="settingForm[customize:isSavedStatesOfTabChanges]" value="true" type="radio"
  213. {% if true === settingForm['customize:isSavedStatesOfTabChanges'] %}checked{% endif %}> ON
  214. </label>
  215. <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:isSavedStatesOfTabChanges'] %}active{% endif %}" data-active-class="default">
  216. <input name="settingForm[customize:isSavedStatesOfTabChanges]" value="false" type="radio"
  217. {% if !settingForm['customize:isSavedStatesOfTabChanges'] %}checked{% endif %}> OFF
  218. </label>
  219. </div>
  220. <p class="help-block">
  221. {{ t("customize_page.save_edit") }}<br>
  222. {{ t("customize_page.by_invalidating") }}
  223. </p>
  224. </div>
  225. </div>
  226. <div class="form-group">
  227. <label for="settingForm[customize:isEnabledAttachTitleHeader]" class="col-xs-3 control-label">{{ t("customize_page.attach_title_header") }}</label>
  228. <div class="col-xs-9">
  229. <div class="btn-group btn-toggle" data-toggle="buttons">
  230. <label class="btn btn-default btn-rounded btn-outline {% if settingForm['customize:isEnabledAttachTitleHeader'] %}active{% endif %}" data-active-class="primary">
  231. <input name="settingForm[customize:isEnabledAttachTitleHeader]" value="true" type="radio" {% if true===settingForm['customize:isEnabledAttachTitleHeader'] %}checked{% endif %}> ON
  232. </label>
  233. <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:isEnabledAttachTitleHeader'] %}active{% endif %}" data-active-class="default">
  234. <input name="settingForm[customize:isEnabledAttachTitleHeader]" value="false" type="radio" {% if !settingForm['customize:isEnabledAttachTitleHeader'] %}checked{% endif %}> OFF
  235. </label>
  236. </div>
  237. <p class="help-block">
  238. {{ t("customize_page.attach_title_header_desc") }}
  239. </p>
  240. </div>
  241. </div>
  242. <div class="form-group">
  243. <div class="col-xs-offset-3 col-xs-6">
  244. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  245. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  246. </div>
  247. </div>
  248. </fieldset>
  249. </form>
  250. <form action="/_api/admin/customize/highlightJsStyle" method="post" class="form-horizontal" id="cutomhighlightJsStyleSettingForm" role="form">
  251. <fieldset>
  252. <legend>{{ t('customize_page.Code Highlight') }}</legend>
  253. <div class="form-group">
  254. <label for="settingForm[customize:highlightJsStyle]" class="col-xs-3 control-label">{{ t('customize_page.Theme') }}</label>
  255. <div class="col-xs-9">
  256. <select class="form-control selectpicker" name="settingForm[customize:highlightJsStyle]" onChange="selectHighlightJsStyle(event)">
  257. {% for key in Object.keys(highlightJsCssSelectorOptions) %}
  258. <option value={{key}} {% if key == highlightJsStyle() %} selected {% endif %}>{{highlightJsCssSelectorOptions[key].name}}</option>
  259. {% endfor %}
  260. </select>
  261. </div>
  262. </div>
  263. <div class="form-group">
  264. <label for="settingForm[customize:highlightJsStyleBorder]" class="col-xs-3 control-label">(TBD) Border</label>
  265. <div class="col-xs-9">
  266. <div class="btn-group btn-toggle" data-toggle="buttons">
  267. <label class="btn btn-default btn-rounded btn-outline {% if settingForm['customize:highlightJsStyleBorder'] %}active{% endif %}" data-active-class="primary">
  268. <input name="settingForm[customize:highlightJsStyleBorder]" value="true" type="radio"
  269. {% if true === settingForm['customize:highlightJsStyleBorder'] %}checked{% endif %}> ON
  270. </label>
  271. <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:highlightJsStyleBorder'] %}active{% endif %}" data-active-class="default">
  272. <input name="settingForm[customize:highlightJsStyleBorder]" value="false" type="radio"
  273. {% if !settingForm['customize:highlightJsStyleBorder'] %}checked{% endif %}> OFF
  274. </label>
  275. </div>
  276. </div>
  277. </div>
  278. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/{{ highlightJsStyle() }}.css" class="highlightJsCss">
  279. <p class="help-block">
  280. Examples:
  281. <pre class="hljs"><code class="highlightjs-demo">function $initHighlight(block, cls) {
  282. try {
  283. if (cls.search(/\bno\-highlight\b/) != -1)
  284. return process(block, true, 0x0F) +
  285. ` class="${cls}"`;
  286. } catch (e) {
  287. /* handle exception */
  288. }
  289. for (var i = 0 / 2; i < classes.length; i++) {
  290. if (checkCondition(classes[i]) === undefined)
  291. console.log('undefined');
  292. }
  293. }
  294. export $initHighlight;</code></pre>
  295. </p>
  296. <div class="form-group">
  297. <div class="col-xs-offset-5 col-xs-6">
  298. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  299. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  300. </div>
  301. </div>
  302. </fieldset>
  303. </form>
  304. <form action="/_api/admin/customize/title" method="post" class="form-horizontal" id="customtitleSettingForm" role="form">
  305. <fieldset>
  306. <legend>カスタム Title</legend>
  307. <p class="well">
  308. <code>&lt;title&gt;</code>タグのコンテンツをカスタマイズできます。<br>
  309. <code>&#123;&#123;sitename&#125;&#125;</code>がサイト名、<code>&#123;&#123;page&#125;&#125;</code>がページ名またはページパスに置換されます
  310. </p>
  311. <p class="help-block">
  312. Default Value: <code>&#123;&#123;page&#125;&#125; - &#123;&#123;sitename&#125;&#125;</code>
  313. <br>
  314. Default Output: <pre><code class="xml">&lt;title&gt;/Sandbox - {{ appTitle }}&lt;&#047;title&gt;</code></pre>
  315. </p>
  316. <div class="form-group">
  317. <div class="col-xs-12">
  318. <input class="form-control" name="settingForm[customize:title]" value="{{ settingForm['customize:title'] }}"></input>
  319. </div>
  320. </div>
  321. <div class="form-group">
  322. <div class="col-xs-offset-5 col-xs-6">
  323. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  324. <button type="submit" class="btn btn-primary">更新</button>
  325. </div>
  326. </div>
  327. </fieldset>
  328. </form>
  329. <form action="/_api/admin/customize/header" method="post" class="form-horizontal" id="cutomheaderSettingForm" role="form">
  330. <fieldset>
  331. <legend>カスタムヘッダーHTML</legend>
  332. <p class="well">
  333. システム全体に適用される HTML を記述できます。<code>&lt;header&gt;</code> タグ内の他の <code>&lt;script&gt;</code> タグ読み込み前に展開されます。<br>
  334. 変更の反映はページの更新が必要です。
  335. </p>
  336. <p class="help-block">
  337. Examples:
  338. <pre class="hljs"><code>&lt;script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/languages/yaml.min.js" defer&gt;&lt;/script&gt;</code></pre>
  339. </p>
  340. <div class="form-group">
  341. <div class="col-xs-12">
  342. <div id="custom-header-editor"></div>
  343. <input type="hidden" id="inputCustomHeader" name="settingForm[customize:header]" value="{{ settingForm['customize:header'] }}">
  344. </div>
  345. <div class="col-xs-12">
  346. <p class="help-block text-right">
  347. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  348. Ctrl+Space でコード補完
  349. </p>
  350. </div>
  351. </div>
  352. <div class="form-group">
  353. <div class="col-xs-offset-5 col-xs-6">
  354. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  355. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  356. </div>
  357. </div>
  358. </fieldset>
  359. </form>
  360. <form action="/_api/admin/customize/css" method="post" class="form-horizontal" id="cutomcssSettingForm" role="form">
  361. <fieldset>
  362. <legend>{{ t('customize_page.Custom CSS') }}</legend>
  363. <p class="well">
  364. {{ t("customize_page.write_CSS") }}<br>
  365. {{ t("customize_page.reflect_change") }}
  366. </p>
  367. <div class="form-group">
  368. <div class="col-xs-12">
  369. <div id="custom-css-editor"></div>
  370. <input type="hidden" id="inputCustomCss" name="settingForm[customize:css]" value="{{ settingForm['customize:css'] }}">
  371. </div>
  372. <div class="col-xs-12">
  373. <p class="help-block text-right">
  374. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  375. {{ t("customize_page.ctrl_space") }}
  376. </p>
  377. </div>
  378. </div>
  379. <div class="form-group">
  380. <div class="col-xs-offset-5 col-xs-6">
  381. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  382. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  383. </div>
  384. </div>
  385. </fieldset>
  386. </form>
  387. <form action="/_api/admin/customize/script" method="post" class="form-horizontal" id="cutomscriptSettingForm" role="form">
  388. <fieldset>
  389. <legend>{{ t('customize_page.Custom script') }}</legend>
  390. <p class="well">
  391. {{ t("customize_page.write_java") }}<br>
  392. {{ t("customize_page.reflect_change") }}
  393. </p>
  394. <p class="help-block">
  395. Placeholders:<br>
  396. (Available after <code>load</code> event)
  397. <dl class="dl-horizontal">
  398. <dt><code>$</code></dt>
  399. <dd>jQuery instance</dd>
  400. <dt><code>crowi</code></dt>
  401. <dd>Crowi context instance</dd>
  402. <dt><code>Crowi</code></dt>
  403. <dd>Crowi legacy instance (jQuery based)</dd>
  404. <dt><code>crowiRenderer</code></dt>
  405. <dd>Crowi Renderer instance</dd>
  406. <dt><code>crowiPlugin</code></dt>
  407. <dd>GROWI plugin manager instance</dd>
  408. </dl>
  409. </p>
  410. <p class="help-block">
  411. Examples:
  412. <pre class="hljs"><code>console.log($('.main-container'));
  413. window.addEventListener('load', (event) => {
  414. console.log('config: ', crowi.config);
  415. });</code></pre>
  416. </p>
  417. <div class="form-group">
  418. <div class="col-xs-12">
  419. <div id="custom-script-editor"></div>
  420. <input type="hidden" id="inputCustomScript" name="settingForm[customize:script]" value="{{ settingForm['customize:script'] }}">
  421. </div>
  422. <div class="col-xs-12">
  423. <p class="help-block text-right">
  424. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  425. {{ t("customize_page.ctrl_space") }}
  426. </p>
  427. </div>
  428. </div>
  429. <div class="form-group">
  430. <div class="col-xs-offset-5 col-xs-6">
  431. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  432. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  433. </div>
  434. </div>
  435. </fieldset>
  436. </form>
  437. </div>
  438. </div>
  439. {% endblock content_main %}
  440. {% block body_end %}
  441. {% parent %}
  442. <script>
  443. $(`#customthemeSettingForm, #cutomlayoutSettingForm, #cutombehaviorSettingForm, #cutomhighlightJsStyleSettingForm,
  444. #customfeaturesSettingForm, #cutomheaderSettingForm, #cutomcssSettingForm, #cutomscriptSettingForm, #customtitleSettingForm`
  445. ).each(function() {
  446. $(this).submit(function()
  447. {
  448. function showMessage(formId, msg, status) {
  449. $('#' + formId + ' .alert').remove();
  450. if (!status) {
  451. status = 'success';
  452. }
  453. var $message = $('<p class="alert"></p>');
  454. $message.addClass('alert-' + status);
  455. $message.html(msg.replace('\n', '<br>'));
  456. $message.insertAfter('#' + formId + ' legend');
  457. if (status == 'success') {
  458. setTimeout(function()
  459. {
  460. $message.fadeOut({
  461. complete: function() {
  462. $message.remove();
  463. }
  464. });
  465. }, 5000);
  466. }
  467. }
  468. var $form = $(this);
  469. var $id = $form.attr('id');
  470. var $button = $('button', this);
  471. $button.attr('disabled', 'disabled');
  472. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  473. {
  474. if (data.status) {
  475. showMessage($id, '更新しました');
  476. } else {
  477. showMessage($id, data.message, 'danger');
  478. }
  479. })
  480. .fail(function() {
  481. showMessage($id, 'エラーが発生しました', 'danger');
  482. })
  483. .always(function() {
  484. $button.prop('disabled', false);
  485. });
  486. return false;
  487. });
  488. });
  489. /*
  490. * highlight.js style switcher
  491. */
  492. hljs.initHighlightingOnLoad()
  493. function selectHighlightJsStyle(event) {
  494. var highlightJsCssDOM = $(".highlightJsCss")[0]
  495. // selected value
  496. var val = event.target.value
  497. // replace css url
  498. // see https://regex101.com/r/gBNZYu/4
  499. highlightJsCssDOM.href = highlightJsCssDOM.href.replace(/[^/]+\.css$/, `${val}.css`);
  500. }
  501. /*
  502. * Theme Selector
  503. */
  504. options = {
  505. hasPreview: false,
  506. fullPath: '',
  507. cookie: {
  508. isManagingLoad: false
  509. }
  510. };
  511. $(document).ready(function() {
  512. $('#themeOptions').styleSwitcher(options);
  513. });
  514. function selectTheme(theme) {
  515. // update hidden
  516. $('#hiddenInputTheme').val(theme);
  517. // update .active class
  518. $('#themeOptions .active').removeClass('active');
  519. $(`#themeOptions #theme-option-${theme}`).addClass('active');
  520. }
  521. </script>
  522. </div>
  523. {% endblock %}
  524. {% block content_footer %}
  525. {% endblock content_footer %}