summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Richardson <trentdrichardson@gmail.com>2011-01-19 16:01:33 -0500
committerTrent Richardson <trentdrichardson@gmail.com>2011-01-19 16:01:33 -0500
commit999803035f9af4e66d5dfe483be39d2a98d902b3 (patch)
treecc5dd7b087917bbea51e698b6dfbb4765c8e305b
parent5d05d23fa61cdbcd58cb70e717dcd02527752750 (diff)
downloadjQuery-Timepicker-Addon-999803035f9af4e66d5dfe483be39d2a98d902b3.zip
jQuery-Timepicker-Addon-999803035f9af4e66d5dfe483be39d2a98d902b3.tar.gz
jQuery-Timepicker-Addon-999803035f9af4e66d5dfe483be39d2a98d902b3.tar.bz2
Add enable and disable feature by wallenium. Feature not yet stable but doesnt impact rest of plugin
-rw-r--r--jquery-ui-timepicker-addon.js35
1 files changed, 31 insertions, 4 deletions
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js
index 9dd6b6a..7f6e553 100644
--- a/jquery-ui-timepicker-addon.js
+++ b/jquery-ui-timepicker-addon.js
@@ -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 + '"' +
@@ -632,8 +634,10 @@ $.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) {
@@ -785,6 +789,29 @@ $.datepicker._gotoToday = function(id) {
};
//#######################################################################################
+// 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
//#######################################################################################
$.datepicker._setTime = function(inst, date) {