diff options
Diffstat (limited to 'dist/jquery-ui-timepicker-addon.js')
-rw-r--r-- | dist/jquery-ui-timepicker-addon.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/dist/jquery-ui-timepicker-addon.js b/dist/jquery-ui-timepicker-addon.js index 1bd022c..07e6592 100644 --- a/dist/jquery-ui-timepicker-addon.js +++ b/dist/jquery-ui-timepicker-addon.js @@ -387,7 +387,7 @@ if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) { var noDisplay = ' ui_tpicker_unit_hide', html = '<div class="ui-timepicker-div' + (o.isRTL ? ' ui-timepicker-rtl' : '') + (o.oneLine && o.controlType === 'select' ? ' ui-timepicker-oneLine' : '') + '"><dl>' + '<dt class="ui_tpicker_time_label' + ((o.showTime) ? '' : noDisplay) + '">' + o.timeText + '</dt>' + - '<dd class="ui_tpicker_time '+ ((o.showTime) ? '' : noDisplay) + '"></dd>'; + '<dd class="ui_tpicker_time '+ ((o.showTime) ? '' : noDisplay) + '"><input class="ui_tpicker_time_input" ' + (o.timeInput ? '' : 'disabled') + '/></dd>'; // Create the markup for (i = 0, l = this.units.length; i < l; i++) { @@ -524,7 +524,21 @@ $dp.append($tp); } - this.$timeObj = $tp.find('.ui_tpicker_time'); + this.$timeObj = $tp.find('.ui_tpicker_time_input'); + this.$timeObj.change(function () { + var timeFormat = tp_inst.inst.settings.timeFormat; + var parsedTime = $.datepicker.parseTime(timeFormat, this.value); + var update = new Date(); + if (parsedTime) { + update.setHours(parsedTime.hour); + update.setMinutes(parsedTime.minute); + update.setSeconds(parsedTime.second); + $.datepicker._setTime(tp_inst.inst, update); + } else { + this.value = tp_inst.formattedTime; + this.blur(); + } + }); if (this.inst !== null) { var timeDefined = this.timeDefined; @@ -862,12 +876,15 @@ // Updates the time within the timepicker this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o); if (this.$timeObj) { + var sPos = this.$timeObj[0].selectionStart; + var ePos = this.$timeObj[0].selectionEnd; if (pickerTimeFormat === o.timeFormat) { - this.$timeObj.text(this.formattedTime + pickerTimeSuffix); + this.$timeObj.val(this.formattedTime + pickerTimeSuffix); } else { - this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix); + this.$timeObj.val($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix); } + this.$timeObj[0].setSelectionRange(sPos, ePos); } this.timeDefined = true; |