/
metallic.html
695 lines (545 loc) · 33.5 KB
/
metallic.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Simplify date time selection with this highly configurable, user-friendly date and time picker jQuery plugin">
<link rel="shortcut icon" href="favicon.ico">
<title>Best jQuery Date Time Picker Plugin - Zebra Datepicker - Super Lightweight & Highly Configurable</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/united/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCoreDefault.min.css" />
<link rel="stylesheet" href="../dist/css/metallic/zebra_datepicker.min.css" type="text/css">
<link rel="stylesheet" href="examples.css" type="text/css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shCore.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushJScript.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushXml.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushCss.min.js"></script>
<script type="text/javascript">
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>
</head>
<body>
<div class="jumbotron">
<div class="container">
<h1>The Ultimate jQuery Date Time Picker:<br>Zebra Datepicker<small>super-lightweight and highly-configurable</small></h1>
<hr>
<p>
<a href="https://github.com/stefangabos/Zebra_Datepicker/archive/master.zip" class="btn btn-primary btn-lg" role="button" style="text-decoration: none">Download</a>
<a href="https://github.com/stefangabos/Zebra_Datepicker" class="btn btn-primary btn-lg" role="button" style="text-decoration: none">View on GitHub</a>
</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12">
<blockquote class="bg-warning"><small class="text-warning">See the examples with the date pickers having the <a href="index.html">default</a> or the <a href="bootstrap.html">bootstrap</a> theme.</small></blockquote>
<div class="row">
<div class="col-md-6">
<p>
Zebra Datepicker is a small, compact and highly configurable date picker / time picker
jQuery plugin, meant to enrich forms by adding the date picker functionality to them.
Zebra Datepicker is a user-friendly and highly configurable date and time picker jQuery plugin.
Its lightweight design makes it easy to implement on any website, and it's compatible with
all major browsers. With a range of customization options, you can easily tailor the plugin
to suit your needs and enhance the functionality of your forms. Whether you're looking for
a simple date time picker or a more advanced one, Zebra Datepicker has you covered.
</p>
<p>
This jQuery plugin will automatically add a calendar icon to the indicated input fields
which, when clicked, will open the attached date picker.
This jQuery date time picker plugin will automatically add a calendar icon to the indicated
input fields which, when clicked, will open the attached date time picker.
</p>
<p>
Users can easily jump between months and years due to the date pickers intuitive interface.
The selected date will be entered in the input field using the date format of choice,
configurable in the date picker's options.
</p>
</div>
<div class="col-md-6">
<div class="screenshot screenshot-metallic"></div>
</div>
</div>
<hr>
<div class="row">
<div class="col-sm-6">
1. <a href="#default-initialization">Default initialization</a><br>
2. <a href="#future-tomorrow">Allow future dates only starting one day in the future</a><br>
3. <a href="#dynamic-interval">Allow dates from a dynamic interval</a><br>
4. <a href="#dates-interval">Allow dates from an interval between 2 dates</a><br>
5. <a href="#after-date">Allow only dates that come after a certain date</a><br>
6. <a href="#disable-dates">Disable dates</a><br>
7. <a href="#date-range">Date ranges (sort of)</a><br>
8. <a href="#date-formats">Date formats</a><br>
</div>
<div class="col-sm-6">
9. <a href="#time">Enabling the time picker</a><br>
10. <a href="#partial-formats">Partial date formats</a><br>
11. <a href="#week-number">Showing week numbers</a><br>
12. <a href="#starting-view">Changing the starting view</a><br>
13. <a href="#custom-classes">Custom classes</a><br>
14. <a href="#on-change">Handling the "onChange" event</a><br>
15. <a href="#always-visible">Always-visible date pickers</a><br>
16. <a href="#rtl-support">RTL support</a><br>
17. <a href="#data-attributes">Data attributes</a><br>
</div>
</div>
<a name="default-initialization"></a>
<hr>
<!-- =========================================================================================== -->
<br><h3><strong>1.</strong> Default initialization</h3>
<p>
All dates are selectable, no restrictions.<br>
There are <strong>a lot</strong> of things that can be <a href="https://github.com/stefangabos/Zebra_Datepicker#properties">configured</a>!
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker();
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="future-tomorrow"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>2.</strong> Allow future dates only, starting one day in the future</h3>
<p>
All past dates, including today, are disabled.<br>
Read more about using the <a href="https://github.com/stefangabos/Zebra_Datepicker#user-content-direction">direction</a> property.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
direction: 1
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-future-tomorrow" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="dynamic-interval"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>3. </strong> Allow dates from a dynamic interval</h3>
<p>
The selectable dates are in the interval starting tomorrow and ending 10 days after that.<br>
Read more about using the <a href="https://github.com/stefangabos/Zebra_Datepicker#user-content-direction">direction</a> property.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
direction: [1, 10]
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-dynamic-interval" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="dates-interval"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>4.</strong> Allow dates from an interval between 2 dates</h3>
<p>
Dates in the <code>direction</code> property have to be written in the date picker's <a href="https://github.com/stefangabos/Zebra_Datepicker#user-content-format">date format</a>.<br>
Read more about using the <a href="https://github.com/stefangabos/Zebra_Datepicker#user-content-direction">direction</a> property.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
direction: ['2012-08-01', '2012-08-12']
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-dates-interval" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="after-date"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>5.</strong> Allow only dates that come after a certain date</h3>
<p>
Dates in the <code>direction</code> property have to be written in the date picker's <a href="https://github.com/stefangabos/Zebra_Datepicker#user-content-format">date format</a>.<br>
Read more about using the <a href="https://github.com/stefangabos/Zebra_Datepicker#user-content-direction">direction</a> property.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
direction: ['2012-08-01', false]
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-after-date" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="disable-dates"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>6.</strong> Disable dates</h3>
<p>
Allow future dates only including the current day.<br>
All past dates are disabled.<br>
Saturday and Sundays are disabled.<br>
Read more about using the <a href="https://github.com/stefangabos/Zebra_Datepicker#user-content-direction">direction</a> property and about <a href="https://github.com/stefangabos/Zebra_Datepicker#user-content-disabled_dates">disabling dates</a>.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
direction: true,
disabled_dates: ['* * * 0,6'] // all days, all months, all years as long
// as the weekday is 0 or 6 (Sunday or Saturday)
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-disabled-dates" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="date-range"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>7.</strong> Date ranges (sort of)</h3>
<p>The second date picker's starting date is the value of the first date picker + 1</p>
<pre class="brush:js">
$('#datepicker-range-start').Zebra_DatePicker({
direction: true,
pair: $('#datepicker-range-end')
});
$('#datepicker-range-end').Zebra_DatePicker({
direction: 1
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-range-start" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
<div class="col-sm-3">
<input id="datepicker-range-end" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="date-formats"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>8.</strong> Date formats</h3>
<p>
Accepts the following characters for date formatting: <code>d</code>, <code>D</code>, <code>j</code>,
<code>l</code>, <code>N</code>, <code>w</code>, <code>S</code>, <code>F</code>, <code>m</code>,
<code>M</code>, <code>n</code>, <code>Y</code>, <code>y</code>, <code>h</code>, <code>H</code>,
<code>g</code>, <code>G</code>, <code>i</code>, <code>s</code>, <code>a</code>, <code>A</code>,
borrowing the syntax from PHP's <a href="http://php.net/manual/en/function.date.php">date</a>
function.<br>
If <code>format</code> property contains time-related characters (<code>g</code>, <code>G</code>,
<code>h</code>, <code>H</code>, <code>i</code>, <code>s</code>, <code>a</code>, <code>A</code>),
the time picker will be automatically enabled.<br>
Note that when setting a date format without days (<code>d</code>, <code>j</code>), the users will
be able to select only years and months, and when setting a format without months and days
(<code>F</code>, <code>m</code>, <code>M</code>, <code>n</code>, <code>t</code>, <code>d</code>,
<code>j</code>), the users will be able to select only years. Similarly, setting a format that
contains only time-related characters, will result in users being able to only select time.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
format: 'M d, Y'
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-formats" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="time"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>9.</strong> Enabling the time picker</h3>
<p>
If <code>format</code> property contains time-related characters (<code>g</code>, <code>G</code>,
<code>h</code>, <code>H</code>, <code>i</code>, <code>s</code>, <code>a</code>, <code>A</code>),
the time picker will be automatically enabled.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
format: 'Y-m-d H:i'
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-time" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="partial-formats"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>10.</strong> Partial date formats</h3>
<p>
The date picker will not show views that are not present in format.<br>
In the example below, the date picker will never get to the <code>day</code> view as there is no
<code>day</code>-related character in the date's format.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
format: 'm Y',
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-partial-date-formats" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="week-number"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>11.</strong> Showing week numbers</h3>
<p>
Show the <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> week number.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
show_week_number: 'Wk'
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-week-number" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="starting-view"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>12.</strong> Changing the starting view</h3>
<p>
Start with the <code>years</code> view, recommended for when users need to select their birth
date.<br>
You can always switch between views by clicking on caption in the date picker's header, between
the <code>previous</code> and <code>next</code> buttons!<br>
Note that the date picker is always cycling <code>days -> months -> years</code> when clicking
on the date picker's header, and <code>years -> months -> days</code> when selecting dates (skipping
the views that are missing because of the date's format)<br>
Also note that the value of the <em>view</em> property may be overridden if the date's format requires so! (i.e. <code>days</code> for the <em>view</em> property makes no sense if the date format doesn't allow the selection of days)
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
view: 'years'
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-starting-view" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="custom-classes"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>13.</strong> Custom classes</h3>
<p>
Disable weekends and apply a custom class to Saturdays and Sundays.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
disabled_dates: ['* * * 0,6'],
custom_classes: {
'myclass': ['* * * 0,6']
}
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-custom-classes" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="on-change"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>14.</strong> Handling the "onChange" event</h3>
<p>
If a callback function is attached to the <code>onChange</code> event, it will be called whenever
the user changes the view (days/months/years), as well as when the user navigates by clicking on
the next/previous icons in any of the views.
</p>
<p>The callback function takes two arguments:</p>
<ul>
<li>
the view (<code>days</code>, <code>months</code> or <code>years</code>)
</li>
<li>
the <em>active</em> elements (not disabled) in that view, as jQuery elements, allowing for
easy customization and interaction with particular cells in the date picker's view
</li>
</ul>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
// execute a function whenever the user changes the view (days/months/years),
// as well as when the user navigates by clicking on the "next"/"previous"
// icons in any of the views
onChange: function(view, elements) {
// on the "days" view...
if (view == 'days') {
// iterate through the active elements in the view
elements.each(function() {
// to simplify searching for particular dates, each element gets a
// "date" data attribute which is the form of:
// - YYYY-MM-DD for elements in the "days" view
// - YYYY-MM for elements in the "months" view
// - YYYY for elements in the "years" view
// so, because we're on a "days" view,
// let's find the 24th day using a regular expression
// (notice that this will apply to every 24th day
// of every month of every year)
if ($(this).data('date').match(/\-24$/))
// and highlight it!
$(this).css({
background: '#C40000',
color: '#FFF'
});
});
}
}
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-on-change" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="always-visible"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>15.</strong> Always-visible date pickers</h3>
<p>
Set the <code>always_visible</code> property's value to a jQuery element which will act as a
container for the date picker.<br>Notice that in this case the element the date picker is attached
to has no icon.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
always_visible: $('#container')
});
</pre>
<div id="container" style="margin: 10px 0 15px 0; height: 255px; position: relative"></div>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-always-visible" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="rtl-support"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>16.</strong> RTL support</h3>
<p>
Set the <code>rtl</code> property to <code>true</code> to have the current language drawn from
right to left.
</p>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker({
rtl: true
});
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-rtl-support" type="text" class="form-control" data-zdp_readonly_element="false">
</div>
</div>
</div>
<a name="data-attributes"></a>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<!-- =========================================================================================== -->
<h3><strong>17.</strong> Data attributes</h3>
<p>
All the properties of the date picker can also be set via <code>data-attributes</code>.<br>
All you have to do is take any property described in the <a href="https://github.com/stefangabos/Zebra_Datepicker#configuration-options">configuration</a> section and
prefix it with <code>data-zdp_</code>.<br>
Remember that if the value of the property is an array, you will have to use <em>double
quotes</em> inside the square brackets and <em>single quotes</em> around the attribute, like in
the example below:
</p>
<pre class="brush:xml">
<input type="text" id="datepicker" data-zdp_direction="1" data-zdp_disabled_dates='["* * * 0,6"]'>
</pre>
<pre class="brush:js">
$('#datepicker').Zebra_DatePicker();
</pre>
<div class="well">
<div class="row">
<div class="col-sm-3">
<input id="datepicker-data-attributes" type="text" class="form-control" data-zdp_direction="1" data-zdp_disabled_dates='["* * * 0,6"]' data-zdp_readonly_element="false">
</div>
</div>
</div>
<div class="top">
<a href="#top" class="small">⯅ To the top</a>
</div>
<p class="text-center">copyright © 2011 - <script>var date = new Date; document.write(date.getFullYear());</script> <a href="https://github.com/stefangabos/">stefan gabos</a></p>
<br>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/zebra_pin@2.0.0/dist/zebra_pin.min.js"></script>
<script src="../dist/zebra_datepicker.min.js"></script>
<script src="examples.js"></script>
</body>
</html>