(bug 34876) improve $.makeCollapsible performance on the initial collapsing
authorMatmaRex <matma.rex@gmail.com>
Sat, 24 Nov 2012 15:54:56 +0000 (16:54 +0100)
committerMatmaRex <matma.rex@gmail.com>
Mon, 10 Dec 2012 16:24:10 +0000 (17:24 +0100)
The logic for it was already present (options.instantHide), but it was
slightly incorrect, causing the instant hiding not to happen under some
circumstances. Unfortunately one of the circumstances was collapsed items
on the watchlist, causing performance issues.

Change-Id: I13313ec4930487566545ede53f25a8e67b9b9f28

resources/jquery/jquery.makeCollapsible.js

index ad15607..ace4a55 100644 (file)
@@ -74,26 +74,26 @@ $.fn.makeCollapsible = function () {
                                                $containers = $collapsible.find( '> tbody > tr' );
                                                if ( $defaultToggle ) {
                                                        // Exclude tablerow containing togglelink
-                                                       $containers.not( $defaultToggle.closest( 'tr' ) ).stop(true, true).fadeOut();
+                                                       $containers = $containers.not( $defaultToggle.closest( 'tr' ) );
+                                               }
+
+                                               if ( options.instantHide ) {
+                                                       $containers.hide();
                                                } else {
-                                                       if ( options.instantHide ) {
-                                                               $containers.hide();
-                                                       } else {
-                                                               $containers.stop( true, true ).fadeOut();
-                                                       }
+                                                       $containers.stop( true, true ).fadeOut();
                                                }
 
                                        } else if ( $collapsible.is( 'ul' ) || $collapsible.is( 'ol' ) ) {
                                                $containers = $collapsible.find( '> li' );
                                                if ( $defaultToggle ) {
                                                        // Exclude list-item containing togglelink
-                                                       $containers.not( $defaultToggle.parent() ).stop( true, true ).slideUp();
+                                                       $containers = $containers.not( $defaultToggle.parent() );
+                                               }
+
+                                               if ( options.instantHide ) {
+                                                       $containers.hide();
                                                } else {
-                                                       if ( options.instantHide ) {
-                                                               $containers.hide();
-                                                       } else {
-                                                               $containers.stop( true, true ).slideUp();
-                                                       }
+                                                       $containers.stop( true, true ).slideUp();
                                                }
 
                                        } else {
@@ -111,10 +111,14 @@ $.fn.makeCollapsible = function () {
                                                // Otherwise assume this is a customcollapse with a remote toggle
                                                // .. and there is no collapsible-content because the entire element should be toggled
                                                } else {
-                                                       if ( $collapsible.is( 'tr' ) || $collapsible.is( 'td' ) || $collapsible.is( 'th' ) ) {
-                                                               $collapsible.fadeOut();
+                                                       if ( options.instantHide ) {
+                                                               $collapsible.hide();
                                                        } else {
-                                                               $collapsible.slideUp();
+                                                               if ( $collapsible.is( 'tr' ) || $collapsible.is( 'td' ) || $collapsible.is( 'th' ) ) {
+                                                                       $collapsible.fadeOut();
+                                                               } else {
+                                                                       $collapsible.slideUp();
+                                                               }
                                                        }
                                                }
                                        }