From 58a5e23a7882e4438e60e354f3f2125562f9a540 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=CC=88rn=20Zaefferer?= Date: Thu, 23 Feb 2012 19:37:31 +0100 Subject: [PATCH] Tooltip: Replace blur with focusout to deal with inputs nested in tooltipped elements. --- tests/unit/tooltip/tooltip_events.js | 6 ++--- tests/visual/tooltip/tooltip.html | 37 +++++++++++++++++----------- ui/jquery.ui.tooltip.js | 4 +-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js index 99e1fbd79..bf60c3cdc 100644 --- a/tests/unit/tooltip/tooltip_events.js +++ b/tests/unit/tooltip/tooltip_events.js @@ -47,9 +47,9 @@ test( "focus events", function() { element.trigger( "focusin" ); element.one( "tooltipclose", function( event ) { - same( event.originalEvent.type, "blur" ); + same( event.originalEvent.type, "focusout" ); }); - element.trigger( "blur" ); + element.trigger( "focusout" ); }); asyncTest( "mixed events", function() { @@ -74,7 +74,7 @@ asyncTest( "mixed events", function() { // blurring is async in IE element.one( "tooltipclose", function( event ) { - same( event.originalEvent.type, "blur" ); + same( event.originalEvent.type, "focusout" ); start(); }); element.simulate( "blur" ); diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index b282a73b7..eb51d56c6 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -23,8 +23,8 @@ function enable() { // default - $("#context1, form, #childish").tooltip(); - + $("#context1, form, #childish, #nested-input").tooltip(); + // custom class, replaces ui-widget-content $("#context2").tooltip({ tooltipClass: "ui-widget-header" @@ -32,7 +32,7 @@ $("#right1").tooltip({ tooltipClass: "ui-state-error" }); - + // synchronous content $("#footnotes").tooltip({ items: "[href^='#']", @@ -65,7 +65,7 @@ return "Loading..."; } }); - + // custom position $("#right2").tooltip({ tooltipClass: "ui-state-highlight", @@ -75,7 +75,7 @@ offset: "0 10" } }); - + $("#button1").button(); $("#button2").button({ icons: { @@ -97,7 +97,7 @@ }); } enable(); - + $("#disable").toggle(function() { $(":ui-tooltip").tooltip("disable"); }, function() { @@ -126,23 +126,23 @@
collision detection should kick in around here
- +
I'm a link to a footnote. I'm another link to a footnote.
- +
right aligned with custom position
- +
gets its content via ajax
gets its content via ajax, caches the response
- +
span
@@ -150,11 +150,11 @@ nested span
- +
Text in bold.
- +
@@ -165,17 +165,24 @@
- + +
+ + + + +
+
- +
This is the footnote, including other elements
This is the other footnote, including other elements
- + diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index cb23e9a4d..6a41f8c4a 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -157,7 +157,7 @@ $.widget( "ui.tooltip", { this._bind( target, { mouseleave: "close", - blur: "close", + focusout: "close", keyup: function( event ) { if ( event.keyCode == $.ui.keyCode.ESCAPE ) { var fakeEvent = $.Event(event); @@ -193,7 +193,7 @@ $.widget( "ui.tooltip", { }); target.removeData( "tooltip-open" ); - target.unbind( "mouseleave.tooltip blur.tooltip keyup.tooltip" ); + target.unbind( "mouseleave.tooltip focusout.tooltip keyup.tooltip" ); this._trigger( "close", event, { tooltip: tooltip } ); }, -- 2.39.5