customize.html 26 KB

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