customize.html 25 KB

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