Fixed issues to falling back to plain datepicker
This commit is contained in:
parent
f49992774e
commit
a06a031f69
1 changed files with 29 additions and 15 deletions
16
jquery-ui-timepicker-addon.js
vendored
16
jquery-ui-timepicker-addon.js
vendored
|
@ -413,6 +413,9 @@
|
||||||
$.datepicker._selectDate = function (id, dateStr) {
|
$.datepicker._selectDate = function (id, dateStr) {
|
||||||
var target = $(id);
|
var target = $(id);
|
||||||
var inst = this._getInst(target[0]);
|
var inst = this._getInst(target[0]);
|
||||||
|
var tp_inst = $.datepicker._get(inst, 'timepicker');
|
||||||
|
|
||||||
|
if(tp_inst){
|
||||||
inst.inline = true;
|
inst.inline = true;
|
||||||
inst.stay_open = true;
|
inst.stay_open = true;
|
||||||
$.datepicker._base_selectDate(id, dateStr);
|
$.datepicker._base_selectDate(id, dateStr);
|
||||||
|
@ -420,6 +423,10 @@
|
||||||
inst.inline = false;
|
inst.inline = false;
|
||||||
this._notifyChange(inst);
|
this._notifyChange(inst);
|
||||||
this._updateDatepicker(inst);
|
this._updateDatepicker(inst);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$.datepicker._base_selectDate(id, dateStr);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//#############################################################################################
|
//#############################################################################################
|
||||||
|
@ -450,13 +457,20 @@
|
||||||
$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
|
$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
|
||||||
$.datepicker._doKeyPress = function(event) {
|
$.datepicker._doKeyPress = function(event) {
|
||||||
var inst = $.datepicker._getInst(event.target);
|
var inst = $.datepicker._getInst(event.target);
|
||||||
|
var tp_inst = $.datepicker._get(inst, 'timepicker');
|
||||||
|
|
||||||
|
if(tp_inst){
|
||||||
if ($.datepicker._get(inst, 'constrainInput')) {
|
if ($.datepicker._get(inst, 'constrainInput')) {
|
||||||
var dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
|
var dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
|
||||||
var chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
var chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
||||||
|
var chrl = chr.toLowerCase();
|
||||||
// keyCode == 58 => ":"
|
// keyCode == 58 => ":"
|
||||||
// keyCode == 32 => " "
|
// keyCode == 32 => " "
|
||||||
return event.ctrlKey || (chr < ' ' || !dateChars || dateChars.indexOf(chr) > -1 || event.keyCode == 58 || event.keyCode == 32);
|
return event.ctrlKey || (chr < ' ' || !dateChars || dateChars.indexOf(chr) > -1 || event.keyCode == 58 || event.keyCode == 32 || chr == ':' || chr == ' ' || chrl == 'a' || chrl == 'p' || charl == 'm');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return $.datepicker._base_doKeyPress(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue