API: Use U+001F (Unit Separator) for separating multi-valued parameters
[lhc/web/wiklou.git] / resources / src / mediawiki.special / mediawiki.special.preferences.js
index 29322f4..163e85d 100644 (file)
@@ -3,10 +3,9 @@
  */
 ( function ( mw, $ ) {
        $( function () {
-               var $preftoc, $preferences, $fieldsets,
-                       labelFunc,
-                       $tzSelect, $tzTextbox, $localtimeHolder, servertime,
-                       allowCloseWindow, notif;
+               var $preftoc, $preferences, $fieldsets, labelFunc,
+                       $tzSelect, $tzTextbox, $localtimeHolder, servertime, allowCloseWindow,
+                       convertmessagebox = require( 'mediawiki.notification.convertmessagebox' );
 
                labelFunc = function () {
                        return this.id.replace( /^mw-prefsection/g, 'preftab' );
                        }
                }
 
-               // 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 = mw.notification.notify( mw.message( 'savedprefs' ), { autoHide: false } );
-                               // 'change' event not reliable!
-                               $( '#preftoc, .prefsection' ).one( 'change keydown mousedown', function () {
-                                       if ( notif ) {
-                                               notif.close();
-                                               notif = null;
-                                       }
-                               } );
-                       }
-               }
+               // Check for successbox to replace with notifications
+               convertmessagebox();
 
                // Enable keyboard users to use left and right keys to switch tabs
                $preftoc.on( 'keydown', function ( event ) {
 
                // Check if all of the form values are unchanged
                function isPrefsChanged() {
-                       var inputs = $( '#mw-prefs-form :input' ),
+                       var inputs = $( '#mw-prefs-form :input[name]' ),
                                input, $input, inputType,
                                index, optIndex,
                                opt;
                                $input = $( input );
 
                                // Different types of inputs have different methods for accessing defaults
-                               if ( $input.is( 'select' ) ) { // <select> has the property defaultSelected for each option
+                               if ( $input.is( 'select' ) ) {
+                                       // <select> has the property defaultSelected for each option
                                        for ( optIndex = 0; optIndex < input.options.length; optIndex++ ) {
                                                opt = input.options[ optIndex ];
                                                if ( opt.selected !== opt.defaultSelected ) {