Просмотр исходного кода

auto-tempate for crowi completed

sou 7 лет назад
Родитель
Сommit
2a80d72115
1 измененных файлов с 10 добавлено и 6 удалено
  1. 10 6
      lib/views/modal/create_page.html

+ 10 - 6
lib/views/modal/create_page.html

@@ -56,7 +56,7 @@
                 </select>
               </div>
               <div class="create-page-button-container">
-                  <a id="link-to-template" href="{{ page.path }}"><button class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b"><i class="icon-fw icon-doc"></i>{{ t('Create') }}</button></a>
+                  <a id="link-to-template" href="{{ page.path || path }}"><button class="fcbtn btn btn-outline btn-rounded btn-primary btn-1b"><i class="icon-fw icon-doc"></i>{{ t('Create') }}</button></a>
               </div>
             </div>
           </fieldset>
@@ -68,15 +68,19 @@
   </div><!-- /.modal-dialog -->
 </div><!-- /.modal -->
 <script>
-  if($('#create-page')) {
-    const pagePath = $("#link-to-template").attr("href");
+  if($("#create-page")) {
+    let pagePath = $("#link-to-template").attr("href");
 
-    $('#template-type').on('change', () => {
-      if ($('#template-type').val() === 'local') {
+    if (pagePath.endsWith("/")) {
+      pagePath = pagePath.slice(0, -1);
+    };
+
+    $("#template-type").on("change", () => {
+      if ($("#template-type").val() === "local") {
         href = pagePath + "/__template#edit-form";
         $("#link-to-template").attr("href", href);
       }
-      else if ($('#template-type').val() === 'global') {
+      else if ($("#template-type").val() === "global") {
         href = pagePath + "/_template#edit-form";
         $("#link-to-template").attr("href", href);
       };