Merge "Enhanced RC: Optimization of the initial collapsing"
authorTheDJ <hartman.wiki@gmail.com>
Sun, 25 Aug 2013 13:03:14 +0000 (13:03 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 25 Aug 2013 13:03:14 +0000 (13:03 +0000)
1  2 
resources/jquery/jquery.makeCollapsible.js

                        }
                }
  
-               wasCollapsed = $collapsible.hasClass( 'mw-collapsed' );
+               // This allows the element to be hidden on initial toggle without fiddling with the class
+               if ( options.wasCollapsed !== undefined ) {
+                       wasCollapsed = options.wasCollapsed;
+               } else {
+                       wasCollapsed = $collapsible.hasClass( 'mw-collapsed' );
+               }
  
                // Toggle the state of the collapsible element (that is, expand or collapse)
                $collapsible.toggleClass( 'mw-collapsed', !wasCollapsed );
  
                        // Attributes for accessibility. This isn't necessary when the toggler is already
                        // an <a> or a <button> etc., but it doesn't hurt either, and it's consistent.
 -                      $toggleLink.prop( 'tabIndex', 0 ).attr( 'role', 'button' );
 +                      $toggleLink.prop( 'tabIndex', 0 );
  
                        // Initial state
                        if ( options.collapsed || $collapsible.hasClass( 'mw-collapsed' ) ) {
-                               // Remove here so that the toggler goes in the right direction (the class is re-added)
-                               $collapsible.removeClass( 'mw-collapsed' );
                                // One toggler can hook to multiple elements, and one element can have
                                // multiple togglers. This is the sanest way to handle that.
-                               actionHandler.call( $toggleLink.get( 0 ), null, { instantHide: true } );
+                               actionHandler.call( $toggleLink.get( 0 ), null, { instantHide: true, wasCollapsed: false } );
                        }
                } );
        };