-
/*!
* JavaScript for Special:Preferences
*/
}
}
- // If there is a #mw-preferences-success box and javascript is enabled, use a slick notification instead!
- if ( $( '#mw-preferences-success' ).length ) {
- notif = mediaWiki.notification.notify( mediaWiki.message( 'savedprefs' ), { autoHide: false } );
- $( '#preftoc, .prefsection' ).one( 'change keydown mousedown', function () { // 'change' event not reliable!
- if ( notif ) {
- notif.close();
- }
- } );
+ // Check for messageboxes (.successbox, .warningbox, .errorbox) to replace with notifications
+ if ( $( '.mw-preferences-messagebox' ).length ) {
+ // If there is a #mw-preferences-success box and javascript is enabled, use a slick notification instead!
+ if ( $( '#mw-preferences-success' ).length ) {
+ notif = mediaWiki.notification.notify( mediaWiki.message( 'savedprefs' ), { autoHide: false } );
+ // 'change' event not reliable!
+ $( '#preftoc, .prefsection' ).one( 'change keydown mousedown', function () {
+ if ( notif ) {
+ notif.close();
+ notif = null;
+ }
+ } );
- // Remove now-unnecessary success=1 querystring to prevent reappearance of notification on reload
- if ( history.replaceState ) {
- history.replaceState( {}, document.title, document.URL.replace( /&?success=1/, '' ) );
+ // Remove now-unnecessary success=1 querystring to prevent reappearance of notification on reload
+ if ( history.replaceState ) {
+ history.replaceState( {}, document.title, location.href.replace( /&?success=1/, '' ) );
+ }
}
}
// Disable the button to save preferences unless preferences have changed
$( '#prefcontrol' ).prop( 'disabled', true );
$( '.prefsection' ).one( 'change keydown mousedown', function () {
- $( '#prefcontrol' ).prop( 'disabled', false);
+ $( '#prefcontrol' ).prop( 'disabled', false );
} );
// Enable keyboard users to use left and right keys to switch tabs