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