summaryrefslogtreecommitdiffstats
path: root/jquery-ui-timepicker-addon.js
diff options
context:
space:
mode:
authorTrent Richardson <trentdrichardson@gmail.com>2010-11-09 07:48:43 -0500
committerTrent Richardson <trentdrichardson@gmail.com>2010-11-09 07:48:43 -0500
commitd705098ff41145aee32d73380f7ccc7883760ec5 (patch)
tree7a16aa1bc307696f6f09150ab8976636f1e226fe /jquery-ui-timepicker-addon.js
parentda98d6c3a16e4658d2c67d1e69060de02e9bcfed (diff)
downloadjQuery-Timepicker-Addon-d705098ff41145aee32d73380f7ccc7883760ec5.zip
jQuery-Timepicker-Addon-d705098ff41145aee32d73380f7ccc7883760ec5.tar.gz
jQuery-Timepicker-Addon-d705098ff41145aee32d73380f7ccc7883760ec5.tar.bz2
added _keyup event by TC
Diffstat (limited to 'jquery-ui-timepicker-addon.js')
-rwxr-xr-xjquery-ui-timepicker-addon.js61
1 files changed, 42 insertions, 19 deletions
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js
index 5fe44aa..14b4717 100755
--- a/jquery-ui-timepicker-addon.js
+++ b/jquery-ui-timepicker-addon.js
@@ -1,8 +1,8 @@
/*
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
-* Version 0.7.2
-* Last Modified: 10/21/2010
+* Version 0.7.3
+* Last Modified: 11/9/2010
*
* Copyright 2010 Trent Richardson
* Dual licensed under the MIT and GPL licenses.
@@ -442,7 +442,7 @@
if (dp_inst !== null)
{
var timeDefined = tp_inst.timeDefined;
- tp_inst.onTimeChange(dp_inst, tp_inst);
+ tp_inst.onTimeChange(dp_inst, tp_inst, true);
tp_inst.timeDefined = timeDefined;
}
}
@@ -452,7 +452,7 @@
// when a slider moves..
// on time change is also called when the time is updated in the text field
//########################################################################
- onTimeChange: function(dp_inst, tp_inst) {
+ onTimeChange: function(dp_inst, tp_inst, force) {
var hour = (tp_inst.hour_slider)? tp_inst.hour_slider.slider('value') : tp_inst.hour;
var minute = (tp_inst.minute_slider)? tp_inst.minute_slider.slider('value') : tp_inst.minute;
var second = (tp_inst.second_slider)? tp_inst.second_slider.slider('value') : tp_inst.second;
@@ -462,7 +462,7 @@
// If the update was done in the input field, this field should not be updated.
// If the update was done using the sliders, update the input field.
- if (tp_inst.hour != hour || tp_inst.minute != minute || tp_inst.second != second || (tp_inst.ampm.length > 0 && tp_inst.ampm != ampm)) {
+ if (tp_inst.hour != hour || tp_inst.minute != minute || tp_inst.second != second || (tp_inst.ampm.length > 0 && tp_inst.ampm != ampm) || (force != undefined && force == true)) {
hasChanged = true;
}
@@ -719,7 +719,30 @@
}
};
-
+
+ //#######################################################################################
+ // Override key up event to sync manual input changes.
+ //#######################################################################################
+ $.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
+ $.datepicker._doKeyUp = function (event) {
+
+ var inst = $.datepicker._getInst(event.target);
+ var tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst != null) {
+ if (tp_inst.defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
+ try {
+ $.datepicker._updateDatepicker(inst);
+ }
+ catch (event) {
+ $.datepicker.log(event);
+ }
+ }
+ }
+
+ return $.datepicker._base_doKeyUp(event);
+ };
+
//#######################################################################################
// override "Today" button to also grab the time.
//#######################################################################################
@@ -764,25 +787,25 @@
tp_inst.second = second;
}
- tp_inst.onTimeChange(inst, tp_inst);
+ tp_inst.onTimeChange(inst, tp_inst, true);
}
};
//#######################################################################################
// override getDate() to allow getting time too within date object
//#######################################################################################
- $.datepicker._base_setDate = $.datepicker._setDate;
- $.datepicker._setDate = function(inst, date, noChange) {
- var tp_inst = $.datepicker._get(inst, 'timepicker');
- var tp_date = new Date(date.getYear(), date.getMonth(), date.getDay(), date.getHours(), date.getMinutes(), date.getSeconds());
-
- $.datepicker._base_setDate(inst, date, noChange);
-
- if(tp_inst){
- this._setTime(inst, tp_date);
- }
-
- };
+ $.datepicker._base_setDate = $.datepicker._setDate;
+ $.datepicker._setDate = function(inst, date, noChange) {
+ var tp_inst = $.datepicker._get(inst, 'timepicker');
+ var tp_date = new Date(date.getYear(), date.getMonth(), date.getDay(), date.getHours(), date.getMinutes(), date.getSeconds());
+
+ $.datepicker._base_setDate(inst, date, noChange);
+
+ if(tp_inst){
+ this._setTime(inst, tp_date);
+ }
+
+ };
//#######################################################################################
// override getDate() to allow getting time too within date object