customize.html 24 KB

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