Skip to content
Permalink
Browse files

Custom tooltip animations based on widget-animations branch.

  • Loading branch information
jzaefferer committed Apr 15, 2011
1 parent 00559b3 commit e609bebaae7f3f762dd61d92fb0529af9ef5f2d1
Showing with 26 additions and 9 deletions.
  1. +4 −7 demos/tooltip/custom-animation.html
  2. +2 −2 ui/jquery.ui.tooltip.js
  3. +20 −0 ui/jquery.ui.widget.js
@@ -11,15 +11,12 @@
<link type="text/css" href="../demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
// TODO overhaul this with custom animation API
$(".demo").tooltip({
open: function() {
$(".ui-tooltip").stop(false, true).hide().slideDown();
show: {
effect: "slideDown"
},
close: function() {
$(".ui-tooltip").stop(false, false).show().slideUp(function() {
$(this).remove();
});
hide: {
effect: "slideUp"
}
});
});
@@ -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();
});

@@ -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;

This comment has been minimized.

Copy link
@ctumolosus

ctumolosus Jun 25, 2013

this overrides the complete option set by users

for example, in the following snippet the complete method passed as an option is overriden when a dialog is opened.

jQuery('selector').dialog({ 
    show: { 
        effect: 'fade', 
        complete: function(){ 
            console.log('animation finished');
        }
    } 
});

jQuery('selector').dialog('open') // calls `jQuery.Widget.prototype._show` and overrides `complete` method...

This comment has been minimized.

Copy link
@scottgonzalez

scottgonzalez Jun 25, 2013

Member

Yup, you're not supposed to use complete here. It's not documented for a reason.


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() {

0 comments on commit e609beb

Please sign in to comment.
You can’t perform that action at this time.