Skip to content

Commit

Permalink
Tooltip: Reposition tracking tooltips when they gain focus.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Jun 14, 2012
1 parent 556497f commit 7c46b78
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ui/jquery.ui.tooltip.js
Expand Up @@ -118,8 +118,19 @@ $.widget( "ui.tooltip", {
target = $( event ? event.target : this.element ) target = $( event ? event.target : this.element )
.closest( this.options.items ); .closest( this.options.items );


// if ui-tooltip-id exists, then the tooltip is already open // No element to show a tooltip for
if ( !target.length || target.data( "ui-tooltip-id" ) ) { 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 ) );
// TODO: Do we need to unbind the mousemove handler here?
return; return;
} }


Expand Down Expand Up @@ -251,7 +262,7 @@ $.widget( "ui.tooltip", {
target.removeData( "tooltip-open" ); target.removeData( "tooltip-open" );
target.unbind( "mouseleave.tooltip focusout.tooltip keyup.tooltip" ); target.unbind( "mouseleave.tooltip focusout.tooltip keyup.tooltip" );


// TODO use _off // TODO use _off (see associated TODO in open())
this.document.unbind( "mousemove.tooltip" ); this.document.unbind( "mousemove.tooltip" );


this.closing = true; this.closing = true;
Expand Down

0 comments on commit 7c46b78

Please sign in to comment.