diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-10-19 18:16:11 -0400 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-10-21 12:50:12 -0400 |
commit | 6b48ef5eca67f389d7a58f3c8a263ceb82c8becb (patch) | |
tree | 799e6d484e16c82a21962dd1bf71ec7ed58baabd /ui/jquery.ui.tooltip.js | |
parent | 77a55f1291861b87d30011ac5fd948f6b38d2c60 (diff) | |
download | jquery-ui-6b48ef5eca67f389d7a58f3c8a263ceb82c8becb.tar.gz jquery-ui-6b48ef5eca67f389d7a58f3c8a263ceb82c8becb.zip |
Tooltip: Only bind blur when opening via focus, mouseleave for mouseover. Remove the keep-open-on-focusout workaround. Now matching behaviour described in ARIA Authoring Practices. Fixes #8699 - Moving focus on click of a tooltipped element shows native tooltip in IE/Firefox on Windows
Diffstat (limited to 'ui/jquery.ui.tooltip.js')
-rw-r--r-- | ui/jquery.ui.tooltip.js | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 73321633b..b56d939e8 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -206,7 +206,7 @@ $.widget( "ui.tooltip", { }, _open: function( event, target, content ) { - var tooltip, positionOption; + var tooltip, positionOption, events; if ( !content ) { return; } @@ -261,9 +261,7 @@ $.widget( "ui.tooltip", { this._trigger( "open", event, { tooltip: tooltip } ); - this._on( target, { - mouseleave: "close", - focusout: "close", + events = { keyup: function( event ) { if ( event.keyCode === $.ui.keyCode.ESCAPE ) { var fakeEvent = $.Event(event); @@ -271,7 +269,14 @@ $.widget( "ui.tooltip", { this.close( fakeEvent, true ); } } - }); + }; + if ( !event || event.type === "mouseover" ) { + events.mouseleave = "close"; + } + if ( !event || event.type === "focusin" ) { + events.focusout = "close"; + } + this._on( target, events ); }, close: function( event, force ) { @@ -285,16 +290,6 @@ $.widget( "ui.tooltip", { return; } - // don't close if the element has focus - // this prevents the tooltip from closing if you hover while focused - // - // we have to check the event type because tabbing out of the document - // may leave the element as the activeElement - if ( !force && event && event.type !== "focusout" && - this.document[0].activeElement === target[0] ) { - return; - } - // only set title if we had one before (see comment in _open()) if ( target.data( "ui-tooltip-title" ) ) { target.attr( "title", target.data( "ui-tooltip-title" ) ); |