Repository navigation
Expand file tree
/
Copy pathmodal.html
More file actions
1123 lines (1080 loc) · 43.2 KB
/
Copy pathmodal.html
File metadata and controls
1123 lines (1080 loc) · 43.2 KB
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
<article class="component" id="modal">
<h3 class="component-title">Modal</h3>
<p class="component-description">Modal 是从App的主要内容区域上弹出的一小块内容块. Modals经常被用来向用户询问信息,或通知或警告用户。 Modal和其他所有的遮罩图层一样,是所谓的“临时视图”的一部分。</p>
<p class="component-description">Modals 可以只用JavaScript打开。所以让我们来看看使用modals的相关APP方法</p>
<h3 class="component-title">预定义的 Modals</h3>
<ul>
<li>1.注意,如果你没有指定预定义的modal标题,它讲使用默认的标题("Framework7"),这个可以在App 初始化时,通过传递 modalTitle 参数改变。</li>
<li>2.预定义modals的按钮文本(如 "Ok" 和 "Cancel") 也可以在 App 初始化时,通过传递 modalButtonOk 和 modalButtonCancel 参数改变。</li>
</ul>
<p class="component-description">首先,让我们看看已经预定义的最常用的modal:</p>
<h3 class="component-title">Alert</h3>
<p class="component-description">我们需要调用以下任一一种App方法来打开Alert modal :<code>myApp.alert(text, [title, callbackOk])</code> </br>或者</br> <code>myApp.alert(text, [callbackOk])</code></p>
<ul>
<li><code>text</code> - string. Alert文本</li>
<li><code>title</code> - string. Optional. Alert modal 标题</li>
<li><code>callbackOk</code> - function. Optional.在Alert modal下,当用户点击“Ok”按钮时,回调函数将被执行。</li>
</ul>
<p class="component-description">该方法返回动态创建的modal的HTML元素。</p>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content-block">
<p><a href="" class="alert-text">Alert With Text</a></p>
<p><a href="" class="alert-text-title">Alert With Text and Title</a></p>
<p><a href="" class="alert-text-title-callback">Alert With Text and Title and Callback</a></p>
<p><a href="" class="alert-text-callback">Alert With Text and Callback</a></p>
</div>
<script type="text/javascript">
$(function(){
//只在本站例子中需要加这行改变容器,默认document.body
$.modal.prototype.defaults.modalContainer = ".device-content";
$(document).on('click','.alert-text',function () {
$.alert('Here goes alert text haha');
});
$(document).on('click','.alert-text-title', function () {
$.alert('Here goes alert text', 'Custom Title!');
});
$(document).on('click', '.alert-text-title-callback',function () {
$.alert('Here goes alert text', 'Custom Title!', function () {
$.alert('Button clicked!')
});
});
$(document).on('click', '.alert-text-callback',function () {
$.alert('Here goes alert text', function () {
$.alert('Button clicked!')
});
});
})
</script>
</div>
</div>
{% highlight html %}
<header class="bar bar-nav">
<h1 class="title">Alert</h1>
</header>
...
<div class="content">
<div class="content-block">
<p><a href="#" class="alert-text">Alert With Text</a></p>
<p><a href="#" class="alert-text-title">Alert With Text and Title</a></p>
<p><a href="#" class="alert-text-title-callback">Alert With Text and Title and Callback</a></p>
<p><a href="#" class="alert-text-callback">Alert With Text and Callback</a></p>
</div>
</div>
...
{% endhighlight %}
{% highlight js %}
$(function(){
//只在本站例子中需要加这行改变容器,默认document.body
$.modal.prototype.defaults.modalContainer = ".device-content";
$(document).on('click','.alert-text',function () {
$.alert('Here goes alert text');
});
$(document).on('click','.alert-text-title', function () {
$.alert('Here goes alert text', 'Custom Title!');
});
$(document).on('click', '.alert-text-title-callback',function () {
$.alert('Here goes alert text', 'Custom Title!', function () {
$.alert('Button clicked!')
});
});
$(document).on('click', '.alert-text-callback',function () {
$.alert('Here goes alert text', function () {
$.alert('Button clicked!')
});
});
})
{% endhighlight %}
</article>
<article class="component active">
<h3 class="component-title">Confirm</h3>
<p class="component-description">Confirm modal 经常在需要确认一些行为时被使用. 打开Alert modal同样也需要调用以下任一一种App方法:<code>myApp.confirm(text, [title, callbackOk, callbackCancel])</code></br>或者 </br>
<code>myApp.confirm(text, [callbackOk, callbackCancel])</code></p>
<ul>
<li><code>text - string. Confirm 文本</code></li>
<li><code>title - string. Optional</code>. Confirm modal 标题</li>
<li><scode>callbackOk - function. Optional</code>. 在 Confirm modal下,当用户点击“Ok”按钮时,回调函数将被执行。(当用户确认操作)</li>
<li><code>callbackCancel - function. Optional</code>. 在 Confirm modal下,当用户点击“Cancel”按钮时,回调函数将被执行。(当用户不想进行操作)</li>
</ul>
<p class="component-description">该方法返回动态创建的modal的HTML元素。</p>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content-block">
<p><a href="#" class="confirm-ok">Confirm with text and Ok callback</a></p>
<p><a href="#" class="confirm-ok-cancel">Confirm with text, Ok and Cancel callbacks</a></p>
<p><a href="#" class="confirm-title-ok">Confirm with text, title and Ok callback</a></p>
<p><a href="#" class="confirm-title-ok-cancel">Confirm with text, title, Ok and Cancel callback</a></p>
</div>
<script type="text/javascript">
$(document).on('click','.confirm-ok', function () {
$.confirm('Are you sure?', function () {
$.alert('You clicked Ok button');
});
});
$(document).on('click', '.confirm-ok-cancel',function () {
$.confirm('Are you sure?',
function () {
$.alert('You clicked Ok button');
},
function () {
$.alert('You clicked Cancel button');
}
);
});
$(document).on('click','.confirm-title-ok', function () {
$.confirm('Are you sure?', 'Custom Title', function () {
$.alert('You clicked Ok button');
});
});
$(document).on('click','.confirm-title-ok-cancel', function () {
$.confirm('Are you sure?', 'Custom Title',
function () {
$.alert('You clicked Ok button');
},
function () {
$.alert('You clicked Cancel button');
}
);
});
</script>
</div>
</div>
{% highlight html %}
<header class="bar bar-nav">
<h1 class="title">Confirm</h1>
</header>
...
<div class="content">
<div class="content-block">
<p><a href="#" class="confirm-ok">Confirm with text and Ok callback</a></p>
<p><a href="#" class="confirm-ok-cancel">Confirm with text, Ok and Cancel callbacks</a></p>
<p><a href="#" class="confirm-title-ok">Confirm with text, title and Ok callback</a></p>
<p><a href="#" class="confirm-title-ok-cancel">Confirm with text, title, Ok and Cancel callback</a></p>
</div>
</div>
...
{% endhighlight %}
{% highlight js %}
$(document).on('click','.confirm-ok', function () {
$.confirm('Are you sure?', function () {
$.alert('You clicked Ok button');
});
});
$(document).on('click', '.confirm-ok-cancel',function () {
$.confirm('Are you sure?',
function () {
$.alert('You clicked Ok button');
},
function () {
$.alert('You clicked Cancel button');
}
);
});
$(document).on('click','.confirm-title-ok', function () {
$.confirm('Are you sure?', 'Custom Title', function () {
$.alert('You clicked Ok button');
});
});
$(document).on('click','.confirm-title-ok-cancel', function () {
$.confirm('Are you sure?', 'Custom Title',
function () {
$.alert('You clicked Ok button');
},
function () {
$.alert('You clicked Cancel button');
}
);
});
{% endhighlight %}
</article>
<article class="component active">
<h3 class="component-title">Prompt</h3>
<p class="component-description">Prompt modal 经常在需要从用户那里得到一些数据/答案时使用。打开 Prompt modal同样也需要调用以下任一一种App方法:<code>myApp.prompt(text, [title, callbackOk, callbackCancel])</code></br>或者</br>
<code>myApp.prompt(text, [callbackOk, callbackCancel])</code></p>
<ul>
<li><code>text - string</code>. Prompt 文本/问题</li>
<li><code>title - string</code>. Optional. Prompt modal 标题</li>
<li><code>callbackOk - function</code>. Optional. 在 Prompt modal下,当用户点击“Ok”按钮时,回调函数将被执行。回调函数的参数是输入框的值</li>
<li><code>callbackCancel - function</code>. Optional. 在 Prompt modal下,当用户点击“Cancel”按钮时,回调函数将被执行。回调函数的参数是输入框的值</li>
</ul>
<p class="component-description">该方法返回动态创建的modal的HTML元素。</p>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content-block">
<p><a href="#" class="prompt-ok">Prompt with text and Ok callback</a></p>
<p><a href="#" class="prompt-ok-cancel">Prompt with text, Ok and Cancel callbacks</a></p>
<p><a href="#" class="prompt-title-ok">Prompt with text, title and Ok callback</a></p>
<p><a href="#" class="prompt-title-ok-cancel">Prompt with text, title, Ok and Cancel callback</a></p>
</div>
<script type="text/javascript">
$(document).on('click','.prompt-ok', function () {
$.prompt('What is your name?', function (value) {
$.alert('Your name is "' + value + '". You clicked Ok button');
});
});
$(document).on('click','.prompt-ok-cancel', function () {
$.prompt('What is your name?',
function (value) {
$.alert('Your name is "' + value + '". You clicked Ok button');
},
function (value) {
$.alert('Your name is "' + value + '". You clicked Cancel button');
}
);
});
$(document).on('click', '.prompt-title-ok',function () {
$.prompt('What is your name?', 'Custom Title', function (value) {
$.alert('Your name is "' + value + '". You clicked Ok button');
});
});
$(document).on('click', '.prompt-title-ok-cancel',function () {
$.prompt('What is your name?', 'Custom Title',
function (value) {
$.alert('Your name is "' + value + '". You clicked Ok button');
},
function (value) {
$.alert('Your name is "' + value + '". You clicked Cancel button');
}
);
});
</script>
</div>
</div>
{% highlight html %}
<header class="bar bar-nav">
<h1 class="title">Prompt</h1>
</header>
...
<div class="content">
<div class="content-block">
<p><a href="#" class="prompt-ok">Prompt with text and Ok callback</a></p>
<p><a href="#" class="prompt-ok-cancel">Prompt with text, Ok and Cancel callbacks</a></p>
<p><a href="#" class="prompt-title-ok">Prompt with text, title and Ok callback</a></p>
<p><a href="#" class="prompt-title-ok-cancel">Prompt with text, title, Ok and Cancel callback</a></p>
</div>
</div>
...
{% endhighlight %}
{% highlight js %}
$(document).on('click','.prompt-ok', function () {
$.prompt('What is your name?', function (value) {
$.alert('Your name is "' + value + '". You clicked Ok button');
});
});
$(document).on('click','.prompt-ok-cancel', function () {
$.prompt('What is your name?',
function (value) {
$.alert('Your name is "' + value + '". You clicked Ok button');
},
function (value) {
$.alert('Your name is "' + value + '". You clicked Cancel button');
}
);
});
$(document).on('click', '.prompt-title-ok',function () {
$.prompt('What is your name?', 'Custom Title', function (value) {
$.alert('Your name is "' + value + '". You clicked Ok button');
});
});
$(document).on('click', '.prompt-title-ok-cancel',function () {
$.prompt('What is your name?', 'Custom Title',
function (value) {
$.alert('Your name is "' + value + '". You clicked Ok button');
},
function (value) {
$.alert('Your name is "' + value + '". You clicked Cancel button');
}
);
});
{% endhighlight %}
</article>
<article class="component active">
<h3 class="component-title">预加载 Modal (Preloader Modal)</h3>
<p class="component-description">预加载 Modal 用来提示一些后台活动(像Ajax请求)和阻止在这个活动期间的任何用户操作。 打开预加载 modal 我们也需要调用适当的App方法: myApp.show预加载(<code>[title]</code>)- 显示 预加载 modal</p>
<ul>
<li><code>title - string. Optional</code>. 预加载 modal 标题. 默认(没有指定)的时候,它等同于 "Loading...". 你可以在App初始化时通过 modal预加载Title 参数改变默认的 预加载 标题。</li>
</ul>
<p class="component-description">该方法返回动态创建的modal的HTML元素。</p>
<p class="component-description">myApp.hide预加载() - 隐藏/关闭 预加载 modal. 因为 预加载 modal 没有任何按钮, 它应该用 JavaScript 来关闭</p>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content-block">
<p><a href="#" class="open-preloader">Open Preloader</a></p>
<p><a href="#" class="open-preloader-title">Open Preloader with custom title</a></p>
</div>
<script type="text/javascript">
$(document).on('click', '.open-preloader', function () {
$.showPreloader();
setTimeout(function () {
$.hidePreloader();
}, 2000);
});
$(document).on('click','.open-preloader-title', function () {
$.showPreloader('Custom Title')
setTimeout(function () {
$.hidePreloader();
}, 2000);
});
</script>
</div>
</div>
{% highlight html %}
<header class="bar bar-nav">
<h1 class="title">预加载 Modal (Preloader Modal)</h1>
</header>
...
<div class="content">
<div class="content-block">
<p><a href="#" class="open-preloader">Open Preloader</a></p>
<p><a href="#" class="open-preloader-title">Open Preloader with custom title</a></p>
</div>
</div>
...
{% endhighlight %}
{% highlight js %}
$(document).on('click', '.open-preloader', function () {
$.showPreloader();
setTimeout(function () {
$.hidePreloader();
}, 2000);
});
$(document).on('click','.open-preloader-title', function () {
$.showPreloader('Custom Title')
setTimeout(function () {
$.hidePreloader();
}, 2000);
});
{% endhighlight %}
</article>
<article class="component active">
<h3 class="component-title">指示器(indicator)</h3>
<p class="component-description">如果你不需要用像预加载Modal这样如此大的modal 窗口去指示活动, 你可以使用简单并且小的指示器modal: </p>
<p class="component-description">myApp.showIndicator() - 显示指示器 modal </p>
<p class="component-description">myApp.hideIndicator() - 隐藏/关闭指示器 modal. 因为指示器modal没有任何按钮, 它需要用JavaScript来关闭 </p>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content-block">
<p><a href="#" class="open-indicator">Open Indicator</a></p>
</div>
<script type="text/javascript">
$(document).on('click','.open-indicator', function () {
$.showIndicator();
setTimeout(function () {
$.hideIndicator();
}, 2000);
});
</script>
</div>
</div>
{% highlight html %}
<header class="bar bar-nav">
<h1 class="title">指示器(indicator)</h1>
</header>
...
<div class="content">
<div class="content-block">
<p><a href="#" class="open-indicator">Open Indicator</a></p>
</div>
</div>
...
{% endhighlight %}
{% highlight js %}
$(document).on('click','.open-indicator', function () {
$.showIndicator();
setTimeout(function () {
$.hideIndicator();
}, 2000);
});
{% endhighlight %}
</article>
<article class="component active">
<h3 class="component-title">自定义Modals</h3>
<p class="component-description">Ok, 所有的预定义modals都只是一些适用于特定的场景的方法. 让我们看看如何创建自定义的 modals: </p>
<p class="component-description"><code>myApp.modal(parameters)</code> - 显示 custom modal </p>
<ul>
<li><code>parameters - object</code>. Modal 的 parameters/options对象</li>
</ul>
<p class="component-description">该方法返回动态创建的modal的HTML元素。 </p>
<p class="component-description">这里有 Modal 的参数列表: </p>
<table class="params-table">
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>默认值</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>title</td>
<td>字符串</td>
<td></td>
<td>可选. Modal 标题 (可以是html字符串)</td>
</tr>
<tr>
<td>text</td>
<td>字符串</td>
<td></td>
<td>可选. Modal 文本 (可以是html字符串)</td>
</tr>
<tr>
<td>afterText</td>
<td>字符串</td>
<td></td>
<td>可选. 将被放在"text"后的文本 (可以是html字符串)</td>
</tr>
<tr>
<td>buttons</td>
<td>数组</td>
<td></td>
<td>可选. 按钮数组. 每个按钮应该被表示为带按钮参数的对象 (看下面)</td>
</tr>
<tr>
<td>verticalButtons</td>
<td>boolean</td>
<td>false</td>
<td>Optional. Set to <code>true</code> to enable vertical buttons layout</td>
</tr>
<tr>
<td>onClick</td>
<td>函数</td>
<td></td>
<td>可选. 回调函数将在用户点击任何Modal按钮后被触发执行. 它接收 <b>modal</b> (Modal的 HTML元素) 和 <b>index</b>作为参数 (被点击按钮的索引号)</td>
</tr>
</tbody>
</table>
<p class="component-description">让我们一起来看看按钮参数: </p>
<table class="params-table">
<thead>
<tr>
<th>参数</th>
<th>类型</th>
<th>默认值</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>text</td>
<td>字符串</td>
<td></td>
<td>按钮文本 (可以是 HTML 字符串)</td>
</tr>
<tr>
<td>bold</td>
<td>布尔值</td>
<td>false</td>
<td>可选. 设置为true会加粗按钮文本</td>
</tr>
<tr>
<td>close</td>
<td>布尔值</td>
<td>true</td>
<td>可选. 如果是“true”,点击这个按钮后modal会被关闭</td>
</tr>
<tr>
<td>onClick</td>
<td>函数</td>
<td></td>
<td>可选. 用户点击这个按钮后,回调函数会被执行</td>
</tr>
</tbody>
</table>
<p class="component-description">这样的配置选项允许我们创建灵活的modals。让我们来看一些例子 </p>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content-block">
<p><a href="#" class="open-3-modal">Modal With 3 Buttons</a></p>
<p><a href="#" class="open-slider-modal">Modal With Slider</a></p>
<p><a href="#" class="open-tabs-modal">Modal With Tabs</a></p>
<p><a href="#" class="open-vertical-modal">Modal With Vertical Buttons</a></p>
</div>
<script type="text/javascript">
$(document).on('click','.open-3-modal', function () {
$.modal({
title: 'Modal with 3 buttons',
text: 'Vivamus feugiat diam velit. Maecenas aliquet egestas lacus, eget pretium massa mattis non. Donec volutpat euismod nisl in posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae',
buttons: [
{
text: 'B1',
onClick: function() {
$.alert('You clicked first button!')
}
},
{
text: 'B2',
onClick: function() {
$.alert('You clicked second button!')
}
},
{
text: 'B3',
bold: true,
onClick: function() {
$.alert('You clicked third button!')
}
},
]
})
});
$(document).on('click','.open-slider-modal', function () {
var modal = $.modal({
title: 'Awesome Photos?',
text: 'What do you think about my photos?',
afterText: '<div class="swiper-container" style="width: auto; margin:5px -15px -15px">'+
'<div class="swiper-pagination"></div>'+
'<div class="swiper-wrapper">'+
'<div class="swiper-slide"><img src="..." height="150" style="display:block"></div>' +
'<div class="swiper-slide"><img src="..." height="150" style="display:block"></div>'+
'</div>'+
'</div>',
buttons: [
{
text: 'Bad :('
},
{
text: 'Awesome!',
bold: true,
onClick: function () {
$.alert('Thanks! I know you like it!')
}
},
]
})
$.swiper($$(modal).find('.swiper-container'), {pagination: '.swiper-pagination'});
});
$(document).on('click','.open-tabs-modal', function () {
$.modal({
title: '<div class="buttons-row">'+
'<a href="#tab1" class="button active tab-link">Tab 1</a>'+
'<a href="#tab2" class="button tab-link">Tab 2</a>'+
'</div>',
text: '<div class="tabs">'+
'<div class="tab active" id="tab1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam convallis nunc non dolor euismod feugiat. Sed at sapien nisl. Ut et tincidunt metus. Suspendisse nec risus vel sapien placerat tincidunt. Nunc pulvinar urna tortor.</div>'+
'<div class="tab" id="tab2">Vivamus feugiat diam velit. Maecenas aliquet egestas lacus, eget pretium massa mattis non. Donec volutpat euismod nisl in posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae</div>'+
'</div>',
buttons: [
{
text: 'Ok, got it',
bold: true
},
]
})
});
$(document).on('click','.open-vertical-modal', function () {
$.modal({
title: 'Vertical Buttons Layout',
text: 'Vivamus feugiat diam velit. Maecenas aliquet egestas lacus, eget pretium massa mattis non. Donec volutpat euismod nisl in posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae',
verticalButtons: true,
buttons: [
{
text: 'Button 1',
onClick: function() {
$.alert('You clicked first button!')
}
},
{
text: 'Button 2',
onClick: function() {
$.alert('You clicked second button!')
}
},
{
text: 'Button 3',
onClick: function() {
$.alert('You clicked third button!')
}
},
]
})
});
</script>
</div>
</div>
{% highlight html %}
<header class="bar bar-nav">
<h1 class="title">自定义Modals</h1>
</header>
...
<div class="content">
<div class="content-block">
<p><a href="#" class="open-3-modal">Modal With 3 Buttons</a></p>
<p><a href="#" class="open-slider-modal">Modal With Slider</a></p>
<p><a href="#" class="open-tabs-modal">Modal With Tabs</a></p>
<p><a href="#" class="open-vertical-modal">Modal With Vertical Buttons</a></p>
</div>
</div>
...
{% endhighlight %}
{% highlight js %}
$(document).on('click','.open-3-modal', function () {
$.modal({
title: 'Modal with 3 buttons',
text: 'Vivamus feugiat diam velit. Maecenas aliquet egestas lacus, eget pretium massa mattis non. Donec volutpat euismod nisl in posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae',
buttons: [
{
text: 'B1',
onClick: function() {
$.alert('You clicked first button!')
}
},
{
text: 'B2',
onClick: function() {
$.alert('You clicked second button!')
}
},
{
text: 'B3',
bold: true,
onClick: function() {
$.alert('You clicked third button!')
}
},
]
})
});
$(document).on('click','.open-slider-modal', function () {
var modal = $.modal({
title: 'Awesome Photos?',
text: 'What do you think about my photos?',
afterText: '<div class="swiper-container" style="width: auto; margin:5px -15px -15px">'+
'<div class="swiper-pagination"></div>'+
'<div class="swiper-wrapper">'+
'<div class="swiper-slide"><img src="..." height="150" style="display:block"></div>' +
'<div class="swiper-slide"><img src="..." height="150" style="display:block"></div>'+
'</div>'+
'</div>',
buttons: [
{
text: 'Bad :('
},
{
text: 'Awesome!',
bold: true,
onClick: function () {
$.alert('Thanks! I know you like it!')
}
},
]
})
$.swiper($$(modal).find('.swiper-container'), {pagination: '.swiper-pagination'});
});
$(document).on('click','.open-tabs-modal', function () {
$.modal({
title: '<div class="buttons-row">'+
'<a href="#tab1" class="button active tab-link">Tab 1</a>'+
'<a href="#tab2" class="button tab-link">Tab 2</a>'+
'</div>',
text: '<div class="tabs">'+
'<div class="tab active" id="tab1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam convallis nunc non dolor euismod feugiat. Sed at sapien nisl. Ut et tincidunt metus. Suspendisse nec risus vel sapien placerat tincidunt. Nunc pulvinar urna tortor.</div>'+
'<div class="tab" id="tab2">Vivamus feugiat diam velit. Maecenas aliquet egestas lacus, eget pretium massa mattis non. Donec volutpat euismod nisl in posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae</div>'+
'</div>',
buttons: [
{
text: 'Ok, got it',
bold: true
},
]
})
});
$(document).on('click','.open-vertical-modal', function () {
$.modal({
title: 'Vertical Buttons Layout',
text: 'Vivamus feugiat diam velit. Maecenas aliquet egestas lacus, eget pretium massa mattis non. Donec volutpat euismod nisl in posuere. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae',
verticalButtons: true,
buttons: [
{
text: 'Button 1',
onClick: function() {
$.alert('You clicked first button!')
}
},
{
text: 'Button 2',
onClick: function() {
$.alert('You clicked second button!')
}
},
{
text: 'Button 3',
onClick: function() {
$.alert('You clicked third button!')
}
},
]
})
});
{% endhighlight %}
<h3 class="component-title">用 JavaScript 关闭 Modals</h3>
<p class="component-description">任何 Modal 可以用 JavaScript 来关闭,不仅仅是通过点击按钮。因此我们需要看看相关App方法:</p>
<p class="component-description"><code>myApp.closeModal(modal)</code> - 关闭任意 modal</p>
<ul>
<li><code>modal - HTMLElement or string ( CSS 选择器)</code>. 可选. 除了指定的,任何被打开modal都将被关闭。</li>
</ul>
<h3 class="component-title">Modal 事件</h3>
<p class="component-description">如果你希望能自定义 modal 模板,你可在 初始化APP 的时候传入一个 modalTemplate 参数。这个参数的值是一个 Template7 模板,当编译该模板的时候会传入一个 groups 参数。</p>
<p class="component-description">这个模板可能是这样的:</p>
{% highlight html %}
<div class="modal {{#unless buttons}}modal-no-buttons{{/unless}}">
<div class="modal-inner">
{{#if title}}
<div class="modal-title">{{title}}</div>
{{/if}}
{{#if text}}
<div class="modal-text">{{text}}</div>
{{/if}}
{{#if afterText}}
{{afterText}}
{{/if}}
</div>
{{#if buttons}}
<div class="modal-buttons">
{{#each buttons}}
<span class="modal-button {{#if bold}}modal-button-bold{{/if}}">{{text}}</span>
{{/each}}
</div>
{{/if}}
</div>
{% endhighlight %}
</article>
<article class="component active">
<h3 class="component-title">Popup</h3>
<p class="component-description">Popup 是一种可以包含任何Html内容的弹出窗口,从App的主内容区域上弹出。 Popup 和其他所有的遮罩图层一样,是所谓的“临时视图”的一部分。</p>
<h3 class="component-title">Popup 布局</h3>
<p class="component-description">Popup 布局相当简单. 你所需要做的就是将 <div class="popup"> 任何需要展示的内容 </div> 放到 body 里正确的位置上:</p>
{% highlight html %}
<div class="modal {{#unless buttons}}modal-no-buttons{{/unless}}">
...
<div class="popup">
Any HTML content goes here
</div>
</div>
{% endhighlight %}
<h3 class="component-title">Popup 尺寸</h3>
<p class="component-description">默认的 Popup 在手机和平板(iPad)上尺寸有一些不同。在手机上是全屏的,在平板上宽高都是630px。如果你想使它在平板上也是全屏的,你应该添加额外的"tablet-fullscreen"类到需要的popup中:</p>
{% highlight html %}
<div class="modal {{#unless buttons}}modal-no-buttons{{/unless}}">
...
<!-- This popup has fullscreen size on tablets -->
<div class="popup tablet-fullscreen">
Any HTML content goes here
</div>
</div>
{% endhighlight %}
<h3 class="component-title">打开和关闭 Popup</h3>
<h4 class="component-title">通过HTML</h4>
<p class="component-description">可以通过在链接上使用特定的类和data属性打开和关闭所需的popups:</p>
<ul>
<li>为了打开popup,我们需要添加 "open-popup" 类到任意 HTML 元素上 (最好是链接)</li>
<li>为了关闭popup,我们需要添加 "close-popup" 类到任意 HTML 元素上 (最好是链接)</li>
<li>如果你的App里有超过一个popups, 你需要指定适当popup,则需添加额外的属性 data-popup=".my-popup" 到这个 HTML 元素上</li>
</ul>
<p class="component-description">根据上面的注意点:</p>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content-block">
<!-- In data-popup attribute we specify CSS selector of popup we need to open -->
<p><a href="#" data-popup=".popup-about" class="open-popup">Open About Popup </a></p>
<p><a href="#" data-popup=".popup-services" class="open-popup">Open Services Popup </a></p>
</div>
</div>
<!-- About Popup -->
<div class="popup popup-about">
<div class="content-block">
<p>About</p>
<p><a href="#" class="close-popup">Close popup</a></p>
<p>Lorem ipsum dolor ...</p>
</div>
</div>
<!-- Services Popup -->
<div class="popup popup-services">
<div class="content-block">
<p>Services</p>
<p><a href="#" class="close-popup">Close popup</a></p>
<p>Lorem ipsum dolor ...</p>
</div>
</div>
</div>
{% highlight html %}
<header class="bar bar-nav">
<h1 class="title">Popup(HTML)</h1>
</header>
...
<div class="content">
<div class="content-block">
<p><a href="#" class="open-about">Open About Popup </a></p>
<p><a href="#" class="open-services">Open Services Popup </a></p>
</div>
</div>
<!-- About Popup -->
<div class="popup popup-about">
<div class="content-block">
<p>About</p>
<p><a href="#" class="close-popup">Close popup</a></p>
<p>Lorem ipsum dolor ...</p>
</div>
</div>
<!-- Services Popup -->
<div class="popup popup-services">
<div class="content-block">
<p>Services</p>
<p><a href="#" class="close-popup">Close popup</a></p>
<p>Lorem ipsum dolor ...</p>
</div>
</div>
{% endhighlight %}
</article>
<article class="component active">
<h4 class="component-title">使用 JavaScript</h4>
<p class="component-description">我们也可以用使用JavaScript来打开和关闭Popups ,因此我们需要看一下相关的App方法:</p>
<p class="component-description"><code>myApp.popup(popup)</code> - 打开 Popup</p>
<ul>
<li><code>popup - HTML元素 或者 字符串 (需要打开的popup的 CSS 选择器) </code>. 必需</li>
</ul>
<p class="component-description"><code>myApp.closeModal(popup)</code> - 关闭 Popup</p>
<ul>
<li><code>popup - HTML元素 或者 字符串 (需要打开的popup的 CSS 选择器)</code>. 可选. 如果没有设置这个值,任何打开着的Popup/Modal 都将被关闭</li>
</ul>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content-block">
<p><a href="#" class="open-about">Open About Popup </a></p>
<p><a href="#" class="open-services">Open Services Popup </a></p>
</div>
<script type="text/javascript">
$(document).on('click','.open-about', function () {
$.popup('.popup-about');
});
$(document).on('click','.open-services', function () {
$.popup('.popup-services');
});
</script>
</div>
<!-- About Popup -->
<div class="popup popup-about">
<div class="content-block">
<p>About</p>
<p><a href="#" class="close-popup">Close popup</a></p>
<p>Lorem ipsum dolor ...</p>
</div>
</div>
<!-- Services Popup -->
<div class="popup popup-services">
<div class="content-block">
<p>Services</p>
<p><a href="#" class="close-popup">Close popup</a></p>
<p>Lorem ipsum dolor ...</p>
</div>
</div>
</div>
{% highlight html %}
<header class="bar bar-nav">
<h1 class="title">Popup(JavaScript)</h1>
</header>
...
<div class="content">
<div class="content-block">
<p><a href="#" class="open-about">Open About Popup </a></p>
<p><a href="#" class="open-services">Open Services Popup </a></p>
</div>
</div>
<!-- About Popup -->
<div class="popup popup-about">
<div class="content-block">
<p>About</p>
<p><a href="#" class="close-popup">Close popup</a></p>
<p>Lorem ipsum dolor ...</p>
</div>
</div>
<!-- Services Popup -->
<div class="popup popup-services">
<div class="content-block">
<p>Services</p>
<p><a href="#" class="close-popup">Close popup</a></p>
<p>Lorem ipsum dolor ...</p>
</div>
</div>
{% endhighlight %}
{% highlight js %}
$(document).on('click','.open-about', function () {
$.popup('.popup-about');
});
$(document).on('click','.open-services', function () {
$.popup('.popup-services');
});
{% endhighlight %}
</article>
<article class="component active">
<h3 class="component-title">Popup 事件</h3>
<p class="component-description">Popup 和 Modals有一样的事件, 如果你需要在打开/关闭popup时使用JavaScript做一些事情的时候,这些事件会很有用。</p>
<table class="events-table">
<thead>
<tr>
<th>事件</th>
<th>目标</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>open</td>
<td>Popup Element<span><div class="popup"></span></td>
<td>当 Popup 开始打开动画时,事件将被触发。</td>
</tr>
<tr>
<td>opened</td>
<td>Popup Element<span><div class="popup"></span></td>
<td>当 Popup 完成打开动画时,事件将被触发。</td>
</tr>
<tr>
<td>close</td>
<td>Popup Element<span><div class="popup"></span></td>
<td>当 Popup 开始结束动画时,事件将被触发。</td>
</tr>
<tr>
<td>closed</td>
<td>Popup Element<span><div class="popup"></span></td>
<td>当 Popup 完成结束动画后,事件将被触发。</td>
</tr>
</tbody>
</table>
<div class="component-example component-example-fullbleed">
<div class="">
<div class="content">
<div class="content-block">
<!-- In data-popup attribute we specify CSS selector of popup we need to open -->
<p><a href="#" data-popup=".popup-about" class="open-popup">Open About Popup </a></p>
<p><a href="#" data-popup=".popup-services" class="open-popup">Open Services Popup </a></p>
</div>
</div>
<script type="text/javascript">
$(document).on('click','.popup-about', function () {
console.log('About Popup opened')
});
$(document).on('click','.popup-about', function () {
console.log('About Popup is closing')
});
$(document).on('click','.popup-services', function () {
console.log('Services Popup is opening')