customize.html 26 KB

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