Created
May 2, 2011 11:37
-
-
Save gnarf/951480 to your computer and use it in GitHub Desktop.
widget show/hide function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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 (options.delay) { | |
element.delay( options.delay ); | |
} | |
if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { | |
element[ method ]( options ); | |
} else if ( effectName !== method && element[ effectName ] ) { | |
element[ effectName ]( options.duration, options.easing, callback ); | |
} else { | |
element.queue( function() { | |
$( this )[ method ](); | |
if ( callback ) { | |
callback.call( element[ 0 ] ); | |
} | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment