From 1b52cefc26da3a3c5bcb9116db79f68dbcc5de81 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 30 May 2011 18:27:48 -0400 Subject: Widget: Fixed _show() and _hide() implementation and added tests. --- ui/jquery.ui.widget.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'ui/jquery.ui.widget.js') diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index da52a5a9c..00bc07c4f 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -375,9 +375,20 @@ $.Widget.prototype = { $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { + if ( typeof options === "string" ) { + options = { effect: options }; + } + var hasOptions, + effectName = !options ? + method : + options === true || typeof options === "number" ? + defaultEffect : + options.effect || defaultEffect; options = options || {}; - var hasOptions = !$.isEmptyObject( options ), - effectName = options.effect || defaultEffect; + if ( typeof options === "number" ) { + options = { duration: options }; + } + hasOptions = !$.isEmptyObject( options ); options.complete = callback; if ( options.delay ) { element.delay( options.delay ); @@ -387,11 +398,12 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { } else if ( effectName !== method && element[ effectName ] ) { element[ effectName ]( options.duration, options.easing, callback ); } else { - element.queue( function() { + element.queue(function( next ) { $( this )[ method ](); if ( callback ) { callback.call( element[ 0 ] ); } + next(); }); } }; -- cgit v1.2.3