customize.html 24 KB

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