Skip to content

Commit e66ac89

Browse files
- Added support for specifying a defaultValue that will be used when the text input fires a focus event and has an empty value
- Added support for providing separate options for the start and end inputs in the range methods using "start" and "end" properties in the options object
1 parent b7c99d1 commit e66ac89

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ function Timepicker() {
9595
timezoneIso8601: false,
9696
timezoneList: null,
9797
addSliderAccess: false,
98-
sliderAccessArgs: null
98+
sliderAccessArgs: null,
99+
defaultValue: null,
99100
};
100101
$.extend(this._defaults, this.regional['']);
101102
}
@@ -747,6 +748,22 @@ $.extend(Timepicker.prototype, {
747748
// on time change is also called when the time is updated in the text field
748749
//########################################################################
749750
_onTimeChange: function() {
751+
if( !this.$input.val() && this._defaults.defaultValue ) {
752+
this.$input.val(this._defaults.defaultValue);
753+
var inst = $.datepicker._getInst(this.$input.get(0)),
754+
tp_inst = $.datepicker._get(inst, 'timepicker');
755+
if (tp_inst) {
756+
if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
757+
try {
758+
$.datepicker._updateDatepicker(inst);
759+
}
760+
catch (err) {
761+
$.datepicker.log(err);
762+
}
763+
}
764+
}
765+
}
766+
750767
var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
751768
minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
752769
second = (this.second_slider) ? this.second_slider.slider('value') : false,
@@ -1591,23 +1608,23 @@ $.timepicker.dateRange = function( startTime, endTime, options, method ) {
15911608
* @return jQuery
15921609
*/
15931610
$.timepicker.handleRange = function( method, startTime, endTime, options ) {
1594-
$.fn[method].call(startTime, $.extend({}, {
1611+
$.fn[method].call(startTime, $.extend({
15951612
onClose: function(dateText, inst) {
15961613
checkDates(this, endTime, dateText);
15971614
},
15981615
onSelect: function (selectedDateTime) {
15991616
selected(this, endTime, 'minDate');
16001617
}
1601-
}, options)
1618+
}, options, options.start)
16021619
);
1603-
$.fn[method].call(endTime, $.extend({}, {
1620+
$.fn[method].call(endTime, $.extend({
16041621
onClose: function(dateText, inst) {
16051622
checkDates(this, startTime, dateText);
16061623
},
16071624
onSelect: function (selectedDateTime) {
16081625
selected(this, startTime, 'maxDate');
16091626
}
1610-
}, options)
1627+
}, options, options.end)
16111628
);
16121629
// timepicker doesn't provide access to its 'timeFormat' option,
16131630
// nor could I get datepicker.formatTime() to behave with times, so I

0 commit comments

Comments
 (0)