diff options
author | Simon Wade <simon.wade@gmail.com> | 2012-08-29 01:47:53 +1000 |
---|---|---|
committer | Simon Wade <simon.wade@gmail.com> | 2012-08-29 02:21:18 +1000 |
commit | e66ac892aa54f6cc38e4b9adffc9d0ef255d127f (patch) | |
tree | a9d6454bfde3fcdfeca5577b5f14e6509faaa645 /jquery-ui-timepicker-addon.js | |
parent | b7c99d12ea6e35a17ebf6e80ab0ee1ca0a6fa40d (diff) | |
download | jQuery-Timepicker-Addon-e66ac892aa54f6cc38e4b9adffc9d0ef255d127f.zip jQuery-Timepicker-Addon-e66ac892aa54f6cc38e4b9adffc9d0ef255d127f.tar.gz jQuery-Timepicker-Addon-e66ac892aa54f6cc38e4b9adffc9d0ef255d127f.tar.bz2 |
- 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
Diffstat (limited to 'jquery-ui-timepicker-addon.js')
-rw-r--r-- | jquery-ui-timepicker-addon.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 2e59d6f..971276f 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -95,7 +95,8 @@ function Timepicker() { timezoneIso8601: false, timezoneList: null, addSliderAccess: false, - sliderAccessArgs: null + sliderAccessArgs: null, + defaultValue: null, }; $.extend(this._defaults, this.regional['']); } @@ -747,6 +748,22 @@ $.extend(Timepicker.prototype, { // on time change is also called when the time is updated in the text field //######################################################################## _onTimeChange: function() { + if( !this.$input.val() && this._defaults.defaultValue ) { + this.$input.val(this._defaults.defaultValue); + var inst = $.datepicker._getInst(this.$input.get(0)), + tp_inst = $.datepicker._get(inst, 'timepicker'); + if (tp_inst) { + if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) { + try { + $.datepicker._updateDatepicker(inst); + } + catch (err) { + $.datepicker.log(err); + } + } + } + } + var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false, minute = (this.minute_slider) ? this.minute_slider.slider('value') : false, second = (this.second_slider) ? this.second_slider.slider('value') : false, @@ -1591,23 +1608,23 @@ $.timepicker.dateRange = function( startTime, endTime, options, method ) { * @return jQuery */ $.timepicker.handleRange = function( method, startTime, endTime, options ) { - $.fn[method].call(startTime, $.extend({}, { + $.fn[method].call(startTime, $.extend({ onClose: function(dateText, inst) { checkDates(this, endTime, dateText); }, onSelect: function (selectedDateTime) { selected(this, endTime, 'minDate'); } - }, options) + }, options, options.start) ); - $.fn[method].call(endTime, $.extend({}, { + $.fn[method].call(endTime, $.extend({ onClose: function(dateText, inst) { checkDates(this, startTime, dateText); }, onSelect: function (selectedDateTime) { selected(this, startTime, 'maxDate'); } - }, options) + }, options, options.end) ); // timepicker doesn't provide access to its 'timeFormat' option, // nor could I get datepicker.formatTime() to behave with times, so I |