Skip to content

Instantly share code, notes, and snippets.

@gnarf
Created May 2, 2011 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnarf/951480 to your computer and use it in GitHub Desktop.
Save gnarf/951480 to your computer and use it in GitHub Desktop.
widget show/hide function
$.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