-/*
+/**
* JavaScript for Special:Preferences
*/
jQuery( document ).ready( function ( $ ) {
$( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
- $preftoc = $('<ul id="preftoc"></ul>'),
- $preferences = $( '#preferences' )
- .addClass( 'jsprefs' )
- .before( $preftoc ),
- $fieldsets = $preferences.children( 'fieldset' )
- .hide()
- .addClass( 'prefsection' ),
- $legends = $fieldsets
- .children( 'legend' )
- .addClass( 'mainLegend' );
+ $preftoc = $('<ul id="preftoc"></ul>');
+ $preferences = $( '#preferences' )
+ .addClass( 'jsprefs' )
+ .before( $preftoc );
+ $fieldsets = $preferences.children( 'fieldset' )
+ .hide()
+ .addClass( 'prefsection' );
+ $legends = $fieldsets
+ .children( 'legend' )
+ .addClass( 'mainLegend' );
/**
- * It uses document.getElementById for security reasons (html injections in
- * jQuery()).
+ * It uses document.getElementById for security reasons (HTML injections in $()).
*
* @param String name: the name of a tab without the prefix ("mw-prefsection-")
* @param String mode: [optional] A hash will be set according to the current
$tzTextbox.blur( updateTimezoneSelection );
updateTimezoneSelection();
}
+
+ // Preserve the tab after saving the preferences
+ // Not using cookies, because their deletion results are inconsistent.
+ // Not using jStorage due to its enormous size (for this feature)
+ if ( window.sessionStorage ) {
+ if ( sessionStorage.getItem( 'mediawikiPreferencesTab' ) !== null ) {
+ switchPrefTab( sessionStorage.getItem( 'mediawikiPreferencesTab' ), 'noHash' );
+ }
+ // Deleting the key, the tab states should be reset until we press Save
+ sessionStorage.removeItem( 'mediawikiPreferencesTab' );
+
+ $( '#mw-prefs-form' ).submit( function () {
+ var storageData = $( $preftoc ).find( 'li.selected a' ).attr( 'id' ).replace( 'preftab-', '' );
+ sessionStorage.setItem( 'mediawikiPreferencesTab', storageData );
+ } );
+ }
} );