@@ -97,6 +97,13 @@ $.extend(Timepicker.prototype, {
97
97
var tp_inst = new Timepicker(),
98
98
inlineSettings = {};
99
99
100
+ tp_inst.hour = tp_inst._defaults.hour;
101
+ tp_inst.minute = tp_inst._defaults.minute;
102
+ tp_inst.second = tp_inst._defaults.second;
103
+ tp_inst.ampm = '';
104
+ tp_inst.$input = $input;
105
+
106
+
100
107
for (var attrName in this._defaults) {
101
108
var attrValue = $input.attr('time:' + attrName);
102
109
if (attrValue) {
@@ -109,18 +116,12 @@ $.extend(Timepicker.prototype, {
109
116
}
110
117
tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
111
118
beforeShow: function(input, dp_inst) {
112
- tp_inst.hour = tp_inst._defaults.hour;
113
- tp_inst.minute = tp_inst._defaults.minute;
114
- tp_inst.second = tp_inst._defaults.second;
115
- tp_inst.ampm = '';
116
- tp_inst.$input = $(input);
117
119
if (o.altField)
118
120
tp_inst.$altInput = $($.datepicker._get(dp_inst, 'altField'))
119
121
.css({ cursor: 'pointer' })
120
122
.focus(function(){
121
123
$input.trigger("focus");
122
124
});
123
- tp_inst.inst = dp_inst;
124
125
if ($.isFunction(o.beforeShow))
125
126
o.beforeShow(input, dp_inst);
126
127
},
@@ -166,6 +167,8 @@ $.extend(Timepicker.prototype, {
166
167
order = this._getFormatPositions(),
167
168
treg;
168
169
170
+ if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
171
+
169
172
if (withDate || !this._defaults.timeOnly) {
170
173
// the time should come after x number of characters and a space.
171
174
// x = at least the length of text specified by the date format
@@ -462,7 +465,6 @@ $.extend(Timepicker.prototype, {
462
465
this._formatTime();
463
466
if (this.$timeObj) this.$timeObj.text(this.formattedTime);
464
467
this.timeDefined = true;
465
-
466
468
if (hasChanged) this._updateDateTime();
467
469
},
468
470
@@ -506,8 +508,8 @@ $.extend(Timepicker.prototype, {
506
508
//########################################################################
507
509
// update our input with the new date time..
508
510
//########################################################################
509
- _updateDateTime: function() {
510
- var dp_inst = this.inst,
511
+ _updateDateTime: function(dp_inst ) {
512
+ dp_inst = this.inst || dp_inst ,
511
513
dt = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
512
514
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
513
515
formatCfg = $.datepicker._getFormatConfig(dp_inst),
@@ -732,10 +734,8 @@ $.datepicker._getDateDatepicker = function(target, noDefault) {
732
734
if (tp_inst) {
733
735
this._setDateFromField(inst, noDefault);
734
736
var date = this._getDate(inst);
735
- date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
736
- return (!inst.currentYear || (inst.input && inst.input.val() == '')) ?
737
- null :
738
- date;
737
+ if (date && tp_inst._parseTime($(target).val(), true)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second);
738
+ return date;
739
739
}
740
740
else return this._base_getDateDatepicker(inst);
741
741
};
0 commit comments