From e609bebaae7f3f762dd61d92fb0529af9ef5f2d1 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Fri, 15 Apr 2011 16:49:29 +0200 Subject: Custom tooltip animations based on widget-animations branch. --- ui/jquery.ui.tooltip.js | 4 ++-- ui/jquery.ui.widget.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 534b3c947..bff17d7b5 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -91,7 +91,7 @@ $.widget("ui.tooltip", { }, this.options.position ) ).hide(); - tooltip.fadeIn(); + this._show( tooltip, this.options.show ); this._trigger( "open", event ); @@ -111,7 +111,7 @@ $.widget("ui.tooltip", { var tooltip = this._find( target ); target.removeAttr( "aria-describedby" ); - tooltip.fadeOut( function() { + this._hide( tooltip, this.options.hide, function() { $( this ).remove(); }); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 27d08ccd2..9593c1eaf 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -353,6 +353,26 @@ $.Widget.prototype = { } }; +$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { + $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { + options = options || {}; + var hasOptions = !$.isEmptyObject( options ), + effectName = options.effect || defaultEffect; + options.complete = callback; + + if ( hasOptions && $.effects && $.effects[ effectName ] ) { + element[ method ]( options ); + } else if ( element[ effectName ] ) { + element[ effectName ]( options.duration, options.easing, callback ); + } else { + element[ method ](); + if ( callback ) { + callback.call( element[ 0 ] ); + } + } + }; +}); + // DEPRECATED if ( $.uiBackCompat !== false ) { $.Widget.prototype._getCreateOptions = function() { -- cgit v1.2.3