Address my own CR in r75332.
[lhc/web/wiklou.git] / resources / mediawiki / mediawiki.specials.preferences.js
1 /*
2 * JavaScript for Special:Preferences
3 */
4
5 $( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
6 $( '#preferences' )
7 .addClass( 'jsprefs' )
8 .before( $( '<ul id="preftoc"></ul>' ) )
9 .children( 'fieldset' )
10 .hide()
11 .addClass( 'prefsection' )
12 .children( 'legend' )
13 .addClass( 'mainLegend' )
14 .each( function( i ) {
15 $(this).parent().attr( 'id', 'prefsection-' + i );
16 if ( i === 0 ) {
17 $(this).parent().show();
18 }
19 $( '#preftoc' ).append(
20 $( '<li></li>' )
21 .addClass( i === 0 ? 'selected' : null )
22 .append(
23 $( '<a></a>')
24 .text( $(this).text() )
25 .attr( 'href', '#prefsection-' + i )
26 .mousedown( function( e ) {
27 $(this).parent().parent().find( 'li' ).removeClass( 'selected' );
28 $(this).parent().addClass( 'selected' );
29 e.preventDefault();
30 return false;
31 } )
32 .click( function( e ) {
33 $( '#preferences > fieldset' ).hide();
34 $( '#prefsection-' + i ).show();
35 e.preventDefault();
36 return false;
37 } )
38 )
39 );
40 } );