create_page.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <div class="modal create-page" id="create-page">
  2. <div class="modal-dialog">
  3. <div class="modal-content">
  4. <div class="modal-header bg-primary">
  5. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  6. <div class="modal-title">{{ t('New Page') }}</div>
  7. </div>
  8. <div class="modal-body">
  9. <form class="row form-horizontal" id="create-page-today" role="form">
  10. <fieldset class="col-xs-12">
  11. <legend>{{ t("Create today's") }}</legend>
  12. <div class="d-flex create-page-input-container">
  13. <div class="create-page-input-row d-flex align-items-center">
  14. <span class="page-today-prefix">{{ userPageRoot(user) }}/</span>
  15. <input type="text" data-prefix="{{ userPageRoot(user) }}/" class="page-today-input1 form-control text-center" value="{{ t('Memo') }}" id="" name="">
  16. <span class="page-today-suffix">/{{ now|datetz('Y/m/d') }}/</span>
  17. <input type="text" data-prefix="/{{ now|datetz('Y/m/d') }}/" class="page-today-input2 form-control" id="page-today-input2" name="" placeholder="{{ t('Input page name (optional)') }}">
  18. </div>
  19. <div class="create-page-button-container">
  20. <button type="submit" class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b"><i class="icon-fw icon-doc"></i>{{ t('Create') }}</button>
  21. </div>
  22. </div>
  23. </fieldset>
  24. </form>
  25. <form class="row form-horizontal m-t-15" id="create-page-under-tree" role="form">
  26. <fieldset class="col-xs-12">
  27. <legend>{{ t('Create under') }}</legend>
  28. <div class="d-flex create-page-input-container">
  29. <div class="create-page-input-row d-flex align-items-center">
  30. {% if searchConfigured() %}
  31. <div id="page-name-inputter"></div>
  32. {% else %}
  33. <input type="text" value="{{ parentPath(path) }}" class="page-name-input form-control " placeholder="{{ t('Input page name') }}" required />
  34. {% endif %}
  35. </div>
  36. <div class="create-page-button-container">
  37. <button type="submit" class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b"><i class="icon-fw icon-doc"></i>{{ t('Create') }}</button>
  38. </div>
  39. </div>
  40. </fieldset>
  41. </form>
  42. <div id="template-form" class="row form-horizontal m-t-15">
  43. <fieldset class="col-xs-12">
  44. <legend>{{ t('template.modal_label.Create template under', parentPath(path)) }}</legend>
  45. <div class="d-flex create-page-input-container">
  46. <div class="create-page-input-row d-flex align-items-center">
  47. <select id="template-type" class="form-control selectpicker" title="{{ t('template.option_label.select') }}">
  48. <option value="children" data-subtext="- {{ t('template.children.desc') }}">{{ t('template.children.label') }}(_template)</option>
  49. <option value="decentants" data-subtext="- {{ t('template.decendants.desc') }}">{{ t('template.decendants.label') }}(__template)</option>
  50. </select>
  51. </div>
  52. <div class="create-page-button-container">
  53. <a id="link-to-template" href="{{ page.path || path }}" class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b disabled">
  54. <i class="icon-fw icon-doc"></i>
  55. <span id="create-template-button-link">{{ t('Create') }}/{{ t('Edit') }}</span>
  56. </a>
  57. </div>
  58. </div>
  59. </fieldset>
  60. </div>
  61. </div><!-- /.modal-body -->
  62. </div><!-- /.modal-content -->
  63. </div><!-- /.modal-dialog -->
  64. </div><!-- /.modal -->
  65. <script>
  66. let buttonTextChildren;
  67. let buttonTextDecendants;
  68. let pagePath = $("#link-to-template").attr("href");
  69. if (pagePath.endsWith("/")) {
  70. pagePath = pagePath.slice(0, -1);
  71. };
  72. $.get('/_api/pages.templates?path=' + pagePath) // don't use template literal(`...${}`) for IE11
  73. .then(function(templateInfo) { // don't use arrow function for IE11
  74. buttonTextChildren = templateInfo.childrenTemplateExists ? '{{ t("Edit") }}' : '{{ t("Create") }}';
  75. buttonTextDecendants = templateInfo.decendantsTemplateExists ? '{{ t("Edit") }}' : '{{ t("Create") }}';
  76. });
  77. $("#template-type").on("change", function() {
  78. // enable button
  79. $('#link-to-template').removeClass("disabled");
  80. if ($("#template-type").val() === "children") {
  81. href = pagePath + "/_template#edit-form";
  82. $("#link-to-template").attr("href", href);
  83. $('#create-template-button-link').text(buttonTextChildren);
  84. }
  85. else if ($("#template-type").val() === "decentants") {
  86. href = pagePath + "/__template#edit-form";
  87. $("#link-to-template").attr("href", href);
  88. $('#create-template-button-link').text(buttonTextDecendants);
  89. };
  90. });
  91. </script>