diff options
author | TJ VanToll <tj.vantoll@gmail.com> | 2014-07-23 12:50:49 -0400 |
---|---|---|
committer | TJ VanToll <tj.vantoll@gmail.com> | 2014-07-23 15:10:37 -0400 |
commit | c399f1f77a015d4f269e3bda98720ebea9bb0c7a (patch) | |
tree | f885ca670646bf7bf184f9203dc56766737e3e4f /ui | |
parent | 69f25dbff71d9864ce7ce46c47003413f8b7deb2 (diff) | |
download | jquery-ui-c399f1f77a015d4f269e3bda98720ebea9bb0c7a.tar.gz jquery-ui-c399f1f77a015d4f269e3bda98720ebea9bb0c7a.zip |
Datepicker: Abstract mouseover logic to avoid explicit event trigger
The reliance on `.mouseover()` caused an issue in some circumstances
(see #5816). The removal of `.mouseover()` broke keyboard navigation
(see #10319).
Fixes #10319
Closes gh-1290
Diffstat (limited to 'ui')
-rw-r--r-- | ui/datepicker.js | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/ui/datepicker.js b/ui/datepicker.js index 46b6a5f4d..d3fe3dd1f 100644 --- a/ui/datepicker.js +++ b/ui/datepicker.js @@ -799,12 +799,16 @@ $.extend(Datepicker.prototype, { datepicker_instActive = inst; // for delegate hover events inst.dpDiv.empty().append(this._generateHTML(inst)); this._attachHandlers(inst); - inst.dpDiv.find("." + this._dayOverClass + " a"); var origyearshtml, numMonths = this._getNumberOfMonths(inst), cols = numMonths[1], - width = 17; + width = 17, + activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ); + + if ( activeCell.length > 0 ) { + datepicker_handleMouseover.apply( activeCell.get( 0 ) ); + } inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""); if (cols > 1) { @@ -2000,18 +2004,20 @@ function datepicker_bindHover(dpDiv) { $(this).removeClass("ui-datepicker-next-hover"); } }) - .delegate(selector, "mouseover", function(){ - if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? dpDiv.parent()[0] : datepicker_instActive.input[0])) { - $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"); - $(this).addClass("ui-state-hover"); - if (this.className.indexOf("ui-datepicker-prev") !== -1) { - $(this).addClass("ui-datepicker-prev-hover"); - } - if (this.className.indexOf("ui-datepicker-next") !== -1) { - $(this).addClass("ui-datepicker-next-hover"); - } - } - }); + .delegate( selector, "mouseover", datepicker_handleMouseover ); +} + +function datepicker_handleMouseover() { + if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) { + $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"); + $(this).addClass("ui-state-hover"); + if (this.className.indexOf("ui-datepicker-prev") !== -1) { + $(this).addClass("ui-datepicker-prev-hover"); + } + if (this.className.indexOf("ui-datepicker-next") !== -1) { + $(this).addClass("ui-datepicker-next-hover"); + } + } } /* jQuery extend now ignores nulls! */ |