Explorar el Código

公共弹框插件,模块化

xueli.xue hace 9 años
padre
commit
8e2d6d8dac

+ 6 - 108
xxl-job-admin/src/main/webapp/WEB-INF/template/common/common.macro.ftl Ver fichero

@@ -44,10 +44,14 @@
44 44
     <script src="${request.contextPath}/static/plugins/scrollup/jquery.scrollUp.min.js"></script>
45 45
     <!-- pace -->
46 46
     <script src="${request.contextPath}/static/plugins/pace/pace.min.js"></script>
47
-    <script src="${request.contextPath}/static/plugins/jquery/jquery.cookie.js"></script>
47
+    <#-- jquery cookie -->
48
+	<script src="${request.contextPath}/static/plugins/jquery/jquery.cookie.js"></script>
49
+
50
+	<#-- common -->
51
+    <script src="${request.contextPath}/static/js/xxl.alert.1.js"></script>
48 52
     <script src="${request.contextPath}/static/js/common.1.js"></script>
49
-    
50 53
     <script>var base_url = '${request.contextPath}';</script>
54
+
51 55
 </#macro>
52 56
 
53 57
 <#macro commonHeader>
@@ -175,110 +179,4 @@
175 179
 			<a href="http://my.oschina.net/xuxueli/blog/690978" target="_blank" >oschina</a>
176 180
 		</strong><!-- All rights reserved. -->
177 181
 	</footer>
178
-</#macro>
179
-
180
-<#macro comAlert >
181
-	<!-- ComAlert.模态框Modal -->
182
-	<div class="modal fade" id="ComAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
183
-		<div class="modal-dialog">
184
-			<div class="modal-content">
185
-				<!--	<div class="modal-header"><h4 class="modal-title"><strong>提示:</strong></h4></div>	-->
186
-	         	<div class="modal-body"><div class="alert alert-success"></div></div>
187
-	         	<div class="modal-footer">
188
-	         		<div class="text-center" >
189
-	            		<button type="button" class="btn btn-default ok" data-dismiss="modal" >确认</button>
190
-	            	</div>
191
-	         	</div>
192
-			</div>
193
-		</div>
194
-	</div>
195
-	<!-- ComConfirm.模态框Modal -->
196
-	<div class="modal fade" id="ComConfirm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
197
-		<div class="modal-dialog">
198
-			<div class="modal-content">
199
-	         	<div class="modal-body"><div class="alert alert-success"></div></div>
200
-	         	<div class="modal-footer">
201
-	         		<div class="text-center" >
202
-	            		<button type="button" class="btn btn-primary ok" data-dismiss="modal" >确认</button>
203
-	            		<button type="button" class="btn btn-default cancel" data-dismiss="modal" >取消</button>
204
-	            	</div>
205
-	         	</div>
206
-			</div>
207
-		</div>
208
-	</div>
209
-	<!-- ComAlertTec.模态框Modal-科技感 -->
210
-	<div class="modal fade" id="ComAlertTec" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
211
-		<div class="modal-dialog">
212
-			<div class="modal-content-tec">
213
-	         	<div class="modal-body"><div class="alert" style="color:#fff;"></div></div>
214
-	         	<div class="modal-footer">
215
-	         		<div class="text-center" >
216
-	            		<button type="button" class="btn btn-info ok" data-dismiss="modal" >确认</button>
217
-	            	</div>
218
-	         	</div>
219
-			</div>
220
-		</div>
221
-	</div>
222
-	<script>
223
-		// 通用提示
224
-		var ComAlert = {
225
-			show:function(type, msg, callback){
226
-				// 弹框初始
227
-				if (type == 1) {
228
-					$('#ComAlert .alert').attr('class', 'alert alert-success');
229
-				} else {
230
-					$('#ComAlert .alert').attr('class', 'alert alert-warning');
231
-				}
232
-				$('#ComAlert .alert').html(msg);
233
-				$('#ComAlert').modal('show');
234
-				
235
-				$('#ComAlert .ok').click(function(){
236
-					$('#ComAlert').modal('hide');
237
-					if(typeof callback == 'function') {
238
-						callback();
239
-					}
240
-				});
241
-				
242
-				// $("#ComAlert").on('hide.bs.modal', function () {	});	// 监听关闭
243
-			}
244
-		};
245
-		// 通用确认弹框
246
-		var ComConfirm = {
247
-			show:function(msg, callback){
248
-				// 弹框初始
249
-				$('#ComConfirm .alert').attr('class', 'alert alert-warning');
250
-				$('#ComConfirm .alert').html(msg);
251
-				$('#ComConfirm').modal('show');
252
-				
253
-				$('#ComConfirm .ok').unbind("click");	// 解绑陈旧事件
254
-				$('#ComConfirm .ok').click(function(){
255
-					$('#ComConfirm').modal('hide');
256
-					if(typeof callback == 'function') {
257
-						callback();
258
-						return;
259
-					}
260
-				});
261
-				
262
-				$('#ComConfirm .cancel').click(function(){
263
-					$('#ComConfirm').modal('hide');
264
-					return;
265
-				});
266
-			}
267
-		};
268
-		// 提示-科技主题
269
-		var ComAlertTec = {
270
-			show:function(msg, callback){
271
-				// 弹框初始
272
-				$('#ComAlertTec .alert').html(msg);
273
-				$('#ComAlertTec').modal('show');
274
-				
275
-				$('#ComAlertTec .ok').click(function(){
276
-					$('#ComAlertTec').modal('hide');
277
-					if(typeof callback == 'function') {
278
-						callback();
279
-					}
280
-				});
281
-			}
282
-		};
283
-	</script>
284 182
 </#macro>

