customize.html 28 KB

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