r81573 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81572‎ | r81573 | r81574 >
Date:21:54, 5 February 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
Preserve Special:Preferences tab state across reload, open in new tab/window.

* removed the preventDefault()s from handlers on the tab links, so the document hash gets updated (and thus preserved on reload)
* switched from #prefsection-N to #preftab-N on the generated links, so they don't cause the doc to jump down to the top of the tab sections on click now that the preventDefault is gone
* added a check for the hash after tab setup; if we have a #preftab-N then we invoke the tab-switch straight off.

This should keep devs from going insane when doing work on any preferences panel other than the first one
Modified paths:
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.js
@@ -23,24 +23,29 @@
2424 .append(
2525 $( '<a></a>')
2626 .text( $(this).text() )
27 - .attr( 'href', '#prefsection-' + i )
 27+ .attr( 'id', 'preftab-' + i + '-tab' )
 28+ .attr( 'href', '#preftab-' + i ) // Use #preftab-N instead of #prefsection-N to avoid jumping on click
2829 .mousedown( function( e ) {
2930 $(this).parent().parent().find( 'li' ).removeClass( 'selected' );
3031 $(this).parent().addClass( 'selected' );
31 - e.preventDefault();
32 - return false;
3332 } )
3433 .click( function( e ) {
3534 $( '#preferences > fieldset' ).hide();
3635 $( '#prefsection-' + i ).show();
37 - e.preventDefault();
38 - return false;
3936 } )
4037 )
4138 );
4239 }
4340 );
4441
 42+// If we've reloaded the page or followed an open-in-new-window,
 43+// make the selected tab visible.
 44+var hash = window.location.hash;
 45+if( hash.match( /^#preftab-[\d]+$/ ) ) {
 46+ var tab = $( hash + '-tab' );
 47+ tab.mousedown().click();
 48+}
 49+
4550 /**
4651 * Given an email validity status (true, false, null) update the label CSS class
4752 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r81585Three small fixes to mediawiki.specials.preferences.js...krinkle03:31, 6 February 2011
r819531.17wmf1: MFT r81573, r81585catrope10:11, 11 February 2011

Comments

#Comment by Fomafix (talk | contribs)   09:06, 8 February 2011

Fixes Bug 16013.

#Comment by Brion VIBBER (talk | contribs)   09:09, 8 February 2011

sweet, I knew that was in bugzilla somewhere but couldn't turn it up :D

Status & tagging log