-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
625 lines (587 loc) · 24 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>pcshowmodal</title>
<link type="text/css" href="dist/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<style>
.m-b-1pc {
margin-bottom: 1pc;
}
.code {
white-space: pre-wrap;
overflow: hidden;
word-break: break-all;
word-wrap: break-word;
}
</style>
</head>
<body>
<ol class="list-unstyle">
<li class="h3">不需要修改默认提示的标题仅做修改提示内容</li>
<button class="btn btn-info m-b-1pc changeContent">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({content:"请确认相关信息是否都填写完成"});
</pre>
<li class="h3">primary弹窗</li>
<button class="btn btn-info m-b-1pc primaryModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"primary",Qclose: true});
</pre>
<li class="h3">secondary弹窗</li>
<button class="btn btn-info m-b-1pc secondaryModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"secondary",Qclose: true});
</pre>
<li class="h3">success弹窗</li>
<button class="btn btn-info m-b-1pc successModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"success",Qclose: true});
</pre>
<li class="h3">danger弹窗</li>
<button class="btn btn-info m-b-1pc dangerModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"danger",Qclose: true});
</pre>
<li class="h3">warning弹窗</li>
<button class="btn btn-info m-b-1pc warningModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"warning",Qclose: true});
</pre>
<li class="h3">info弹窗(默认值)</li>
<button class="btn btn-info m-b-1pc infoModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"info",Qclose: true});
</pre>
<li class="h3">light弹窗</li>
<button class="btn btn-info m-b-1pc lightModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"light",Qclose: true});
</pre>
<li class="h3">dark弹窗</li>
<button class="btn btn-info m-b-1pc darkModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"dark",Qclose: true});
</pre>
<li class="h3">white弹窗</li>
<button class="btn btn-info m-b-1pc whiteModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({flag:"white",Qclose: true});
</pre>
<li class="h3">需要修改默认提示的标题并修改提示内容相关样式</li>
<button class="btn btn-info m-b-1pc changeTitleContent">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
SWidth: 200,
fontSize: 14
});
</pre>
<li class="h3">模态窗body内容左对齐,标题居中对齐显示</li>
<button class="btn btn-info m-b-1pc changeBodyAlign">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成, 请确认相关信息是否都填写完成, 请确认相关信息是否都填写完成",
SWidth: 400,
fontSize: 14,
titleCenter:true,
contentLeft:true
});
</pre>
<li class="h3"> 点击模态窗灰色背景处模态窗不会消失</li>
<button class="btn btn-info m-b-1pc clickBg">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({content:"请确认相关信息是否都填写完成",hideClick:"static "});
</pre>
<li class="h3">在弹窗初始加载之后做点事情</li>
<button class="btn btn-info m-b-1pc modalShow">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
content:"请确认相关信息是否都填写完成",
callbackShown:function(){
console.log("西瓜酱喜欢吃西瓜,已经打开弹窗啦");
}
})
</pre>
<li class="h3">在弹窗关闭之后做点事情</li>
<button class="btn btn-info m-b-1pc modalHide">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
content:"请确认相关信息是否都填写完成",
callbackHide:function(){
console.log("西瓜酱喜欢吃西瓜,已经打开弹窗啦");
}
})
</pre>
<li class="h3">modal-body内容为iframe,需要传比较少的参数</li>
<button class="btn btn-info m-b-1pc BodyIframe">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
isText: false,//该参数一定要设置为false,src相关参数才会起作用
title: "打开西瓜博客",
src: "https://mowatermelon.github.io/?key=demo",//该参数用于绑定iframe的地址,也可通过地址传参
Bclose: false
});
</pre>
<li class="h3">需要通过iframe地址传递部分参数,需要传比较多的参数</li>
<button class="btn btn-info m-b-1pc BodyIframeBig">尝试一下</button>
<br />
<pre class="code text-info h6">
let bigParam = {
a: 1,
b: 2,
c: '西瓜',
d: 1,
e: 2,
f: '西瓜',
g: 1,
h: 2,
i: '西瓜'
}
showmodal({
isText: false,
src: "https://mowatermelon.github.io/",
data: bigParam,
callbackShown:function(){
let _this = this;
console.log(_this.src);
console.log(_this.translateParamsToJson());
}
})
</pre>
<li class="h3">modal-body内容为iframe,需要modal-body中存在padding</li>
<button class="btn btn-info m-b-1pc BodyIframePadding">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
isText: false,//该参数一定要设置为false,src相关参数才会起作用
title: "打开西瓜博客",
src: "https://mowatermelon.github.io/",//该参数用于绑定iframe的地址
iframePadding: true
});
</pre>
<li class="h3">modal-body内容为iframe,且iframe中使用到input</li>
<button class="btn btn-info m-b-1pc BodyIframeInput">尝试一下</button>
<br />
<pre class="code text-info h6">
//在父级页面中
showmodal({
isText: false, //该参数一定要设置为false,src相关参数才会起作用
title: "打开西瓜博客 ",
src: "https://mowatermelon.github.io/",//该参数用于绑定iframe的地址
Bclose: false
});
//在子级页面中添加以下语句
$(function () {
$(document).off('focusin.bs.modal');//避免bootstrap 的input内部聚焦错乱,导致iframe中的input不能正常聚焦,这句话在子页面一定要写。
$("#txtXXX").focus();
})
</pre>
<li class="h3">确认按钮有回调事件(非异步)</li>
<button class="btn btn-info m-b-1pc Bcallback">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
callbackB: true,
callbackBF:function(){
//dosomething
console.log("确认按钮的非异步回调事件");
return true;
/*
请注意一定要写返回值,
不需要阻断模态窗关闭事件,则直接返回true
需要阻断模态窗关闭事件,则直接返回false
*/
}
});
</pre>
<li class="h3">确认按钮有回调事件(异步)</li>
<button class="btn btn-info m-b-1pc BcallbackSync">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
callbackB: true,
callbackBF:function(){
var _this=this; // 请注意一定要先在ajax外部指明需要需要使用到的this,这个this即showmodal,这样在ajax内部才能调用到showmodal默认的相关方法
//如果是谷歌浏览器,需要在启动项中设置--allow-file-access-from-files才能进行跨域
$.ajax({
type: "POST",
url: "demo.json? &T=" + Math.random(),
dataType: 'text',
async: false,
success: function (t) {
var data = window.eval('(' + t + ')');
if (t.length > 0) {
console.log("确认按钮的异步回调事件完成");
console.log("请求到的参数是"+data.news);
_this.closeModal();
//请注意在异步事件状态为完成的时候再调用关闭模态窗事件
}
}
});
return false;// 请注意异步执行的回调方法一定要返回false
}
});
</pre>
<li class="h3">取消按钮有回调事件(非异步)需要两个按钮两端对齐</li>
<button class="btn btn-info m-b-1pc justifyQcallback">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
Qclose: true,
Justify:true,
callbackQ: true,
callbackQF:function(){
//dosomething
console.log("取消按钮的非异步回调事件");
return true;
/*
请注意一定要写返回值,
不需要阻断模态窗关闭事件,则直接返回true
需要阻断模态窗关闭事件,则直接返回false
*/
}
});
</pre>
<li class="h3">取消按钮有回调事件(非异步)不需要两个按钮两端对齐</li>
<button class="btn btn-info m-b-1pc Qcallback">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
Qclose: true,
callbackQ: true,
callbackQF:function(){
//dosomething
console.log("取消按钮的非异步回调事件");
return true;
}
});
</pre>
<li class="h3">需要多次嵌套调用模态窗</li>
<button class="btn btn-info m-b-1pc manyModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
title: "提示信息",
content: "确定吗1",
modalIndex: "01",
Qclose: true,
callbackB: true,
callbackBF: function() {
showmodal({
title: "提示信息",
modalIndex: "02",
content: "确定吗2",
Qclose: true,
SWidth: "300",
hideClick: "static",
fontSize: "18",
callbackB: true,
callbackBF: function() {
showmodal({
title: "提示信息",
modalIndex: "03",
content: "确定吗3",
Qclose: true,
SWidth: "200",
hideClick: "static",
fontSize: "18"
});
return false;
}
});
return false;
}
});
</pre>
<li class="h3">需要使用全屏显示按钮</li>
<button class="btn btn-info m-b-1pc zoomModal">尝试一下</button>
<br />
<pre class="code text-info h6">
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成, 请确认相关信息是否都填写完成, 请确认相关信息是否都填写完成",
isZoom: true,
zoomCallback: function (){
console.log(this.Sheight,this.SWidth);
}
});
</pre>
</ol>
</body>
<script type="text/javascript" src="dist/js/jquery.min.js"></script>
<script type="text/javascript" src="dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="dist/js/pcmodal.js"></script>
<script type="text/javascript">
$(function () {
$(".changeContent").click(function () {
showmodal({
content: "请确认相关信息是否都填写完成"
});
});
$(".primaryModal").click(function () {
showmodal({ flag: "primary",Qclose: true });
});
$(".secondaryModal").click(function () {
showmodal({ flag: "secondary",Qclose: true });
});
$(".successModal").click(function () {
showmodal({ flag: "success",Qclose: true});
});
$(".dangerModal").click(function () {
showmodal({ flag: "danger",Qclose: true });
});
$(".warningModal").click(function () {
showmodal({ flag: "warning",Qclose: true });
});
$(".infoModal").click(function () {
showmodal({ flag: "info",Qclose: true });
});
$(".lightModal").click(function () {
showmodal({ flag: "light",Qclose: true });
});
$(".darkModal").click(function () {
showmodal({ flag: "dark",Qclose: true });
});
$(".whiteModal").click(function () {
showmodal({ flag: "white",Qclose: true });
});
$(".changeTitleContent").click(function () {
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
SWidth: 200,
fontSize: 14
});
});
$(".changeBodyAlign").click(function () {
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成, 请确认相关信息是否都填写完成, 请确认相关信息是否都填写完成",
SWidth: 400,
fontSize: 14,
titleCenter: true,
contentLeft: true
});
});
$(".clickBg").click(function () {
showmodal({
content: "请确认相关信息是否都填写完成",
hideClick: "static"
});
});
$(".modalShow").click(function () {
showmodal({
content: "请确认相关信息是否都填写完成",
callbackShown: function () {
console.log("西瓜酱喜欢吃西瓜,已经打开弹窗啦");
}
})
});
$(".modalHide").click(function () {
showmodal({
content: "请确认相关信息是否都填写完成",
callbackHide: function () {
console.log("西瓜酱喜欢吃西瓜,关闭弹窗啦");
}
})
});
$(".BodyIframe").click(function () {
showmodal({
isText: false, //该参数一定要设置为false,src相关参数才会起作用
title: "打开西瓜博客",
src: "https://mowatermelon.github.io/?key=demo", //该参数用于绑定iframe的地址,也可通过地址传参
Bclose: false
});
});
$(".BodyIframeBig").click(function () {
let bigParam = {
a: 1,
b: 2,
c: '西瓜',
d: 1,
e: 2,
f: '西瓜',
g: 1,
h: 2,
i: '西瓜'
}
showmodal({
isText: false, //该参数一定要设置为false,src相关参数才会起作用
title: "打开西瓜博客",
src: "https://mowatermelon.github.io/", //该参数用于绑定iframe的地址,也可通过地址传参
data: bigParam,
callbackShown: function () {
let _this = this;
console.log(_this.src);
console.log(_this.translateParamsToJson());
}
});
});
$(".BodyIframePadding").click(function () {
showmodal({
isText: false, //该参数一定要设置为false,src相关参数才会起作用
title: "打开西瓜博客",
src: "https://mowatermelon.github.io/", //该参数用于绑定iframe的地址,也可通过地址传参
Bclose: false,
iframePadding: true
});
});
$(".BodyIframeInput").click(function () {
showmodal({
isText: false, //该参数一定要设置为false,src相关参数才会起作用
title: "打开西瓜博客",
src: "https://mowatermelon.github.io/", //该参数用于绑定iframe的地址,也可通过地址传参
Bclose: false
});
});
$(".Bcallback").click(function () {
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
callbackB: true,
callbackBF: function () {
//dosomething
console.log("确认按钮的非异步回调事件");
return true;
/*
请注意一定要写返回值,
不需要阻断模态窗关闭事件,则直接返回true
需要阻断模态窗关闭事件,则直接返回false
*/
}
});
});
$(".BcallbackSync").click(function () {
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
callbackB: true,
callbackBF: function () {
var _this = this; // 请注意一定要先在ajax外部指明需要需要使用到的this,这个this即showmodal,这样在ajax内部才能调用到showmodal默认的相关方法
$.ajax({
type: "POST",
url: "demo.json? &T=" + Math.random(),
dataType: 'text',
async: false,
success: function (t) {
var data = window.eval('(' + t + ')');
if (t.length > 0) {
console.log("确认按钮的异步回调事件完成");
console.log("请求到的参数是" + data.news);
_this.closeModal();
//请注意在异步事件状态为完成的时候再调用关闭模态窗事件
}
}
});
return false; // 请注意异步执行的回调方法一定要返回false
}
});
});
$(".Qcallback").click(function () {
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
Qclose: true,
callbackQ: true,
callbackQF: function () {
//dosomething
console.log("取消按钮的非异步回调事件");
return true;
/*
请注意一定要写返回值,
不需要阻断模态窗关闭事件,则直接返回true
需要阻断模态窗关闭事件,则直接返回false
*/
}
});
});
$(".justifyQcallback").click(function () {
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成",
Qclose: true,
Justify: true,
callbackQ: true,
callbackQF: function () {
//dosomething
console.log("取消按钮的非异步回调事件");
return true;
}
});
});
$(".manyModal").click(function () {
showmodal({
title: "提示信息",
content: "确定吗1",
modalIndex: "01",
Qclose: true,
callbackB: true,
callbackBF: function () {
showmodal({
title: "提示信息",
modalIndex: "02",
content: "确定吗2",
Qclose: true,
SWidth: "300",
hideClick: "static",
fontSize: "18",
callbackB: true,
callbackBF: function () {
showmodal({
title: "提示信息",
modalIndex: "03",
content: "确定吗3",
Qclose: true,
SWidth: "200",
hideClick: "static",
fontSize: "18"
});
return false;
}
});
return false;
}
});
});
$(".zoomModal").click(function () {
showmodal({
title: "警告",
content: "请确认相关信息是否都填写完成, 请确认相关信息是否都填写完成, 请确认相关信息是否都填写完成",
isZoom: true,
zoomCallback: function () {
console.log(this.Sheight, this.SWidth);
}
});
})
})
</script>
</html>