jquery.makeCollapsible: Use promise().done instead of when().then
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 18 Sep 2013 04:47:11 +0000 (06:47 +0200)
committerHelder.wiki <helder.wiki@gmail.com>
Wed, 18 Sep 2013 11:45:53 +0000 (11:45 +0000)
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

resources/jquery/jquery.makeCollapsible.js

index 27c4c6c..0cd6417 100644 (file)
                                        $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' ) ) ) {
                                        $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 {
                                                $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
                                                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 );
                                        }
                                }
                        }