forked from amsul/pickadate.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.htm
1210 lines (778 loc) · 72.4 KB
/
api.htm
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>
<meta charset="utf-8">
<meta name="author" content="Amsul - http://amsul.ca">
<meta name="viewport" content="width=device-width">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>pickadate.js / api</title>
<link rel="shortcut icon" href="demo/images/favicon.ico">
<link rel="stylesheet" href="demo/styles/css/main.css">
<link rel="stylesheet" href="lib/themes/default.css" id="theme_base">
<link rel="stylesheet" href="lib/themes/default.date.css" id="theme_date">
<link rel="stylesheet" href="lib/themes/default.time.css" id="theme_time">
<!--[if lt IE 9]>
<script>document.createElement('section')</script>
<![endif]-->
<body>
<header class="section section--header section--splash">
<div class="section__block section__block--scoped">
<nav class="menu menu--header page-target" id="menu">
<ul class="menu__list menu__list--header">
<li class="menu__item menu__item--touch menu__item--logo"><a class="menu__link menu__link--dimmed" href="index.htm"><span class="logocon"><span class="logocon__p">p</span><span class="logocon__u"></span></span></a></li>
<li class="menu__item menu__item--touch menu__item--toggle">
<a class="menu__link menu__link--dimmed page-target__display" href="#menu"><span class="page-target__toggle"></span></a>
<a class="menu__link menu__link--dimmed page-target__display--flip" href="#"><span class="page-target__toggle"></span></a>
</li>
<li class="menu__item menu__item--clear"></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed" href="date.htm">Date picker</a></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed" href="time.htm">Time picker</a></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed menu__link--active" href="api.htm">API</a></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed" href="v2-(deprecated)/index.htm">v2 docs</a></li>
<li class="menu__item menu__item--responsive page-target__reveal"><a class="menu__link menu__link--dimmed" href="https://github.com/amsul/pickadate.js">Github</a></li>
<li class="menu__item menu__item--responsive page-target__reveal menu__item--trail">
<span class="menu__link">Themes: <input class="theme-toggle__input" type="radio" id="show_theme_default" name="show_theme" value="default" checked hidden><label class="theme-toggle__label theme-toggle__label--first" for="show_theme_default">default</label><input class="theme-toggle__input" type="radio" id="show_theme_classic" name="show_theme" value="classic" hidden><label class="theme-toggle__label theme-toggle__label--last" for="show_theme_classic" class="checked-negative">classic</label></span>
</li>
</ul>
</nav>
</div> <!-- .section__block -->
</header> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h1 class="heading heading--divide-center heading--divide-first"><span class="heading__text">The API<a class="heading__anchor" name="picker" href="#picker">§</a></span></h1>
<h3 class="heading heading--thin">You can play with the picker API to extend and create custom functionality:</h3>
<pre><code data-language="javascript">var $input = $('.datepicker').pickadate()
// Use the picker object directly.
var picker = $input.pickadate('picker')
picker.<a href="#api-methods">methodName</a>(argument1, argument2, ...)
picker.<a href="#api-objects">objectName</a>
// Or pass through the element’s plugin data.
$input.pickadate(<a href="#api-methods">methodName</a>, argument1, argument2, ...)
$input.pickadate(<a href="#api-objects">objectName</a>)</code></pre>
<div class="section__block section__block--notification">
<p>For most examples on this page, the date picker is used, but the same API applies to the time picker as well.</p>
</div>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Methods<a class="heading__anchor" name="api-methods" href="#api-methods">§</a></span></h2>
<p>There are <i>eleven</i> methods available on the picker:</p>
<ol>
<li><code class="function"><a href="#method-open-close">open</a></code></li>
<li><code class="function"><a href="#method-open-close">close</a></code></li>
<li><code class="function"><a href="#method-start-stop">start</a></code></li>
<li><code class="function"><a href="#method-start-stop">stop</a></code></li>
<li><code class="function"><a href="#method-render">render</a></code></li>
<li><code class="function"><a href="#method-clear">clear</a></code></li>
<li><code class="function"><a href="#method-get">get</a></code></li>
<li><code class="function"><a href="#method-set">set</a></code></li>
<li><code class="function"><a href="#method-on">on</a></code></li>
<li><code class="function"><a href="#method-off">off</a></code></li>
<li><code class="function"><a href="#method-trigger">trigger</a></code></li>
</ol>
<p>All these methods (except <code class="function">get</code>) return the picker object and are therefore chainable:</p>
<pre><code data-language="javascript">picker.open().clear().close()...</code></pre>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Objects<a class="heading__anchor" name="api-objects" href="#api-objects">§</a></span></h2>
<p>There are <i>four</i> objects available through the picker:</p>
<ol>
<li><code><a href="#object-node">$node</a></code></li>
<li><code><a href="#object-root">$root</a></code></li>
<li><code><a href="#object-hidden">_hidden</a></code></li>
<li><code><a href="#object-component">component</a></code></li>
</ol>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h1 class="heading heading--divide-center"><span class="heading__text">The Methods<a class="heading__anchor" name="methods" href="#methods">§</a></span></h1>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Open and Close<a class="heading__anchor" name="method-open-close" href="#method-open-close">§</a></span></h2>
<p>Open and close the picker holder. To check if it’s already open, use <a href="#method-get">the <code class="function">get</code> method</a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.open()
picker.close()
// If a “click” is involved, prevent the event bubbling.
event.stopPropagation()
// If we want to maintain focus on the input,
// prevent the default action on “mousedown”.
event.preventDefault()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-open-close class="fieldset__button button button--small">Open</button><input id="demo__api-open-close" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h3 class="heading heading--divide"><span class="heading__text">Close with focus<a class="heading__anchor--bigger" name="method-close-focus" href="#method-close-focus">§</a></span></h3>
<p>Close the picker while keeping focus on the <code class="tag-name">input</code> element by passing a truth-y argument.</p>
<pre class="pre--demo"><code data-language="javascript">picker.close(true)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-close-focus class="fieldset__button button button--small">Close with focus</button><input id="demo__api-close-focus" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h3 class="heading heading--divide"><span class="heading__text">Open without focus<a class="heading__anchor--bigger" name="method-open-focus" href="#method-open-focus">§</a></span></h3>
<p>Open the picker without focusing onto the <code class="tag-name">input</code> element by passing <code class="constant">false</code> as the first argument. Opening the picker this way, there’s a few things to note:</p>
<p><b>(1)</b> The only way to close it is with a separate custom binding – in this example, on document click.</p>
<p><b>(2)</b> <a href="#events-callbacks">The “opening” events</a> are still triggered – however, using <a href="#method-get">the <code>get</code> method</a> to see if the picker is open will return <code class="constant">false</code>.</p>
<p><b>(3)</b> If any of the picker elements is focused/clicked, it resumes normal behavior.</p>
<pre class="pre--demo"><code data-language="javascript">picker.open(false)
$(document).on('click', function() {
picker.close()
})</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-open-focus class="fieldset__button button button--small">Open without focus</button><input id="demo__api-open-focus" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Start and Stop<a class="heading__anchor" name="method-start-stop" href="#method-start-stop">§</a></span></h2>
<p>Destroy and rebuild the picker. To check if it’s already started, use <a href="#method-get">the <code class="function">get</code> method</a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.stop()
picker.start()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-start-stop class="fieldset__button button button--small">Stop</button><input id="demo__api-start-stop" class="fieldset__input " type=date value="" placeholder="Try me…"></div></fieldset>
<div class="section__block section__block--notification">
<p>Destroying the picker also clears any <a href="#events-callbacks">events’ callbacks</a> bound on it.</p>
</div>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Render<a class="heading__anchor" name="method-render" href="#method-render">§</a></span></h2>
<p>Refresh the picker after adding something to the holder.</p>
<pre class="pre--demo"><code data-language="javascript">picker.render()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-render class="fieldset__button button button--small">Add stuff</button><input id="demo__api-render" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
<p>By default, only the “face” of the picker (i.e. the <code>box</code> element), has it’s contents re-rendered. To render the entire picker from the <code>root</code> up, pass <code class="constant">true</code> as the first argument:</p>
<pre><code data-language="javascript">picker.render(true)</code></pre>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Clear<a class="heading__anchor" name="method-clear" href="#method-clear">§</a></span></h2>
<p>Clear the value in the picker’s <code class="tag-name">input</code> element.</p>
<pre class="pre--demo"><code data-language="javascript">picker.clear()</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-clear class="fieldset__button button button--small">Clear</button><input id="demo__api-clear" class="fieldset__input " type=text value="15 February, 2014" placeholder="Try me…"></div></fieldset>
<p>This is a shorthand that uses <a href="#method-set">the <code class="function">set</code> method</a> behind the scenes.</p>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get<a class="heading__anchor" name="method-get" href="#method-get">§</a></span></h2>
<p>Get the properties, objects, and states of the picker.</p>
<pre><code data-language="javascript">picker.get(thing)</code></pre>
<p>The <code>thing</code> argument is an optional string and can be one of the following:</p>
<ul>
<li><code><a href="#method-get-value">value</a></code> (default)</li>
<li><code><a href="#method-get-select">select</a></code> <b>*</b></li>
<li><code><a href="#method-get-highlight">highlight</a></code> <b>*</b></li>
<li><code><a href="#method-get-view">view</a></code> <b>*</b></li>
<li><code><a href="#method-get-min">min</a></code> <b>*</b></li>
<li><code><a href="#method-get-max">max</a></code> <b>*</b></li>
<li><code><a href="#method-get-open">open</a></code></li>
<li><code><a href="#method-get-start">start</a></code></li>
<li><code><a href="#method-get-id">id</a></code></li>
<li><code><a href="#method-get-disable">disable</a></code></li>
<li><code><a href="#method-get-enable">enable</a></code></li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text"><b>*</b> Item Objects<a class="heading__anchor--bigger" name="item-objects" href="#item-objects">§</a></span></h3>
<p>The <code>thing</code>s denoted in the list above with an asterisk (<b>*</b>) return a picker item object that can be formatted by passing a second string argument using the <a href="date.htm#formats">date</a> or <a href="time.htm#formats">time</a> formatting rules:</p>
<pre><code data-language="javascript">picker.get(thing, format)</code></pre>
<p>Each “date” or “time” within the picker has an item object accompanying it behind the scenes.</p>
<p>Here’s a <b>date picker item object</b> for <u>20 April, 2013</u>:</p>
<pre><code data-language="javascript">{
// The full year.
year: 2013,
// The month with zero-as-index.
month: 3,
// The date of the month.
date: 20,
// The day of the week with zero-as-index.
day: 6,
// The underlying JavaScript Date object.
obj: { 'Sat Apr 20 2013 00:00:00 GMT-0400 (EDT)' },
// The “pick” value used for comparisons.
pick: 1366430400000
}</code></pre>
<p>Here’s a <b>time picker item object</b> for <u>4:20 PM</u>:</p>
<pre><code data-language="javascript">{
// Hour of the day from 0 to 23.
hour: 16,
// The minutes of the hour from 0 to 59 (based on the interval).
mins: 20,
// The “pick” value used for comparisons.
pick: 980
}</code></pre>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">value</code><a class="heading__anchor" name="method-get-value" href="#method-get-value">§</a></span></h2>
<p>Returns the string value of the picker’s <code>input</code> element.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get() // Short for `picker.get('value')`.</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--value class="fieldset__button button button--small">Log the value</button><input id="demo__api-get--value" class="fieldset__input " type=text value="15 February, 2014" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">select</code><a class="heading__anchor" name="method-get-select" href="#method-get-select">§</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that is <b>visually selected</b>.</p>
<p>Defaults to <code class="null">null</code> when there’s no <a href="#method-get-value"><code class="string">value</code></a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('select')
picker.get('select', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--select class="fieldset__button button button--small">Log the select</button><button id=button__api-get--select-format class="fieldset__button button button--small">Log the select formatted</button><input id="demo__api-get--select" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">highlight</code><a class="heading__anchor" name="method-get-highlight" href="#method-get-highlight">§</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that is <b>visually highlighted</b>.</p>
<p>Defaults to “today” (or “now” for the time picker) when there’s no <a href="#method-get-value"><code class="string">value</code></a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('highlight')
picker.get('highlight', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--highlight class="fieldset__button button button--small">Log the highlight</button><button id=button__api-get--highlight-format class="fieldset__button button button--small">Log the highlight formatted</button><input id="demo__api-get--highlight" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">view</code><a class="heading__anchor" name="method-get-view" href="#method-get-view">§</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that determines the <b>current view</b>.</p>
<p>Defaults to the first day of the current month (or “now” for the time picker) when there’s no <a href="#method-get-value"><code class="string">value</code></a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('view')
picker.get('view', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--view class="fieldset__button button button--small">Log the view</button><button id=button__api-get--view-format class="fieldset__button button button--small">Log the view formatted</button><input id="demo__api-get--view" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">min</code><a class="heading__anchor" name="method-get-min" href="#method-get-min">§</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that determines the <b>lower limit</b>.</p>
<p>Defaults to a <code class="keyword">-Infinity</code> <a href="#item-objects">item object</a> when it is not explicitly set in the <a href="date.htm#limits">options</a> or through the picker’s <a href="#method-set-min">API</a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('min')
picker.get('min', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--min class="fieldset__button button button--small">Log the min</button><button id=button__api-get--min-format class="fieldset__button button button--small">Log the min formatted</button><input id="demo__api-get--min" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">max</code><a class="heading__anchor" name="method-get-max" href="#method-get-max">§</a></span></h2>
<p>Returns the <a href="#item-objects">item object</a> or formatted string of the date that determines the <b>upper limit</b>.</p>
<p>Defaults to an <code class="keyword">Infinity</code> <a href="#item-objects">item object</a> when it is not explicitly set in the <a href="date.htm#limits">options</a> or through the picker’s <a href="#method-set-max">API</a>.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('max')
picker.get('max', 'yyyy/mm/dd')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--max class="fieldset__button button button--small">Log the max</button><button id=button__api-get--max-format class="fieldset__button button button--small">Log the max formatted</button><input id="demo__api-get--max" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">open</code><a class="heading__anchor" name="method-get-open" href="#method-get-open">§</a></span></h2>
<p>Returns a boolean value of whether the picker is open or not.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('open')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--open class="fieldset__button button button--small">Log the open state</button><input id="demo__api-get--open" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">start</code><a class="heading__anchor" name="method-get-start" href="#method-get-start">§</a></span></h2>
<p>Returns a boolean value of whether the picker has started or not.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('start')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--start class="fieldset__button button button--small">Log the start state</button><button id=button__api-get--start-stop class="fieldset__button button button--small">Stop picker</button><input id="demo__api-get--start" class="fieldset__input " type=date value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Get <code class="string">id</code><a class="heading__anchor" name="method-get-id" href="#method-get-id">§</a></span></h2>
<p>Returns a unique string that is the ID of the picker and it’s element. If the element has no ID, it is set to something random.</p>
<pre class="pre--demo"><code data-language="javascript">picker.get('id')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--id class="fieldset__button button button--small">Log the picker ID</button><input id="demo__api-get--id" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><a name="method-get-enable"></a><span class="heading__text">Get <code class="string">disable</code> and <code class="string">enable</code><a class="heading__anchor" name="method-get-disable" href="#method-get-disable">§</a></span></h2>
<p>Both these things work together to determine which <a href="#item-objects">item objects</a> to disable on the picker:</p>
<pre class="pre--demo"><code data-language="javascript">// Array passed in options to disable dates
var datesToDisable = [ 1, 4, 7, [2013,3,8], [2013,3,19], new Date(2013,3,26) ]
// Returns `1` to represent a base “enabled” state
picker.get('enable')
// Returns the collection of dates to disable
picker.get('disable')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--disable class="fieldset__button button button--small">Log the base state and collection</button><input id="demo__api-get--disable" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
<p>However, when <a href="date.htm#disable-dates-all">all dates are disabled and a select few are enabled</a>, it behaves differently:</p>
<pre class="pre--demo"><code data-language="javascript">// Array passed in options to disable all dates except a few
var datesToDisable = [ true, 1, 4, 7, [2013,3,8], [2013,3,19], new Date(2013,3,26) ]
// Returns `-1` to represent a base “flipped” state
picker.get('enable')
// Returns the collection of dates to *not* disable
picker.get('disable')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-get--enable class="fieldset__button button button--small">Log the base state and collection</button><input id="demo__api-get--enable" class="fieldset__input " type=text value="" placeholder="Open your console and try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set<a class="heading__anchor" name="method-set" href="#method-set">§</a></span></h2>
<p>Set the properties, objects, and states of the picker.</p>
<pre><code data-language="javascript">// One at a time
picker.set(thing, value)
// Multiple at once
picker.set({
thing: value,
thing: value,
thing: value
})</code></pre>
<p>The <code>value</code> is based on the <code>thing</code> being set. The <code>thing</code>, is a string that can be:</p>
<ul>
<li><code><a href="#method-set-clear">clear</a></code></li>
<li><code><a href="#method-set-select">select</a></code> <b>*</b></li>
<li><code><a href="#method-set-highlight">highlight</a></code> <b>*</b></li>
<li><code><a href="#method-set-view">view</a></code></li>
<li><code><a href="#method-set-min">min</a></code> <b>*</b></li>
<li><code><a href="#method-set-max">max</a></code> <b>*</b></li>
<li><code><a href="#method-set-disable-enable">disable</a></code> <b>*</b></li>
<li><code><a href="#method-set-disable-enable">enable</a></code> <b>*</b></li>
<li><code><a href="#method-set-interval">interval</a></code> (time picker only) <b>*</b></li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text"><b>*</b> cascading changes<a class="heading__anchor--bigger" name="cascading-changes" href="#cascading-changes">§</a></span></h3>
<p>When the <code>thing</code>s denoted in the list above with an asterisk (<b>*</b>) are set, they cascade into updating other things using the same value.</p>
<h3 class="heading heading--divide"><span class="heading__text">muted callbacks<a class="heading__anchor--bigger" name="muted-callbacks" href="#muted-callbacks">§</a></span></h3>
<p>By default, any callbacks bound with <a href="#method-on">the <code class="function">on</code> method</a> will be fired when it’s relevant <code>thing</code> is set. To silenty set a <code>thing</code>, pass an options object with the <code>muted</code> parameter set to <code class="constant">true</code>:</p>
<pre><code data-language="javascript">// One at a time
picker.set(thing, value, { muted: true })
// Multiple at once
picker.set({
thing: value,
thing: value,
thing: value
}, { muted: true })
</code></pre>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set <code class="string">clear</code><a class="heading__anchor" name="method-set-clear" href="#method-set-clear">§</a></span></h2>
<p>Clear the value in the picker’s <code class="tag-name">input</code> element.</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('clear')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set-clear class="fieldset__button button button--small">Clear</button><input id="demo__api-set-clear" class="fieldset__input " type=text value="15 February, 2014" placeholder="Try me…"></div></fieldset>
<p>This is the full form of <a href="#method-clear">the <code class="function">clear</code> method</a>.</p>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set <code class="string">select</code><a class="heading__anchor" name="method-set-select" href="#method-set-select">§</a></span></h2>
<p>Setting <code class="string">select</code> has <a href="#cascading-changes">cascading changes</a> that update the <code>highlight</code>, the <code>view</code>, and the value of the <code class="tag-name">input</code> element based on the settings <code>format</code>.</p>
<h3 class="heading heading--divide"><span class="heading__text">Select a date <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-select-date" href="#method-set-select-date">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('select', [2013,3,20])
// Using JavaScript Date objects.
picker.set('select', new Date(2013, 3, 30))
// Using positive integers as UNIX timestamps.
picker.set('select', 1366898887654)
// Using a string along with the parsing format (defaults to <a href="date.htm#formats">`format` option</a>).
picker.set('select', '2014-04-20', { format: 'yyyy-mm-dd' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--select-date-array class="fieldset__button button button--small">Select using an array</button><button id=button__api-set--select-date-js class="fieldset__button button button--small">Select using a JS Date</button><button id=button__api-set--select-date-integer class="fieldset__button button button--small">Select using an integer</button><button id=button__api-set--select-date-string class="fieldset__button button button--small">Select using a string and format</button><input id="demo__api-set--select-date" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Select a time <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-select-time" href="#method-set-select-time">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('select', [3,0])
// Using JavaScript Date objects.
picker.set('select', new Date(2013, 3, 20, 10, 30))
// Using positive integers as minutes.
picker.set('select', 540)
// Using a string along with the parsing format (defaults to <a href="time.htm#formats">`format` option</a>).
picker.set('select', '04-30', { format: 'hh-i' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--select-time-array class="fieldset__button button button--small">Select using an array</button><button id=button__api-set--select-time-js class="fieldset__button button button--small">Select using a JS Date</button><button id=button__api-set--select-time-integer class="fieldset__button button button--small">Select using an integer</button><button id=button__api-set--select-time-string class="fieldset__button button button--small">Select using a string and format</button><input id="demo__api-set--select-time" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set <code class="string">highlight</code><a class="heading__anchor" name="method-set-highlight" href="#method-set-highlight">§</a></span></h2>
<p>Setting <code class="string">highlight</code> has a <a href="#cascading-changes">cascading change</a> that updates the <a href="#item-objects">item object</a> that sets the <code>view</code> of the picker.</p>
<h3 class="heading heading--divide"><span class="heading__text">Highlight a date <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-highlight-date" href="#method-set-highlight-date">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('highlight', [2013,3,20])
// Using JavaScript Date objects.
picker.set('highlight', new Date(2013, 3, 30))
// Using positive integers as UNIX timestamps.
picker.set('highlight', 1366898887654)
// Using a string along with the parsing format (defaults to <a href="date.htm#formats">`format` option</a>).
picker.set('highlight', '2014-04-20', { format: 'yyyy-mm-dd' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--highlight-date-array class="fieldset__button button button--small">Highlight using an array</button><button id=button__api-set--highlight-date-js class="fieldset__button button button--small">Highlight using a JS Date</button><button id=button__api-set--highlight-date-integer class="fieldset__button button button--small">Highlight using an integer</button><button id=button__api-set--highlight-date-string class="fieldset__button button button--small">Highlight using a string and format</button><input id="demo__api-set--highlight-date" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Highlight a time <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-highlight-time" href="#method-set-highlight-time">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('highlight', [15,30])
// Using JavaScript Date objects.
picker.set('highlight', new Date(2013, 3, 20, 10, 30))
// Using positive integers as minutes.
picker.set('highlight', 1080)
// Using a string along with the parsing format (defaults to <a href="time.htm#formats">`format` option</a>).
picker.set('highlight', '04-30', { format: 'hh-i' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--highlight-time-array class="fieldset__button button button--small">Highlight using an array</button><button id=button__api-set--highlight-time-js class="fieldset__button button button--small">Highlight using a JS Date</button><button id=button__api-set--highlight-time-integer class="fieldset__button button button--small">Highlight using an integer</button><button id=button__api-set--highlight-time-string class="fieldset__button button button--small">Highlight using a string and format</button><input id="demo__api-set--highlight-time" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set <code class="string">view</code><a class="heading__anchor" name="method-set-view" href="#method-set-view">§</a></span></h2>
<p>Setting <code class="string">view</code> has no <a href="#cascading-changes">cascading changes</a> and the <code class="string">highlight</code> remains unaffected.</p>
<h3 class="heading heading--divide"><span class="heading__text">Viewset a date <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-view-date" href="#method-set-view-date">§</a></span></h3>
<p>The <code>value</code> passed gets normalized to the first date of the month to bring into view.</p>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('view', [2000,3,20])
// Using JavaScript Date objects.
picker.set('view', new Date(1988,7,14))
// Using positive integers as UNIX timestamps.
picker.set('view', 1587355200000)
// Using a string along with the parsing format (defaults to <a href="date.htm#formats">`format` option</a>).
picker.set('view', '2014-04-20', { format: 'yyyy-mm-dd' })</code></code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--view-date-array class="fieldset__button button button--small">Viewset using an array</button><button id=button__api-set--view-date-js class="fieldset__button button button--small">Viewset using a JS Date</button><button id=button__api-set--view-date-integer class="fieldset__button button button--small">Viewset using an integer</button><button id=button__api-set--view-date-string class="fieldset__button button button--small">Viewset using a string and format</button><input id="demo__api-set--view-date" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Viewset a time <a href="#item-objects">item object</a><a class="heading__anchor--bigger" name="method-set-view-time" href="#method-set-view-time">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('view', [15,30])
// Using JavaScript Date objects.
picker.set('view', new Date(2013, 3, 20, 10, 30))
// Using positive integers as minutes.
picker.set('view', 1080)
// Using a string along with the parsing format (defaults to <a href="time.htm#formats">`format` option</a>).
picker.set('view', '04-30', { format: 'hh-i' })</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--view-time-array class="fieldset__button button button--small">Viewset using an array</button><button id=button__api-set--view-time-js class="fieldset__button button button--small">Viewset using a JS Date</button><button id=button__api-set--view-time-integer class="fieldset__button button button--small">Viewset using an integer</button><button id=button__api-set--view-time-string class="fieldset__button button button--small">Viewset using a string and format</button><input id="demo__api-set--view-time" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set <code class="string">min</code><a class="heading__anchor" name="method-set-min" href="#method-set-min">§</a></span></h2>
<p>Setting <code class="string">min</code> has <a href="#cascading-changes">cascading changes</a> on the <code class="string">select</code>, <code class="string">highlight</code>, and <code class="string">view</code> only when the particular <a href="#item-objects">item object</a> goes out of range.</p>
<h3 class="heading heading--divide"><span class="heading__text">Limit the min date <a class="heading__anchor--bigger" name="method-set-min-date" href="#method-set-min-date">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('min', [2013,3,20])
// Using JavaScript Date objects.
picker.set('min', new Date(2013,7,14))
// Using integers as days relative to today.
picker.set('min', -4)
// Using `true` for “today”.
picker.set('min', true)
// Using `false` to remove.
picker.set('min', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--min-date-array class="fieldset__button button button--small">Limit using an array</button><button id=button__api-set--min-date-js class="fieldset__button button button--small">Limit using a JS Date</button><button id=button__api-set--min-date-integer class="fieldset__button button button--small">Limit using an integer</button><button id=button__api-set--min-date-true class="fieldset__button button button--small">Limit using `true`</button><button id=button__api-set--min-date-false class="fieldset__button button button--small">Limit using `false`</button><input id="demo__api-set--min-date" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Limit the min time <a class="heading__anchor--bigger" name="method-set-min-time" href="#method-set-min-time">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('min', [15,30])
// Using JavaScript Date objects.
picker.set('min', new Date(2013, 3, 20, 10, 30))
// Using integers as intervals relative from now.
picker.set('min', -4)
// Using `true` for “now”.
picker.set('min', true)
// Using `false` to remove.
picker.set('min', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--min-time-array class="fieldset__button button button--small">Limit using an array</button><button id=button__api-set--min-time-js class="fieldset__button button button--small">Limit using a JS Date</button><button id=button__api-set--min-time-integer class="fieldset__button button button--small">Limit using an integer</button><button id=button__api-set--min-time-true class="fieldset__button button button--small">Limit using `true`</button><button id=button__api-set--min-time-false class="fieldset__button button button--small">Limit using `false`</button><input id="demo__api-set--min-time" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set <code class="string">max</code><a class="heading__anchor" name="method-set-max" href="#method-set-max">§</a></span></h2>
<p>Setting <code class="string">max</code> has <a href="#cascading-changes">cascading changes</a> on the <code class="string">select</code>, <code class="string">highlight</code>, and <code class="string">view</code> only when the particular <a href="#item-objects">item object</a> goes out of range.</p>
<h3 class="heading heading--divide"><span class="heading__text">Limit the max date <a class="heading__anchor--bigger" name="method-set-max-date" href="#method-set-max-date">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [YEAR,MONTH,DATE].
picker.set('max', [2013,3,20])
// Using JavaScript Date objects.
picker.set('max', new Date(2013,7,14))
// Using integers as days relative to today.
picker.set('max', 4)
// Using `true` for “today”.
picker.set('max', true)
// Using `false` to remove.
picker.set('max', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--max-date-array class="fieldset__button button button--small">Limit using an array</button><button id=button__api-set--max-date-js class="fieldset__button button button--small">Limit using a JS Date</button><button id=button__api-set--max-date-integer class="fieldset__button button button--small">Limit using an integer</button><button id=button__api-set--max-date-true class="fieldset__button button button--small">Limit using `true`</button><button id=button__api-set--max-date-false class="fieldset__button button button--small">Limit using `false`</button><input id="demo__api-set--max-date" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
<h3 class="heading heading--divide"><span class="heading__text">Limit the max time <a class="heading__anchor--bigger" name="method-set-max-time" href="#method-set-max-time">§</a></span></h3>
<pre class="pre--demo"><code data-language="javascript">// Using arrays formatted as [HOUR,MINUTE].
picker.set('max', [15,30])
// Using JavaScript Date objects.
picker.set('max', new Date(2013, 3, 20, 10, 30))
// Using integers as intervals relative from now.
picker.set('max', 4)
// Using `true` for “now”.
picker.set('max', true)
// Using `false` to remove.
picker.set('max', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--max-time-array class="fieldset__button button button--small">Limit using an array</button><button id=button__api-set--max-time-js class="fieldset__button button button--small">Limit using a JS Date</button><button id=button__api-set--max-time-integer class="fieldset__button button button--small">Limit using an integer</button><button id=button__api-set--max-time-true class="fieldset__button button button--small">Limit using `true`</button><button id=button__api-set--max-time-false class="fieldset__button button button--small">Limit using `false`</button><input id="demo__api-set--max-time" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><a name="method-set-enable"></a><span class="heading__text">Set <code class="string">disable</code> and <code class="string">enable</code><a class="heading__anchor" name="method-set-disable-enable" href="#method-set-disable-enable">§</a></span></h2>
<p>Setting <code class="string">disable</code> or <code class="string">enable</code> has <a href="#cascading-changes">cascading changes</a> on the <code class="string">select</code>, <code class="string">highlight</code>, and <code class="string">view</code> only when the currently selected <a href="#item-objects">item object</a> becomes disabled.</p>
<div class="section__block section__block--notification">
<p>An important thing to note here is that “setting” something as enabled or disabled adds the new elements to the collection of items to disable rather than completely replacing them with the new collection.</p>
</div>
<h3 class="heading heading--divide"><span class="heading__text">Disable/enable dates <a class="heading__anchor--bigger" name="method-set-disable-enable-dates" href="#method-set-disable-enable-dates">§</a></span></h3>
<p>You can disable sets of dates and then enable the entire set or specific dates within those sets by the following methods:</p>
<ul>
<li>
<p>Specific dates:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Using a collection of arrays formatted as [YEAR,MONTH,DATE]
[2014,9,3], [2014,9,9], [2014,9,20],
// Using JavaScript Date objects
new Date(2013,9,13), new Date(2013,9,24)
])
picker.set('enable', [
[2014,9,9],
[2014,9,13],
new Date(2013,9,20)
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-date-specific class="fieldset__button button button--small">Disable specific dates</button><button id=button__api-set--enable-date-specific class="fieldset__button button button--small">Enable specific dates</button><input id="demo__api-set--disable-enable-date-specific" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</li>
<li>
<p>Ranges of dates:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Using integers as the days of the week (1 to 7)
1, 4, 7,
// Using a range object with a “from” and “to” property
{ from: [2014,2,14], to: [2014,2,27] }
])
picker.set('enable', [
4,
{ from: [2014,2,24], to: [2014,2,27] }
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-date-ranges class="fieldset__button button button--small">Disable dates ranges</button><button id=button__api-set--enable-date-ranges class="fieldset__button button button--small">Enable dates ranges</button><input id="demo__api-set--disable-enable-date-ranges" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</li>
<li>
<p>“Flip” the enabled and disabled dates:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', 'flip')
picker.set('enable', 'flip')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-date-flip class="fieldset__button button button--small">Flip the enabled & disabled dates</button><input id="demo__api-set--disable-enable-date-flip" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</li>
<li>
<p>All the dates:</p>
<pre class="pre--demo"><code data-language="javascript">// Disable all the dates
picker.set('disable', true)
picker.set('enable', false)
// Enable all the dates
picker.set('enable', true)
picker.set('disable', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-date-all class="fieldset__button button button--small">Disable all dates</button><button id=button__api-set--enable-date-all class="fieldset__button button button--small">Enable all dates</button><input id="demo__api-set--disable-enable-date-all" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text">Disable/enable times <a class="heading__anchor--bigger" name="method-set-disable-enable-times" href="#method-set-disable-enable-times">§</a></span></h3>
<p>You can disable sets of times and then enable the entire set or specific times within those sets by the following methods:</p>
<ul>
<li>
<p>Specific times:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Using a collection of arrays formatted as [HOUR,MINUTES]
[2,30], [4,30], [9,0],
// Using JavaScript Date objects
new Date(2013,9,13,6), new Date(2013,9,13,12,30)
])
picker.set('enable', [
[4,30], [6,0],
new Date(2013,9,13,9)
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-time-specific class="fieldset__button button button--small">Disable specific times</button><button id=button__api-set--enable-time-specific class="fieldset__button button button--small">Enable specific times</button><input id="demo__api-set--disable-enable-time-specific" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</li>
<li>
<p>Ranges of times:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Using integers as hours of the day (from 0 to 23)
1, 4, 7,
// Using a range object with a “from” and “to” property
{ from: [10,30], to: [18,0] }
})
picker.set('enable', [
4,
{ from: [14,0], to: [16,30] }
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-time-ranges class="fieldset__button button button--small">Disable times ranges</button><button id=button__api-set--enable-time-ranges class="fieldset__button button button--small">Enable times ranges</button><input id="demo__api-set--disable-enable-time-ranges" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</li>
<li>
<p>“Flip” the enabled and disabled times:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', 'flip')
picker.set('enable', 'flip')</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-time-flip class="fieldset__button button button--small">Flip the enabled & disabled times</button><input id="demo__api-set--disable-enable-time-flip" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</li>
<li>
<p>All the times:</p>
<pre class="pre--demo"><code data-language="javascript">// Disable all the times
picker.set('disable', true)
picker.set('enable', true)
// Enable all the dates
picker.set('enable', true)
picker.set('disable', false)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--disable-time-all class="fieldset__button button button--small">Disable all times</button><button id=button__api-set--enable-time-all class="fieldset__button button button--small">Enable all times</button><input id="demo__api-set--disable-enable-time-all" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</li>
</ul>
<h3 class="heading heading--divide"><span class="heading__text">Enable an element within a disabled range <a class="heading__anchor--bigger" name="method-set-enable-disable-in-range" href="#method-set-enable-disable-in-range">§</a></span></h3>
<p>When a date or time you want to enable falls within a disabled range, add the <code class="string">inverted</code> property to the item:</p>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Disable all Mondays, except November 17<sup>th</sup>, 2013.
1, [2013, 10, 17, 'inverted'],
// Disable all dates from March 2<sup>nd</sup>, 2014 to March 28<sup>th</sup>, 2014
// except for March 10<sup>th</sup> and all between March 14<sup>th</sup> and March 23<sup>rd</sup>.
{ from: [2014, 2, 2], to: [2014, 2, 28] },
[2014, 2, 10, 'inverted'],
{ from: [2014, 2, 14], to: [2014, 2, 23], inverted: true }
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="demo__api-set--enable-disable-in-range-date" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
<pre class="pre--demo"><code data-language="javascript">picker.set('disable', [
// Disable all times from 1:00 AM to 1:59 AM, except 1:30 AM.
1, [1, 30, 'inverted'],
// Disable all times from 3:00 AM to 6:00 PM except
// for 4:30 AM and all between 7:30 AM and 11:30 AM.
{ from: [3,0], to: [18,0] },
[4, 30, 'inverted'],
{ from: [7,30], to: [11,30], inverted: true }
])</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><input id="demo__api-set--enable-disable-in-range-time" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Set <code class="string">interval</code><a class="heading__anchor" name="method-set-interval" href="#method-set-interval">§</a></span></h2>
<p>For the time picker only, you can change the interval between each time display.</p>
<p>Setting <code class="string">interval</code> has <a href="#cascading-changes">cascading changes</a> on the <code class="string">select</code>, <code class="string">highlight</code>, and <code class="string">view</code> only when the particular <a href="#item-objects">item object</a> goes out of range.</p>
<pre class="pre--demo"><code data-language="javascript">// Using integers representing the interval length in minutes
picker.set('interval', 15)
picker.set('interval', 20)
picker.set('interval', 120)</code></pre>
<fieldset class="fieldset fieldset--demo js__fieldset"><div class="fieldset__wrapper"><button id=button__api-set--interval-fifteen class="fieldset__button button button--small">Set it to 15</button><button id=button__api-set--interval-twenty class="fieldset__button button button--small">Set it to 20</button><button id=button__api-set--interval-onetwenty class="fieldset__button button button--small">Set it to 120</button><input id="demo__api-set--interval" class="fieldset__input " type=text value="" placeholder="Try me…"></div></fieldset>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h1 class="heading heading--divide-center"><span class="heading__text">The Events and Callbacks<a class="heading__anchor" name="events-callbacks" href="#events-callbacks">§</a></span></h1>
</div> <!-- .section__block -->
</section> <!-- .section -->
<section class="section">
<div class="section__block section__block--scoped">
<h2 class="heading heading--divide"><span class="heading__text">Event <code class="function">on</code><a class="heading__anchor" name="method-on" href="#method-on">§</a></span></h2>
<p>Bind callbacks to get fired off when the relative <a href="#api-methods">picker method</a> is called (unless if <a href="#muted-callbacks">the callback is “muted”</a>):</p>
<pre><code data-language="javascript">// One at a time
picker.on(methodName, function() { … })
// Multiple at once
picker.on({
methodName: function() { … },
methodName: function() { … },
methodName: function() { … }
})</code></pre>
<p>The <code>methodName</code> can be <code class="string">open</code>, <code class="string">close</code>, <code class="string">render</code>, <code class="string">start</code>, <code class="string">stop</code>, or <code class="string">set</code>.</p>
<p>Within scope of these callbacks, <code class="keyword">this</code> refers to <a href="#picker">the picker object</a> – and for most events, no arguments are passed.</p>
<p>The only exception is the <code class="function">set</code> method, which is passed an argument that provides more context as to what is being “set”.</p>
</div> <!-- .section__block -->
<div class="section__block section__block--scoped">
<h3 class="heading heading--divide"><span class="heading__text">Event callbacks as bindings<a class="heading__anchor--bigger" name="method-on-callback-bindings" href="#method-on-callback-bindings">§</a></span></h3>
<p><i>After</i> the picker has been initiated, callbacks to events can be set using the <code class="function">on</code> method:</p>