Skip to content

Commit c851cef

Browse files
Fixed altField, added altFieldTimeOnly for more customization
1 parent b394ee8 commit c851cef

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ function Timepicker() {
6464
minuteGrid: 0,
6565
secondGrid: 0,
6666
alwaysSetTime: true,
67-
separator: ' '
67+
separator: ' ',
68+
altFieldTimeOnly: true
6869
};
6970
$.extend(this._defaults, this.regional['']);
7071
}
@@ -155,7 +156,7 @@ $.extend(Timepicker.prototype, {
155156
// add our sliders to the calendar
156157
//########################################################################
157158
_addTimePicker: function(dp_inst) {
158-
var currDT = (this.$altInput) ?
159+
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
159160
this.$input.val() + ' ' + this.$altInput.val() :
160161
this.$input.val();
161162

@@ -598,22 +599,24 @@ $.extend(Timepicker.prototype, {
598599

599600
if (this._defaults.timeOnly === true) {
600601
formattedDateTime = this.formattedTime;
601-
if (this.$altInput) {
602-
this.$altInput.val(this.formattedDateTime);
603-
}
604-
} else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
605-
if (this.$altInput) {
606-
if (this._defaults.timeOnly !== true) {
607-
this.$altInput.val(this.$altInput.val() + this._defaults.separator + this.formattedTime);
608-
} else {
609-
this.$altInput.val(this.formattedDateTime);
610-
}
611-
}
602+
} else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
612603
formattedDateTime += this._defaults.separator + this.formattedTime;
613604
}
614605

615606
this.formattedDateTime = formattedDateTime;
616-
this.$input.val(formattedDateTime).trigger("change");
607+
608+
if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
609+
this.$altInput.val(this.formattedTime);
610+
this.$input.val(this.formattedDate);
611+
} else if(this.$altInput) {
612+
this.$altInput.val(formattedDateTime);
613+
this.$input.val(formattedDateTime);
614+
}
615+
else{
616+
this.$input.val(formattedDateTime);
617+
}
618+
619+
this.$input.trigger("change");
617620
}
618621

619622
});

0 commit comments

Comments
 (0)