From: Timo Tijhof Date: Wed, 18 Sep 2013 04:47:11 +0000 (+0200) Subject: jquery.makeCollapsible: Use promise().done instead of when().then X-Git-Tag: 1.31.0-rc.0~18743^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=45e9c20ed1a1741354b727656670597559902a59;p=lhc%2Fweb%2Fwiklou.git jquery.makeCollapsible: Use promise().done instead of when().then Follows up b340bd4f6b. They both work, but in this case there is no need to use $.when since there is only 1 promise. And there is no need for the filtering proxy of Promise#then either, a straight done is enough. $.when( $foo ).then( callback ) $.when( $foo ).done( callback ) $foo.promise().done( callback ) Change-Id: I4df755a32c124481ca690078191a735d2e2b511a --- diff --git a/resources/jquery/jquery.makeCollapsible.js b/resources/jquery/jquery.makeCollapsible.js index 27c4c6cc4d..0cd6417c29 100644 --- a/resources/jquery/jquery.makeCollapsible.js +++ b/resources/jquery/jquery.makeCollapsible.js @@ -75,10 +75,10 @@ $containers.hide(); hookCallback(); } else { - $.when( $containers.stop( true, true ).fadeOut() ).then( hookCallback ); + $containers.stop( true, true ).fadeOut().promise().done( hookCallback ); } } else { - $.when( $containers.stop( true, true ).fadeIn() ).then( hookCallback ); + $containers.stop( true, true ).fadeIn().promise().done( hookCallback ); } } else if ( !options.plainMode && ( $collapsible.is( 'ul' ) || $collapsible.is( 'ol' ) ) ) { @@ -94,10 +94,10 @@ $containers.hide(); hookCallback(); } else { - $.when( $containers.stop( true, true ).slideUp() ).then( hookCallback ); + $containers.stop( true, true ).slideUp().promise().done( hookCallback ); } } else { - $.when( $containers.stop( true, true ).slideDown() ).then( hookCallback ); + $containers.stop( true, true ).slideDown().promise().done( hookCallback ); } } else { @@ -111,10 +111,10 @@ $collapsibleContent.hide(); hookCallback(); } else { - $.when( $collapsibleContent.slideUp() ).then( hookCallback ); + $collapsibleContent.slideUp().promise().done( hookCallback ); } } else { - $.when( $collapsibleContent.slideDown() ).then( hookCallback ); + $collapsibleContent.slideDown().promise().done( hookCallback ); } // Otherwise assume this is a customcollapse with a remote toggle @@ -126,16 +126,16 @@ hookCallback(); } else { if ( $collapsible.is( 'tr' ) || $collapsible.is( 'td' ) || $collapsible.is( 'th' ) ) { - $.when( $collapsible.fadeOut() ).then( hookCallback ); + $collapsible.fadeOut().promise().done( hookCallback ); } else { - $.when( $collapsible.slideUp() ).then( hookCallback ); + $collapsible.slideUp().promise().done( hookCallback ); } } } else { if ( $collapsible.is( 'tr' ) || $collapsible.is( 'td' ) || $collapsible.is( 'th' ) ) { - $.when( $collapsible.fadeIn() ).then( hookCallback ); + $collapsible.fadeIn().promise().done( hookCallback ); } else { - $.when( $collapsible.slideDown() ).then( hookCallback ); + $collapsible.slideDown().promise().done( hookCallback ); } } }