From e530d06c98571c9330fc8cfda62a438d07e8f65b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 30 May 2011 18:42:06 -0400 Subject: [PATCH] Tooltip: Pass the tooltip element in the open and close events. --- demos/tooltip/custom-animation.html | 21 +++++++++------------ ui/jquery.ui.tooltip.js | 13 +++++-------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html index e96960f47..c7d1aa5b8 100644 --- a/demos/tooltip/custom-animation.html +++ b/demos/tooltip/custom-animation.html @@ -26,16 +26,14 @@ delay: 250 } }); - $( "#position-option" ).tooltip({ + $( "#open-event" ).tooltip({ + show: null, position: { my: "left top", - at: "left bottom+10", - using: function( pos ) { - $( this ).css({ - left: pos.left, - top: pos.top - 10 - }).animate({ top: pos.top }, "fast" ); - } + at: "left bottom" + }, + open: function( event, ui ) { + ui.tooltip.animate({ top: ui.tooltip.position().top + 10 }, "fast" ); } }); }); @@ -48,16 +46,15 @@

There are various ways to customize the animation of a tooltip.

You can use the show and hide options.

-

You can also use the position option.

+

You can also use the open event.

-

This demo shows how to customize animations. The tooltip is shown, after a -delay of 250ms, using a slide down animation, and hidden, after another delay, -without an animation.

+

This demo shows how to customize animations using the show and hide options, +as well as the open event.

diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index a6ccc07bc..f19061bc3 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -138,16 +138,13 @@ $.widget( "ui.tooltip", { tooltip .stop( true ) .position( $.extend({ - of: target, - using: function( pos ) { - // we only want to hide if there's no custom using defined - $( this ).css( pos ).hide(); - } - }, this.options.position ) ); + of: target + }, this.options.position ) ) + .hide(); this._show( tooltip, this.options.show ); - this._trigger( "open", event ); + this._trigger( "open", event, { tooltip: tooltip } ); this._bind( target, { mouseleave: "close", @@ -181,7 +178,7 @@ $.widget( "ui.tooltip", { target.unbind( "mouseleave.tooltip blur.tooltip" ); - this._trigger( "close", event ); + this._trigger( "close", event, { tooltip: tooltip } ); }, _tooltip: function( element ) { -- 2.39.5