Skip to content

Commit 971e0b9

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 3032076 commit 971e0b9

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
}
@@ -742,6 +743,22 @@ $.extend(Timepicker.prototype, {
742743
// on time change is also called when the time is updated in the text field
743744
//########################################################################
744745
_onTimeChange: function() {
746+
if( !this.$input.val() && this._defaults.defaultValue ) {
747+
this.$input.val(this._defaults.defaultValue);
748+
var inst = $.datepicker._getInst(this.$input.get(0)),
749+
tp_inst = $.datepicker._get(inst, 'timepicker');
750+
if (tp_inst) {
751+
if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
752+
try {
753+
$.datepicker._updateDatepicker(inst);
754+
}
755+
catch (err) {
756+
$.datepicker.log(err);
757+
}
758+
}
759+
}
760+
}
761+
745762
var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
746763
minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
747764
second = (this.second_slider) ? this.second_slider.slider('value') : false,
@@ -1580,23 +1597,23 @@ $.timepicker.dateRange = function( startTime, endTime, options, method ) {
15801597
* @return jQuery
15811598
*/
15821599
$.timepicker.handleRange = function( method, startTime, endTime, options ) {
1583-
$.fn[method].call(startTime, $.extend({}, {
1600+
$.fn[method].call(startTime, $.extend({
15841601
onClose: function(dateText, inst) {
15851602
checkDates(this, endTime, dateText);
15861603
},
15871604
onSelect: function (selectedDateTime) {
15881605
selected(this, endTime, 'minDate');
15891606
}
1590-
}, options)
1607+
}, options, options.start)
15911608
);
1592-
$.fn[method].call(endTime, $.extend({}, {
1609+
$.fn[method].call(endTime, $.extend({
15931610
onClose: function(dateText, inst) {
15941611
checkDates(this, startTime, dateText);
15951612
},
15961613
onSelect: function (selectedDateTime) {
15971614
selected(this, startTime, 'maxDate');
15981615
}
1599-
}, options)
1616+
}, options, options.end)
16001617
);
16011618
// timepicker doesn't provide access to its 'timeFormat' option,
16021619
// nor could I get datepicker.formatTime() to behave with times, so I

0 commit comments

Comments
 (0)