From: Federico Leva Date: Sat, 3 May 2014 11:12:46 +0000 (+0200) Subject: Remove collapsibleNav: performance cost too high X-Git-Tag: 1.31.0-rc.0~15900 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=db13c65237a7d7ec4cb3966f433e6492694e57a9;p=lhc%2Fweb%2Fwiklou.git Remove collapsibleNav: performance cost too high Appears to be unused by any extension in gerrit. Bug: 39035 Change-Id: I220057c799bef7e8c4d964f47d56f61ec120d8c2 --- diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index fc4a35722d..5185517eb0 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -26,6 +26,8 @@ production. option and a size specification set will now always ignore the provided size and display an unscaled image, as the documentation has always claimed it would. +* (bug 39035) Improved Vector skin performance by removing collapsibleNav, + which used to collapse some sidebar elements by default. * (bug 890) Links in Special:RecentChanges and Special:Watchlist no longer follow redirects to their target pages. diff --git a/resources/Resources.php b/resources/Resources.php index cf37005272..6057b39417 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -186,22 +186,6 @@ return array( 'remoteBasePath' => $GLOBALS['wgStylePath'], 'localBasePath' => $GLOBALS['wgStyleDirectory'], ), - 'skins.vector.collapsibleNav' => array( - 'scripts' => array( - 'vector/collapsibleNav.js', - ), - 'messages' => array( - 'vector-collapsiblenav-more', - ), - 'dependencies' => array( - 'jquery.client', - 'jquery.cookie', - 'jquery.tabIndex', - ), - 'remoteBasePath' => $GLOBALS['wgStylePath'], - 'localBasePath' => $GLOBALS['wgStyleDirectory'], - 'position' => 'bottom', - ), /* jQuery */ diff --git a/skins/Vector.php b/skins/Vector.php index 7a714ad623..35861c2286 100644 --- a/skins/Vector.php +++ b/skins/Vector.php @@ -58,7 +58,7 @@ class SkinVector extends SkinTemplate { "/{$this->stylename}/csshover{$min}.htc\")}" ); - $out->addModules( array( 'skins.vector.js', 'skins.vector.collapsibleNav' ) ); + $out->addModules( array( 'skins.vector.js' ) ); } /** diff --git a/skins/vector/collapsibleNav.js b/skins/vector/collapsibleNav.js deleted file mode 100644 index 45258e50ad..0000000000 --- a/skins/vector/collapsibleNav.js +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Collapsible navigation for Vector - */ -( function ( mw, $ ) { - 'use strict'; - var map; - - // Use the same function for all navigation headings - don't repeat - function toggle( $element ) { - var isCollapsed = $element.parent().is( '.collapsed' ); - - $.cookie( - 'vector-nav-' + $element.parent().attr( 'id' ), - isCollapsed, - { 'expires': 30, 'path': '/' } - ); - - $element - .parent() - .toggleClass( 'expanded' ) - .toggleClass( 'collapsed' ) - .find( '.body' ) - .slideToggle( 'fast' ); - isCollapsed = !isCollapsed; - - $element - .find( '> a' ) - .attr( { - 'aria-pressed': isCollapsed ? 'false' : 'true', - 'aria-expanded': isCollapsed ? 'false' : 'true' - } ); - } - - /* Browser Support */ - - map = { - // Left-to-right languages - ltr: { - // Collapsible Nav is broken in Opera < 9.6 and Konqueror < 4 - opera: [['>=', 9.6]], - konqueror: [['>=', 4.0]], - blackberry: false, - ipod: false, - iphone: false, - ps3: false - }, - // Right-to-left languages - rtl: { - opera: [['>=', 9.6]], - konqueror: [['>=', 4.0]], - blackberry: false, - ipod: false, - iphone: false, - ps3: false - } - }; - if ( !$.client.test( map ) ) { - return true; - } - - $( function ( $ ) { - var $headings, tabIndex; - - /* General Portal Modification */ - - // Always show the first portal - $( '#mw-panel > .portal:first' ).addClass( 'first persistent' ); - // Apply a class to the entire panel to activate styles - $( '#mw-panel' ).addClass( 'collapsible-nav' ); - // Use cookie data to restore preferences of what to show and hide - $( '#mw-panel > .portal:not(.persistent)' ) - .each( function ( i ) { - var id = $(this).attr( 'id' ), - state = $.cookie( 'vector-nav-' + id ); - $(this).find( 'ul:first' ).attr( 'id', id + '-list' ); - // Add anchor tag to heading for better accessibility - $( this ).find( 'h3' ).wrapInner( - $( '' ) - .attr( { - href: '#', - 'aria-haspopup': 'true', - 'aria-controls': id + '-list', - role: 'button' - } ) - .click( false ) - ); - // In the case that we are not showing the new version, let's show the languages by default - if ( - state === 'true' || - ( state === null && i < 1 ) || - ( state === null && id === 'p-lang' ) - ) { - $(this) - .addClass( 'expanded' ) - .removeClass( 'collapsed' ) - .find( '.body' ) - .hide() // bug 34450 - .show(); - $(this).find( 'h3 > a' ) - .attr( { - 'aria-pressed': 'true', - 'aria-expanded': 'true' - } ); - } else { - $(this) - .addClass( 'collapsed' ) - .removeClass( 'expanded' ); - $(this).find( 'h3 > a' ) - .attr( { - 'aria-pressed': 'false', - 'aria-expanded': 'false' - } ); - } - // Re-save cookie - if ( state !== null ) { - $.cookie( 'vector-nav-' + $(this).attr( 'id' ), state, { 'expires': 30, 'path': '/' } ); - } - } ); - - /* Tab Indexing */ - - $headings = $( '#mw-panel > .portal:not(.persistent) > h3' ); - - // Get the highest tab index - tabIndex = $( document ).lastTabIndex() + 1; - - // Fix the search not having a tabindex - $( '#searchInput' ).attr( 'tabindex', tabIndex++ ); - - // Make it keyboard accessible - $headings.attr( 'tabindex', function () { - return tabIndex++; - }); - - // Toggle the selected menu's class and expand or collapse the menu - $( '#mw-panel' ) - .delegate( '.portal:not(.persistent) > h3', 'keydown', function ( e ) { - // Make the space and enter keys act as a click - if ( e.which === 13 /* Enter */ || e.which === 32 /* Space */ ) { - toggle( $(this) ); - } - } ) - .delegate( '.portal:not(.persistent) > h3', 'mousedown', function ( e ) { - if ( e.which !== 3 ) { // Right mouse click - toggle( $(this) ); - $(this).blur(); - } - return false; - } ); - }); - -}( mediaWiki, jQuery ) ); diff --git a/skins/vector/components/navigation.less b/skins/vector/components/navigation.less index f3a5a49d06..24e9843f29 100644 --- a/skins/vector/components/navigation.less +++ b/skins/vector/components/navigation.less @@ -1,6 +1,5 @@ @import "mediawiki.mixins"; @import "personalMenu"; -@import "collapsibleNav"; @import "search"; @import "tabs";