Index: branches/wmf/1.17wmf1/resources/mediawiki.special/mediawiki.special.preferences.js |
— | — | @@ -12,35 +12,41 @@ |
13 | 13 | .addClass( 'prefsection' ) |
14 | 14 | .children( 'legend' ) |
15 | 15 | .addClass( 'mainLegend' ) |
16 | | - .each( function( i ) { |
17 | | - $(this).parent().attr( 'id', 'prefsection-' + i ); |
| 16 | + .each( function( i, legend ) { |
| 17 | + $(legend).parent().attr( 'id', 'prefsection-' + i ); |
18 | 18 | if ( i === 0 ) { |
19 | | - $(this).parent().show(); |
| 19 | + $(legend).parent().show(); |
20 | 20 | } |
21 | 21 | $( '#preftoc' ).append( |
22 | 22 | $( '<li></li>' ) |
23 | 23 | .addClass( i === 0 ? 'selected' : null ) |
24 | 24 | .append( |
25 | 25 | $( '<a></a>') |
26 | | - .text( $(this).text() ) |
27 | | - .attr( 'href', '#prefsection-' + i ) |
28 | | - .mousedown( function( e ) { |
| 26 | + .text( $(legend).text() ) |
| 27 | + .attr( 'id', 'preftab-' + i + '-tab' ) |
| 28 | + .attr( 'href', '#preftab-' + i ) // Use #preftab-N instead of #prefsection-N to avoid jumping on click |
| 29 | + .click( function() { |
29 | 30 | $(this).parent().parent().find( 'li' ).removeClass( 'selected' ); |
30 | | - $(this).parent().addClass( 'selected' ); |
31 | | - e.preventDefault(); |
32 | | - return false; |
33 | | - } ) |
34 | | - .click( function( e ) { |
| 31 | + $(this).parent().addClass( 'selected' ) |
35 | 32 | $( '#preferences > fieldset' ).hide(); |
36 | 33 | $( '#prefsection-' + i ).show(); |
37 | | - e.preventDefault(); |
38 | | - return false; |
39 | 34 | } ) |
40 | 35 | ) |
41 | 36 | ); |
42 | 37 | } |
43 | 38 | ); |
44 | 39 | |
| 40 | +// If we've reloaded the page or followed an open-in-new-window, |
| 41 | +// make the selected tab visible. |
| 42 | +// On document ready: |
| 43 | +$( function() { |
| 44 | + var hash = window.location.hash; |
| 45 | + if( hash.match( /^#preftab-[\d]+$/ ) ) { |
| 46 | + var $tab = $( hash + '-tab' ); |
| 47 | + $tab.click(); |
| 48 | + } |
| 49 | +} ); |
| 50 | + |
45 | 51 | /** |
46 | 52 | * Given an email validity status (true, false, null) update the label CSS class |
47 | 53 | */ |