-
Notifications
You must be signed in to change notification settings - Fork 7
/
demo.php
1139 lines (974 loc) · 37.9 KB
/
demo.php
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>
<html>
<head>
<meta charset="UTF-8">
<title>DOC & DEMO - zdatepicker - a simple,light-weight datepicker plugin for jquery.</title>
<meta name="keywords" content="zdatepicker,js,jquery,plugin,datepicker,calendar,NolanChou 周" />
<meta name="description" content="zdatepicker - a simple,light-weight datepicker plugin for jquery." />
<meta name="generator" content="Jquery" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="./zdatepicker.js?v=3.1.9"></script>
<style type="text/css">
body{ font:12px/120% Helvetica, Geneva, Arial, sans-serif; padding:0px 30px; margin:0px; margin-left:250px; box-shadow:inset 5px 0px 5px #EEE; }
a{ color:#0080FF; }
a:hover{ color:#0063C6; }
h1{ font-size:25px; color:#333; border-bottom:#CCC dashed 1px; margin:0px; padding:40px 0px; margin-bottom:0px; }
h2{ font-size:18px; color:#555; padding:10px 0px; margin:30px 0px 20px 0px; }
h4{ font-size:14px; color:#666; padding:0px; }
h5{ font-size:12px; color:#666; padding:0px; margin:0px; }
.demo{ padding:0px 10px 20px 10px; }
.code{ background:#EEE; border:#CCC dashed 1px; padding:10px; padding-bottom:20px; margin-top:20px; }
.code .syntaxhighlighter{ padding:15px 0px; background:#FFF; margin-bottom:0px!important; }
input{ font:14px/120% Helvetica, Geneva, Arial, sans-serif; border:#999 solid 1px; border-radius:5px; padding:5px 10px; color:#666; }
input:focus{ border:#0080FF solid 1px; box-shadow:inset 0px 0px 5px #999; outline:#0080FF; color:#333; }
dl,dt,dd{ margin:0px; padding:0px; }
ul{ margin-top:0px; }
ul .note{ list-style:none; color:#999; margin-left:-20px; padding:5px 0px; }
.directory{ position:fixed; top:0px; left:0px; padding:20px; width:200px; overflow:auto; }
.directory h2{ margin:0px; }
.directory ul{ padding-left:20px; }
.directory ul li{ font-size:14px; line-height:20px; width:100%; }
.directory ul li ul li{ font-size:12px; }
.directory ul li b{ display:inline-block; color:#0080FF; width:10px; text-align:center; font-weight:normal; margin-right:2px; cursor:pointer; }
.directory .new{ font-size:12px; line-height:100%; display:inline-block; padding:2px 5px; background:#E00; color:#FFF; margin-left:2px; margin-top:-5px; border-radius:5px 5px 5px 0px; }
</style>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="http://agorbatchev.typepad.com/pub/sh/3_0_83/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="./zdatepicker.css?v=3.1.9" />
</head>
<body>
<div class="directory">
<h2>Directory</h2>
<ul>
<li>
<a href="#style">Style</a>
</li>
<li>
<b>+</b><a href="#options">Options</a>
<ul style="display:none;">
<li><a href="#classname">classname</a></li>
<li><a href="#event">event</a></li>
<li><a href="#viewmonths">viewmonths</a></li>
<li><a href="#format">format</a></li>
<li><a href="#daystr">daystr</a></li>
<li><a href="#monthstr">monthstr</a></li>
<li><a href="#weekoffset">weekoffset</a></li>
<li><a href="#year2str">year2str</a></li>
<li><a href="#str2year">str2year</a></li>
<li><a href="#initmonth">initmonth</a></li>
<li><a href="#symbiont">symbiont</a></li>
<li><a href="#readonly">readonly</a></li>
<li><a href="#disable">disable</a></li>
<li><a href="#area">area</a></li>
<li><a href="#selected">selected</a></li>
<li><a href="#replace">replace</a></li>
<li><a href="#pos">pos</a></li>
<li><a href="#use">use</a></li>
<li><a href="#show">show</a></li>
<li><a href="#prevbtn">prevbtn</a><em class="new">new</em></li>
<li><a href="#nextbtn">nextbtn</a><em class="new">new</em></li>
<li><a href="#closebtn">closebtn</a></li>
<li><a href="#onFilter">onFilter</a><em class="new">new</em></li>
<li><a href="#onReturn">onReturn</a></li>
</ul>
</li>
<li>
<b>+</b><a href="#callback">Callback</a>
<ul style="display:none;">
<li><a href="#type">parameter - type</a></li>
<li><a href="#arg">parameter - arg</a></li>
</ul>
</li>
<li>
<b>-</b><a href="#demo">Demo</a>
<ul>
<li><a href="#demo_1-1">Simple</a></li>
<li><a href="#demo_1-2">Show one month.</a></li>
<li><a href="#demo_1-3">Replace a date display.</a></li>
<li><a href="#demo_2">Pick multiple dates.</a></li>
<li><a href="#demo_3-1">Set date ranges are disable.</a></li>
<li><a href="#demo_3-2">Setting option use array.</a></li>
<li><a href="#demo_4">Set dates or ranges are selected.</a></li>
<li><a href="#demo_5-1">Set a "AREA" range.</a></li>
<li><a href="#demo_5-2">Use a function to get ranges.</a></li>
<li><a href="#demo_6">Change other dom's event to get zdatepicker.</a></li>
<li><a href="#demo_7-1">Position by direction</a></li>
<li><a href="#demo_7-2">Position by coordinate</a></li>
<li><a href="#demo_8">Close button</a></li>
<li><a href="#demo_9">Symbiont</a></li>
<li><a href="#demo_10">Show after zdatepicker init.</a></li>
<li><a href="#demo_11">Not show anything.</a></li>
<li><a href="#demo_12">Readonly</a></li>
<li><a href="#demo_13">Change Event for show zdatepicker.</a></li>
<li><a href="#demo_14-1">Date format</a></li>
<li><a href="#demo_14-2">Special era</a></li>
<li><a href="#demo_14-3">i18n</a><em class="new">new</em></li>
<li><a href="#demo_15">Replace return function, and use callback.</a></li>
<li><a href="#demo_16">Advanced setting for date's status.</a><em class="new">new</em></li>
</ul>
</li>
</ul>
</div>
<h1>DOC & DEMO - zdatepicker</h1>
<h2 id="style">Style</h2>
<p>You can rewrite all of these:</p>
<pre class="brush:css; toolbar:false;">
/* zdatepicker main */
.zdatepicker{ position:absolute; width:280px; z-index:9998; display:none; overflow:hidden; margin:2px 0px; background:#FFF; border:1px solid rgba(0,0,0,.15); border-radius:5px; box-shadow:0 6px 12px rgba(0,0,0,.175); }
.zdatepicker dl{ width:278px; margin:0px; padding:1px; display:block; float:left; }
/* zdatepicker title (prev/next button) */
.zdatepicker dt{ width:100%; height:35px; line-height:35px; background:#fff; font-size:0px; font-weight:normal; word-spacing:0px; text-align:center; vertical-align:top; }
.zdatepicker dt a,
.zdatepicker dt .empty{ display:inline-block; width:10%; text-decoration:none; font-size:14px; color:#333; margin:0px; vertical-align:top; }
.zdatepicker dt a:hover{ background:#eee; color:#333; }
.zdatepicker dt .prev,
.zdatepicker dt .next { font-family:FontAwesome; font-weight:normal; color:#666; }
.zdatepicker dt .prev:before { content:"\f0d9"; }
.zdatepicker dt .next:before { content:"\f0da"; }
/* zdatepicker title (year/month) */
.zdatepicker dt span { display:inline-block; width:80%; font-size:14px; cursor:pointer; }
.zdatepicker dt span a { display:inline-block; width:auto; padding:0px 5px; font-size:14px; color:#333; margin:0px 2px; }
.zdatepicker dt span a:after { font-family:FontAwesome; font-size:12px; content:"\f0d7"; margin-left:2px; }
/* zdatepicker main */
.zdatepicker dd { width:98%; padding:0px 2px; padding:0 0 5px 0; font-size:0px; word-spacing:-11px; text-align:left; }
/* zdatepicker sub-title (week) */
.zdatepicker dd div { background:#fff; margin-bottom:3px; }
.zdatepicker dd div span,
.zdatepicker dd span { display:inline-block; width:14%; height:35px; line-height:32px; font-size:14px; word-spacing:normal; text-align:center; color:#666; vertical-align:top; }
.zdatepicker dd div span { font-size:12px; height:25px; line-height:25px; }
/* zdatepicker body */
.zdatepicker dd span a,
.zdatepicker dd span span { display:inline-block; width:100%; line-height:33px; margin-top:1px; text-decoration:none; color:#666; }
.zdatepicker dd span a:hover { background:#eee; color:#333; border-radius:5px; }
.zdatepicker dd span .selected,
.zdatepicker dd span .selected:hover,
.zdatepicker dd span .disable,
.zdatepicker dd span .disable:hover,
.zdatepicker dd span .area,
.zdatepicker dd span .area:hover { border-radius:0px; }
.zdatepicker dd .month,
.zdatepicker dd .year { width:25%; height:65px; margin-top:2px; margin-bottom:5px; }
.zdatepicker dd .month a,
.zdatepicker dd .year a { width:100%; height:65px; line-height:65px; overflow:hidden; }
/* zdatepicker close */
.zdatepicker .close { display:block; height:0px; width:100%; margin-top:10px; padding:0px; filter:alpha(opacity=100); opacity:1;}
.zdatepicker .close:hover { background:transparent; }
.zdatepicker .close a { position:absolute; right:5px; bottom:5px; display:inline-block; border-radius:40px; height:40px; width:40px; text-align:center; line-height:40px; text-decoration:none; box-shadow:0 3px 4px rgba(0,0,0,.175); }
.zdatepicker .close a:before { font-family:FontAwesome; content:"\f00d"; font-size:22px; }
.zdatepicker .close a:hover { }
/* bootstrap theme */
.zdatepicker dd .week0 { color:#d9534f; }
.zdatepicker dd .week6 { color:#5cb85c; }
.zdatepicker dd span a:hover { }
.zdatepicker dd span .selected { color:#fff; background:#428bca; }
.zdatepicker dd span .selected:hover { color:#fff; background:#3071a9; }
.zdatepicker dd span .disable,
.zdatepicker dd span .disable:hover { color:#ccc; background:#eee; cursor:not-allowed; }
.zdatepicker dd span .area { color:#fff; background:#5bc0de; }
.zdatepicker dd span .area.selected,
.zdatepicker dd span .area:hover { color:#fff; background:#31b0d5; }
.zdatepicker .close a { color:#fff; background:#d9534f; }
.zdatepicker .close a:hover { color:#fff; background:#c9302c; }
</pre>
<h2 id="options">Options</h2>
<h5 id="classname">classname</h5>
<ul>
<li class="note">zdatepicker container's class name.</li>
<li>type:string</li>
<li>default:"zdatepicker"</li>
</ul>
<h5 id="event">event</h5>
<ul>
<li class="note">event of show zdatepicker. (don't use 'focus' and 'blur')</li>
<li>type:string</li>
<li>default:"click"</li>
</ul>
<h5 id="viewmonths">viewmonths</h5>
<ul>
<li class="note">how many months to show.</li>
<li>type:number</li>
<li>default:2</li>
</ul>
<h5 id="format">format</h5>
<ul>
<li class="note">all settings of string format for view.</li>
<li>type:object</li>
<li>default:{date:"yyyy-mm-dd",month:"yyyy-mm",year:"yyyy",onlymonth:"mm"}</li>
</ul>
<h5 id="daystr">daystr</h5>
<ul>
<li>type:array</li>
<li>default:["Sun","Mon","Tue","Wed","Thur","Fri","Sat"]</li>
</ul>
<h5 id="monthstr">monthstr</h5>
<ul>
<li>type:array</li>
<li>default:["01","02","03","04","05","06","07","08","09","10","11","12"]</li>
</ul>
<h5 id="weekoffset">weekoffset</h5>
<ul>
<li class="note">Select the day to start the week from. Default option is Sunday(0), but you can start a week on Friday if you want to by setting this option to 5.</li>
<li>type:number</li>
<li>default:0</li>
</ul>
<h5 id="year2str">year2str</h5>
<ul>
<li class="note">format a date to return.</li>
<li>type:function</li>
<li>default:null</li>
</ul>
<h5 id="str2year">str2year</h5>
<ul>
<li class="note">format a string from input's value.</li>
<li>type:function</li>
<li>default:null</li>
</ul>
<h5 id="initmonth">initmonth</h5>
<ul>
<li class="note">select a month to show.</li>
<li>type:string, microtime, Date obj, Dom, function</li>
<li>default:null</li>
</ul>
<h5 id="symbiont">symbiont</h5>
<ul>
<li class="note">...(i can't explain it)</li>
<li>type:boolean</li>
<li>default:true</li>
</ul>
<h5 id="readonly">readonly</h5>
<ul>
<li>type:boolean</li>
<li>default:false</li>
</ul>
<h5 id="disable">disable</h5>
<ul>
<li class="note">set date or ranges be disable. (date must format to like "2014-01-01")</li>
<li>type:function, array, object</li>
<li>default:{}</li>
</ul>
<h5 id="area">area</h5>
<ul>
<li class="note">use two date / dom's value to make up a "AREA". (date must format to like "2014-01-01")</li>
<li>type:function, array, object</li>
<li>default:{}</li>
</ul>
<h5 id="selected">selected</h5>
<ul>
<li class="note">set date or ranges be selected. <br />(if setting is true, picking multiple dates is enabled. date must format to like "2014-01-01")</li>
<li>type:boolean, object</li>
<li>default:false</li>
</ul>
<h5 id="replace">replace</h5>
<ul>
<li class="note">replace a date to any string. (key must be like "2014-01-01")</li>
<li>type:object</li>
<li>default:null</li>
</ul>
<h5 id="pos">pos</h5>
<ul>
<li>type:object</li>
<li>default:{}</li>
</ul>
<h5 id="use">use</h5>
<ul>
<li class="note">use other dom (jquery selector: #id / .class ..) to build zdatepicker.</li>
<li>type:string</li>
<li>default:false</li>
</ul>
<h5 id="show">show</h5>
<ul>
<li class="note">true: show when init / false: don't show on any event.</li>
<li>type:boolean</li>
<li>default:null</li>
</ul>
<h5 id="prevbtn">prevbtn</h5>
<ul>
<li class="note">previous button</li>
<li>type:string</li>
<li>default:<</li>
</ul>
<h5 id="nextbtn">nextbtn</h5>
<ul>
<li class="note">next button</li>
<li>type:string</li>
<li>default:></li>
</ul>
<h5 id="closebtn">closebtn</h5>
<ul>
<li class="note">close button</li>
<li>type:boolean/string</li>
<li>default:false</li>
</ul>
<h5 id="onFilter">onFilter</h5>
<ul>
<li class="note">filter date status(disable? selected? other?). 5 args(date, month, year, day, status), return array.</li>
<li>type:function</li>
<li>default:null</li>
</ul>
<h5 id="onReturn">onReturn</h5>
<ul>
<li class="note">change the default return func.</li>
<li>type:function</li>
<li>default:null</li>
</ul>
<h2 id="callback">Callback</h2>
<h4>$.fn.zdatepicker.callback with two parameters: type and arg.<br />It's a global function! You can rewrite it.</h4>
<h5 id="type">parameter - type</h5>
<ul>
<li>return : after return date by 'onReturn'.</li>
<li>close : after click close button.</li>
<li>prev_month : after click prev month.</li>
<li>next_month : after click next month.</li>
<li>prev_year : after click prev year to show prev 12 months.</li>
<li>next_year : after click next year to show next 12 months.</li>
<li>prev_years : after click prev 10 years.</li>
<li>next_years : after click next 10 years.</li>
<li>select_month : after select a month in changing month.</li>
<li>select_year : after select a year in changing year.</li>
<li>area : after return date when get a AREA.</li>
<li>fail_to_area : after AREA have a fail, like : one date is null or two date can't be make up a range.</li>
</ul>
<h5 id="arg">parameter - arg</h5>
<ul>
<li>input : the dom of input.</li>
<li>calendar : the dom of zdatepicker.</li>
<li>a : a "A" dom at last click.</li>
<li>date : string of date to return, if have.</li>
<li>dateObj : a Dateobj about date, if have.</li>
<li>area : a array of new AREA, if have.</li>
<li>year : number of selected year, if have.</li>
<li>month : number of selected month, if have.</li>
</ul>
<h2 id="demo">Demo</h2>
<h4 id="demo_1-1">1-1. Simple</h4>
<div class="demo">
<input class="time1" value="" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time1").zdatepicker();
</pre>
<script type="text/javascript">
$(".time1").zdatepicker();
</script>
</div>
</div>
<h4 id="demo_1-2">1-2. Show one month.</h4>
<div class="demo">
<input class="time1_2" value="" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time1_2").zdatepicker({viewmonths:1});
</pre>
<script type="text/javascript">
$(".time1_2").zdatepicker({viewmonths:1});
</script>
</div>
</div>
<h4 id="demo_1-3">1-3. Replace a date display.</h4>
<div class="demo">
<input class="time1_3" value="" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time1_3").zdatepicker({replace:{'<?=date('Y-m-d')?>':'Today'}});
</pre>
<script type="text/javascript">
$(".time1_3").zdatepicker({replace:{'<?=date('Y-m-d')?>':'Today'}});
</script>
</div>
</div>
<h4 id="demo_2">2. Pick multiple dates.</h4>
<div class="demo">
<input class="time2" value="" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time2").zdatepicker({selected:true});
</pre>
<script type="text/javascript">
$(".time2").zdatepicker({selected:true});
</script>
</div>
</div>
<h4 id="demo_3-1">3-1. Set date ranges are disable.</h4>
<div class="demo">
<input class="time3" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time3").zdatepicker({
disable:{
0:{0:"<?=date('Y-m')?>-02",1:"<?=date('Y-m')?>-11"},
1:{0:"<?=date('Y-m')?>-20",1:"<?=date('Y-m')?>-29"}
}
});
</pre>
<script type="text/javascript">
$(".time3").zdatepicker({
disable:{
0:{0:"<?=date('Y-m')?>-02",1:"<?=date('Y-m')?>-11"},
1:{0:"<?=date('Y-m')?>-20",1:"<?=date('Y-m')?>-29"}
}
});
</script>
</div>
</div>
<h4 id="demo_3-2">3-2. Setting option use array.</h4>
<div class="demo">
<input class="time3_2" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time3_2").zdatepicker({
disable:[
["<?=date('Y-m')?>-02","<?=date('Y-m')?>-11"],
["<?=date('Y-m')?>-20","<?=date('Y-m')?>-29"]
]
});
</pre>
<script type="text/javascript">
$(".time3_2").zdatepicker({
disable:[
["<?=date('Y-m')?>-02","<?=date('Y-m')?>-11"],
["<?=date('Y-m')?>-20","<?=date('Y-m')?>-29"]
]
});
</script>
</div>
</div>
<h4 id="demo_4">4. Set dates or ranges are selected.</h4>
<div class="demo">
<input class="time4" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time4").zdatepicker({
selected:{
0:{0:"<?=date('Y-m')?>-05", 1:"<?=date('Y-m')?>-08"},
1:{0:"<?=date('Y-m')?>-29"}
}
});
</pre>
<script type="text/javascript">
$(".time4").zdatepicker({
selected:{
0:{0:"<?=date('Y-m')?>-05", 1:"<?=date('Y-m')?>-08"},
1:{0:"<?=date('Y-m')?>-29"}
}
});
</script>
</div>
</div>
<h4 id="demo_5-1">5-1. Set a "AREA" range.</h4>
<div class="demo">
<input class="time5_a" value="<?=date('Y-m')?>-15" /> -- <input class="time5_b" value="<?=date('Y-m')?>-23" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time5_a").zdatepicker({
viewmonths:2,
area:{
0:'',
1:$(".time5_b")
},
disable:{
0:{0:"<?=date('Y')?>-<?=(date('n')+1)?>-22", 1:"<?=date('Y')?>-<?=(date('n')+1)?>-25"}
}
});
$(".time5_b").zdatepicker({
viewmonths:2,
initmonth:$(".time5_a"),
area:{
0:$(".time5_a"),
1:''
},
disable:{
0:{0:"<?=date('Y')?>-<?=(date('n')+1)?>-22", 1:"<?=date('Y')?>-<?=(date('n')+1)?>-25"}
}
});
</pre>
<script type="text/javascript">
$(".time5_a").zdatepicker({
viewmonths:2,
area:{
0:'',
1:$(".time5_b")
},
disable:{
0:{0:"<?=date('Y')?>-<?=(date('n')+1)?>-22", 1:"<?=date('Y')?>-<?=(date('n')+1)?>-25"}
}
});
$(".time5_b").zdatepicker({
viewmonths:2,
initmonth:$(".time5_a"),
area:{
0:$(".time5_a"),
1:''
},
disable:{
0:{0:"<?=date('Y')?>-<?=(date('n')+1)?>-22", 1:"<?=date('Y')?>-<?=(date('n')+1)?>-25"}
}
});
</script>
</div>
</div>
<h4 id="demo_5-2">5-2. Use a function to get ranges.</h4>
<div class="demo">
<input class="time5_2_a" value="<?=date('Y-m')?>-02" /> -- <input class="time5_2_b" value="<?=date('Y-m')?>-05"><br />
<input class="time5_2_a" value="<?=date('Y-m')?>-09" /> -- <input class="time5_2_b" value="<?=date('Y-m')?>-12"><br />
<input class="time5_2_a" value="<?=date('Y-m')?>-29" /> -- <input class="time5_2_b" value="<?=date('Y')?>-<?=sprintf('%02d', date('n')+1)?>-03" /><br />
<input class="time5_2_a" value="<?=date('Y')?>-<?=sprintf('%02d', date('n')+1)?>-11" /> -- <input class="time5_2_b" value="<?=date('Y')?>-<?=sprintf('%02d', date('n')+1)?>-23" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
function getDisable(start, end){
var date = [];
start.siblings(".time5_2_a").each(function(i){
date[i] = [];
date[i][0] = $(this).val();
date[i][1] = $(this).nextAll(".time5_2_b").eq(0).val();
});
return date;
}
$(".time5_2_a").click(function(){
$(this).zdatepicker({
viewmonths:2,
show:true,
area:{
0:'',
1:$(this).nextAll(".time5_2_b").eq(0)
},
disable:getDisable($(this), $(this).nextAll(".time5_2_b").eq(0))
});
})
$(".time5_2_b").click(function(){
$(this).zdatepicker({
viewmonths:2,
initmonth:$(this).prevAll(".time5_2_a").eq(0),
show:true,
area:{
0:$(this).prevAll(".time5_2_a").eq(0),
1:''
},
disable:getDisable($(this).prevAll(".time5_2_a").eq(0), $(this))
});
})
</pre>
<script type="text/javascript">
function getDisable(start, end){
var date = [];
start.siblings(".time5_2_a").each(function(i){
date[i] = [];
date[i][0] = $(this).val();
date[i][1] = $(this).nextAll(".time5_2_b").eq(0).val();
});
return date;
}
$(".time5_2_a").click(function(){
$(this).zdatepicker({
viewmonths:2,
show:true,
area:{
0:'',
1:$(this).nextAll(".time5_2_b").eq(0)
},
disable:getDisable($(this), $(this).nextAll(".time5_2_b").eq(0))
});
})
$(".time5_2_b").click(function(){
$(this).zdatepicker({
viewmonths:2,
initmonth:$(this).prevAll(".time5_2_a").eq(0),
show:true,
area:{
0:$(this).prevAll(".time5_2_a").eq(0),
1:''
},
disable:getDisable($(this).prevAll(".time5_2_a").eq(0), $(this))
});
})
</script>
</div>
</div>
<h4 id="demo_6">6. Change other dom's event to get zdatepicker.</h4>
<div class="demo">
<input class="time6" value="<?=date('Y-m')?>-15" /><input type="button" value="click me!" onclick="dozdatepicker()" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
// "click me!!" button's onclick is "dozdatepicker()"
function dozdatepicker(){
var rand = Math.round(Math.random() * 28);
var zdp = $(".time6").zdatepicker({
event:'',
viewmonths:1,
selected:{0:{0:"<?=date('Y-m')?>-"+rand}},
show:true
});
$(".time6").focus();
}
</pre>
<script type="text/javascript">
function dozdatepicker(){
var rand = Math.round(Math.random() * 28);
var zdp = $(".time6").zdatepicker({
event:'',
viewmonths:1,
selected:{0:{0:"<?=date('Y-m')?>-"+rand}},
show:true
});
console.log(zdp);
$(".time6").focus();
}
</script>
</div>
</div>
<h4 id="demo_7-1">7-1. Position by direction</h4>
<div class="demo">
<input class="time7_1" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time7_1").zdatepicker({
viewmonths:1,
pos:{top:"bottom", left:"right"}
});
</pre>
<script type="text/javascript">
$(".time7_1").zdatepicker({viewmonths:1, pos:{top:"bottom", left:"right"}});
</script>
</div>
</div>
<h4 id="demo_7-2">7-2. Position by coordinate</h4>
<div class="demo">
<input class="time7_2" value="<?=date('Y-m')?>-15" />
<div class="code">
<pre class="brush:js; toolbar:false;">
$(".time7_2").zdatepicker({
viewmonths:1,
pos:{top:-100, left:300}
});
</pre>
<script type="text/javascript">
$(".time7_2").zdatepicker({viewmonths:1, pos:{top:-100, left:300}});
</script>
</div>
</div>
<h4 id="demo_8">8. Close button</h4>
<div class="demo">
<input class="time8" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time8").zdatepicker({
viewmonths:2,
closebtn:true
});
</pre>
<script type="text/javascript">
$(".time8").zdatepicker({viewmonths:2, closebtn:true});
</script>
</div>
</div>
<h4 id="demo_9">9. Symbiont</h4>
<div class="demo">
<input class="time9_a" value="<?=date('Y-m')?>-15" /> -------
<input class="time9_a" value="<?=date('Y-m')?>-15" /> -------
<input class="time9_a" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time9_a").zdatepicker({
viewmonths:1,
symbiont:false,
closebtn:true
});
</pre>
<script type="text/javascript">
$(".time9_a").zdatepicker({viewmonths:1, symbiont:false, closebtn:true});
</script>
</div>
<div style="margin-top:20px"> </div>
<input class="time9_b" value="<?=date('Y-m')?>-15" /> -------
<input class="time9_b" value="<?=date('Y-m')?>-15" /> -------
<input class="time9_b" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time9_b").zdatepicker({
viewmonths:1
});
</pre>
<script type="text/javascript">
$(".time9_b").zdatepicker({viewmonths:1});
</script>
</div>
</div>
<h4 id="demo_10">10. Show after zdatepicker init.</h4>
<div class="demo">
<input class="time10" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
// input's position is changed after SyntaxHighlighter init.
$(".time10").zdatepicker({
viewmonths:1,
show:true
});
</pre>
<script type="text/javascript">$(".time10").zdatepicker({viewmonths:1, show:true});</script>
</div>
</div>
<h4 id="demo_11">11. Not show anything.(but zdatepicker is inited.</h4>
<div class="demo">
<input class="time11" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time11").zdatepicker({
viewmonths:1,
show:false
});
</pre>
<script type="text/javascript">
$(".time11").zdatepicker({viewmonths:1, show:false});
</script>
</div>
</div>
<h4 id="demo_12">12. Readonly</h4>
<div class="demo">
<input class="time12" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time12").zdatepicker({
viewmonths:1,
readonly:true
});
</pre>
<script type="text/javascript">
$(".time12").zdatepicker({viewmonths:1, readonly:true});
</script>
</div>
</div>
<h4 id="demo_13">13. Change Event for show zdatepicker.</h4>
<div class="demo">
<input class="time13" value="<?=date('Y-m')?>-15" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time13").zdatepicker({
viewmonths:1,
event:"mouseover"
});
</pre>
<script type="text/javascript">
$(".time13").zdatepicker({viewmonths:1, event:"mouseover"});
</script>
</div>
</div>
<h4 id="demo_14-1">14-1. Date format</h4>
<div class="demo">
<input class="time14_1" value="15,<?=date('M')?>/<?=date('Y')?>" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;">
$(".time14_1").zdatepicker({
format:{date:"dd,mm\/yyyy", month:"mm\/yyyy", year:"yyyy", onlymonth:"mm."}, // use regular for replace, so you need use \ to some char.
daystr:["S","M","T","W","Th","F","S"],
monthstr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
});
</pre>
<script type="text/javascript">
$(".time14_1").zdatepicker({
format:{date:"dd,mm\/yyyy", month:"mm\/yyyy", year:"yyyy", onlymonth:"mm."},
daystr:["S","M","T","W","Th","F","S"],
monthstr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
});
</script>
</div>
</div>
<h4 id="demo_14-2">14-2. Special era</h4>
<div class="demo">
<input class="time14_2" value="" />
<div class="code">
<h5>Code:</h5>
<pre class="brush:js; toolbar:false;" style="height:400px;">
// China_taiwan era.
$(".time14_2").zdatepicker({
format:{date:"yyyy年mm月dd日", month:"yyyy年mm月", year:"yyyy年", onlymonth:"mm月"},
daystr:["日","一","二","三","四","五","六"],
monthstr:["1","2","3","4","5","6","7","8","9","10","11","12"],
year2str : function(year){
if(year - 1911 > 0){
if(year == 1912) return "民國元";
return '民國'+(year-1911);
}else{
return '民國前'+(1912-year);
}
},
str2year : function(str){
var n = str.match(/\d+/);
if(str.match("前")){
return 1912 - n;
}else{
if(!n) return 1912;
return 1911 + n;
}
}
});
</pre>
<script type="text/javascript">
$(".time14_2").zdatepicker({
format:{date:"yyyy年mm月dd日", month:"yyyy年mm月", year:"yyyy年", onlymonth:"mm月"},
daystr:["日","一","二","三","四","五","六"],
monthstr:["1","2","3","4","5","6","7","8","9","10","11","12"],
year2str : function(year){
if(year - 1911 > 0){
if(year == 1912) return "民國元";
return '民國'+(year-1911);
}else{
return '民國前'+(1912-year);
}
},
str2year : function(str){
var n = parseInt(str.match(/\d+/), 10);
if(str.match("前")){
return 1912 - n;
}else{
if(!n) return 1912;
return 1911 + n;
}
}
});
</script>
</div>
</div>
<h4 id="demo_14-3">14-3. i18n</h4>
<div class="demo">
<input class="time14_3" value="" />
<div class="code">