r81953 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81952‎ | r81953 | r81954 >
Date:10:11, 11 February 2011
Author:catrope
Status:ok
Tags:
Comment:
1.17wmf1: MFT r81573, r81585
Modified paths:
  • /branches/wmf/1.17wmf1/resources/mediawiki.special/mediawiki.special.preferences.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/resources/mediawiki.special/mediawiki.special.preferences.js
@@ -12,35 +12,41 @@
1313 .addClass( 'prefsection' )
1414 .children( 'legend' )
1515 .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 );
1818 if ( i === 0 ) {
19 - $(this).parent().show();
 19+ $(legend).parent().show();
2020 }
2121 $( '#preftoc' ).append(
2222 $( '<li></li>' )
2323 .addClass( i === 0 ? 'selected' : null )
2424 .append(
2525 $( '<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() {
2930 $(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' )
3532 $( '#preferences > fieldset' ).hide();
3633 $( '#prefsection-' + i ).show();
37 - e.preventDefault();
38 - return false;
3934 } )
4035 )
4136 );
4237 }
4338 );
4439
 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+
4551 /**
4652 * Given an email validity status (true, false, null) update the label CSS class
4753 */

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81573Preserve Special:Preferences tab state across reload, open in new tab/window....brion21:54, 5 February 2011
r81585Three small fixes to mediawiki.specials.preferences.js...krinkle03:31, 6 February 2011

Status & tagging log