Skip to content

Commit 6f33592

Browse files
add min/max ranges for times
1 parent bd5442d commit 6f33592

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
hour: 0,
3838
minute: 0,
3939
second: 0,
40+
hourMin: 0,
41+
minuteMin: 0,
42+
secondMin: 0,
43+
hourMax: 23,
44+
minuteMax: 59,
45+
secondMax: 59,
4046
alwaysSetTime: true
4147
};
4248
$.extend(this.defaults, this.regional['']);
@@ -149,9 +155,9 @@
149155
// Added by Peter Medeiros:
150156
// - Figure out what the hour/minute/second max should be based on the step values.
151157
// - Example: if stepMinute is 15, then minMax is 45.
152-
var hourMax = 23 - (23 % opts.stepHour);
153-
var minMax = 59 - (59 % opts.stepMinute);
154-
var secMax = 59 - (59 % opts.stepSecond);
158+
var hourMax = opts.hourMax - (opts.hourMax % opts.stepHour);
159+
var minMax = opts.minuteMax - (opts.minuteMax % opts.stepMinute);
160+
var secMax = opts.secondMax - (opts.secondMax % opts.stepSecond);
155161

156162
// Prevent displaying twice
157163
if ($dp.find("div#ui-timepicker-div").length === 0) {
@@ -181,7 +187,7 @@
181187
tp_inst.hour_slider = $tp.find('#ui_tpicker_hour').slider({
182188
orientation: "horizontal",
183189
value: tp_inst.hour,
184-
min: 0,
190+
min: opts.hourMin,
185191
max: hourMax,
186192
step: opts.stepHour,
187193
slide: function(event, ui) {
@@ -195,7 +201,7 @@
195201
tp_inst.minute_slider = $tp.find('#ui_tpicker_minute').slider({
196202
orientation: "horizontal",
197203
value: tp_inst.minute,
198-
min: 0,
204+
min: opts.minuteMin,
199205
max: minMax,
200206
step: opts.stepMinute,
201207
slide: function(event, ui) {
@@ -208,7 +214,7 @@
208214
tp_inst.second_slider = $tp.find('#ui_tpicker_second').slider({
209215
orientation: "horizontal",
210216
value: tp_inst.second,
211-
min: 0,
217+
min: opts.secondMin,
212218
max: secMax,
213219
step: opts.stepSecond,
214220
slide: function(event, ui) {

0 commit comments

Comments
 (0)