+ 0 - 1
xxl-job-admin/src/main/webapp/WEB-INF/template/help.ftl Ver fichero

@@ -52,6 +52,5 @@
52 52
 	<@netCommon.commonFooter />
53 53
 </div>
54 54
 <@netCommon.commonScript />
55
-<@netCommon.comAlert />
56 55
 </body>
57 56
 </html>

+ 0 - 1
xxl-job-admin/src/main/webapp/WEB-INF/template/jobcode/jobcode.index.ftl Ver fichero

@@ -88,7 +88,6 @@
88 88
 		<@netCommon.commonFooter />
89 89
 	</div>
90 90
 	
91
-<@netCommon.comAlert />
92 91
 <@netCommon.commonScript />
93 92
 <script src="${request.contextPath}/static/plugins/codemirror/lib/codemirror.js"></script>
94 93
 <script src="${request.contextPath}/static/plugins/codemirror/mode/clike/clike.js"></script>

+ 0 - 1
xxl-job-admin/src/main/webapp/WEB-INF/template/jobinfo/jobinfo.index.ftl Ver fichero

@@ -250,7 +250,6 @@ public class DemoJobHandler extends IJobHandler {
250 250
 </div>
251 251
 
252 252
 <@netCommon.commonScript />
253
-<@netCommon.comAlert />
254 253
 <!-- DataTables -->
255 254
 <script src="${request.contextPath}/static/adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
256 255
 <script src="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>

+ 0 - 1
xxl-job-admin/src/main/webapp/WEB-INF/template/joblog/joblog.index.ftl Ver fichero

@@ -104,7 +104,6 @@
104 104
 </div>
105 105
 
106 106
 <@netCommon.commonScript />
107
-<@netCommon.comAlert />
108 107
 <!-- DataTables -->
109 108
 <script src="${request.contextPath}/static/adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
110 109
 <script src="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>

+ 0 - 1
xxl-job-admin/src/main/webapp/WEB-INF/template/login.ftl Ver fichero

@@ -38,7 +38,6 @@
38 38
 		</form>
39 39
 	</div>
40 40
 <@netCommon.commonScript />
41
-<@netCommon.comAlert />
42 41
 <script src="${request.contextPath}/static/plugins/jquery/jquery.validate.min.js"></script>
43 42
 <script src="${request.contextPath}/static/plugins/iCheck/icheck.min.js"></script>
44 43
 <script src="${request.contextPath}/static/js/login.1.js"></script>

+ 132 - 0
xxl-job-admin/src/main/webapp/static/js/xxl.alert.1.js Ver fichero

@@ -0,0 +1,132 @@
1
+/**
2
+ * Created by xuxueli on 16/8/12.
3
+ *
4
+ * dependency, jquery + bootstrap
5
+ */
6
+
7
+// 通用提示
8
+var ComAlert = {
9
+    html:function(){
10
+        var html =
11
+            '<div class="modal fade" id="ComAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
12
+                '<div class="modal-dialog">' +
13
+                    '<div class="modal-content">' +
14
+                        '<div class="modal-header hidden"><h4 class="modal-title"><strong>提示:</strong></h4></div>' +
15
+                        '<div class="modal-body"><div class="alert alert-success"></div></div>' +
16
+                        '<div class="modal-footer">' +
17
+                            '<div class="text-center" >' +
18
+                                '<button type="button" class="btn btn-default ok" data-dismiss="modal" >确认</button>' +
19
+                            '</div>' +
20
+                        '</div>' +
21
+                    '</div>' +
22
+                '</div>' +
23
+            '</div>';
24
+        return html;
25
+    },
26
+    show:function(type, msg, callback){
27
+        // dom init
28
+        if ($('#ComAlert').length == 0){
29
+            $('body').append(ComAlert.html());
30
+        }
31
+
32
+        // 弹框初始
33
+        if (type == 1) {
34
+            $('#ComAlert .alert').attr('class', 'alert alert-success');
35
+        } else {
36
+            $('#ComAlert .alert').attr('class', 'alert alert-warning');
37
+        }
38
+        $('#ComAlert .alert').html(msg);
39
+        $('#ComAlert').modal('show');
40
+
41
+        $('#ComAlert .ok').click(function(){
42
+            $('#ComAlert').modal('hide');
43
+            if(typeof callback == 'function') {
44
+                callback();
45
+            }
46
+        });
47
+
48
+        // $("#ComAlert").on('hide.bs.modal', function () {	});	// 监听关闭
49
+    }
50
+};
51
+
52
+// 通用确认弹框
53
+var ComConfirm = {
54
+    html:function(){
55
+        var html =
56
+            '<div class="modal fade" id="ComConfirm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
57
+                '<div class="modal-dialog">' +
58
+                    '<div class="modal-content">' +
59
+                        '<div class="modal-body"><div class="alert alert-success"></div></div>' +
60
+                            '<div class="modal-footer">' +
61
+                            '<div class="text-center" >' +
62
+                                '<button type="button" class="btn btn-primary ok" data-dismiss="modal" >确认</button>' +
63
+                                '<button type="button" class="btn btn-default cancel" data-dismiss="modal" >取消</button>' +
64
+                            '</div>' +
65
+                        '</div>' +
66
+                    '</div>' +
67
+                '</div>' +
68
+            '</div>';
69
+        return html;
70
+    },
71
+    show:function(msg, callback){
72
+        // dom init
73
+        if ($('#ComConfirm').length == 0){
74
+            $("body").append(ComConfirm.html());
75
+        }
76
+
77
+        // 弹框初始
78
+        $('#ComConfirm .alert').attr('class', 'alert alert-warning');
79
+        $('#ComConfirm .alert').html(msg);
80
+        $('#ComConfirm').modal('show');
81
+
82
+        $('#ComConfirm .ok').unbind("click");	// 解绑陈旧事件
83
+        $('#ComConfirm .ok').click(function(){
84
+            $('#ComConfirm').modal('hide');
85
+            if(typeof callback == 'function') {
86
+                callback();
87
+                return;
88
+            }
89
+        });
90
+
91
+        $('#ComConfirm .cancel').click(function(){
92
+            $('#ComConfirm').modal('hide');
93
+            return;
94
+        });
95
+    }
96
+};
97
+// 提示-科技主题
98
+var ComAlertTec = {
99
+    html:function(){
100
+        var html =
101
+            '<div class="modal fade" id="ComAlertTec" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
102
+                '<div class="modal-dialog">' +
103
+                    '<div class="modal-content-tec">' +
104
+                        '<div class="modal-body"><div class="alert" style="color:#fff;"></div></div>' +
105
+                        '<div class="modal-footer">' +
106
+                            '<div class="text-center" >' +
107
+                                '<button type="button" class="btn btn-info ok" data-dismiss="modal" >确认</button>' +
108
+                            '</div>' +
109
+                        '</div>' +
110
+                    '</div>' +
111
+                '</div>' +
112
+            '</div>';
113
+        return html;
114
+    },
115
+    show:function(msg, callback){
116
+        // dom init
117
+        if ($('#ComAlertTec').length == 0){
118
+            $('body').append(ComAlertTec.html());
119
+        }
120
+
121
+        // 弹框初始
122
+        $('#ComAlertTec .alert').html(msg);
123
+        $('#ComAlertTec').modal('show');
124
+
125
+        $('#ComAlertTec .ok').click(function(){
126
+            $('#ComAlertTec').modal('hide');
127
+            if(typeof callback == 'function') {
128
+                callback();
129
+            }
130
+        });
131
+    }
132
+};