2 * Collapsible navigation for Vector
8 // Use the same function for all navigation headings - don't repeat
9 function toggle( $element
) {
11 'vector-nav-' + $element
.parent().attr( 'id' ),
12 $element
.parent().is( '.collapsed' ),
13 { 'expires': 30, 'path': '/' }
17 .toggleClass( 'expanded' )
18 .toggleClass( 'collapsed' )
20 .slideToggle( 'fast' );
26 // Left-to-right languages
28 // Collapsible Nav is broken in Opera < 9.6 and Konqueror < 4
30 konqueror
: [['>=', 4.0]],
36 // Right-to-left languages
39 konqueror
: [['>=', 4.0]],
46 if ( !$.client
.test( map
) ) {
51 var $headings
, tabIndex
;
53 /* General Portal Modification */
55 // Always show the first portal
56 $( '#mw-panel > .portal:first' ).addClass( 'first persistent' );
57 // Apply a class to the entire panel to activate styles
58 $( '#mw-panel' ).addClass( 'collapsible-nav' );
59 // Use cookie data to restore preferences of what to show and hide
60 $( '#mw-panel > .portal:not(.persistent)' )
61 .each( function ( i
) {
62 var id
= $(this).attr( 'id' ),
63 state
= $.cookie( 'vector-nav-' + id
);
64 // Add anchor tag to heading for better accessibility
65 $( this ).find( 'h3' ).wrapInner( $( '<a href="#"></a>' ).click( false ) );
66 // In the case that we are not showing the new version, let's show the languages by default
69 ( state
=== null && i
< 1 ) ||
70 ( state
=== null && id
=== 'p-lang' )
73 .addClass( 'expanded' )
74 .removeClass( 'collapsed' )
80 .addClass( 'collapsed' )
81 .removeClass( 'expanded' );
84 if ( state
!== null ) {
85 $.cookie( 'vector-nav-' + $(this).attr( 'id' ), state
, { 'expires': 30, 'path': '/' } );
91 $headings
= $( '#mw-panel > .portal:not(.persistent) > h3' );
93 // Get the highest tab index
94 tabIndex
= $( document
).lastTabIndex() + 1;
96 // Fix the search not having a tabindex
97 $( '#searchInput' ).attr( 'tabindex', tabIndex
++ );
99 // Make it keyboard accessible
100 $headings
.attr( 'tabindex', function () {
104 // Toggle the selected menu's class and expand or collapse the menu
106 .delegate( '.portal:not(.persistent) > h3', 'keydown', function ( e
) {
107 // Make the space and enter keys act as a click
108 if ( e
.which
=== 13 /* Enter */ || e
.which
=== 32 /* Space */ ) {
112 .delegate( '.portal:not(.persistent) > h3', 'mousedown', function ( e
) {
113 if ( e
.which
!== 3 ) { // Right mouse click
121 }( mediaWiki
, jQuery
) );