customize.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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. <div class="form-group">
  230. <label for="settingForm[customize:isSavedStatesOfTabChanges]" class="col-xs-3 control-label">{{ t("customize_page.tab_switch") }}</label>
  231. <div class="col-xs-9">
  232. <div class="btn-group btn-toggle" data-toggle="buttons">
  233. <label class="btn btn-default btn-rounded btn-outline {% if settingForm['customize:isSavedStatesOfTabChanges'] %}active{% endif %}" data-active-class="primary">
  234. <input name="settingForm[customize:isSavedStatesOfTabChanges]" value="true" type="radio"
  235. {% if true === settingForm['customize:isSavedStatesOfTabChanges'] %}checked{% endif %}> ON
  236. </label>
  237. <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:isSavedStatesOfTabChanges'] %}active{% endif %}" data-active-class="default">
  238. <input name="settingForm[customize:isSavedStatesOfTabChanges]" value="false" type="radio"
  239. {% if !settingForm['customize:isSavedStatesOfTabChanges'] %}checked{% endif %}> OFF
  240. </label>
  241. </div>
  242. <p class="help-block">
  243. {{ t("customize_page.save_edit") }}<br>
  244. {{ t("customize_page.by_invalidating") }}
  245. </p>
  246. </div>
  247. </div>
  248. <div class="form-group">
  249. <label for="settingForm[customize:isEnabledAttachTitleHeader]" class="col-xs-3 control-label">{{ t("customize_page.attach_title_header") }}</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:isEnabledAttachTitleHeader'] %}active{% endif %}" data-active-class="primary">
  253. <input name="settingForm[customize:isEnabledAttachTitleHeader]" value="true" type="radio" {% if true===settingForm['customize:isEnabledAttachTitleHeader'] %}checked{% endif %}> ON
  254. </label>
  255. <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:isEnabledAttachTitleHeader'] %}active{% endif %}" data-active-class="default">
  256. <input name="settingForm[customize:isEnabledAttachTitleHeader]" value="false" type="radio" {% if !settingForm['customize:isEnabledAttachTitleHeader'] %}checked{% endif %}> OFF
  257. </label>
  258. </div>
  259. <p class="help-block">
  260. {{ t("customize_page.attach_title_header_desc") }}
  261. </p>
  262. </div>
  263. </div>
  264. <div class="form-group">
  265. <label for="settingForm[customize:showRecentCreatedNumber]" class="col-xs-3 control-label">{{ t("customize_page.recent_created_page_num") }}</label>
  266. <div class="col-xs-5">
  267. <select class="form-control selectpicker" name="settingForm[customize:showRecentCreatedNumber]" value="{{ settingForm['customize:showRecentCreatedNumber'] }}">
  268. <option value="10" {% if 10 == settingForm['customize:showRecentCreatedNumber'] %}selected{% endif %}>10</option>
  269. <option value="30" {% if 30 == settingForm['customize:showRecentCreatedNumber'] %}selected{% endif %}>30</option>
  270. <option value="50" {% if 50 == settingForm['customize:showRecentCreatedNumber'] %}selected{% endif %}>50</option>
  271. </select>
  272. <p class="help-block">
  273. {{ t("customize_page.recent_created_page_num_desc") }}
  274. </p>
  275. </div>
  276. </div>
  277. <div class="form-group">
  278. <div class="col-xs-offset-3 col-xs-6">
  279. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  280. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  281. </div>
  282. </div>
  283. </fieldset>
  284. </form>
  285. <form action="/_api/admin/customize/highlightJsStyle" method="post" class="form-horizontal" id="customhighlightJsStyleSettingForm" role="form">
  286. <fieldset>
  287. <legend>{{ t('customize_page.Code Highlight') }}</legend>
  288. <div class="form-group">
  289. <label for="settingForm[customize:highlightJsStyle]" class="col-xs-3 control-label">{{ t('customize_page.Theme') }}</label>
  290. <div class="col-xs-9">
  291. <select class="form-control selectpicker" name="settingForm[customize:highlightJsStyle]" onChange="selectHighlightJsStyle(event)" {% if noCdn() %}disabled{% endif %}>
  292. {% for key in Object.keys(highlightJsCssSelectorOptions) %}
  293. <option value={{key}} {% if key == highlightJsStyle() %} selected {% endif %}>{{highlightJsCssSelectorOptions[key].name}}</option>
  294. {% endfor %}
  295. </select>
  296. <p class="help-block text-warning">{{ t('customize_page.nocdn_desc') }}</p>
  297. </div>
  298. </div>
  299. <div class="form-group">
  300. <label for="settingForm[customize:highlightJsStyleBorder]" class="col-xs-3 control-label">Border</label>
  301. <div class="col-xs-9">
  302. <div class="btn-group btn-toggle" data-toggle="buttons">
  303. <label class="btn btn-default btn-rounded btn-outline {% if settingForm['customize:highlightJsStyleBorder'] %}active{% endif %}" data-active-class="primary" onclick="selectBorderOn()">
  304. <input name="settingForm[customize:highlightJsStyleBorder]" value="true" type="radio"
  305. {% if true === settingForm['customize:highlightJsStyleBorder'] %}checked{% endif %}> ON
  306. </label>
  307. <label class="btn btn-default btn-rounded btn-outline {% if !settingForm['customize:highlightJsStyleBorder'] %}active{% endif %}" data-active-class="default" onclick="selectBorderOff()">
  308. <input name="settingForm[customize:highlightJsStyleBorder]" value="false" type="radio"
  309. {% if !settingForm['customize:highlightJsStyleBorder'] %}checked{% endif %}> OFF
  310. </label>
  311. </div>
  312. </div>
  313. </div>
  314. <div id="highlightJsCssContainer">
  315. {{ cdnHighlightJsStyleTag(highlightJsStyle()) }}
  316. </div>
  317. <p class="help-block">
  318. Examples:
  319. <div class="wiki">
  320. <pre class="hljs {% if !settingForm['customize:highlightJsStyleBorder'] %}hljs-no-border{% endif %}"><code class="highlightjs-demo">function $initHighlight(block, cls) {
  321. try {
  322. if (cls.search(/\bno\-highlight\b/) != -1)
  323. return process(block, true, 0x0F) +
  324. ` class="${cls}"`;
  325. } catch (e) {
  326. /* handle exception */
  327. }
  328. for (var i = 0 / 2; i < classes.length; i++) {
  329. if (checkCondition(classes[i]) === undefined)
  330. console.log('undefined');
  331. }
  332. }
  333. export $initHighlight;</code></pre>
  334. </div>
  335. </p>
  336. <div class="form-group">
  337. <div class="col-xs-offset-5 col-xs-6">
  338. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  339. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  340. </div>
  341. </div>
  342. </fieldset>
  343. </form>
  344. <form action="/_api/admin/customize/title" method="post" class="form-horizontal" id="customtitleSettingForm" role="form">
  345. <fieldset>
  346. <legend>{{ t('customize_page.custom_title') }}</legend>
  347. <p class="well">
  348. {{ t('customize_page.custom_title_detail', '&lt;title&gt;', '&#123;&#123;sitename&#125;&#125;', '&#123;&#123;page&#125;&#125;') }}
  349. </p>
  350. <p class="help-block">
  351. Default Value: <code>&#123;&#123;page&#125;&#125; - &#123;&#123;sitename&#125;&#125;</code>
  352. <br>
  353. Default Output: <pre><code class="xml">&lt;title&gt;/Sandbox - {{ appTitle }}&lt;&#047;title&gt;</code></pre>
  354. </p>
  355. <div class="form-group">
  356. <div class="col-xs-12">
  357. <input class="form-control" name="settingForm[customize:title]" value="{{ settingForm['customize:title'] }}"></input>
  358. </div>
  359. </div>
  360. <div class="form-group">
  361. <div class="col-xs-offset-5 col-xs-6">
  362. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  363. <button type="submit" class="btn btn-primary">更新</button>
  364. </div>
  365. </div>
  366. </fieldset>
  367. </form>
  368. <form action="/_api/admin/customize/header" method="post" class="form-horizontal" id="customheaderSettingForm" role="form">
  369. <fieldset>
  370. <legend>{{ t('customize_page.custom_header') }}</legend>
  371. <p class="well">
  372. {{ t('customize_page.custom_header_detail', '&lt;header&gt;', '&lt;script&gt;') }}
  373. </p>
  374. <p class="help-block">
  375. {{ t('Example') }}:
  376. <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>
  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. {{ t("customize_page.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/g, '<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. hljs.initLineNumbersOnLoad()
  532. function selectHighlightJsStyle(event) {
  533. var highlightJsCssDOM = $("#highlightJsCssContainer link")[0]
  534. // selected value
  535. var val = event.target.value
  536. // replace css url
  537. // see https://regex101.com/r/gBNZYu/4
  538. highlightJsCssDOM.href = highlightJsCssDOM.href.replace(/[^/]+\.css$/, `${val}.css`);
  539. }
  540. function selectableTheme(event) {
  541. var val = event.target.value;
  542. var themeButtons = document.getElementsByClassName('theme-button');
  543. if(val == 'kibela') {
  544. $('#themeOptions').addClass("disabled");
  545. var i=0;
  546. while(i < themeButtons.length) {
  547. themeButtons[i].removeAttribute("onclick");
  548. i++;
  549. }
  550. }
  551. else {
  552. $('#themeOptions').removeClass("disabled")
  553. var i=0;
  554. while(i < themeButtons.length) {
  555. var name = themeButtons[i].getAttribute("id");
  556. themeButtons[i].setAttribute("onclick",`selectTheme('${name}')`);
  557. i++;
  558. }
  559. }
  560. }
  561. /*
  562. * Theme Selector
  563. */
  564. options = {
  565. hasPreview: false,
  566. fullPath: '',
  567. cookie: {
  568. isManagingLoad: false
  569. }
  570. };
  571. $(document).ready(function() {
  572. $('#themeOptions').styleSwitcher(options);
  573. });
  574. function selectTheme(theme) {
  575. // update hidden
  576. $('#hiddenInputTheme').val(theme);
  577. // update .active class
  578. $('#themeOptions .active').removeClass('active');
  579. $(`#themeOptions #theme-option-${theme}`).addClass('active');
  580. }
  581. function selectBorderOn(){
  582. $('.hljs-no-border').removeClass('hljs-no-border');
  583. }
  584. function selectBorderOff(){
  585. $('#customhighlightJsStyleSettingForm .hljs').addClass('hljs-no-border')
  586. }
  587. </script>
  588. </div>
  589. {% endblock %}
  590. {% block content_footer %}
  591. {% endblock content_footer %}