]> source.dussan.org Git - jquery-ui.git/commitdiff
Tooltip: Reposition tracking tooltips when they gain focus.
authorScott González <scott.gonzalez@gmail.com>
Thu, 14 Jun 2012 14:06:21 +0000 (10:06 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 14 Jun 2012 16:40:03 +0000 (12:40 -0400)
ui/jquery.ui.tooltip.js

index 2c80f328c051c336f1487a9f93d48517a717db37..5ef5051afef5478c7347aaa58f16c82c31abb82f 100644 (file)
@@ -118,8 +118,18 @@ $.widget( "ui.tooltip", {
                        target = $( event ? event.target : this.element )
                                .closest( this.options.items );
 
-               // if ui-tooltip-id exists, then the tooltip is already open
-               if ( !target.length || target.data( "ui-tooltip-id" ) ) {
+               // No element to show a tooltip for
+               if ( !target.length ) {
+                       return;
+               }
+
+               // If the tooltip is open and we're tracking then reposition the tooltip.
+               // This makes sure that a tracking tooltip doesn't obscure a focused element
+               // if the user was hovering when the element gained focused.
+               if ( this.options.track && target.data( "ui-tooltip-id" ) ) {
+                       this._find( target ).position( $.extend({
+                               of: target
+                       }, this.options.position ) );
                        return;
                }
 
@@ -250,9 +260,7 @@ $.widget( "ui.tooltip", {
 
                target.removeData( "tooltip-open" );
                this._off( target, "mouseleave focusout keyup" );
-
-               // TODO use _off
-               this.document.unbind( "mousemove.tooltip" );
+               this._off( this.document, "mousemove" );
 
                this.closing = true;
                this._trigger( "close", event, { tooltip: tooltip } );