customize.html 25 KB

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