Disable Preferences save button before setting change
authorGeoffrey Mon <geofbot@gmail.com>
Sun, 7 Jun 2015 01:03:37 +0000 (21:03 -0400)
committerSn1per <geofbot@gmail.com>
Fri, 12 Jun 2015 18:00:00 +0000 (18:00 +0000)
Disable the Special:Preferences 'Save' button if no
settings have been changed (uses keydown and mousedown
events as an alternative to change event, so is not perfect)
This prevents unnecessary saving when you can't remember
if you saved the settings or not.

Bug: T89457
Change-Id: I7c2e11302099280c561e435425b23afb9fb760b5

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

index fa9e452..a385ad3 100644 (file)
@@ -110,6 +110,12 @@ jQuery( function ( $ ) {
                $preftoc.append( $li );
        } );
 
+       // Disable the button to save preferences unless preferences have changed
+       $( '#prefcontrol' ).prop( 'disabled', true );
+       $( '.prefsection' ).one( 'change keydown mousedown', function () {
+               $( '#prefcontrol' ).prop( 'disabled', false);
+       } );
+
        // Enable keyboard users to use left and right keys to switch tabs
        $preftoc.on( 'keydown', function ( event ) {
                var keyLeft = 37,