customize.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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. {{ cdnStyleTag('jquery-ui') }}
  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. <div class="form-group">
  62. <div class="col-sm-4">
  63. <h4>
  64. <div class="radio radio-primary">
  65. <input type="radio" id="radioLayoutGrowi" name="settingForm[customize:layout]" value="growi" onclick="selectableTheme(event)"
  66. {% if 'growi' === settingForm['customize:layout'] %}checked="checked"{% endif %}>
  67. <label for="radioLayoutGrowi">
  68. GROWI Enhanced Layout <small class="text-success">(Recommended)</small>
  69. </label>
  70. </div>
  71. </h4>
  72. <a href="/images/admin/customize/layout-crowi-plus.gif" class="ss-container">
  73. <img src="/images/admin/customize/layout-crowi-plus-thumb.gif" width="240px">
  74. </a>
  75. <h4>Simple and Clear</h4>
  76. <ul>
  77. <li>Full screen layout and thin margins/paddings</li>
  78. <li>Show and post comments at the bottom of the page</li>
  79. <li>Affix Table-of-contents</li>
  80. </ul>
  81. </div>
  82. <div class="col-sm-4">
  83. <h4>
  84. <div class="radio radio-primary">
  85. <input type="radio" id="radioLayoutKibela" name="settingForm[customize:layout]" value="kibela" onclick="selectableTheme(event)"
  86. {% if 'kibela' === settingForm['customize:layout'] %}checked="checked"{% endif %}>
  87. <label for="radioLayoutKibela">
  88. Kibela Like Layout
  89. </label>
  90. </div>
  91. </h4>
  92. <a href="/images/admin/customize/layout-kibela.gif" class="ss-container">
  93. <img src="/images/admin/customize/layout-kibela-thumb.gif" width="240px">
  94. </a>
  95. <h4>Easy Viewing Structure</h4>
  96. <ul>
  97. <li>Center aligned contents</li>
  98. <li>Show and post comments at the bottom of the page</li>
  99. <li>Affix Table-of-contents</li>
  100. </ul>
  101. </div>
  102. <div class="col-sm-4">
  103. <h4>
  104. <div class="radio radio-primary">
  105. <input type="radio" id="radioLayoutCrowi" name="settingForm[customize:layout]" value="crowi" onclick="selectableTheme(event)"
  106. {% if 'crowi' === settingForm['customize:layout'] %}checked="checked"{% endif %}>
  107. <label for="radioLayoutCrowi">
  108. Crowi Classic Layout
  109. </label>
  110. </div>
  111. </h4>
  112. <a href="/images/admin/customize/layout-classic.gif" class="ss-container">
  113. <img src="/images/admin/customize/layout-classic-thumb.gif" width="240px">
  114. </a>
  115. <h4>Separated Functions</h4>
  116. <ul>
  117. <li>Collapsible Sidebar</li>
  118. <li>Show and post comments in Sidebar</li>
  119. <li>Collapsible Table-of-contents</li>
  120. </ul>
  121. </div>
  122. </div>
  123. <h2>{{ t('customize_page.Theme') }}</h2>
  124. {% if env === 'development' %}
  125. <div class="alert alert-warning">
  126. <strong>DEBUG MESSAGE:</strong> development build では、リアルタイムプレビューが無効になります
  127. </div>
  128. {% endif %}
  129. <div id="themeOptions" {% if 'kibela' == settingForm['customize:layout'] %}class="disabled"{% endif %}>
  130. {# Light Themes #}
  131. <div class="d-flex">
  132. {% include 'widget/theme-colorbox.html' with { name: 'default', bg: '#ffffff', topbar: '#334455', theme: '#112744'} %}
  133. {% include 'widget/theme-colorbox.html' with { name: 'nature', bg: '#f9fff3', topbar: '#118050', theme: '#460039'} %}
  134. {% include 'widget/theme-colorbox.html' with { name: 'mono-blue', bg: '#F7FBFD', topbar: '#00587A', theme: '#00587A'} %}
  135. {% include 'widget/theme-colorbox.html' with { name: 'wood', bg: '#fffefb', topbar: '#aaa45f', theme: '#dddebf'} %}
  136. {% include 'widget/theme-colorbox.html' with { name: 'island', bg: '#8ecac0', topbar: '#0c2a44', theme: '#cef2ef'} %}
  137. {% include 'widget/theme-colorbox.html' with { name: 'christmas', bg: '#fffefb', topbar: '#b3000c', theme: '#017e20'} %}
  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.recent_created_page_num") }}</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.recent_created_page_num_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)" {% if noCdn() %}disabled{% endif %}>
  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. <p class="help-block text-warning">{{ t('customize_page.nocdn_desc') }}</p>
  300. </div>
  301. </div>
  302. <div class="form-group">
  303. <label for="settingForm[customize:highlightJsStyleBorder]" class="col-xs-3 control-label">Border</label>
  304. <div class="col-xs-9">
  305. <div class="btn-group btn-toggle" data-toggle="buttons">
  306. <label class="btn btn-default btn-rounded btn-outline {% if settingForm['customize:highlightJsStyleBorder'] %}active{% endif %}" data-active-class="primary" onclick="selectBorderOn()">
  307. <input name="settingForm[customize:highlightJsStyleBorder]" value="true" type="radio"
  308. {% if true === settingForm['customize:highlightJsStyleBorder'] %}checked{% endif %}> ON
  309. </label>
  310. <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:highlightJsStyleBorder'] %}active{% endif %}" data-active-class="default" onclick="selectBorderOff()">
  311. <input name="settingForm[customize:highlightJsStyleBorder]" value="false" type="radio"
  312. {% if !settingForm['customize:highlightJsStyleBorder'] %}checked{% endif %}> OFF
  313. </label>
  314. </div>
  315. </div>
  316. </div>
  317. <div id="highlightJsCssContainer">
  318. {{ cdnHighlightJsStyleTag(highlightJsStyle()) }}
  319. </div>
  320. <p class="help-block">
  321. Examples:
  322. <div class="wiki">
  323. <pre class="hljs {% if !settingForm['customize:highlightJsStyleBorder'] %}hljs-no-border{% endif %}"><code class="highlightjs-demo">function $initHighlight(block, cls) {
  324. try {
  325. if (cls.search(/\bno\-highlight\b/) != -1)
  326. return process(block, true, 0x0F) +
  327. ` class="${cls}"`;
  328. } catch (e) {
  329. /* handle exception */
  330. }
  331. for (var i = 0 / 2; i < classes.length; i++) {
  332. if (checkCondition(classes[i]) === undefined)
  333. console.log('undefined');
  334. }
  335. }
  336. export $initHighlight;</code></pre>
  337. </div>
  338. </p>
  339. <div class="form-group">
  340. <div class="col-xs-offset-5 col-xs-6">
  341. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  342. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  343. </div>
  344. </div>
  345. </fieldset>
  346. </form>
  347. <form action="/_api/admin/customize/title" method="post" class="form-horizontal" id="customtitleSettingForm" role="form">
  348. <fieldset>
  349. <legend>カスタム Title</legend>
  350. <p class="well">
  351. <code>&lt;title&gt;</code>タグのコンテンツをカスタマイズできます。<br>
  352. <code>&#123;&#123;sitename&#125;&#125;</code>がサイト名、<code>&#123;&#123;page&#125;&#125;</code>がページ名またはページパスに置換されます
  353. </p>
  354. <p class="help-block">
  355. Default Value: <code>&#123;&#123;page&#125;&#125; - &#123;&#123;sitename&#125;&#125;</code>
  356. <br>
  357. Default Output: <pre><code class="xml">&lt;title&gt;/Sandbox - {{ appTitle }}&lt;&#047;title&gt;</code></pre>
  358. </p>
  359. <div class="form-group">
  360. <div class="col-xs-12">
  361. <input class="form-control" name="settingForm[customize:title]" value="{{ settingForm['customize:title'] }}"></input>
  362. </div>
  363. </div>
  364. <div class="form-group">
  365. <div class="col-xs-offset-5 col-xs-6">
  366. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  367. <button type="submit" class="btn btn-primary">更新</button>
  368. </div>
  369. </div>
  370. </fieldset>
  371. </form>
  372. <form action="/_api/admin/customize/header" method="post" class="form-horizontal" id="customheaderSettingForm" role="form">
  373. <fieldset>
  374. <legend>カスタムヘッダーHTML</legend>
  375. <p class="well">
  376. システム全体に適用される HTML を記述できます。<code>&lt;header&gt;</code> タグ内の他の <code>&lt;script&gt;</code> タグ読み込み前に展開されます。<br>
  377. 変更の反映はページの更新が必要です。
  378. </p>
  379. <p class="help-block">
  380. Examples:
  381. <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>
  382. </p>
  383. <div class="form-group">
  384. <div class="col-xs-12">
  385. <div id="custom-header-editor"></div>
  386. <input type="hidden" id="inputCustomHeader" name="settingForm[customize:header]" value="{{ settingForm['customize:header'] }}">
  387. </div>
  388. <div class="col-xs-12">
  389. <p class="help-block text-right">
  390. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  391. Ctrl+Space でコード補完
  392. </p>
  393. </div>
  394. </div>
  395. <div class="form-group">
  396. <div class="col-xs-offset-5 col-xs-6">
  397. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  398. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  399. </div>
  400. </div>
  401. </fieldset>
  402. </form>
  403. <form action="/_api/admin/customize/css" method="post" class="form-horizontal" id="customcssSettingForm" role="form">
  404. <fieldset>
  405. <legend>{{ t('customize_page.Custom CSS') }}</legend>
  406. <p class="well">
  407. {{ t("customize_page.write_CSS") }}<br>
  408. {{ t("customize_page.reflect_change") }}
  409. </p>
  410. <div class="form-group">
  411. <div class="col-xs-12">
  412. <div id="custom-css-editor"></div>
  413. <input type="hidden" id="inputCustomCss" name="settingForm[customize:css]" value="{{ settingForm['customize:css'] }}">
  414. </div>
  415. <div class="col-xs-12">
  416. <p class="help-block text-right">
  417. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  418. {{ t("customize_page.ctrl_space") }}
  419. </p>
  420. </div>
  421. </div>
  422. <div class="form-group">
  423. <div class="col-xs-offset-5 col-xs-6">
  424. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  425. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  426. </div>
  427. </div>
  428. </fieldset>
  429. </form>
  430. <form action="/_api/admin/customize/script" method="post" class="form-horizontal" id="customscriptSettingForm" role="form">
  431. <fieldset>
  432. <legend>{{ t('customize_page.Custom script') }}</legend>
  433. <p class="well">
  434. {{ t("customize_page.write_java") }}<br>
  435. {{ t("customize_page.reflect_change") }}
  436. </p>
  437. <p class="help-block">
  438. Placeholders:<br>
  439. (Available after <code>load</code> event)
  440. <dl class="dl-horizontal">
  441. <dt><code>$</code></dt>
  442. <dd>jQuery instance</dd>
  443. <dt><code>crowi</code></dt>
  444. <dd>Crowi context instance</dd>
  445. <dt><code>Crowi</code></dt>
  446. <dd>Crowi legacy instance (jQuery based)</dd>
  447. <dt><code>crowiRenderer</code></dt>
  448. <dd>Crowi Renderer instance</dd>
  449. <dt><code>crowiPlugin</code></dt>
  450. <dd>GROWI plugin manager instance</dd>
  451. </dl>
  452. </p>
  453. <p class="help-block">
  454. Examples:
  455. <pre class="hljs"><code>console.log($('.main-container'));
  456. window.addEventListener('load', (event) => {
  457. console.log('config: ', crowi.config);
  458. });</code></pre>
  459. </p>
  460. <div class="form-group">
  461. <div class="col-xs-12">
  462. <div id="custom-script-editor"></div>
  463. <input type="hidden" id="inputCustomScript" name="settingForm[customize:script]" value="{{ settingForm['customize:script'] }}">
  464. </div>
  465. <div class="col-xs-12">
  466. <p class="help-block text-right">
  467. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  468. {{ t("customize_page.ctrl_space") }}
  469. </p>
  470. </div>
  471. </div>
  472. <div class="form-group">
  473. <div class="col-xs-offset-5 col-xs-6">
  474. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  475. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  476. </div>
  477. </div>
  478. </fieldset>
  479. </form>
  480. </div>
  481. </div>
  482. {% endblock content_main %}
  483. {% block body_end %}
  484. {% parent %}
  485. <script>
  486. $(`#customlayoutSettingForm, #custombehaviorSettingForm, #customhighlightJsStyleSettingForm,
  487. #customfeaturesSettingForm, #customheaderSettingForm, #customcssSettingForm, #customscriptSettingForm, #customtitleSettingForm`
  488. ).each(function() {
  489. $(this).submit(function()
  490. {
  491. function showMessage(formId, msg, status) {
  492. $('#' + formId + ' #alert-results').remove();
  493. if (!status) {
  494. status = 'success';
  495. }
  496. var $message = $('<p id="alert-results" class="alert"></p>');
  497. $message.addClass('alert-' + status);
  498. $message.html(msg.replace(/\n/g, '<br>'));
  499. $message.insertAfter('#' + formId + ' legend');
  500. if (status == 'success') {
  501. setTimeout(function()
  502. {
  503. $message.fadeOut({
  504. complete: function() {
  505. $message.remove();
  506. }
  507. });
  508. }, 5000);
  509. }
  510. }
  511. var $form = $(this);
  512. var $id = $form.attr('id');
  513. var $button = $('button', this);
  514. $button.attr('disabled', 'disabled');
  515. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  516. {
  517. if (data.status) {
  518. showMessage($id, '更新しました');
  519. } else {
  520. showMessage($id, data.message, 'danger');
  521. }
  522. })
  523. .fail(function() {
  524. showMessage($id, 'エラーが発生しました', 'danger');
  525. })
  526. .always(function() {
  527. $button.prop('disabled', false);
  528. });
  529. return false;
  530. });
  531. });
  532. /*
  533. * highlight.js style switcher
  534. */
  535. hljs.initHighlightingOnLoad()
  536. hljs.initLineNumbersOnLoad()
  537. function selectHighlightJsStyle(event) {
  538. var highlightJsCssDOM = $("#highlightJsCssContainer link")[0]
  539. // selected value
  540. var val = event.target.value
  541. // replace css url
  542. // see https://regex101.com/r/gBNZYu/4
  543. highlightJsCssDOM.href = highlightJsCssDOM.href.replace(/[^/]+\.css$/, `${val}.css`);
  544. }
  545. function selectableTheme(event) {
  546. var val = event.target.value;
  547. var themeButtons = document.getElementsByClassName('theme-button');
  548. if(val == 'kibela') {
  549. $('#themeOptions').addClass("disabled");
  550. var i=0;
  551. while(i < themeButtons.length) {
  552. themeButtons[i].removeAttribute("onclick");
  553. i++;
  554. }
  555. }
  556. else {
  557. $('#themeOptions').removeClass("disabled")
  558. var i=0;
  559. while(i < themeButtons.length) {
  560. var name = themeButtons[i].getAttribute("id");
  561. themeButtons[i].setAttribute("onclick",`selectTheme('${name}')`);
  562. i++;
  563. }
  564. }
  565. }
  566. /*
  567. * Theme Selector
  568. */
  569. options = {
  570. hasPreview: false,
  571. fullPath: '',
  572. cookie: {
  573. isManagingLoad: false
  574. }
  575. };
  576. $(document).ready(function() {
  577. $('#themeOptions').styleSwitcher(options);
  578. });
  579. function selectTheme(theme) {
  580. // update hidden
  581. $('#hiddenInputTheme').val(theme);
  582. // update .active class
  583. $('#themeOptions .active').removeClass('active');
  584. $(`#themeOptions #theme-option-${theme}`).addClass('active');
  585. }
  586. function selectBorderOn(){
  587. $('.hljs-no-border').removeClass('hljs-no-border');
  588. }
  589. function selectBorderOff(){
  590. $('#customhighlightJsStyleSettingForm .hljs').addClass('hljs-no-border')
  591. }
  592. </script>
  593. </div>
  594. {% endblock %}
  595. {% block content_footer %}
  596. {% endblock content_footer %}