customize.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. {% extends '../layout/admin.html' %}
  2. {% block html_title %}カスタマイズ · {% endblock %}
  3. {% block html_additional_headers %}
  4. <!-- CodeMirror -->
  5. <link rel="stylesheet" href="https://cdn.jsdelivr.net/g/codemirror@4.5.0(codemirror.css+addon/hint/show-hint.css)">
  6. <link rel="stylesheet" href="https://cdn.jsdelivr.net/jquery.ui/1.11.4/jquery-ui.min.css">
  7. <link rel="stylesheet" href="https://cdn.jsdelivr.net/codemirror/4.5.0/theme/eclipse.css">
  8. <style>
  9. .CodeMirror {
  10. border: 1px solid #eee;
  11. }
  12. </style>
  13. {% endblock %}
  14. {% block content_head %}
  15. <div class="header-wrap">
  16. <header id="page-header">
  17. <h1 class="title" id="">カスタマイズ</h1>
  18. </header>
  19. </div>
  20. {% endblock %}
  21. {% block content_main %}
  22. <div class="content-main">
  23. {% set smessage = req.flash('successMessage') %}
  24. {% if smessage.length %}
  25. <div class="alert alert-success">
  26. {{ smessage }}
  27. </div>
  28. {% endif %}
  29. {% set emessage = req.flash('errorMessage') %}
  30. {% if emessage.length %}
  31. <div class="alert alert-danger">
  32. {{ emessage }}
  33. </div>
  34. {% endif %}
  35. <div class="row">
  36. <div class="col-md-3">
  37. {% include './widget/menu.html' with {current: 'customize'} %}
  38. </div>
  39. <div class="col-md-9">
  40. <form action="/_api/admin/customize/layout" method="post" class="form-horizontal" id="cutomlayoutSettingForm" role="form">
  41. <fieldset>
  42. <legend>レイアウト</legend>
  43. <div class="form-group">
  44. <div class="col-xs-6">
  45. <h4>
  46. <input type="radio" name="settingForm[customize:layout]" value="crowi"
  47. {% if !settingForm['customize:layout'] || 'crowi' === settingForm['customize:layout'] %}checked="checked"{% endif %}>
  48. Official Crowi Classic Layout
  49. </h4>
  50. <a href="http://placehold.it"><img src="http://placehold.it/350x150"></a>
  51. </div>
  52. <div class="col-xs-6">
  53. <h4>
  54. <input type="radio" name="settingForm[customize:layout]" value="crowi-plus"
  55. {% if 'crowi-plus' === settingForm['customize:layout'] %}checked="checked"{% endif %}>
  56. crowi-plus Enhanced Layout
  57. </h4>
  58. <a href="http://placehold.it"><img src="http://placehold.it/350x150"></a>
  59. </div>
  60. </div>
  61. <div class="form-group">
  62. <div class="col-xs-offset-5 col-xs-6">
  63. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  64. <button type="submit" class="btn btn-primary">更新</button>
  65. </div>
  66. </div>
  67. </fieldset>
  68. </form>
  69. <form action="/_api/admin/customize/css" method="post" class="form-horizontal" id="cutomcssSettingForm" role="form">
  70. <fieldset>
  71. <legend>カスタムCSS</legend>
  72. <p class="help-block">
  73. システム全体に適用されるCSSを記述できます。<br>
  74. 変更の反映はページの更新が必要です。
  75. </p>
  76. <div class="form-group">
  77. <div class="col-xs-12">
  78. <textarea id="taCustomCss" class="form-control" type="textarea" name="settingForm[customize:css]" rows="20">{{ settingForm['customize:css'] }}</textarea>
  79. </div>
  80. <div class="col-xs-12">
  81. <p class="help-block text-right">
  82. <i class="fa fa-fw fa-keyboard-o" aria-hidden="true"></i>
  83. Ctrl+Space でコード補完
  84. </p>
  85. </div>
  86. </div>
  87. <div class="form-group">
  88. <div class="col-xs-offset-5 col-xs-6">
  89. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  90. <button type="submit" class="btn btn-primary">更新</button>
  91. </div>
  92. </div>
  93. </fieldset>
  94. </form>
  95. </div>
  96. </div>
  97. <script>
  98. $('#cutomcssSettingForm, #cutomlayoutSettingForm').each(function() {
  99. $(this).submit(function()
  100. {
  101. function showMessage(formId, msg, status) {
  102. $('#' + formId + ' .alert').remove();
  103. if (!status) {
  104. status = 'success';
  105. }
  106. var $message = $('<p class="alert"></p>');
  107. $message.addClass('alert-' + status);
  108. $message.html(msg.replace('\n', '<br>'));
  109. $message.insertAfter('#' + formId + ' legend');
  110. if (status == 'success') {
  111. setTimeout(function()
  112. {
  113. $message.fadeOut({
  114. complete: function() {
  115. $message.remove();
  116. }
  117. });
  118. }, 5000);
  119. }
  120. }
  121. var $form = $(this);
  122. var $id = $form.attr('id');
  123. var $button = $('button', this);
  124. $button.attr('disabled', 'disabled');
  125. var jqxhr = $.post($form.attr('action'), $form.serialize(), function(data)
  126. {
  127. if (data.status) {
  128. showMessage($id, '更新しました');
  129. } else {
  130. showMessage($id, data.message, 'danger');
  131. }
  132. })
  133. .fail(function() {
  134. showMessage($id, 'エラーが発生しました', 'danger');
  135. })
  136. .always(function() {
  137. $button.prop('disabled', false);
  138. });
  139. return false;
  140. });
  141. });
  142. </script>
  143. <!-- CodeMirror -->
  144. <script src="https://cdn.jsdelivr.net/g/codemirror@4.5.0(codemirror.min.js+addon/lint/css-lint.js+mode/css/css.js+addon/hint/css-hint.js+addon/hint/show-hint.js+addon/edit/matchbrackets.js+addon/edit/closebrackets.js),jquery.ui@1.11.4"></script>
  145. <script>
  146. var editor = CodeMirror.fromTextArea(document.getElementById('taCustomCss'), {
  147. mode: "css",
  148. lineNumbers: true,
  149. tabSize: 2,
  150. indentUnit: 2,
  151. theme: 'eclipse',
  152. matchBrackets: true,
  153. autoCloseBrackets: true,
  154. extraKeys: {"Ctrl-Space": "autocomplete"},
  155. });
  156. editor.on('change', function(cm, change) {
  157. cm.save();
  158. });
  159. // resizable with jquery.ui
  160. $(editor.getWrapperElement()).resizable({
  161. resize: function() {
  162. editor.setSize($(this).width(), $(this).height());
  163. }
  164. });
  165. </script>
  166. </div>
  167. {% endblock content_main %}
  168. {% block content_footer %}
  169. {% endblock content_footer %}