aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2013-04-07 14:16:31 -0400
committerMike Sherov <mike.sherov@gmail.com>2013-04-07 14:16:31 -0400
commit1c1b64fcf017471970c3903a2bc89cc7d108aaa3 (patch)
tree73d59649bbe62afb195c1c2d74cdda8d4e3faa7e /ui
parent58d9130ba3f7f6560582c41066ca0678c036d8e3 (diff)
downloadjquery-ui-1c1b64fcf017471970c3903a2bc89cc7d108aaa3.tar.gz
jquery-ui-1c1b64fcf017471970c3903a2bc89cc7d108aaa3.zip
Datepicker Tests: Fix IE tests by accounting for async nature of focus/blur and by correctly not double focusing a programmatically focused date picker.
A partial fix was implemented to resolve #6694, and this commit completes the fix so we can programmatically focus a date picker without focus being fired twice.
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.datepicker.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index 976534c94..b433cb79b 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -774,9 +774,10 @@ $.extend(Datepicker.prototype, {
inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
}
- if (inst.input.is(":visible") && !inst.input.is(":disabled")) {
+ if ( $.datepicker._shouldFocusInput( inst ) ) {
inst.input.focus();
}
+
$.datepicker._curInst = inst;
}
},
@@ -803,10 +804,7 @@ $.extend(Datepicker.prototype, {
inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
"Class"]("ui-datepicker-rtl");
- // #6694 - don't focus the input if it's already focused
- // this breaks the change event in IE
- if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
- inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) {
+ if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
inst.input.focus();
}
@@ -823,6 +821,13 @@ $.extend(Datepicker.prototype, {
}
},
+ // #6694 - don't focus the input if it's already focused
+ // this breaks the change event in IE
+ // Support: IE and jQuery <1.9
+ _shouldFocusInput: function( inst ) {
+ return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
+ },
+
/* Check positioning to remain on screen. */
_checkOffset: function(inst, offset, isFixed) {
var dpWidth = inst.dpDiv.outerWidth(),