Browse Source

修改对话框

star7th 8 years ago
parent
commit
43990b0c54

+ 1 - 0
Application/Home/View/Common/footer.html

@@ -3,6 +3,7 @@
     <script src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script>
     <script src="__PUBLIC__/bootstrap/js/bootstrap.min.js"></script>
     <script src="__PUBLIC__/js/common/showdoc.js?v=1.1"></script>
     <script src="__PUBLIC__/js/common/showdoc.js?v=1.1"></script>
     <script src="__PUBLIC__/layer/layer.js"></script>
     <script src="__PUBLIC__/layer/layer.js"></script>
+    <script src="__PUBLIC__/js/dialog.js"></script>
     <div style="display:none">
     <div style="display:none">
     	{:C("STATS_CODE")}
     	{:C("STATS_CODE")}
     </div>
     </div>

+ 4 - 4
Public/js/catalog/edit.js

@@ -91,7 +91,7 @@ $(function(){
             secondCatList();
             secondCatList();
             //alert(lang["save_success"]);
             //alert(lang["save_success"]);
           }else{
           }else{
-            layer.alert(lang["save_fail"]);
+            $.alert(lang["save_fail"]);
           }
           }
           getCatList();
           getCatList();
         },
         },
@@ -103,7 +103,7 @@ $(function(){
 
 
   //删除目录
   //删除目录
   $("#delete-cat").click(function(){
   $("#delete-cat").click(function(){
-    layer.confirm(lang["confirm_to_delete"],{},function(){
+    $.confirm(lang["confirm_to_delete"],{},function(){
         var cat_id = $("#cat_id").val();
         var cat_id = $("#cat_id").val();
         if (cat_id > 0 ) {
         if (cat_id > 0 ) {
             $.post(
             $.post(
@@ -115,9 +115,9 @@ $(function(){
                     window.location.href="?s=home/catalog/edit&item_id="+item_id;
                     window.location.href="?s=home/catalog/edit&item_id="+item_id;
                   }else{
                   }else{
                     if (data.error_message) {
                     if (data.error_message) {
-                      layer.alert(data.error_message);
+                      $.alert(data.error_message);
                     }else{
                     }else{
-                      layer.alert(lang["delete_fail"]);
+                      $.alert(lang["delete_fail"]);
                     }
                     }
                     
                     
                   }
                   }

+ 65 - 0
Public/js/dialog.js

@@ -0,0 +1,65 @@
+/**
+ *  将layer.js的一些方法封装为showdoc常用的对话框.
+ *  调用方法如$.window("https://www.showdoc.cc/","测试","50%","50%");
+ */
+$(document).ready(function(){
+    jQuery.extend({
+        dialog_self:null,
+        //加载url,弹出窗口
+        window:function(url ,title , width ,height ,callback){
+            if (!title) {
+                title = '';
+            };
+            if (!width) {
+                width = '40%';
+            };
+            if (!height) {
+                height = '40%' ;
+            };
+            return layer.open({
+              type: 2,
+              title: title,
+              shadeClose: true,
+              shade: 0.8,
+              area: [width, height],
+              content: url ,//iframe的url
+              end:callback
+            });
+        },
+        //这是对应上面window()的关闭函数。window里面的iframe页面可以调用此方法来关闭自身
+        close_self_window:function(){
+            //假设这是iframe页
+            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
+            return parent.layer.close(index); //再执行关闭  
+        },
+
+        alert:function(content, options, yes){
+            return layer.alert(content, options, yes)
+        },
+
+        confirm:function(content, options, yes, cancel){
+            return layer.confirm(content, options, yes, cancel) ;
+        },
+
+        closeDialog:function(index){
+            return layer.close(index)  ;
+        },  
+
+        closeAll:function(type){
+            return layer.closeAll(type) ;
+        },
+    
+        prompt:function(options, yes){
+            return layer.prompt(options, yes);
+        },
+
+        msg:function(content, options, end){
+            return layer.msg(content, options, end);
+        },
+
+        photos:function(options){
+            return layer.photos(options);
+        },
+
+    });
+});

+ 1 - 1
Public/js/item/export.js

@@ -82,7 +82,7 @@ $(".export-submit").click(function(){
             var url = DocConfig.server+'/api/export/word_cat&item_id='+item_id+'&cat_id='+cat_id ;
             var url = DocConfig.server+'/api/export/word_cat&item_id='+item_id+'&cat_id='+cat_id ;
             window.location.href = url;
             window.location.href = url;
         }else{
         }else{
-            layer.alert("请选择要导出的目录");
+            $.alert("请选择要导出的目录");
         }
         }
     }
     }
 
 

+ 17 - 17
Public/js/item/setting.js

@@ -26,7 +26,7 @@ $(function(){
             $("#item_domain").val(data.data.item_domain);
             $("#item_domain").val(data.data.item_domain);
             $("#password").val(data.data.password);
             $("#password").val(data.data.password);
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"
@@ -46,10 +46,10 @@ $(function(){
         {"item_id":item_id,"item_name":item_name,"item_description":item_description,"item_domain":item_domain,"password":password},
         {"item_id":item_id,"item_name":item_name,"item_description":item_description,"item_domain":item_domain,"password":password},
         function(data){
         function(data){
           if (data.error_code === 0 ) {
           if (data.error_code === 0 ) {
-            layer.msg('保存成功',{"time":1000});
+            $.msg('保存成功',{"time":1000});
             get_base_info() ;
             get_base_info() ;
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"
@@ -74,14 +74,14 @@ $(function(){
         {"username": username ,"item_id": item_id , "password": password  },
         {"username": username ,"item_id": item_id , "password": password  },
         function(data){
         function(data){
           if (data.error_code == 0) {
           if (data.error_code == 0) {
-            layer.msg('转让成功,正在跳转回主页..',{"time":3000});
+            $.msg('转让成功,正在跳转回主页..',{"time":3000});
             //跳转
             //跳转
             setTimeout(function(){
             setTimeout(function(){
               window.location.href="?s=/home/item/index";
               window.location.href="?s=/home/item/index";
             },3000)
             },3000)
             
             
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"
@@ -105,14 +105,14 @@ $(function(){
         {"item_id": item_id , "password": password  },
         {"item_id": item_id , "password": password  },
         function(data){
         function(data){
           if (data.error_code == 0) {
           if (data.error_code == 0) {
-            layer.msg('删除成功,正在跳转回主页..',{"time":3000});
+            $.msg('删除成功,正在跳转回主页..',{"time":3000});
             //跳转
             //跳转
             setTimeout(function(){
             setTimeout(function(){
               window.location.href="?s=/home/item/index";
               window.location.href="?s=/home/item/index";
             },3000)
             },3000)
             
             
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"
@@ -154,7 +154,7 @@ $(function(){
 
 
             };
             };
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"
@@ -174,11 +174,11 @@ $(function(){
             $('#member-modal').modal('hide');
             $('#member-modal').modal('hide');
             $("#member_username").val('');
             $("#member_username").val('');
             $("#member_group_id").removeAttr("checked");
             $("#member_group_id").removeAttr("checked");
-            layer.msg('添加成功',{"time":1000});
+            $.msg('添加成功',{"time":1000});
             get_member_list();
             get_member_list();
             
             
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"
@@ -190,17 +190,17 @@ $(function(){
     //删除成员
     //删除成员
     $("#member-list").on("click",'.member-delete',function(){
     $("#member-list").on("click",'.member-delete',function(){
       var item_member_id = $(this).data("id");
       var item_member_id = $(this).data("id");
-      layer.confirm("确定删除成员吗",{},function(){
+      $.confirm("确定删除成员吗",{},function(){
           $.post(
           $.post(
             DocConfig.server+"/api/member/delete",
             DocConfig.server+"/api/member/delete",
             {"item_id": item_id , "item_member_id": item_member_id  },
             {"item_id": item_id , "item_member_id": item_member_id  },
             function(data){
             function(data){
               if (data.error_code == 0) {
               if (data.error_code == 0) {
-                layer.msg('删除成功',{"time":1000});
+                $.msg('删除成功',{"time":1000});
                 get_member_list();
                 get_member_list();
                 
                 
               }else{
               }else{
-                layer.alert(data.error_message);
+                $.alert(data.error_message);
               }
               }
             },
             },
             "json"
             "json"
@@ -225,10 +225,10 @@ $(function(){
         {"item_id": item_id , "password": password  },
         {"item_id": item_id , "password": password  },
         function(data){
         function(data){
           if (data.error_code == 0) {
           if (data.error_code == 0) {
-            layer.msg('归档成功',{"time":3000});
+            $.msg('归档成功',{"time":3000});
             $('#archive-item-modal').modal('hide');
             $('#archive-item-modal').modal('hide');
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"
@@ -249,7 +249,7 @@ $(function(){
             $("#api_key").html(data.data.api_key);
             $("#api_key").html(data.data.api_key);
             $("#api_token").html(data.data.api_token);
             $("#api_token").html(data.data.api_token);
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"
@@ -267,7 +267,7 @@ $(function(){
             $("#api_key").html(data.data.api_key);
             $("#api_key").html(data.data.api_key);
             $("#api_token").html(data.data.api_token);
             $("#api_token").html(data.data.api_token);
           }else{
           }else{
-            layer.alert(data.error_message);
+            $.alert(data.error_message);
           }
           }
         },
         },
         "json"
         "json"

+ 2 - 2
Public/js/item/show.js

@@ -289,7 +289,7 @@ function iFrameHeight() { 
       {"page_id":page_id},
       {"page_id":page_id},
       function(data){
       function(data){
         var html = "<p>最后编辑时间:"+data.data.addtime+"</p><p>编辑人:"+data.data.author_username+"</p>";
         var html = "<p>最后编辑时间:"+data.data.addtime+"</p><p>编辑人:"+data.data.author_username+"</p>";
-         layer.alert(html);
+         $.alert(html);
       },
       },
       "json"
       "json"
 
 
@@ -317,7 +317,7 @@ function iFrameHeight() { 
               }
               }
             ]
             ]
           }
           }
-        layer.photos({
+        $.photos({
           photos: json
           photos: json
           ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
           ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
         });
         });

+ 1 - 1
Public/js/item/show_single_page.js

@@ -113,7 +113,7 @@ $(function() {
         ]
         ]
       }
       }
 
 
-      layer.photos({
+      $.photos({
         photos: json,
         photos: json,
         anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
         anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
       });
       });

+ 8 - 8
Public/js/page/edit.js

@@ -341,7 +341,7 @@ $(function() {
   //{"Result":[{"name":"test1","list":{"pros":"prosfsf","ppps":{"images":[{"22":"22"}]}}}]}
   //{"Result":[{"name":"test1","list":{"pros":"prosfsf","ppps":{"images":[{"22":"22"}]}}}]}
 
 
   $("#save-to-templ").click(function() {
   $("#save-to-templ").click(function() {
-    layer.prompt({
+    $.prompt({
       title: lang["save_templ_title"]
       title: lang["save_templ_title"]
     }, function(template_title, index) {
     }, function(template_title, index) {
       if (template_title != null && template_title != "") {
       if (template_title != null && template_title != "") {
@@ -353,8 +353,8 @@ $(function() {
           },
           },
           function(data) {
           function(data) {
             if (data.error_code == 0) {
             if (data.error_code == 0) {
-              layer.close(index);
-              layer.alert(lang["saved_templ_msg1"] + template_title + lang["saved_templ_msg2"]);
+              $.closeDialog(index);
+              $.alert(lang["saved_templ_msg1"] + template_title + lang["saved_templ_msg2"]);
             } else {
             } else {
               $.bootstrapGrowl(lang["save_fail"]);
               $.bootstrapGrowl(lang["save_fail"]);
 
 
@@ -387,7 +387,7 @@ $(function() {
         } else {
         } else {
           //$.bootstrapGrowl("获取模板列表失败");
           //$.bootstrapGrowl("获取模板列表失败");
           $("#more-templ-modal").modal("hide");
           $("#more-templ-modal").modal("hide");
-          layer.alert(lang["no_templ_msg"]);
+          $.alert(lang["no_templ_msg"]);
 
 
         }
         }
       },
       },
@@ -429,18 +429,18 @@ $(function() {
               // 服务器返回错误
               // 服务器返回错误
             case 'error':
             case 'error':
               $the.attr('disabled', false);
               $the.attr('disabled', false);
-              layer.close(layer_index);
-              layer.alert('图片上传失败');
+              layer.closeDialog(layer_index);
+              $.alert('图片上传失败');
               break;
               break;
               // 上传成功
               // 上传成功
             case 'success':
             case 'success':
               $the.attr('disabled', false);
               $the.attr('disabled', false);
-              layer.close(layer_index);
+              layer.closeDialog(layer_index);
               if (data.success == 1) {
               if (data.success == 1) {
                 var value = '![](' + data.url + ')';
                 var value = '![](' + data.url + ')';
                 editormd.insertValue(value);
                 editormd.insertValue(value);
               } else {
               } else {
-                layer.alert(data.message);
+                $.alert(data.message);
               }
               }
 
 
               break;
               break;