Add enable and disable feature by wallenium. Feature not yet stable but doesnt impact rest of plugin

This commit is contained in:
Trent Richardson 2011-01-19 16:01:33 -05:00
parent 5d05d23fa6
commit 999803035f

View file

@ -65,7 +65,8 @@ function Timepicker() {
secondGrid: 0,
alwaysSetTime: true,
separator: ' ',
altFieldTimeOnly: true
altFieldTimeOnly: true,
showTimepicker: true
};
$.extend(this._defaults, this.regional['']);
}
@ -253,7 +254,8 @@ $.extend(Timepicker.prototype, {
dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
// Prevent displaying twice
if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
//if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
var noDisplay = ' style="display:none;"',
html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
'<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
@ -633,7 +635,9 @@ $.extend(Timepicker.prototype, {
this.formattedDateTime = formattedDateTime;
if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
if(!this._defaults.showTimepicker) {
this.$input.val(this.formattedDate);
} else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
this.$altInput.val(this.formattedTime);
this.$input.val(this.formattedDate);
} else if(this.$altInput) {
@ -784,6 +788,29 @@ $.datepicker._gotoToday = function(id) {
this._setTime(this._getInst($(id)[0]), new Date());
};
//#######################################################################################
// Disable & enable the Time in the datetimepicker
//#######################################################################################
$.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
tp_inst._defaults.showTimepicker = false;
tp_inst._onTimeChange();
tp_inst._updateDateTime(inst);
}
};
$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
var inst = this._getInst(target),
tp_inst = this._get(inst, 'timepicker');
if (tp_inst) {
tp_inst._defaults.showTimepicker = true;
tp_inst._onTimeChange();
tp_inst._updateDateTime(inst);
}
};
//#######################################################################################
// Create our own set time function
//#######################################################################################