customize.html 27 KB

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