Disable Preferences save button if settings have not changed
authorGeoffrey Mon <geofbot@gmail.com>
Fri, 27 Nov 2015 16:53:39 +0000 (11:53 -0500)
committerTheDJ <hartman.wiki@gmail.com>
Sat, 26 Dec 2015 00:01:16 +0000 (00:01 +0000)
Disable the Special:Preferences 'Save' button if no
settings have been changed. This prevents unnecessary saving when
you can't remember if you saved the settings or not.
Uses new check for preference change to prevent disabling the button
if the user makes preferences changes before JS is done loading.

Bug: T89457
Change-Id: I1064c5e76a3c1f856b9b9288baaf39cc102edf8a

resources/src/mediawiki.special/mediawiki.special.preferences.js

index 7f3de38..c2b9a4f 100644 (file)
                        return false;
                }
 
+               // Disable the button to save preferences unless preferences have changed
+               // Check if preferences have been changed before JS has finished loading
+               if ( !isPrefsChanged() ) {
+                       $( '#prefcontrol' ).prop( 'disabled', true );
+                       $( '#preferences > fieldset' ).one( 'change keydown mousedown', function () {
+                               $( '#prefcontrol' ).prop( 'disabled', false );
+                       } );
+               }
+
                // Set up a message to notify users if they try to leave the page without
                // saving.
                allowCloseWindow = mw.confirmCloseWindow( {