customize.html 29 KB

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