-jQuery( function ( $ ) {
- var $preftoc, $preferences, $fieldsets, $legends,
- hash, labelFunc,
- $tzSelect, $tzTextbox, $localtimeHolder, servertime,
- $checkBoxes, allowCloseWindow,
- notif;
-
- labelFunc = function () {
- return this.id.replace( /^mw-prefsection/g, 'preftab' );
- };
-
- $( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
- $preftoc = $( '<ul>' )
- .attr( {
- id: 'preftoc',
- role: 'tablist'
- } );
- $preferences = $( '#preferences' )
- .addClass( 'jsprefs' )
- .before( $preftoc );
- $fieldsets = $preferences.children( 'fieldset' )
- .hide()
- .attr( {
- role: 'tabpanel',
- 'aria-hidden': 'true',
- 'aria-labelledby': labelFunc
- } )
- .addClass( 'prefsection' );
- $legends = $fieldsets
- .children( 'legend' )
- .addClass( 'mainLegend' );
-
- // Make sure the accessibility tip is selectable so that screen reader users take notice,
- // but hide it per default to reduce interface clutter. Also make sure it becomes visible
- // when selected. Similar to jquery.mw-jump
- $( '<div>' ).addClass( 'mw-navigation-hint' )
- .text( mediaWiki.msg( 'prefs-tabs-navigation-hint' ) )
- .attr( 'tabIndex', 0 )
- .on( 'focus blur', function ( e ) {
- if ( e.type === 'blur' || e.type === 'focusout' ) {
- $( this ).css( 'height', '0' );
- } else {
- $( this ).css( 'height', 'auto' );
+( function ( mw, $ ) {
+ $( function () {
+ var $preftoc, $preferences, $fieldsets,
+ hash, labelFunc,
+ $tzSelect, $tzTextbox, $localtimeHolder, servertime,
+ allowCloseWindow, notif;
+
+ labelFunc = function () {
+ return this.id.replace( /^mw-prefsection/g, 'preftab' );
+ };
+
+ $( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
+ $preftoc = $( '#preftoc' );
+ $preferences = $( '#preferences' );
+
+ $fieldsets = $preferences.children( 'fieldset' )
+ .attr( {
+ role: 'tabpanel',
+ 'aria-labelledby': labelFunc
+ } )
+ .not( '#mw-prefsection-personal' )
+ .hide()
+ .attr( 'aria-hidden', 'true' );
+
+ // T115692: The following is kept for backwards compatibility with older skins
+ $preferences.addClass( 'jsprefs' );
+ $fieldsets.addClass( 'prefsection' );
+ $fieldsets.children( 'legend' ).addClass( 'mainLegend' );
+
+ // Make sure the accessibility tip is selectable so that screen reader users take notice,
+ // but hide it per default to reduce interface clutter. Also make sure it becomes visible
+ // when selected. Similar to jquery.mw-jump
+ $( '<div>' ).addClass( 'mw-navigation-hint' )
+ .text( mw.msg( 'prefs-tabs-navigation-hint' ) )
+ .attr( 'tabIndex', 0 )
+ .on( 'focus blur', function ( e ) {
+ if ( e.type === 'blur' || e.type === 'focusout' ) {
+ $( this ).css( 'height', '0' );
+ } else {
+ $( this ).css( 'height', 'auto' );
+ }
+ } ).insertBefore( $preftoc );
+
+ /**
+ * It uses document.getElementById for security reasons (HTML injections in $()).
+ *
+ * @ignore
+ * @param {string} name the name of a tab without the prefix ("mw-prefsection-")
+ * @param {string} [mode] A hash will be set according to the current
+ * open section. Set mode 'noHash' to surpress this.
+ */
+ function switchPrefTab( name, mode ) {
+ var $tab, scrollTop;
+ // Handle hash manually to prevent jumping,
+ // therefore save and restore scrollTop to prevent jumping.
+ scrollTop = $( window ).scrollTop();
+ if ( mode !== 'noHash' ) {
+ location.hash = '#mw-prefsection-' + name;
+ }
+ $( window ).scrollTop( scrollTop );
+
+ $preftoc.find( 'li' ).removeClass( 'selected' )
+ .find( 'a' ).attr( {
+ tabIndex: -1,
+ 'aria-selected': 'false'
+ } );
+
+ $tab = $( document.getElementById( 'preftab-' + name ) );
+ if ( $tab.length ) {
+ $tab.attr( {
+ tabIndex: 0,
+ 'aria-selected': 'true'
+ } )
+ .focus()
+ .parent().addClass( 'selected' );
+
+ $preferences.children( 'fieldset' ).hide().attr( 'aria-hidden', 'true' );
+ $( document.getElementById( 'mw-prefsection-' + name ) ).show().attr( 'aria-hidden', 'false' );