Set defaultValue property on tz box in Special:Preferences to fix change check
authorGeoffrey Mon <geofbot@gmail.com>
Sun, 17 Jan 2016 01:16:06 +0000 (20:16 -0500)
committerGeoffrey Mon <geofbot@gmail.com>
Sun, 17 Jan 2016 01:51:34 +0000 (20:51 -0500)
It is set client side on load, which causes changed preferences check to go off.

Bug: T122702
Change-Id: I030fd14a893373af879a51b90322dce1faa692ba

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

index 92064a6..29322f4 100644 (file)
                        var minuteDiff, localTime,
                                type = $tzSelect.val();
 
-                       if ( type === 'guess' ) {
-                               // Get browser timezone & fill it in
-                               minuteDiff = -( new Date().getTimezoneOffset() );
-                               $tzTextbox.val( minutesToHours( minuteDiff ) );
-                               $tzSelect.val( 'other' );
-                               $tzTextbox.prop( 'disabled', false );
-                       } else if ( type === 'other' ) {
+                       if ( type === 'other' ) {
+                               // User specified time zone manually in <input>
                                // Grab data from the textbox, parse it.
                                minuteDiff = hoursToMinutes( $tzTextbox.val() );
                        } else {
-                               // Grab data from the $tzSelect value
-                               minuteDiff = parseInt( type.split( '|' )[ 1 ], 10 ) || 0;
-                               $tzTextbox.val( minutesToHours( minuteDiff ) );
+                               // Time zone not manually specified by user
+                               if ( type === 'guess' ) {
+                                       // Get browser timezone & fill it in
+                                       minuteDiff = -( new Date().getTimezoneOffset() );
+                                       $tzTextbox.val( minutesToHours( minuteDiff ) );
+                                       $tzSelect.val( 'other' );
+                                       $tzTextbox.prop( 'disabled', false );
+                               } else {
+                                       // Grab data from the $tzSelect value
+                                       minuteDiff = parseInt( type.split( '|' )[ 1 ], 10 ) || 0;
+                                       $tzTextbox.val( minutesToHours( minuteDiff ) );
+                               }
+
+                               // Set defaultValue prop on the generated box so we don't trigger the
+                               // unsaved preferences check
+                               $tzTextbox.prop( 'defaultValue', $tzTextbox.val() );
                        }
 
                        // Determine local time from server time and minutes difference, for display.