Merge "Call $wgContLang->findVariantLink() in {{PAGESINCATEGORY: }}"
[lhc/web/wiklou.git] / resources / mediawiki.special / mediawiki.special.preferences.js
index 46384a8..03d93d0 100644 (file)
@@ -1,7 +1,7 @@
 /**
  * JavaScript for Special:Preferences
  */
-jQuery( document ).ready( function ( $ ) {
+jQuery( function ( $ ) {
        var $preftoc, $preferences, $fieldsets, $legends,
                hash,
                $tzSelect, $tzTextbox, $localtimeHolder, servertime;
@@ -180,4 +180,20 @@ jQuery( document ).ready( function ( $ ) {
                $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 );
+               } );
+       }
 } );