From d4f6f17c8de859bcc4b76e15e523fb8b74703afe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Sat, 28 May 2011 10:18:39 -0400 Subject: [PATCH] Tooltip: Changed custom animation demo and changed the logic for showing tooltips so custom position options can perform animations. --- demos/tooltip/custom-animation.html | 40 +++++++++++++++++------------ ui/jquery.ui.tooltip.js | 13 +++++++--- ui/jquery.ui.widget.js | 2 +- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html index 23fa9aefe..b8f012d91 100644 --- a/demos/tooltip/custom-animation.html +++ b/demos/tooltip/custom-animation.html @@ -9,25 +9,35 @@ + + - @@ -35,14 +45,10 @@
-

Tooltips can be attached to any element. When you hover -the element with your mouse, the title attribute is displayed in a little box next to the element, just like a native tooltip.

-

But as it's not a native tooltip, it can be styled. Any themes built with -ThemeRoller -will also style tooltips accordingly.

-

Tooltips are also useful for form elements, to show some additional information in the context of each field.

-

-

Hover the field to see the tooltip.

+

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.

diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index b781174c9..c0aaa4fbe 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -90,11 +90,16 @@ $.widget("ui.tooltip", { target.attr( "aria-describedby", tooltip.attr( "id" ) ); } tooltip.find( ".ui-tooltip-content" ).html( content ); - tooltip.position( $.extend({ - of: target - }, this.options.position ) ).hide(); + 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 ) ); - tooltip.stop( true ); this._show( tooltip, this.options.show ); this._trigger( "open", event ); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 4167fd4e5..3bf735cd3 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -379,7 +379,7 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { var hasOptions = !$.isEmptyObject( options ), effectName = options.effect || defaultEffect; options.complete = callback; - if (options.delay) { + if ( options.delay ) { element.delay( options.delay ); } if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) { -- 2.39.5