Update version

This commit is contained in:
Trent Richardson 2011-05-12 13:33:47 -04:00
commit f9fee45d7b
2 changed files with 139 additions and 64 deletions

View file

@ -0,0 +1,5 @@
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; }
.ui-timepicker-div dl dd { margin: -25px 0 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }

View file

@ -1,10 +1,10 @@
/* /*
* jQuery timepicker addon * jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com] * By: Trent Richardson [http://trentrichardson.com]
* Version 0.9.3 * Version 0.9.4
* Last Modified: 02/05/2011 * Last Modified: 05/12/2011
* *
* Copyright 2010 Trent Richardson * Copyright 2011 Trent Richardson
* Dual licensed under the MIT and GPL licenses. * Dual licensed under the MIT and GPL licenses.
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
@ -19,7 +19,7 @@
(function($) { (function($) {
$.extend($.ui, { timepicker: { version: "0.9.3" } }); $.extend($.ui, { timepicker: { version: "0.9.4" } });
/* Time picker manager. /* Time picker manager.
Use the singleton instance of this class, $.timepicker, to interact with the time picker. Use the singleton instance of this class, $.timepicker, to interact with the time picker.
@ -37,7 +37,8 @@ function Timepicker() {
timeText: 'Time', timeText: 'Time',
hourText: 'Hour', hourText: 'Hour',
minuteText: 'Minute', minuteText: 'Minute',
secondText: 'Second' secondText: 'Second',
timezoneText: 'Time Zone'
}; };
this._defaults = { // Global defaults for all the datetime picker instances this._defaults = { // Global defaults for all the datetime picker instances
showButtonPanel: true, showButtonPanel: true,
@ -45,6 +46,7 @@ function Timepicker() {
showHour: true, showHour: true,
showMinute: true, showMinute: true,
showSecond: false, showSecond: false,
showTimezone: false,
showTime: true, showTime: true,
stepHour: 0.05, stepHour: 0.05,
stepMinute: 0.05, stepMinute: 0.05,
@ -52,6 +54,7 @@ function Timepicker() {
hour: 0, hour: 0,
minute: 0, minute: 0,
second: 0, second: 0,
timezone: '+0000',
hourMin: 0, hourMin: 0,
minuteMin: 0, minuteMin: 0,
secondMin: 0, secondMin: 0,
@ -66,7 +69,11 @@ function Timepicker() {
alwaysSetTime: true, alwaysSetTime: true,
separator: ' ', separator: ' ',
altFieldTimeOnly: true, altFieldTimeOnly: true,
showTimepicker: true showTimepicker: true,
timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600",
"-0500", "-0400", "-0300", "-0200", "-0100", "+0000",
"+0100", "+0200", "+0300", "+0400", "+0500", "+0600",
"+0700", "+0800", "+0900", "+1000", "+1100", "+1200"]
}; };
$.extend(this._defaults, this.regional['']); $.extend(this._defaults, this.regional['']);
} }
@ -79,9 +86,11 @@ $.extend(Timepicker.prototype, {
hour_slider: null, hour_slider: null,
minute_slider: null, minute_slider: null,
second_slider: null, second_slider: null,
timezone_select: null,
hour: 0, hour: 0,
minute: 0, minute: 0,
second: 0, second: 0,
timezone: '+0000',
hourMinOriginal: null, hourMinOriginal: null,
minuteMinOriginal: null, minuteMinOriginal: null,
secondMinOriginal: null, secondMinOriginal: null,
@ -92,6 +101,10 @@ $.extend(Timepicker.prototype, {
formattedDate: '', formattedDate: '',
formattedTime: '', formattedTime: '',
formattedDateTime: '', formattedDateTime: '',
timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600",
"-0500", "-0400", "-0300", "-0200", "-0100", "+0000",
"+0100", "+0200", "+0300", "+0400", "+0500", "+0600",
"+0700", "+0800", "+0900", "+1000", "+1100", "+1200"],
/* Override the default settings for all instances of the time picker. /* Override the default settings for all instances of the time picker.
@param settings object - the new settings to use as defaults (anonymous object) @param settings object - the new settings to use as defaults (anonymous object)
@ -108,13 +121,6 @@ $.extend(Timepicker.prototype, {
var tp_inst = new Timepicker(), var tp_inst = new Timepicker(),
inlineSettings = {}; inlineSettings = {};
tp_inst.hour = tp_inst._defaults.hour;
tp_inst.minute = tp_inst._defaults.minute;
tp_inst.second = tp_inst._defaults.second;
tp_inst.ampm = '';
tp_inst.$input = $input;
for (var attrName in this._defaults) { for (var attrName in this._defaults) {
var attrValue = $input.attr('time:' + attrName); var attrValue = $input.attr('time:' + attrName);
if (attrValue) { if (attrValue) {
@ -134,17 +140,23 @@ $.extend(Timepicker.prototype, {
// Update the time as well : this prevents the time from disappearing from the $input field. // Update the time as well : this prevents the time from disappearing from the $input field.
tp_inst._updateDateTime(dp_inst); tp_inst._updateDateTime(dp_inst);
if ($.isFunction(o.onChangeMonthYear)) if ($.isFunction(o.onChangeMonthYear))
o.onChangeMonthYear(year, month, dp_inst, tp_inst); o.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
}, },
onClose: function(dateText, dp_inst) { onClose: function(dateText, dp_inst) {
if (tp_inst.timeDefined === true && $input.val() != '') if (tp_inst.timeDefined === true && $input.val() != '')
tp_inst._updateDateTime(dp_inst); tp_inst._updateDateTime(dp_inst);
if ($.isFunction(o.onClose)) if ($.isFunction(o.onClose))
o.onClose(dateText, dp_inst, tp_inst); o.onClose.call($input[0], dateText, dp_inst, tp_inst);
}, },
timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker'); timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
}); });
tp_inst.hour = tp_inst._defaults.hour;
tp_inst.minute = tp_inst._defaults.minute;
tp_inst.second = tp_inst._defaults.second;
tp_inst.ampm = '';
tp_inst.$input = $input;
if (o.altField) if (o.altField)
tp_inst.$altInput = $(o.altField) tp_inst.$altInput = $(o.altField)
.css({ cursor: 'pointer' }) .css({ cursor: 'pointer' })
@ -185,6 +197,7 @@ $.extend(Timepicker.prototype, {
.replace(/m{1,2}/ig, '(\\d?\\d)') .replace(/m{1,2}/ig, '(\\d?\\d)')
.replace(/s{1,2}/ig, '(\\d?\\d)') .replace(/s{1,2}/ig, '(\\d?\\d)')
.replace(/t{1,2}/ig, '(am|pm|a|p)?') .replace(/t{1,2}/ig, '(am|pm|a|p)?')
.replace(/z{1}/ig, '((\\+|-)\\d\\d\\d\\d)?')
.replace(/\s/g, '\\s?') + '$', .replace(/\s/g, '\\s?') + '$',
order = this._getFormatPositions(), order = this._getFormatPositions(),
treg; treg;
@ -195,7 +208,9 @@ $.extend(Timepicker.prototype, {
// the time should come after x number of characters and a space. // the time should come after x number of characters and a space.
// x = at least the length of text specified by the date format // x = at least the length of text specified by the date format
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator + regstr; // escape special regex characters in the seperator
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator.replace(specials, "\\$&") + regstr;
} }
treg = timeString.match(new RegExp(regstr, 'i')); treg = timeString.match(new RegExp(regstr, 'i'));
@ -216,6 +231,7 @@ $.extend(Timepicker.prototype, {
if (order.m !== -1) this.minute = Number(treg[order.m]); if (order.m !== -1) this.minute = Number(treg[order.m]);
if (order.s !== -1) this.second = Number(treg[order.s]); if (order.s !== -1) this.second = Number(treg[order.s]);
if (order.z !== -1) this.timezone = treg[order.z];
return true; return true;
@ -227,8 +243,8 @@ $.extend(Timepicker.prototype, {
// figure out position of time elements.. cause js cant do named captures // figure out position of time elements.. cause js cant do named captures
//######################################################################## //########################################################################
_getFormatPositions: function() { _getFormatPositions: function() {
var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2})/g), var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2}|z)/g),
orders = { h: -1, m: -1, s: -1, t: -1 }; orders = { h: -1, m: -1, s: -1, t: -1, z: -1 };
if (finds) if (finds)
for (var i = 0; i < finds.length; i++) for (var i = 0; i < finds.length; i++)
@ -329,6 +345,11 @@ $.extend(Timepicker.prototype, {
} else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' + } else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
((o.showSecond) ? '' : noDisplay) + '></dd>'; ((o.showSecond) ? '' : noDisplay) + '></dd>';
html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
html += '<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_' + dp_id + '"' +
((o.showTimezone) ? '' : noDisplay) + '></dd>';
html += '</dl></div>'; html += '</dl></div>';
$tp = $(html); $tp = $(html);
@ -380,6 +401,20 @@ $.extend(Timepicker.prototype, {
} }
}); });
this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('<select></select>').find("select");
$.fn.append.apply(this.timezone_select,
$.map(o.timezoneList, function(val, idx) {
return $("<option />")
.val(typeof val == "object" ? val.value : val)
.text(typeof val == "object" ? val.label : val);
})
);
this.timezone_select.val((typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") ? this.timezone : o.timezone);
this.timezone_select.change(function() {
tp_inst._onTimeChange();
});
// Add grid functionality // Add grid functionality
if (o.showHour && o.hourGrid > 0) { if (o.showHour && o.hourGrid > 0) {
size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin); size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
@ -402,6 +437,7 @@ $.extend(Timepicker.prototype, {
} }
tp_inst.hour_slider.slider("option", "value", h); tp_inst.hour_slider.slider("option", "value", h);
tp_inst._onTimeChange(); tp_inst._onTimeChange();
tp_inst._onSelectHandler();
}).css({ }).css({
cursor: 'pointer', cursor: 'pointer',
width: (100 / hourGridSize) + '%', width: (100 / hourGridSize) + '%',
@ -421,6 +457,7 @@ $.extend(Timepicker.prototype, {
$(this).click(function() { $(this).click(function() {
tp_inst.minute_slider.slider("option", "value", $(this).html()); tp_inst.minute_slider.slider("option", "value", $(this).html());
tp_inst._onTimeChange(); tp_inst._onTimeChange();
tp_inst._onSelectHandler();
}).css({ }).css({
cursor: 'pointer', cursor: 'pointer',
width: (100 / minuteGridSize) + '%', width: (100 / minuteGridSize) + '%',
@ -439,6 +476,7 @@ $.extend(Timepicker.prototype, {
$(this).click(function() { $(this).click(function() {
tp_inst.second_slider.slider("option", "value", $(this).html()); tp_inst.second_slider.slider("option", "value", $(this).html());
tp_inst._onTimeChange(); tp_inst._onTimeChange();
tp_inst._onSelectHandler();
}).css({ }).css({
cursor: 'pointer', cursor: 'pointer',
width: (100 / secondGridSize) + '%', width: (100 / secondGridSize) + '%',
@ -452,7 +490,7 @@ $.extend(Timepicker.prototype, {
if ($buttonPanel.length) $buttonPanel.before($tp); if ($buttonPanel.length) $buttonPanel.before($tp);
else $dp.append($tp); else $dp.append($tp);
this.$timeObj = $('#ui_tpicker_time_'+ dp_id); this.$timeObj = $tp.find('#ui_tpicker_time_'+ dp_id);
if (this.inst !== null) { if (this.inst !== null) {
var timeDefined = this.timeDefined; var timeDefined = this.timeDefined;
@ -461,16 +499,12 @@ $.extend(Timepicker.prototype, {
} }
//Emulate datepicker onSelect behavior. Call on slidestop. //Emulate datepicker onSelect behavior. Call on slidestop.
var onSelect = tp_inst._defaults['onSelect']; var onSelectDelegate = function() {
if (onSelect) { tp_inst._onSelectHandler();
var inputEl = tp_inst.$input ? tp_inst.$input[0] : null;
var onSelectHandler = function() {
onSelect.apply(inputEl, [tp_inst.formattedDateTime, tp_inst]); // trigger custom callback*/
}
this.hour_slider.bind('slidestop',onSelectHandler);
this.minute_slider.bind('slidestop',onSelectHandler);
this.second_slider.bind('slidestop',onSelectHandler);
} }
this.hour_slider.bind('slidestop',onSelectDelegate);
this.minute_slider.bind('slidestop',onSelectDelegate);
this.second_slider.bind('slidestop',onSelectDelegate);
} }
}, },
@ -480,8 +514,9 @@ $.extend(Timepicker.prototype, {
//######################################################################## //########################################################################
_limitMinMaxDateTime: function(dp_inst, adjustSliders){ _limitMinMaxDateTime: function(dp_inst, adjustSliders){
var o = this._defaults, var o = this._defaults,
dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay), dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
tp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay, this.hour, this.minute, this.second, 0);
if(!this._defaults.showTimepicker) return; // No time so nothing to check here
if(this._defaults.minDateTime !== null && dp_date){ if(this._defaults.minDateTime !== null && dp_date){
var minDateTime = this._defaults.minDateTime, var minDateTime = this._defaults.minDateTime,
@ -493,14 +528,22 @@ $.extend(Timepicker.prototype, {
this.secondMinOriginal = o.secondMin; this.secondMinOriginal = o.secondMin;
} }
if(minDateTimeDate.getTime() == dp_date.getTime()){ if(dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
this._defaults.hourMin = minDateTime.getHours(); this._defaults.hourMin = minDateTime.getHours();
if (this.hour <= this._defaults.hourMin) {
this.hour = this._defaults.hourMin;
this._defaults.minuteMin = minDateTime.getMinutes(); this._defaults.minuteMin = minDateTime.getMinutes();
if (this.minute <= this._defaults.minuteMin) {
this.minute = this._defaults.minuteMin;
this._defaults.secondMin = minDateTime.getSeconds(); this._defaults.secondMin = minDateTime.getSeconds();
} else {
if(this.hour < this._defaults.hourMin) this.hour = this._defaults.hourMin;
if(this.minute < this._defaults.minuteMin) this.minute = this._defaults.minuteMin;
if(this.second < this._defaults.secondMin) this.second = this._defaults.secondMin; if(this.second < this._defaults.secondMin) this.second = this._defaults.secondMin;
this._defaults.secondMin = this.secondMinOriginal;
}
} else {
this._defaults.minuteMin = this.minuteMinOriginal;
this._defaults.secondMin = this.secondMinOriginal;
}
}else{ }else{
this._defaults.hourMin = this.hourMinOriginal; this._defaults.hourMin = this.hourMinOriginal;
this._defaults.minuteMin = this.minuteMinOriginal; this._defaults.minuteMin = this.minuteMinOriginal;
@ -518,14 +561,22 @@ $.extend(Timepicker.prototype, {
this.secondMaxOriginal = o.secondMax; this.secondMaxOriginal = o.secondMax;
} }
if(maxDateTimeDate.getTime() == dp_date.getTime()){ if(dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()){
this._defaults.hourMax = maxDateTime.getHours(); this._defaults.hourMax = maxDateTime.getHours();
if (this.hour >= this._defaults.hourMax) {
this.hour = this._defaults.hourMax;
this._defaults.minuteMax = maxDateTime.getMinutes(); this._defaults.minuteMax = maxDateTime.getMinutes();
this._defaults.secondMax = maxDateTime.getSeconds(); if (this.minute >= this._defaults.minuteMax) {
this.minute = this._defaults.minuteMax;
if(this.hour > this._defaults.hourMax){ this.hour = this._defaults.hourMax; } this._defaults.secondMin = maxDateTime.getSeconds();
if(this.minute > this._defaults.minuteMax) this.minute = this._defaults.minuteMax; } else {
if(this.second > this._defaults.secondMax) this.second = this._defaults.secondMax; if(this.second > this._defaults.secondMax) this.second = this._defaults.secondMax;
this._defaults.secondMax = this.secondMaxOriginal;
}
} else {
this._defaults.minuteMax = this.minuteMaxOriginal;
this._defaults.secondMax = this.secondMaxOriginal;
}
}else{ }else{
this._defaults.hourMax = this.hourMaxOriginal; this._defaults.hourMax = this.hourMaxOriginal;
this._defaults.minuteMax = this.minuteMaxOriginal; this._defaults.minuteMax = this.minuteMaxOriginal;
@ -541,6 +592,7 @@ $.extend(Timepicker.prototype, {
}, },
//######################################################################## //########################################################################
// when a slider moves, set the internal time... // when a slider moves, set the internal time...
// 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
@ -548,7 +600,8 @@ $.extend(Timepicker.prototype, {
_onTimeChange: function() { _onTimeChange: function() {
var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false, var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
minute = (this.minute_slider) ? this.minute_slider.slider('value') : false, minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
second = (this.second_slider) ? this.second_slider.slider('value') : false; second = (this.second_slider) ? this.second_slider.slider('value') : false,
timezone = (this.timezone_select) ? this.timezone_select.val() : false
if (hour !== false) hour = parseInt(hour,10); if (hour !== false) hour = parseInt(hour,10);
if (minute !== false) minute = parseInt(minute,10); if (minute !== false) minute = parseInt(minute,10);
@ -558,13 +611,15 @@ $.extend(Timepicker.prototype, {
// If the update was done in the input field, the input 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.
var hasChanged = (hour != this.hour || minute != this.minute || second != this.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) || timezone != this.timezone);
if (hasChanged) { if (hasChanged) {
if (hour !== false)this.hour = hour; if (hour !== false)this.hour = hour;
if (minute !== false) this.minute = minute; if (minute !== false) this.minute = minute;
if (second !== false) this.second = second; if (second !== false) this.second = second;
if (timezone !== false) this.timezone = timezone;
this._limitMinMaxDateTime(this.inst, true);
} }
if (this._defaults.ampm) this.ampm = ampm; if (this._defaults.ampm) this.ampm = ampm;
@ -574,12 +629,24 @@ $.extend(Timepicker.prototype, {
if (hasChanged) this._updateDateTime(); if (hasChanged) this._updateDateTime();
}, },
//########################################################################
// call custom onSelect.
// bind to sliders slidestop, and grid click.
//########################################################################
_onSelectHandler: function() {
var onSelect = this._defaults['onSelect'];
var inputEl = this.$input ? this.$input[0] : null;
if (onSelect && inputEl) {
onSelect.apply(inputEl, [this.formattedDateTime, this]);
}
},
//######################################################################## //########################################################################
// format the time all pretty... // format the time all pretty...
//######################################################################## //########################################################################
_formatTime: function(time, format, ampm) { _formatTime: function(time, format, ampm) {
if (ampm == undefined) ampm = this._defaults.ampm; if (ampm == undefined) ampm = this._defaults.ampm;
time = time || { hour: this.hour, minute: this.minute, second: this.second, ampm: this.ampm }; time = time || { hour: this.hour, minute: this.minute, second: this.second, ampm: this.ampm, timezone: this.timezone };
var tmptime = format || this._defaults.timeFormat.toString(); var tmptime = format || this._defaults.timeFormat.toString();
if (ampm) { if (ampm) {
@ -595,7 +662,8 @@ $.extend(Timepicker.prototype, {
.replace(/TT/g, time.ampm.toUpperCase()) .replace(/TT/g, time.ampm.toUpperCase())
.replace(/tt/g, time.ampm.toLowerCase()) .replace(/tt/g, time.ampm.toLowerCase())
.replace(/T/g, time.ampm.charAt(0).toUpperCase()) .replace(/T/g, time.ampm.charAt(0).toUpperCase())
.replace(/t/g, time.ampm.charAt(0).toLowerCase()); .replace(/t/g, time.ampm.charAt(0).toLowerCase())
.replace(/z/g, time.timezone);
} else { } else {
tmptime = tmptime.toString() tmptime = tmptime.toString()
.replace(/hh/g, ((time.hour < 10) ? '0' : '') + time.hour) .replace(/hh/g, ((time.hour < 10) ? '0' : '') + time.hour)
@ -603,7 +671,8 @@ $.extend(Timepicker.prototype, {
.replace(/mm/g, ((time.minute < 10) ? '0' : '') + time.minute) .replace(/mm/g, ((time.minute < 10) ? '0' : '') + time.minute)
.replace(/m/g, time.minute) .replace(/m/g, time.minute)
.replace(/ss/g, ((time.second < 10) ? '0' : '') + time.second) .replace(/ss/g, ((time.second < 10) ? '0' : '') + time.second)
.replace(/s/g, time.second); .replace(/s/g, time.second)
.replace(/z/g, time.timezone);
tmptime = $.trim(tmptime.replace(/t/gi, '')); tmptime = $.trim(tmptime.replace(/t/gi, ''));
} }
@ -792,9 +861,9 @@ $.datepicker._gotoToday = function(id) {
$.datepicker._disableTimepickerDatepicker = function(target, date, withDate) { $.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
var inst = this._getInst(target), var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker'); tp_inst = this._get(inst, 'timepicker');
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
if (tp_inst) { if (tp_inst) {
tp_inst._defaults.showTimepicker = false; tp_inst._defaults.showTimepicker = false;
tp_inst._onTimeChange();
tp_inst._updateDateTime(inst); tp_inst._updateDateTime(inst);
} }
}; };
@ -802,9 +871,10 @@ $.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) { $.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
var inst = this._getInst(target), var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker'); tp_inst = this._get(inst, 'timepicker');
$(target).datepicker('getDate'); // Init selected[Year|Month|Day]
if (tp_inst) { if (tp_inst) {
tp_inst._defaults.showTimepicker = true; tp_inst._defaults.showTimepicker = true;
tp_inst._onTimeChange(); tp_inst._addTimePicker(inst); // Could be disabled on page load
tp_inst._updateDateTime(inst); tp_inst._updateDateTime(inst);
} }
}; };
@ -858,9 +928,9 @@ $.datepicker._setTimeDatepicker = function(target, date, withDate) {
} }
else tp_date = new Date(date.getTime()); else tp_date = new Date(date.getTime());
if (tp_date.toString() == 'Invalid Date') tp_date = undefined; if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
}
this._setTime(inst, tp_date); this._setTime(inst, tp_date);
} }
}
}; };
@ -906,6 +976,6 @@ function extendRemove(target, props) {
} }
$.timepicker = new Timepicker(); // singleton instance $.timepicker = new Timepicker(); // singleton instance
$.timepicker.version = "0.9.3"; $.timepicker.version = "0.9.4";
})(jQuery); })(jQuery);