Special:Preference: Check for changes before enabling Save button
authorPrateek Saxena <prtksxna@gmail.com>
Mon, 2 Apr 2018 05:08:22 +0000 (10:38 +0530)
committerPrateek Saxena <prtksxna@gmail.com>
Mon, 2 Apr 2018 05:08:22 +0000 (10:38 +0530)
* Changing mousedown and keydown to mouseup and keyup
  …so that isPrefsChanged gets the updated value and can return
  something useful

* Changing one to on
  …so that if a value is updated and then changed back to the
  original, the button can be disabled again

Bug: T180538
Change-Id: I7146f8d3166e09e13b26321e7a6a7c8ac74f9aaf

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

index 45df37f..1b8d6d9 100644 (file)
 
                // 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 );
-                       } );
-               }
+               $( '#prefcontrol' ).prop( 'disabled', !isPrefsChanged() );
+               $( '#preferences > fieldset' ).on( 'change keyup mouseup', function () {
+                       $( '#prefcontrol' ).prop( 'disabled', !isPrefsChanged() );
+               } );
 
                // Set up a message to notify users if they try to leave the page without
                // saving.