From 5feb83885885719e7db1896b4c36e51952f85bd4 Mon Sep 17 00:00:00 2001 From: MatmaRex Date: Sat, 24 Nov 2012 16:54:56 +0100 Subject: [PATCH] (bug 34876) improve $.makeCollapsible performance on the initial collapsing 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 | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/resources/jquery/jquery.makeCollapsible.js b/resources/jquery/jquery.makeCollapsible.js index ad156070dd..ace4a55e5d 100644 --- a/resources/jquery/jquery.makeCollapsible.js +++ b/resources/jquery/jquery.makeCollapsible.js @@ -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(); + } } } } -- 2.20.1