Bugfix for _onTimeChange to always format time and set timeDefined

This commit is contained in:
doublerebel 2010-12-05 13:59:22 -08:00
parent e97d06e554
commit 496ee3acfd

View file

@ -440,31 +440,31 @@ $.extend(Timepicker.prototype, {
// when a slider moves... // when a slider moves...
// on time change is also called when the time is updated in the text field // on time change is also called when the time is updated in the text field
//######################################################################## //########################################################################
_onTimeChange: function(force) { _onTimeChange: function() {
var hour = (this.hour_slider) ? this.hour_slider.slider('value') : this.hour, var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
minute = (this.minute_slider) ? this.minute_slider.slider('value') : this.minute, minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
second = (this.second_slider) ? this.second_slider.slider('value') : this.second, second = (this.second_slider) ? this.second_slider.slider('value') : false,
ampm = (hour < 11.5) ? 'AM' : 'PM', ampm = (hour < 12) ? 'AM' : 'PM';
hasChanged = false;
hour = (hour >= 11.5 && hour < 12) ? 12 : hour;
// If the update was done in the input field, this field should not be updated. // If the update was done in the input field, the input field should not be updated.
// If the update was done using the sliders, update the input field. // If the update was done using the sliders, update the input field.
if (force || this.hour != hour || this.minute != minute || this.second != second || (this.ampm.length > 0 && this.ampm != ampm)) var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || (this.ampm.length > 0 && this.ampm != ampm));
hasChanged = true;
this.hour = parseFloat(hour).toFixed(0);
this.minute = parseFloat(minute).toFixed(0);
this.second = parseFloat(second).toFixed(0);
this.ampm = ampm;
this._formatTime();
if (this.$timeObj) this.$timeObj.text(this.formattedTime);
if (hasChanged) { if (hasChanged) {
this._updateDateTime();
this.timeDefined = true; if (hour) {
this.hour = parseFloat(hour).toFixed(0);
this.ampm = ampm;
}
if (minute) this.minute = parseFloat(minute).toFixed(0);
if (second) this.second = parseFloat(second).toFixed(0);
} }
this._formatTime();
if (this.$timeObj) this.$timeObj.text(this.formattedTime);
this.timeDefined = true;
if (hasChanged) this._updateDateTime();
}, },
//######################################################################## //########################################################################