forked from aui/artDialog
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
1288 lines (1206 loc) · 56.3 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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta name="description" content="artDialog" />
<meta name="keywords" content="artDialog, dialog" />
<title>artDialog</title>
<!--[if gte IE 7]><!-->
<link id="artDialog-skin" href="./skins/green.css" rel="stylesheet" />
<!--<![endif]-->
<!--[if lt IE 7]>
<link id="artDialog-skin" href="./skins/default.css" rel="stylesheet" />
<![endif]-->
<script src="source/artDialog.js" type="text/javascript"></script>
<script type="text/javascript">
(function (d) {
d['okValue'] = '确定';
d['cancelValue'] = '取消';
d['title'] = '消息';
// [more..]
})(art.dialog.defaults);
</script>
<style type="text/css">
body { font-size:14px; color:#666; font-family:'Microsoft Yahei', Tahoma, Arial!important; font-family:Tahoma, Arial; background:#dbdfe3; }
a { color:#039; }
a:hover { color:#06C; }
img { border:none 0; }
body.showChange .change { background:#FF0; border-radius: 3px; }
h1.title { text-align:center; color:#30475e; }
h1.title strong { font-size:42px; position:relative; }
h1.title strong:after { content:''; display:block; position:absolute; left:0; bottom:24px; width:90%; height:1px; box-shadow:0 20px 15px rgba(0, 0, 0, .8); }
#header, #main, #footer { width:640px; margin:auto; }
#header .summary { padding:20px; background:#30475e; color:#FFF; border-radius: 8px; zoom:1; }
#header .summary:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
#header .summary a { color:#FFF; }
#header .summary a:hover { color:#CCC; }
#header .summary strong { display:inline-block; width:5em; }
#header .summary dl { padding:0; margin:0; }
#header .summary dd { margin-left:0; padding:3px 0; }
#header .summary dt { display:none; }
#header .summary dd.photo { float:right; }
#header .summary img { border:1px #506f8e solid; }
#main .card { padding:20px; margin-top:30px; background: #FFF; border:1px solid #d1d6db; border-radius: 8px; }
#main .card:after { position:relative; z-index:-1; content: ""; padding:20px; display: block; height: 10px; border-radius: 10px; box-shadow:0 20px 20px rgba(2, 37, 69, .6); }
#main .card h2 { text-align:center; color:#000; }
#main .card ul dl { padding-left:1em; border-left:1px dashed #DDD; }
#main .card ul dt { padding:8px 0; font-weight:bold; }
#main .card ul dd { margin-left:0; }
#main .card ul dd dl { margin-left:2em; }
#footer { padding:20px 0; text-align:center; color:#999; }
#footer .copyright a { color:#999; }
/*///// code /////*/
.runCode:after { content: "..."; }
.button, .runCode { display:inline-block; padding:1px 12px; text-decoration:none; color: #333 !important; cursor:pointer; border: solid 1px #999; border-radius: 5px; background: #DDD; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#DDDDDD');
background: linear-gradient(top, #FFF, #DDD); background: -moz-linear-gradient(top, #FFF, #DDD); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFF), to(#DDD)); text-shadow: 0px 1px 1px rgba(255, 255, 255, 1); box-shadow: 0 1px 0 rgba(255, 255, 255, .2), 0 -1px 0 rgba(0, 0, 0, .09); -moz-transition:-moz-box-shadow linear .2s;
-webkit-transition: -webkit-box-shadow linear .2s;
transition: box-shadow linear .2s;
white-space: nowrap; }
.button:focus, .runCode:focus { outline:none 0; border-color:#426DC9; box-shadow:0 0 8px rgba(66, 109, 201, .9); }
.button:hover, .runCode:hover { color:#000; border-color:#666; }
.button:active, .runCode:active { border-color:#666; filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#DDDDDD', endColorstr='#FFFFFF');
background: linear-gradient(top, #DDD, #FFF); background: -moz-linear-gradient(top, #DDD, #FFF); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#DDD), to(#FFF)); box-shadow:inset 0 1px 5px rgba(66, 109, 201, .9), inset 0 1px 1em rgba(0, 0, 0, .3); }
.button[disabled] { cursor:default; color:#666; background:#DDD; border: 1px solid #999; filter:alpha(opacity=50); opacity:.5; box-shadow:none; }
pre { position:relative; padding:5px; font-size:12px; border:1px solid #EFEFEF; background:#F9F9F9; z-index:2; border-radius: 5px; }
pre:before, pre:after { visibility:hidden; display:block; content:""; width:0; height:0; border:9px solid transparent; position:absolute; }
pre:before { border-top-color:#EEF7F5; position:absolute; left:18px; bottom:-18px; z-index:2; }
pre:after { border-top-color:#c7dcd3; left:18px; bottom:-19px; z-index:1; }
pre.select { background:#EEF7F5 !important; border:1px solid #D7EAE2; border-right-color:#c7dcd3; border-bottom-color:#c7dcd3; }
pre.select:before, pre.select:after { visibility:visible; }
/*//// skin ////*/
#skins { width:560px; padding:8px 0; }
#skins .button { width:82px; text-align:center; }
#skins ul, #skins li { padding:0; margin:0; list-style:none; }
#skins li { display:inline; }
#skins ul { text-align:center; }
#showChange { position:fixed; bottom:0; right:0; z-index:87; }
@media only screen and (max-width:980px) {
h1.title {
font-size:24px;
}
#header, #main, #footer {
max-width:100%;
}
img {
max-width:100%
}
}
@media print {
#header .summary, a { color: #000 !important; }
#header, #main, #footer { width:auto; }
#main .card { padding:10px; margin-top:10px; box-shadow:none; border:none 0; border-top: 1px dashed #666; border-radius:0; }
#main .card h2 { text-align:left; }
#main .card:after { display:none; }
h1.title strong:after, #index, #print, .runCode, .button, #skin-menu { display:none; }
}
</style>
<!-- Dw 风格代码高亮 -->
<style type="text/css">
pre.sh_sourceCode { color: #000000; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_keyword { color: #009; font-weight: bold; font-style: normal; }
pre.sh_sourceCode .sh_type { color: #0000ff; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_string { color: #00F; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_regexp { color: #060; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_specialchar { color: #C42DA8; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_comment { color: #999; font-weight: normal; font-style: italic; }
pre.sh_sourceCode .sh_number { color: #F00; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_preproc { color: #00b800; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_symbol { color: #009; font-weight: bold; font-style: normal; }
pre.sh_sourceCode .sh_function { color: #000; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_cbracket { color: #009; font-weight: bold; font-style: normal; }
pre.sh_sourceCode .sh_url { color: #ff0000; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_date { color: #0000ff; font-weight: bold; font-style: normal; }
pre.sh_sourceCode .sh_time { color: #0000ff; font-weight: bold; font-style: normal; }
pre.sh_sourceCode .sh_file { color: #0000ff; font-weight: bold; font-style: normal; }
pre.sh_sourceCode .sh_ip { color: #ff0000; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_name { color: #ff0000; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_variable { color: #ec7f15; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_oldfile { color: #C42DA8; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_newfile { color: #ff0000; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_difflines { color: #0000ff; font-weight: bold; font-style: normal; }
pre.sh_sourceCode .sh_selector { color: #ec7f15; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_property { color: #0000ff; font-weight: bold; font-style: normal; }
pre.sh_sourceCode .sh_value { color: #ff0000; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_predef_var { color: #909; font-weight: normal; font-style: normal; }
pre.sh_sourceCode .sh_predef_func { color: #099; font-weight: normal; font-style: normal; }
</style>
</head>
<body>
<div id="header">
<h1 class="title"><strong>artDialog™</strong><span id="artVersion"></span></h1>
<div class="summary" id="summary">
<p>artDialog 是一个设计得十分巧妙的对话框组件,小巧身材却拥有丰富的接口与漂亮的外观。</p>
<ul>
<li>自适应内容</li>
<li>优雅的接口</li>
<li>细致的体验</li>
<li>跨平台兼容</li>
<li>信息无障碍</li>
</ul>
<p><strong>项目主页</strong>: <a href="https://github.com/aui/artDialog">https://github.com/aui/artDialog</a></p>
<p id="skin-menu">对话框样式选择:<a id="showSkinDialog" class="button" href="javascript:;">green</a></p>
</div>
</div>
<div id="main">
<div id="index" class="card">
<h2>文档索引</h2>
<ul>
<li>
<h3><a href="#lead">快速上手</a></h3>
</li>
<li>
<h3><a href="#options">配置参数</a></h3>
<ul>
<li>
<h4>内容</h4>
<ul>
<li><a href="#options-title">title</a></li>
<li><a href="#options-content">content</a></li>
</ul>
</li>
<li>
<h4>按钮</h4>
<ul>
<li><a href="#options-ok" class="change">ok</a></li>
<li><a href="#options-cancel" class="change">cancel</a></li>
<li><a href="#options-okValue" class="change">okValue</a></li>
<li><a href="#options-cancelValue" class="change">cancelValue</a></li>
<li><a href="#options-button" class="change">button</a></li>
</ul>
</li>
<li>
<h4>尺寸</h4>
<ul>
<li><a href="#options-width">width</a></li>
<li><a href="#options-height">height</a></li>
</ul>
</li>
<li>
<h4>位置</h4>
<ul>
<li><a href="#options-fixed">fixed</a><a href="#width"></a></li>
<li><a href="#options-follow">follow</a><a href="#height"></a></li>
</ul>
</li>
<li>
<h4>视觉</h4>
<ul>
<li><a href="#options-lock">lock</a><a href="#fixed"></a><a href="#width"></a></li>
<li><a href="#options-padding">padding</a></li>
</ul>
</li>
<li>
<h4>高级</h4>
<ul>
<li><a href="#options-id">id</a></li>
<li><a href="#options-zIndex">zIndex</a></li>
<li><a href="#options-initialize" class="change">initialize</a></li>
<li><a href="#options-beforeunload" class="change">beforeunload</a></li>
<li><a href="#options-visible" class="change">visible</a></li>
<li><a href="#options-time" class="change">time</a></li>
</ul>
</li>
</ul>
</li>
<li>
<h3><a href="#api">接口</a></h3>
<ul>
<li><a href="#api-get" class="change">art.dialog.get(id)</a></li>
<li><a href="#api-closed" class="change">closed</a></li>
<li><a href="#api-close">close()</a></li>
<li><a href="#api-visible" class="change">visible()</a></li>
<li><a href="#api-hidden" class="change">hidden()</a></li>
<li><a href="#api-title">title(value)</a></li>
<li><a href="#api-content">content(value)</a></li>
<li><a href="#api-button">button(button, button, ..)</a></li>
<li><a href="#api-follow">follow(element)</a></li>
<li><a href="#api-size">size(width, height)</a></li>
<li><a href="#api-lock">lock()</a></li>
<li><a href="#api-unlock">unlock()</a></li>
<li><a href="#api-time" class="change">time(value)</a></li>
</ul>
</li>
<li>
<h3><a href="#plugins">插件</a></h3>
</li>
</ul>
</div>
<div id="lead" class="card">
<h2>快速上手</h2>
<p>artDialog api 风格统一,有一定前端开发经验的同学通过阅读文档5分钟即可上手。
<button id="showChange" class="button">高亮显示更改</button>
</p>
<h3>引入文件</h3>
<p>在页面 head 引入 artDialog 样式与脚本文件:</p>
<pre class="sh_javascript"><link href="./skins/default.css" rel="stylesheet" />
<script src="./artDialog.min.js"></script></pre>
<p>如果使用jquery,引用jquery.artDialog.min.js即可,调用时请把 'art' 前缀替换成 '$'。</p>
<h3>调用方式</h3>
<p>artDialog 有两种调用方式,第一种是最简单的直接传入参数方式;第二种拥有更多的可选项,参见 <a href="#options">配置参数</a>。</p>
<ol>
<li>
<p><strong>art.dialog</strong>(<em>content</em>, <em>[ok]</em>, <em>[cancel]</em>)</p>
<pre class="sh_javascript" id="lead-demo-1">art.dialog('artDialog: I Love You!', function () {alert('Thank you!')});
</pre>
<a class="runCode" href="#lead-demo-1">运行</a> </li>
<li>
<p><strong>art.dialog</strong>(<em>options</em>)</p>
<pre class="sh_javascript" id="lead-demo-2">art.dialog({
title: '欢迎',
content: '欢迎使用artDialog对话框组件!',
ok: function () {
this
.title('警告')
.content('请注意artDialog两秒后将关闭!')
.lock()
.time(2000);
return false;
}
});
</pre>
<a class="runCode" href="#lead-demo-2">运行</a> </li>
</ol>
<h3>扩展接口</h3>
<p>除了上述两种调用方式之外,artDialog 还提供一些接口方便异步操作,比如实现外部程序更新对话框内容、关闭窗口等。这是属于高级操作,详情参见 <a href="#api">接口</a>。</p>
<p>若无特别说明,扩展方法均支持链式调用。</p>
</div>
<div id="options" class="card">
<h2>配置参数</h2>
<ul>
<li>
<h3 id="options-title">title</h3>
<dl>
<dt>概述</dt>
<dd> (默认值: "message") 标题内容</dd>
<dt>类型</dt>
<dd>String</dd>
<dt>示例</dt>
<dd>
<pre id="options-title-demo" class="sh_javascript">art.dialog({
title: 'hello world!'
});</pre>
<a class="runCode" href="#options-title-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-content">content</h3>
<dl>
<dt>概述</dt>
<dd> (默认值: "<div class="d-loading"><span>loading..</span></div>") 设置消息内容。<br />
<br />
如果传入的是 HTMLElement 类型,如果是隐藏元素会给其设置display:block以显示该元素,其他属性与绑定的事件都会完整保留,对话框关闭后此元素又将恢复原来的display属性,并且重新插入原文档所在位置</dd>
<dt>类型</dt>
<dd>String, HTMLElement</dd>
<dt>示例</dt>
<dd>
<pre id="options-content-demo-string" class="sh_javascript">art.dialog({
content: 'hello world!'
});</pre>
<a class="runCode" href="#options-content-demo-string">运行</a></dd>
<dd>
<pre id="options-content-demo-element" class="sh_javascript">art.dialog({
content: document.getElementById('options-content-demo-element'),
id: 'EF893L'
});</pre>
<a class="runCode" href="#options-content-demo-element">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-ok"><span class="change">ok</span></h3>
<dl>
<dt>概述</dt>
<dd>确定按钮。<br />
<br />
回调函数 this 指向 art.dialog 对象,执行完毕默认关闭对话框,若返回 false 则阻止关闭 </dd>
<dt>类型</dt>
<dd>Function</dd>
<dt>示例</dt>
<dd>
<pre id="options-ok-demo" class="sh_javascript">art.dialog({
ok: function () {
this.content('hello world!');
return false;
}
});</pre>
<a class="runCode" href="#options-ok-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="options-cancel"><span class="change">cancel</span></h3>
<dl>
<dt>概述</dt>
<dd>取消按钮。<br />
<br />
取消按钮也等同于标题栏的关闭按钮。回调函数 this 指向 art.dialog 对象,执行完毕默认关闭对话框,若返回 false 则阻止关闭 </dd>
<dt>类型</dt>
<dd>Function</dd>
<dt>示例</dt>
<dd>
<pre id="options-cancel-demo" class="sh_javascript">art.dialog({
cancel: function () {
alert('关闭');
}
});</pre>
<a class="runCode" href="#options-cancel-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="options-okValue"><span class="change">okValue</span></h3>
<dl>
<dt>概述</dt>
<dd> (默认值: "ok") 确定按钮文本</dd>
<dt>类型</dt>
<dd>String</dd>
<dt>示例</dt>
<dd>
<pre id="options-okValue-demo" class="sh_javascript">art.dialog({
okValue: '猛击我',
ok: function () {
this.content('hello world!');
return false;
}
});</pre>
<a class="runCode" href="#options-okValue-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="options-cancelValue"><span class="change">cancelValue</span></h3>
<dl>
<dt>概述</dt>
<dd> (默认值: cancel) 取消按钮文本</dd>
<dt>类型</dt>
<dd>String</dd>
<dt>示例</dt>
<dd>
<pre id="options-cancelValue-demo" class="sh_javascript">art.dialog({
cancelValue: '取消我',
cancel: function () {
alert('关闭');
}
});</pre>
<a class="runCode" href="#options-cancelValue-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="options-button"><span class="change">button</span></h3>
<dl>
<dt>概述</dt>
<dd>
<p>自定义按钮组。<br />
<br />
回调函数 this 指向 art.dialog 对象,执行完毕默认关闭对话框,若返回 false 则阻止关闭</p>
</dd>
<dt>类型</dt>
<dd>Array</dd>
<dt>选项</dt>
<dd>
<dl>
<dt title="String"><span class="change">value</span></dt>
<dd>按钮显示文本</dd>
<dt title="Function">callback</dt>
<dd>(可选) 按钮点击后的回调函数。回调函数 this 指向 art.dialog 对象,执行完毕默认关闭对话框,若返回 false 则阻止关闭</dd>
<dt title="Boolean">focus</dt>
<dd>(默认值: true) 是否聚焦</dd>
<dt title="String"><span class="change">width</span></dt>
<dd>(可选) 设置按钮 CSS width 值</dd>
<dt title="Boolean">disabled</dt>
<dd>(默认值: false) 是否禁用</dd>
<dt title="String"><span class="change">id</span></dt>
<dd>(默认值: 与 value 一致) 唯一标识</dd>
</dl>
</dd>
<dt>示例</dt>
<dd>
<pre id="options-button-demo" class="sh_javascript">art.dialog({
button: [
{
value: '同意',
callback: function () {
this
.content('你同意了')
.button({
id: 'button-disabled',
value: '我变成有效按钮了',
disabled: false
});
return false;
},
focus: true
},
{
value: '不同意',
callback: function () {
alert('你不同意')
}
},
{
id: 'button-disabled',
value: '无效按钮',
disabled: true
},
{
value: '关闭我'
}
]
});</pre>
<a class="runCode" href="#options-button-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-width">width</h3>
<dl>
<dt>概述</dt>
<dd>(默认值: "auto") 设置对话框 <strong>内容</strong> 宽度。<br />
<br />
一般情况下无需设置此值,对话框会自适应内容宽度</dd>
<dt>类型</dt>
<dd>Number, String</dd>
<dt>示例</dt>
<dd>
<pre id="options-width-demo" class="sh_javascript">art.dialog({
width: 460
});</pre>
<a class="runCode" href="#options-width-demo">运行</a> </dd>
<dd>
<pre id="options-width-demo-string" class="sh_javascript">art.dialog({
width: '20em'
});</pre>
<a class="runCode" href="#options-width-demo-string">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="options-height">height</h3>
<dl>
<dt>概述</dt>
<dd>(默认值: "auto") 设置对话框 <strong>内容</strong> 高度。<br />
<br />
一般情况下无需设置此值,对话框会自适应内容宽度</dd>
<dt>类型</dt>
<dd>Number, String</dd>
<dt>示例</dt>
<dd>
<pre id="options-height-demo" class="sh_javascript">art.dialog({
height: 460
});</pre>
<a class="runCode" href="#options-height-demo">运行</a> </dd>
<dd>
<pre id="options-height-demo-string" class="sh_javascript">art.dialog({
height: '20em'
});</pre>
<a class="runCode" href="#options-height-demo-string">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="options-fixed">fixed</h3>
<dl>
<dt>概述</dt>
<dd>(默认值: false) 开启固定定位。<br />
<br />
固定定位是 css2.1 position 的一个属性,它能固定在浏览器某个地方,也不受滚动条拖动影响。IE6 与 部分移动浏览器对其支持不好,内部会转成绝对定位</dd>
<dt>类型</dt>
<dd>Boolean</dd>
<dt>示例</dt>
<dd>
<pre id="options-fixed-demo" class="sh_javascript">art.dialog({
fixed: true,
content: '请拖动滚动条查看'
});</pre>
<a class="runCode" href="#options-fixed-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-follow">follow</h3>
<dl>
<dt>概述</dt>
<dd>让对话框依附在指定元素附近</dd>
<dt>类型</dt>
<dd>HTMLElement</dd>
<dt>示例</dt>
<dd>
<pre id="options-follow-demo" class="sh_javascript">art.dialog({
follow: document.getElementById('options-follow-demo-runCode'),
content: '让对话框跟着某个元素,一个元素同时只能出现一个对话框'
});</pre>
<a id="options-follow-demo-runCode" class="runCode" href="#options-follow-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-lock">lock</h3>
<dl>
<dt>概述</dt>
<dd>(默认值: false) 开启锁屏遮罩。<br />
<br />
中断用户对话框之外的交互,用于显示非常重要的操作/消息。建议只在适合的时候使用它。遮罩的颜色与透明度可在皮肤CSS中设置。</dd>
<dt>类型</dt>
<dd>Boolean</dd>
<dt>示例</dt>
<dd>
<pre id="options-lock-demo" class="sh_javascript">art.dialog({
lock: true
});</pre>
<a class="runCode" href="#options-lock-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-padding">padding</h3>
<dl>
<dt>概述</dt>
<dd>(默认值: "20px 25px") 设置消息内容与消息容器的填充边距,即 style padding 属性</dd>
<dt>类型</dt>
<dd>String</dd>
<dt>示例</dt>
<dd>
<pre id="options-padding-demo" class="sh_javascript">art.dialog({
content: 'hello world',
padding: 0
})</pre>
<a class="runCode" href="#options-padding-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-id">id</h3>
<dl>
<dt>概述</dt>
<dd>设定对话框唯一标识。<br />
<br />
作用:
<ol>
<li>可防止重复 ID 对话框弹出</li>
<li>可后续使用 <a href="#api-get">art.dialog.<strong>get</strong>(id)</a> 获取某个对话框的接口</li>
</ol>
</dd>
<dt>类型</dt>
<dd>String</dd>
<dt>示例</dt>
<dd>
<pre id="options-id-demo" class="sh_javascript">art.dialog({
id: 'id-demo',
content: '再次点击运行看看'
});
art.dialog.get('id-demo').title('8888888888');</pre>
<a class="runCode" href="#options-id-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-zIndex">zIndex</h3>
<dl>
<dt>概述</dt>
<dd>(默认值: 1987) 重置全局 zIndex 初始值,用来改变对话框叠加高度。<br />
<br />
比如有时候配合外部浮动层UI组件,但是它们可能默认 zIndex 没有 artDialog 高,导致无法浮动到 artDialog 之上,这个时候你就可以给对话框指定一个较小的 zIndex 值。
请注意这是一个会影响到全局的配置,后续出现的对话框叠加高度将重新按此累加。</dd>
<dt>类型</dt>
<dd>Number</dd>
<dt>示例</dt>
<dd>
<pre id="options-zIndex-demo" class="sh_javascript">art.dialog({
zIndex: 87
});</pre>
<a class="runCode" href="#options-zIndex-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-initialize"><span class="change">initialize</span></h3>
<dl>
<dt>概述</dt>
<dd>对话框初始化完成后执行的函数。<br />
<br />
回调函数 this 指向 art.dialog 对象</dd>
<dt>类型</dt>
<dd>Function</dd>
<dt>示例</dt>
<dd>
<pre id="options-initialize-demo" class="sh_javascript">art.dialog({
initialize: function () {
this.content('对话框初始化完成');
}
});</pre>
<a class="runCode" href="#options-initialize-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-beforeunload"><span class="change">beforeunload</span></h3>
<dl>
<dt>概述</dt>
<dd>对话框关闭前执行的函数。<br />
<br />
回调函数 this 指向 art.dialog 对象,执行完毕默认关闭对话框,若返回 false 则阻止关闭</dd>
<dt>类型</dt>
<dd>Function</dd>
<dt>示例</dt>
<dd>
<pre id="options-beforeunload-demo" class="sh_javascript">art.dialog({
beforeunload: function () {
return confirm('确定关闭对话框吗');
}
});</pre>
<a class="runCode" href="#options-beforeunload-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-visible"><span class="change">visible</span></h3>
<dl>
<dt>概述</dt>
<dd>(默认值: true) 是否显示对话框</dd>
<dt>类型</dt>
<dd>Boolean</dd>
<dt>示例</dt>
<dd>
<pre id="options-visible-demo" class="sh_javascript">var dialog = art.dialog({
visible: false,
id: 'visible-demo'
});
confirm('显示对话框吗') ? dialog.visible() : dialog.hidden();</pre>
<a class="runCode" href="#options-visible-demo">运行</a></dd>
</dl>
</li>
<li>
<h3 id="options-time"><span class="change">time</span></h3>
<dl>
<dt>概述</dt>
<dd>设置对话框显示时间,超过时间自动关闭 (单位:<span class="change">毫秒</span>)</dd>
<dt>类型</dt>
<dd>Number</dd>
<dt>示例</dt>
<dd>
<pre id="options-time-demo" class="sh_javascript">art.dialog({
time: 2000
});</pre>
<a class="runCode" href="#options-time-demo">运行</a></dd>
</dl>
</li>
</ul>
</div>
<div id="api" class="card">
<h2>接口</h2>
<ul>
<li>
<h3 id="api-get"><span class="change">art.dialog.get(id)</span></h3>
<dl>
<dt>概述</dt>
<dd>根据 id 获取 art.dialog 对象。<strong>注意</strong>:这是一个静态方法</dd>
<dt>参数</dt>
<dd>
<dl>
<dt title="String">id</dt>
<dd>对话框 id</dd>
</dl>
</dd>
<dt>返回值</dt>
<dd>如果存在 id 参数则返回 art.dialog 对象,否则返回页面所有 art.dialog 对象数组</dd>
<dt>示例</dt>
<dd>
<pre id="api-get-demo" class="sh_javascript">art.dialog({
id: 'demo-get'
});
var dialog = art.dialog.get('demo-get');
dialog.title('hello').content('I Love You!');
</pre>
<a class="runCode" href="#api-get-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-closed"><span class="change">closed</span></h3>
<dl>
<dt>概述</dt>
<dd>对话框是否已经关闭。<strong>注意</strong>:这是一个属性,对话框若关闭其值为 true</dd>
<dt>示例</dt>
<dd>
<pre id="api-closed-demo" class="sh_javascript">var dialog = art.dialog();
dialog.close();
alert(dialog.closed);
</pre>
<a class="runCode" href="#api-closed-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-close">close()</h3>
<dl>
<dt>概述</dt>
<dd>关闭对话框</dd>
<dt>示例</dt>
<dd>
<pre id="api-close-demo" class="sh_javascript">var dialog = art.dialog({
content: 'hello world!'
});
if (confirm('关闭对话框吗')) {
dialog.close();
};
</pre>
<a class="runCode" href="#api-close-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-visible"><span class="change">visible()</span></h3>
<dl>
<dt>概述</dt>
<dd>把隐藏的对话框显示</dd>
<dt>示例</dt>
<dd>
<pre id="api-visible-demo" class="sh_javascript">var dialog = art.dialog({
visible: false
});
dialog.visible();</pre>
<a class="runCode" href="#api-visible-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-hidden"><span class="change">hidden()</span></h3>
<dl>
<dt>概述</dt>
<dd>隐藏对话框</dd>
<dt>示例</dt>
<dd>
<pre id="api-hidden-demo" class="sh_javascript">var dialog = art.dialog();
dialog.hidden();</pre>
<a class="runCode" href="#api-hidden-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-title">title(value)</h3>
<dl>
<dt>概述</dt>
<dd>设置对话框标题</dd>
<dt>参数</dt>
<dd>
<dl>
<dt title="String">value</dt>
<dd>标题内容</dd>
</dl>
</dd>
<dt>示例</dt>
<dd>
<pre id="api-title-demo" class="sh_javascript">var dialog = art.dialog({
title: '请等待..'
});
dialog.title('欢迎使用');</pre>
<a class="runCode" href="#api-title-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-content">content(value)</h3>
<dl>
<dt>概述</dt>
<dd>设置消息内容</dd>
<dt>参数</dt>
<dd>
<dl>
<dt title="String, HTMLElement">value</dt>
<dd>消息内容</dd>
</dl>
</dd>
<dt>示例</dt>
<dd>
<pre id="api-content-demo" class="sh_javascript">var dialog = art.dialog();
dialog.content('加载完成!');</pre>
<a class="runCode" href="#api-content-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-button">button(button, [button], ..)</h3>
<dl>
<dt>概述</dt>
<dd>添加或者修改一个或者多个按钮</dd>
<dt>参数</dt>
<dd>
<dl>
<dt title="Options">button</dt>
<dd>按钮配置</dd>
</dl>
</dd>
<dt>选项</dt>
<dd>
<dl>
<dt title="String"><span class="change">value</span></dt>
<dd>按钮显示文本</dd>
<dt title="Function">callback</dt>
<dd>(可选) 按钮点击后的回调函数。回调函数 this 指向 art.dialog 对象,执行完毕默认关闭对话框,若返回 false 则阻止关闭</dd>
<dt title="Boolean">focus</dt>
<dd>(默认值: true) 是否聚焦</dd>
<dt title="String"><span class="change">width</span></dt>
<dd>(可选) 设置按钮 CSS width 值</dd>
<dt title="Boolean">disabled</dt>
<dd>(默认值: false) 是否禁用</dd>
<dt title="String"><span class="change">id</span></dt>
<dd>(默认值: 与 value 一致) 唯一标识</dd>
</dl>
</dd>
<dt>示例</dt>
<dd>
<p>修改按钮与新增按钮:</p>
<pre id="api-button-demo" class="sh_javascript">var dialog = art.dialog({
button: [{
value: '增加一个按钮',
focus: true,
callback: function () {
this.button({
value: '关闭我'
});
return false;
}
}, {
id: 'button',
value: '提交 (5)',
width: '8em',
callback: function () {
alert(0);
return false;
},
disabled: true
}]
});
var i = 5;
var timer = setInterval(function () {
i--;
dialog.button({
id: 'button',
value: '提交 (' + i + ')',
disabled: true
});
if (i === 0) {
clearInterval(timer);
dialog.button({
id: 'button',
value: '提交',
disabled: false
});
};
}, 1000);</pre>
<a class="runCode" href="#api-button-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-follow">follow(element)</h3>
<dl>
<dt>概述</dt>
<dd>让对话框依附在指定元素附近</dd>
<dt>参数</dt>
<dd>
<dl>
<dt title="HTMLElement">element</dt>
<dd>元素</dd>
</dl>
</dd>
<dt>示例</dt>
<dd>
<pre id="api-follow-demo" class="sh_javascript">var dialog = art.dialog();
dialog.follow(document.getElementById('api-follow-demo-runCode'));</pre>
<a id="api-follow-demo-runCode" class="runCode" href="#api-follow-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-size">size(width, height)</h3>
<dl>
<dt>概述</dt>
<dd>指定对话框内容尺寸</dd>
<dt>参数</dt>
<dd>
<dl>
<dt title="Number, String">width</dt>
<dd>内容宽度</dd>
<dt title="Number, String">height</dt>
<dd>内容高度</dd>
</dl>
</dd>
<dt>示例</dt>
<dd>
<pre id="api-size-demo" class="sh_javascript">var dialog = art.dialog();
dialog.size('20em', 60);</pre>
<a class="runCode" href="#api-size-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-lock">lock()</h3>
<dl>
<dt>概述</dt>
<dd>开启锁屏遮罩</dd>
<dt>示例</dt>
<dd>
<pre id="api-lock-demo" class="sh_javascript">var dialog = art.dialog();
dialog.lock();</pre>
<a class="runCode" href="#api-lock-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-unlock">unlock()</h3>
<dl>
<dt>概述</dt>
<dd>关闭锁屏遮罩</dd>
<dt>示例</dt>
<dd>
<pre id="api-unlock-demo" class="sh_javascript">var dialog = art.dialog({
lock: true
});
dialog.unlock();</pre>
<a class="runCode" href="#api-unlock-demo">运行</a> </dd>
</dl>
</li>
<li>
<h3 id="api-time"><span class="change">time(value)</span></h3>
<dl>
<dt>概述</dt>
<dd>设置对话框显示时间,超过时间自动关闭 (单位:<span class="change">毫秒</span>)</dd>
<dt>参数</dt>
<dd>
<dl>
<dt title="Number"><span class="change">value</span></dt>
<dd>毫秒</dd>
</dl>
</dd>
<dt>示例</dt>
<dd>
<pre id="api-time-demo" class="sh_javascript">var dialog = art.dialog();
dialog.time(2000);</pre>
<a class="runCode" href="#api-time-demo">运行</a> </dd>
</dl>
</li>
</ul>
</div>
<div id="plugins" class="card">
<h2>插件</h2>
<p>artDialog 可以通过插件支持拖动、抖动效果, alert、confirm、prompt 方法。只需在 artDialog 之后引用如下文件即可:</p>
<pre class="sh_javascript">
<script src="./artDialog.plugins.min.js"></script></pre>
<p>
<button id="getPlugins" class="button">加载插件</button>
</p>
<div id="plugins-demos">
<h3>演示插件</h3>
<ul>
<li>
<h3 id="plugins-alert">art.alert(content, [callback])</h3>
<pre id="plugins-alert-demo" class="sh_javascript">art.alert('那些年,我们一起追的女孩');
</pre>
<a class="runCode" href="#plugins-alert-demo">运行</a> </li>
<li>
<h3 id="plugins-confirm">art.confirm(content, ok, [cancel])</h3>
<pre id="plugins-confirm-demo" class="sh_javascript">art.confirm('你再也不相信爱情了么?', function () {
alert(0);