summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Richardson <trentdrichardson@gmail.com>2012-09-18 14:01:49 -0400
committerTrent Richardson <trentdrichardson@gmail.com>2012-09-18 14:01:49 -0400
commitdf505b94e527fd5428196eac6709248966f25d8c (patch)
treee273761038da28f0ff1482b411cf3045d4167d86
parentd7537f8488437b632f7898420d3c346573537654 (diff)
downloadjQuery-Timepicker-Addon-df505b94e527fd5428196eac6709248966f25d8c.zip
jQuery-Timepicker-Addon-df505b94e527fd5428196eac6709248966f25d8c.tar.gz
jQuery-Timepicker-Addon-df505b94e527fd5428196eac6709248966f25d8c.tar.bz2
Issue 440 - Simplify min/max constraints of _setTime
-rw-r--r--index.html3
-rw-r--r--jquery-ui-timepicker-addon.js41
2 files changed, 12 insertions, 32 deletions
diff --git a/index.html b/index.html
index 4a24fb7..d421344 100644
--- a/index.html
+++ b/index.html
@@ -752,7 +752,8 @@ var ex13 = $('#utility_example_1');
ex13.datetimepicker({
dateFormat: "D MM d, yy",
separator: ' @ ',
- ampm: true
+ ampm: true,
+ hourMax: 11
});
$('#utility_example_1_setdt').click(function(){
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js
index b532f3f..12d41c2 100644
--- a/jquery-ui-timepicker-addon.js
+++ b/jquery-ui-timepicker-addon.js
@@ -1328,37 +1328,16 @@
$.datepicker._setTime = function(inst, date) {
var tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
- var defaults = tp_inst._defaults,
- // calling _setTime with no date sets time to defaults
- hour = date ? date.getHours() : defaults.hour,
- minute = date ? date.getMinutes() : defaults.minute,
- second = date ? date.getSeconds() : defaults.second,
- millisec = date ? date.getMilliseconds() : defaults.millisec;
- //check if within min/max times..
- // correct check if within min/max times.
- // Rewritten by Scott A. Woodward
- var hourEq = hour === defaults.hourMin,
- minuteEq = minute === defaults.minuteMin,
- secondEq = second === defaults.secondMin;
- var reset = false;
- if (hour < defaults.hourMin || hour > defaults.hourMax) reset = true;
- else if ((minute < defaults.minuteMin || minute > defaults.minuteMax) && hourEq) reset = true;
- else if ((second < defaults.secondMin || second > defaults.secondMax) && hourEq && minuteEq) reset = true;
- else if ((millisec < defaults.millisecMin || millisec > defaults.millisecMax) && hourEq && minuteEq && secondEq) reset = true;
- if (reset) {
- hour = defaults.hourMin;
- minute = defaults.minuteMin;
- second = defaults.secondMin;
- millisec = defaults.millisecMin;
- }
- tp_inst.hour = hour;
- tp_inst.minute = minute;
- tp_inst.second = second;
- tp_inst.millisec = millisec;
- if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
- if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
- if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
- if (tp_inst.millisec_slider) tp_inst.millisec_slider.slider('value', millisec);
+ var defaults = tp_inst._defaults;
+
+ // calling _setTime with no date sets time to defaults
+ tp_inst.hour = date ? date.getHours() : defaults.hour;
+ tp_inst.minute = date ? date.getMinutes() : defaults.minute;
+ tp_inst.second = date ? date.getSeconds() : defaults.second;
+ tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
+
+ //check if within min/max times..
+ tp_inst._limitMinMaxDateTime(inst, true);
tp_inst._onTimeChange();
tp_inst._updateDateTime(inst);