forked from fgelinas/timepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1130 lines (936 loc) · 53.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>jQuery UI Time Picker by Francois Gelinas</title>
<link rel="stylesheet" href="include/ui-1.10.0/ui-lightness/jquery-ui-1.10.0.custom.min.css" type="text/css" />
<link rel="stylesheet" href="jquery.ui.timepicker.css?v=0.3.2" type="text/css" />
<script type="text/javascript" src="include/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="include/ui-1.10.0/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="include/ui-1.10.0/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="include/ui-1.10.0/jquery.ui.tabs.min.js"></script>
<script type="text/javascript" src="include/ui-1.10.0/jquery.ui.position.min.js"></script>
<script type="text/javascript" src="jquery.ui.timepicker.js?v=0.3.2"></script>
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<style type="text/css">
/* some styling for the page */
body { font-size: 10px; /* for the widget natural size */ }
#content { font-size: 1.2em; /* for the rest of the page to show at a normal size */
font-family: "Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
width: 950px; margin: auto;
}
.code { margin: 6px; padding: 9px; background-color: #fdf5ce; border: 1px solid #c77405; }
fieldset { padding: 0.5em 2em }
hr { margin: 0.5em 0; clear: both }
a { cursor: pointer; }
#requirements li { line-height: 1.6em; }
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24327002-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
function plusone_clicked() {
$('#thankyou').fadeIn(300);
}
$(document).ready(function() {
$('#floating_timepicker').timepicker({
onSelect: function(time, inst) {
$('#floating_selected_time').html('You selected ' + time);
}
});
$('#tabs').tabs();
});
</script>
</head>
<body>
<div id="content">
<div style="float: right; padding: 0 0 20px 20px; font-size: 10px; text-align: right">
<div style=" min-height: 50px">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----
">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
<br>
aka beer!
</form>
</div>
<div id="floating_timepicker">
</div>
<span id="floating_selected_time">
</span>
</div>
<h1>jQuery UI Timepicker
<span style="color: #999; font-size:10px;">(By <a href="http://fgelinas.com">François Gélinas</a>)</span>
<g:plusone callback='plusone_clicked'></g:plusone>
<span id="thankyou" style="display: none; font-size: 0.6em;" class="code">
Thanks !! (:
</span>
</h1>
<h2>What is this?</h2>
<p style="font-size: 1.1em;">
This is a jQuery UI time picker plugin built to match with other official jQuery UI widgets.
Based on the existing date picker, it will blend nicely with your form and use your selected jQuery UI theme.
The plugin is very easy to integrate in your form for time (hours / minutes) inputs.
</p>
<p>
Licensed under the same license as jQuery : <a href="http://docs.jquery.com/Licensing">MIT and GPL licenses</a>
</p>
<div style="clear: both"></div>
<div id="tabs">
<ul>
<li><a href="#examples">Examples</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#release_notes">Release notes</a></li>
<li><a href="#get_timepicker">Get Timepicker version 0.3.2</a></li>
</ul>
<div id="examples">
<div>
<label for="timepicker.[1]">Default time picker :</label>
<input type="text" style="width: 70px;" id="timepicker.[1]" value="" />
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker\\.\\[1\\]').timepicker( {
showAnim: 'blind'
} );
});
</script>
<a onclick="$('#script_1').toggle(200); return false;">[Show code]</a>
<pre id="script_1" style="display: none" class="code">$('#timepicker').timepicker();</pre>
</div>
<hr />
<div>
<label for="timepicker_6">Time picker with period (AM/PM) in input and with hours leading 0s :</label>
<input type="text" style="width: 70px;" id="timepicker_6" value="01:30 PM" />
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_6').timepicker({
showPeriod: true,
showLeadingZero: true
});
});
</script>
<a onclick="$('#script_6').toggle(200)">[Show code]</a>
<pre id="script_6" style="display: none" class="code">$('#timepicker').timepicker({
showPeriod: true,
showLeadingZero: true
});</pre>
</div>
<hr />
<div>
<label for="timepicker_locale">Time picker with buttons and labels in another language (Français) :</label>
<input type="text" style="width: 70px;" id="timepicker_locale" value="13h30" />
<br>
See the <a href="i18n/i18n.html">internationalisation page</a> for more information and details.
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_locale').timepicker({
hourText: 'Heures',
minuteText: 'Minutes',
amPmText: ['AM', 'PM'],
timeSeparator: 'h',
showLeadingZero: false,
nowButtonText: 'Maintenant',
showNowButton: true,
closeButtonText: 'Fermer',
showCloseButton: true,
deselectButtonText: 'Désélectionner',
showDeselectButton: true
});
});
</script>
<a onclick="$('#script_locale').toggle(200)">[Show code]</a>
<pre id="script_locale" style="display: none" class="code">$('#timepicker').timepicker({
hourText: 'Heures',
minuteText: 'Minutes',
amPmText: ['AM', 'PM'],
timeSeparator: 'h',
nowButtonText: 'Maintenant',
showNowButton: true,
closeButtonText: 'Fermer',
showCloseButton: true,
deselectButtonText: 'Désélectionner',
showDeselectButton: true
});</pre>
</div>
<hr />
<div>
<label for="timepicker_7">Time picker with restricted (disabled) hours / minutes. 8:30 PM to 6:30 AM disabled :</label>
<input type="text" style="width: 70px" id="timepicker_7" value="01:30 PM" />
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_7').timepicker({
showPeriod: true,
onHourShow: timepicker7OnHourShowCallback,
onMinuteShow: timepicker7OnMinuteShowCallback
});
});
function timepicker7OnHourShowCallback(hour) {
if ((hour > 20) || (hour < 6)) {
return false;
}
return true;
}
function timepicker7OnMinuteShowCallback(hour, minute) {
if ((hour == 20) && (minute >= 30)) { return false; }
if ((hour == 6) && (minute < 30)) { return false; }
return true;
}
</script>
<a onclick="$('#script_7').toggle(200)">[Show code]</a>
<pre id="script_7" style="display: none" class="code">$('#timepicker').timepicker({
showPeriod: true,
onHourShow: OnHourShowCallback,
onMinuteShow: OnMinuteShowCallback
});
function OnHourShowCallback(hour) {
if ((hour > 20) || (hour < 6)) {
return false; // not valid
}
return true; // valid
}
function OnMinuteShowCallback(hour, minute) {
if ((hour == 20) && (minute >= 30)) { return false; } // not valid
if ((hour == 6) && (minute < 30)) { return false; } // not valid
return true; // valid
}</pre>
</div>
<hr />
<div>
<label for="timepicker_showon">Define when the time picker is shown with the <kbd>showOn</kbd> option and set a trigger element with the <kbd>button</kbd> option</label>
<input type="text" style="width: 70px;" id="timepicker_showon" value="13h30" />
<div class='timepicker_button_trigger'
style="width: 16px; height:16px; background: url(include/ui-1.10.0/ui-lightness/images/ui-icons_222222_256x240.png) -80px, -96px;
display: inline-block; border-radius: 2px; border: 1px solid #222222; margin-top: 3px; cursor:pointer"></div>
<button class='timepicker_button_trigger' id="btn_trigger_timepicker">Show</button>
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_showon').timepicker({
showOn: 'button',
button: $('.timepicker_button_trigger'),
showLeadingZero: false,
timeSeparator: 'h'
});
});
</script>
<a onclick="$('#script_showhide').toggle(200)">[Show code]</a>
<pre id="script_showhide" style="display: none" class="code">$('#timepicker').timepicker({
showOn: 'button',
button: '.timepicker_button_trigger'
});
</pre>
</div>
<hr />
<div>
<label for="timepicker_noPeriodLabels">Time picker without the AM/PM labels on the left (showPeriodLabels option set to false:</label>
<input type="text" style="width: 70px;" id="timepicker_noPeriodLabels" value="13:30" />
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_noPeriodLabels').timepicker({
showPeriodLabels: false
});
});
</script>
<a onclick="$('#script_noPeriodLabels').toggle(200)">[Show code]</a>
<pre id="script_noPeriodLabels" style="display: none" class="code">$('#timepicker').timepicker({
showPeriodLabels: false,
});
</pre>
</div>
<hr />
<div>
<label for="timepicker_customrange">Custom defined hours range (Business hours 6am to 7pm) and minutes increment set to 15 instead of 5, on 3 rows</label>
<input type="text" style="width: 70px" id="timepicker_customrange" value="13:30">
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_customrange').timepicker({
hours: { starts: 6, ends: 19 },
minutes: { interval: 15 },
rows: 3,
showPeriodLabels: true,
minuteText: 'Min'
})
});
</script>
<a onclick="$('#script_2').toggle(200)">[Show code]</a>
<pre id="script_2" style="display: none" class="code"> $('#timepicke').timepicker({
hours: { starts: 6, ends: 19 },
minutes: { interval: 15 },
rows: 3
showPeriodLabels: true,
minuteText: 'Min'
});
</pre>
</div>
<hr />
<div>
<label for="timepicker_hours">Input for hours only :</label>
<input type="text" style="width: 70px" id="timepicker_hours" value="5 PM">
, <label for="timepicker_minutes">input for minutes only :</label>
<input type="text" style="width: 70px" id="timepicker_minutes" value="45">
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_hours').timepicker({
showMinutes: false,
showPeriod: true,
showLeadingZero: false
});
$('#timepicker_minutes').timepicker({
showHours: false
});
})
</script>
<a onclick="$('#script_hoursminutesonly').toggle(200)">[Show code]</a>
<pre id="script_hoursminutesonly" style="display: none" class="code">$('#timepicker_hours').timepicker({
showMinutes: false,
showPeriod: true,
showLeadingZero: false
});
$('#timepicker_minutes').timepicker({
showHours: false
});</pre>
<br>
<label for="timepicker_hours_2">Another hour input example arbitrary number of hours, ex: select between 10 and 40 hours</label>
<input type="text" style="width: 70px" id="timepicker_hours_2" value="120">
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_hours_2').timepicker({
hours: {
starts: 10,
ends: 40
},
rows: 8,
showPeriodLabels: false,
showPeriod: false,
showMinutes: false
});
})
</script>
<a onclick="$('#script_hours_2').toggle(200)">[Show code]</a>
<pre id="script_hours_2" style="display: none" class="code">$('#timepicker_hours_2').timepicker({
hours: {
starts: 10,
ends: 40
},
rows: 8,
showPeriodLabels: false,
showPeriod: false,
showMinutes: false
});</pre>
</div>
<hr />
<div>
<label for="timepicker_buttons">Timepicker with the Now, Deselect and Close buttons</label>
<input type="text" style="width: 70px" id="timepicker_buttons" value="12:35">
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_buttons').timepicker({
showNowButton: true,
showDeselectButton: true,
defaultTime: '', // removes the highlighted time for when the input is empty.
showCloseButton: true
});
})
</script>
<a onclick="$('#script_buttonpane').toggle(200)">[Show code]</a>
<pre id="script_buttonpane" style="display: none" class="code">$('#timepicker_buttons').timepicker({
showNowButton: true,
showDeselectButton: true,
defaultTime: '', // removes the highlighted time for when the input is empty.
showCloseButton: true
});</pre>
</div>
<hr />
<div>
<label for="timepicker_3">onSelect (hours and minutes both trigger event), beforeShow and onClose events :</label>
<input type="text" style="width: 70px" id="timepicker_3" value="13:30" />
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_3').timepicker({
beforeShow: function(input, inst) {
log_event('beforeShow triggered for instance id ' + inst.id);
},
onClose: function(time, inst) {
log_event('onClose triggered with time : ' + time + ' for instance id : ' + inst.id);
},
onSelect: function(time, inst) {
log_event('onSelect triggered with time : ' + time + ' for instance id : ' + inst.id);
}
});
});
function log_event(event) {
$('#events_log').val(
$('#events_log').val() + "\n" + event
)
}
</script>
<a onclick="$('#script_3').toggle(200)">[Show code]</a>
<pre id="script_3" style="display: none" class="code">function log_event(event) {
$('#events_log').val(
$('#events_log').val() + "\n" + event
)
}
$('#timepicker').timepicker({
onClose: function(time, inst) {
log_event('onClose triggered with time : ' + time + ' for instance id : ' + inst.id);
},
onSelect: function(time, inst) {
log_event('onSelect triggered with time : ' + time + ' for instance id : ' + inst.id);
}
});
</pre>
<br />
<textarea id="events_log" rows="4" cols="120" >events log :</textarea>
</div>
<hr />
<div>
<div style="float: left; width: 400px;">
Inline time picker :
<span style="color: #888;">
<label for="timepicker_alt">Alternate field :</label>
<input type="text" style="width: 70px" id="timepicker_alt" value="13:30" readonly="readonly" disabled="disabled"/>
</span>
<br />
<input type="button" value="Change time to 16:55" onclick="$('#timepicker_inline_7').timepicker('setTime','16:55');">
<br>
<input type="button" id='tp7_getTime_button' value="Get selected time" onclick="tp7_getTime();" >
<br>
<input type="button" id="tp7_getHourMinute_button" value="Get hour and minute" onclick="tp7_getHourMinute();" >
<br />
<a onclick="$('#script_inline').toggle(200); return false;">[Show code]</a>
</div>
<div id="timepicker_inline_7" style="font-size: 10px; float: left; margin-left: 24px;"></div>
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_inline_7').timepicker({
altField: '#timepicker_alt',
defaultTime: '13:30'
});
});
function tp7_getTime() {
$('#tp7_getTime_button').val('Selected time : ' + $('#timepicker_inline_7').timepicker('getTime'));
}
function tp7_getHourMinute() {
$('#tp7_getHourMinute_button').val(
'Hour : ' + $('#timepicker_inline_7').timepicker('getHour')
+ ', ' +
'minute : ' + $('#timepicker_inline_7').timepicker('getMinute')
);
}
</script>
<div style="clear: both"></div>
<pre class="code" id="script_inline" style="display: none">$('#timepicker_inline_div').timepicker({
altField: '#timepicker_alt_input',
defaultTime: '9:20'
});
function setNewTime() {
$('#timepicker_inline_div').timepicker('setTime','16:55');
}
function getTime() {
$('#getTime_button').val('Selected time : ' + $('#timepicker').timepicker('getTime'));
}
function getHourMinute() {
$('#getHourMinute_button').val(
'Hour : ' + $('#timepicker').timepicker('getHour')
+ ', ' +
'minute : ' + $('#timepicker').timepicker('getMinute')
);
}
</pre>
</div>
<hr />
<div>
Two timepickers to select chronological time range, the first timepicker is restricted to before the time selected in the second timepicker, and vice versa.
<br>
<label for="timepicker_start">Start time :</label>
<input type="text" style="width: 70px" id="timepicker_start" value="9:15" />
<label for="timepicker_end">end time :</label>
<input type="text" style="width: 70px" id="timepicker_end" value="16:30" />
<a onclick="$('#script_time_range').toggle(200); return false;">[Show code]</a>
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_start').timepicker({
showLeadingZero: false,
onHourShow: tpStartOnHourShowCallback,
onMinuteShow: tpStartOnMinuteShowCallback
});
$('#timepicker_end').timepicker({
showLeadingZero: false,
onHourShow: tpEndOnHourShowCallback,
onMinuteShow: tpEndOnMinuteShowCallback
});
});
function tpStartOnHourShowCallback(hour) {
var tpEndHour = $('#timepicker_end').timepicker('getHour');
// all valid if no end time selected
if ($('#timepicker_end').val() == '') { return true; }
// Check if proposed hour is prior or equal to selected end time hour
if (hour <= tpEndHour) { return true; }
// if hour did not match, it can not be selected
return false;
}
function tpStartOnMinuteShowCallback(hour, minute) {
var tpEndHour = $('#timepicker_end').timepicker('getHour');
var tpEndMinute = $('#timepicker_end').timepicker('getMinute');
// all valid if no end time selected
if ($('#timepicker_end').val() == '') { return true; }
// Check if proposed hour is prior to selected end time hour
if (hour < tpEndHour) { return true; }
// Check if proposed hour is equal to selected end time hour and minutes is prior
if ( (hour == tpEndHour) && (minute < tpEndMinute) ) { return true; }
// if minute did not match, it can not be selected
return false;
}
function tpEndOnHourShowCallback(hour) {
var tpStartHour = $('#timepicker_start').timepicker('getHour');
// all valid if no start time selected
if ($('#timepicker_start').val() == '') { return true; }
// Check if proposed hour is after or equal to selected start time hour
if (hour >= tpStartHour) { return true; }
// if hour did not match, it can not be selected
return false;
}
function tpEndOnMinuteShowCallback(hour, minute) {
var tpStartHour = $('#timepicker_start').timepicker('getHour');
var tpStartMinute = $('#timepicker_start').timepicker('getMinute');
// all valid if no start time selected
if ($('#timepicker_start').val() == '') { return true; }
// Check if proposed hour is after selected start time hour
if (hour > tpStartHour) { return true; }
// Check if proposed hour is equal to selected start time hour and minutes is after
if ( (hour == tpStartHour) && (minute > tpStartMinute) ) { return true; }
// if minute did not match, it can not be selected
return false;
}
</script>
<pre class="code" id="script_time_range" style="display: none">
$(document).ready(function() {
$('#timepicker_start').timepicker({
showLeadingZero: false,
onHourShow: tpStartOnHourShowCallback,
onMinuteShow: tpStartOnMinuteShowCallback
});
$('#timepicker_end').timepicker({
showLeadingZero: false,
onHourShow: tpEndOnHourShowCallback,
onMinuteShow: tpEndOnMinuteShowCallback
});
});
function tpStartOnHourShowCallback(hour) {
var tpEndHour = $('#timepicker_end').timepicker('getHour');
// all valid if no end time selected
if ($('#timepicker_end').val() == '') { return true; }
// Check if proposed hour is prior or equal to selected end time hour
if (hour <= tpEndHour) { return true; }
// if hour did not match, it can not be selected
return false;
}
function tpStartOnMinuteShowCallback(hour, minute) {
var tpEndHour = $('#timepicker_end').timepicker('getHour');
var tpEndMinute = $('#timepicker_end').timepicker('getMinute');
// all valid if no end time selected
if ($('#timepicker_end').val() == '') { return true; }
// Check if proposed hour is prior to selected end time hour
if (hour < tpEndHour) { return true; }
// Check if proposed hour is equal to selected end time hour and minutes is prior
if ( (hour == tpEndHour) && (minute < tpEndMinute) ) { return true; }
// if minute did not match, it can not be selected
return false;
}
function tpEndOnHourShowCallback(hour) {
var tpStartHour = $('#timepicker_start').timepicker('getHour');
// all valid if no start time selected
if ($('#timepicker_start').val() == '') { return true; }
// Check if proposed hour is after or equal to selected start time hour
if (hour >= tpStartHour) { return true; }
// if hour did not match, it can not be selected
return false;
}
function tpEndOnMinuteShowCallback(hour, minute) {
var tpStartHour = $('#timepicker_start').timepicker('getHour');
var tpStartMinute = $('#timepicker_start').timepicker('getMinute');
// all valid if no start time selected
if ($('#timepicker_start').val() == '') { return true; }
// Check if proposed hour is after selected start time hour
if (hour > tpStartHour) { return true; }
// Check if proposed hour is equal to selected start time hour and minutes is after
if ( (hour == tpStartHour) && (minute > tpStartMinute) ) { return true; }
// if minute did not match, it can not be selected
return false;
}
</pre>
</div>
<hr />
<div>
Example to disable and re-enable a timepicker.
<br />
<div style="float:left; width: 400px">
<input type="text" style="width: 70px" id="timepicker_disable" value="9:15" />
<div class="timepicker_disable_button_trigger" style="width: 16px; height:16px; background: url(include/ui-1.10.0/ui-lightness/images/ui-icons_222222_256x240.png) -80px, -96px;
display: inline-block; border-radius: 2px; border: 1px solid #222222; margin-top: 3px; cursor:pointer"></div>
<br />
<button id="btn_disable_tp">Disable the time pickers</button>
<br />
<button id="btn_enable_tp">Re-enable the time pickers</button>
<br />
<a onclick="$('#script_tp_disable').toggle(200); return false;">[Show code]</a>
</div>
<div id="timepicker_disable_inline" style="font-size: 10px;"></div>
<div style="clear: both"></div>
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_disable_inline').timepicker({
showNowButton: true,
showCloseButton: true,
showDeselectButton: true
});
$('#timepicker_disable').timepicker({
showLeadingZero: false,
showOn: 'both',
button: '.timepicker_disable_button_trigger'
});
$('#btn_disable_tp').click(function() {
$('#timepicker_disable_inline').timepicker('disable');
$('#timepicker_disable').timepicker('disable');
});
$('#btn_enable_tp').click(function() {
$('#timepicker_disable_inline').timepicker('enable');
$('#timepicker_disable').timepicker('enable');
});
});
</script>
<pre class="code" style="display: none" id="script_tp_disable">
$('#timepicker_disable_inline').timepicker();
$('#timepicker_disable').timepicker({showLeadingZero: false });
$('#btn_disable_tp').click(function() {
$('#timepicker_disable_inline').timepicker('disable');
$('#timepicker_disable').timepicker('disable');
});
$('#btn_enable_tp').click(function() {
$('#timepicker_disable_inline').timepicker('enable');
$('#timepicker_disable').timepicker('enable');
});
</pre>
</div>
<hr />
<div>
Set the timepicker date with a Date object and get the selected time as a Date object
<br />
<div style="float: left; width: 400px;">
<button id="btn_set_time_with_date_obj"> Set the time to now using the Date object </button>
<br>
<button id="btn_get_time_as_date"> Get selected time as Date object </button>
<br>
<span id="timepicker_selected_time"></span>
<br>
<span id="timepicker_selected_time_warning">Also, note that in the returned date object, the time is correct but the yeat/month/day part of the date is wrong, you have to extract the time of the object.</span>
<br>
<a onclick="$('#script_tp_date_obj').toggle(200); return false;">[Show code]</a>
</div>
<div id="timepicker_date_obj_inline" style="font-size: 10px;"></div>
<div style="clear: both"></div>
<script type="text/javascript">
$(document).ready(function() {
$('#timepicker_date_obj_inline').timepicker();
$('#btn_set_time_with_date_obj').click(function() {
var newTime = new Date('2012-11-24 7:10');
console.log(newTime);
$('#timepicker_date_obj_inline').timepicker('setTime', newTime);
});
$('#btn_get_time_as_date').click(function() {
var selectedTime = $('#timepicker_date_obj_inline').timepicker('getTimeAsDate');
$('#timepicker_selected_time').html('Selected time as date object returned : ' + selectedTime.toString());
});
});
</script>
<pre class="code" style="display: none" id="script_tp_date_obj">
$('#timepicker_date_obj_inline').timepicker();
$('#btn_set_time_with_date_obj').click(function() {
var newTime = new Date('2012-11-24 7:10');
$('#timepicker_date_obj_inline').timepicker('setTime', newTime);
});
$('#btn_get_time_as_date').click(function() {
var selectedTime = $('#timepicker_date_obj_inline').timepicker('getTimeAsDate');
$('#timepicker_selected_time').html('Selected time as date object returned : ' + selectedTime.toString());
});
});
</pre>
</div>
</div>
<!------------------------------------------------------------------------------------------------------------->
<!------------------------------------------------------------------------------------------------------------->
<!------------------------------------------------------------------------------------------------------------->
<div id="usage">
<h2><a name="documentation"></a>Usage:</h2>
<pre class="code">$('#timepicker').timepicker({
// Options
timeSeparator: ':', // The character to use to separate hours and minutes. (default: ':')
showLeadingZero: true, // Define whether or not to show a leading zero for hours < 10.
(default: true)
showMinutesLeadingZero: true, // Define whether or not to show a leading zero for minutes < 10.
(default: true)
showPeriod: false, // Define whether or not to show AM/PM with selected time. (default: false)
showPeriodLabels: true, // Define if the AM/PM labels on the left are displayed. (default: true)
periodSeparator: ' ', // The character to use to separate the time from the time period.
altField: '#alternate_input', // Define an alternate input to parse selected time to
defaultTime: '12:34', // Used as default time when input field is empty or for inline timePicker
// (set to 'now' for the current time, '' for no highlighted time,
default value: now)
// trigger options
showOn: 'focus', // Define when the timepicker is shown.
// 'focus': when the input gets focus, 'button' when the button trigger element is clicked,
// 'both': when the input gets focus and when the button is clicked.
button: null, // jQuery selector that acts as button trigger. ex: '#trigger_button'
// Localization
hourText: 'Hour', // Define the locale text for "Hours"
minuteText: 'Minute', // Define the locale text for "Minute"
amPmText: ['AM', 'PM'], // Define the locale text for periods
// Position
myPosition: 'left top', // Corner of the dialog to position, used with the jQuery UI Position utility if present.
atPosition: 'left bottom', // Corner of the input to position
// Events
beforeShow: beforeShowCallback, // Callback function executed before the timepicker is rendered and displayed.
onSelect: onSelectCallback, // Define a callback function when an hour / minutes is selected.
onClose: onCloseCallback, // Define a callback function when the timepicker is closed.
onHourShow: onHourShow, // Define a callback to enable / disable certain hours. ex: function onHourShow(hour)
onMinuteShow: onMinuteShow, // Define a callback to enable / disable certain minutes. ex: function onMinuteShow(hour, minute)
// custom hours and minutes
hours: {
starts: 0, // First displayed hour
ends: 23 // Last displayed hour
},
minutes: {
starts: 0, // First displayed minute
ends: 55, // Last displayed minute
interval: 5 // Interval of displayed minutes
},
rows: 4, // Number of rows for the input tables, minimum 2, makes more sense if you use multiple of 2
showHours: true, // Define if the hours section is displayed or not. Set to false to get a minute only dialog
showMinutes: true, // Define if the minutes section is displayed or not. Set to false to get an hour only dialog
// buttons
showCloseButton: false, // shows an OK button to confirm the edit
closeButtonText: 'Done', // Text for the confirmation button (ok button)
showNowButton: false, // Shows the 'now' button
nowButtonText: 'Now', // Text for the now button
showDeselectButton: false, // Shows the deselect time button
deselectButtonText: 'Deselect' // Text for the deselect button
});</pre>
</div>
<!------------------------------------------------------------------------------------------------------------->
<!------------------------------------------------------------------------------------------------------------->
<!------------------------------------------------------------------------------------------------------------->
<div id="requirements">
<h2>Requirements : </h2>
<ul>
<li>
<a href="http://jquery.com">
jQuery (tested with version up to 1.9.0)
</a>
</li>
<li>
<a href="http://jqueryui.com/">
jQuery UI Core (included in jquery-ui-x.x.x.custom.min.js, tested with version 1.10.0)
</a>
</li>
<li>
<a href="http://jqueryui.com/demos/position/">
jQuery UI Position utility (optional for special position of the dialog)
</a>
</li>
<li>
<a href="http://jqueryui.com/">
jQuery UI Theme.css (included in jquery-ui-x.x.x.custom.css)
</a>
</li>
<li>
<a href="jquery.ui.timepicker.js?v=0.3.2">
jquery.ui.timepicker.js
</a>
</li>
<li>
<a href="jquery.ui.timepicker.css?v=0.3.2">
jquery.ui.timepicker.css
</a>
</li>
</ul>
</div>
<!------------------------------------------------------------------------------------------------------------->
<!------------------------------------------------------------------------------------------------------------->
<!------------------------------------------------------------------------------------------------------------->
<div id="release_notes">
<h2>Releases :</h2>
<dl>
<dt>0.3.3 - ????</dt>
<dd>Better zIndex detection - Thanks Mark Larter <a href="https://github.com/fgelinas/timepicker/issues/62">ref #62</a></dd>
<dd>Added Hungarian localisation - Thanks Bálint Dávid Tarcsa.</dd>
<dt>0.3.2 - 25 January 2013</dt>
<dd>Updated to jQuery 1.9.0 and UI 1.10.0. Removed deprecated IE6 hacks.</dd>
<dd>Added support for Date object with the setTime and getTimeAsDate function - thanks AAverin.</dd>
<dd>Removed an extra </tr>, thanks FishB8.</dd>
<dd>Fixed an error that occurs on some showAnim effects like 'blind'.</dd>
<dd>Fixed a problem when wither hours or minutes was required and missing, the parsed time was not formatted correctly.</dd>
<dd>Fixed a problem when available hours are all AM or all PM only and they would not show in the grid, thanks @malerbabomba</dd>
<dt>0.3.1 - 19 July 2012<dt>
<dd>Added the "destroy" method.</dd>
<dd>Fixed a bug in the deselect function, thanks Kazu.</dd>
<dd>Allow for hours and minutes outside normal time range (0-23, 0-59) for more flexibility.</dd>
<dd>Fixed a bug with the onClose callback that could generate an infinite loop.</dd>
<dd>Added Croatian/Bosnian translation, thanks Rene Brakus.</dd>
<dd>Added Portuguese/Brazilan tranlsation, thanks Daniel Almeida.</dd>
<dd>Added Spanish tranlsation, thanks Jandro González.</dd>
<dt>Release 0.3.0 - 27 March 2012</dt>
<dd>Fixed a zIndex problem in jQuery Dialog when the user clicked on the input while the timepicker was still visible.</dd>
<dd>Added Czech translation, thanks David Spohr</dd>
<dd>Added Swedish translation, thanks Björn Westlin</dd>
<dd>Added Dutch translation, thanks Lowie Hulzinga</dd>
<dd>Prevent showing the timepicker dialog with the button when disabled(Thanks ruhley. ref #38)</dd>
<dd>Add ui-state-disabled class to button trigger when disabled.</dd>
<dd>Fixed onClose function on first time passes the hours variable as string (Thanks Zanisimo, ref #39)</dd>
<dd>Added refresh method. ex: $('selector').timepicker('refresh');</dd>
<dt>Release 0.2.9 - November 13, 2011</dt>
<dd>Fixed the zIndex problem and removed the zIndex option (Thanks everyone who reported the problem)</dd>
<dd>Fix a bug where repeatedly clicking on hour cells made the timepicker very slow.</dd>
<dd>Added Italian translation, thanks to Serge Margarita.</dd>
<dt>Release 0.2.8 - October 28, 2011</dt>
<dd>Updated defaultTime to allow for Date object (github issue #26)</dd>
<dd>Fixed the now and deselect buttons in IE</dd>
<dt>Release 0.2.7 - October 19, 2011</dt>
<dd>Added option to omit minutes in parsed time when user select 0 for minutes. (Thanks tribalvibes, Github issue #23)</dd>
<dd>Added support for internationalisation (fr, de and ja, Thanks Bernd Plagge).</dd>
<dd>Added an <a href="i18n/i18n.html">internationalisation page</a></dd>
<dt>0.2.6 - October 12, 2011</dt>
<dd>Fixed a bug when input ID have more then one special char. (Thanks Jacqueline Krijnen)</dd>
<dd>Fixed a bug when parsing hours only or minutes only time. (Thanks protron, <a href="https://github.com/fgelinas/timepicker/issues/20">github issue #20</a>)</dd>
<dd>Added 'Now', 'Deselect' and 'Close' buttons. (Thanks Christian Grobmeier for the close button code, <a href="https://github.com/fgelinas/timepicker/issues/20">github issue #22</a>)</dd>
<dt>0.2.5 - September 13, 2011</dt>
<dd>Added support for disable and enable. (Suggested by danielrex, github issue #17)</dd>
<dd>Added an example for 2 timepicker to behave as a period selector (start time and end time). (Thanks Bill Pellowe)</dd>
<dd>Renamed the stylesheet to jquery.ui.timepicker.css to be more consistent with jQuery UI file name convention.</dd>
<dt>0.2.4 - August 5, 2011</dt>
<dd>Fixed the hand cursor in the css file. (Thanks Mike Neumegen)</dd>
<dd>Added position option to use with the jquery ui position utility.</dd>
<dd>Added option to display only hours or only minutes.</dd>
<dt>0.2.3 - July 11, 2011 </dt>
<dd>Fix github issue #3 : Bug when hours or minutes choices does not divide by number of rows (thanks wukimus).</dd>
<dd>Changed default behavior of the defaultTime option, if set to '' and input is empty, there will be no highlighted time in the popup (Thanks Rasmus Schultz)</dd>
<dd>Fix github issue #4 : Error when generating empty minute cell. (Thanks 123Haynes)</dd>
<dd>Fix github issue #5 : Add functionality for "getTime" option. (Thanks edanuff)</dd>
<dd>Added the periodSeparator option. (thanks jrchamp)</dd>
<dd>Fixed "getTime" for inline timepickers. (thanks Mike Neumegen)</dd>
<dd>Added "getHour" and "getMinute" to get individual values.</dd>
<dd>New page interface, about time :)</dd>
<dt>0.2.2 - June 16, 2011</dt>
<dd>Fixed a "console.log" line that I forgot to remove before release 0.2.1. (Thanks Derek Lavine)</dd>
<dt>0.2.1 - June 8, 2011</dt>
<dd>Timepicker does not give the focus back to the input any more after time selection. This is similar to the datepicker behaviour and is more natural to the user because it shows the dialog again when the user click on the input again, as expected.</dd>
<dd>Added options to customize the hours and minutes ranges and interval for more customization.</dd>
<dt>0.2 - May 28, 2011</dt>
<dd>In the last release, I messed up versions and lost some changes so I'm fixing all this up with release 0.2</dd>
<dt>0.1.2 - May 26, 2011</dt>
<dd>Fixed a bug with inline timepickers that would append a #timepickr hashtag when selecting hours and minutes.</dd>
<dd>Fixed z-index problem with IE6 (Thanks Graham Bentley)</dd>
<dd>Added selection of highlighted text when enter is pressed on the input field (Thanks Glen Chiacchieri)</dd>
<dd>Adjusted some focus problems, now the input gets the focus back when the used click on hours / minutes.</dd>
<dt>0.1.something aka the lost release - around April 11</dt>
<dd>Fixed a bug for when input Id had a dot in it, it was getting double escaped when it should not. (Thanks Zdenek Machac)</dd>