jenkins-bot has submitted this change and it was merged.

Change subject: Revert "Simplify the cancel logic for input and display 
settings"
......................................................................


Revert "Simplify the cancel logic for input and display settings"

This reverts commit a5d79594a35bc5ff9e04bead8707890e53b5d932.

Causes new integration tests to fail.

Change-Id: I7e14d73d0d726a3253e8c6e6bdf5066230d8454c
---
M resources/js/ext.uls.displaysettings.js
M resources/js/ext.uls.inputsettings.js
M resources/js/ext.uls.languagesettings.js
3 files changed, 48 insertions(+), 11 deletions(-)

Approvals:
  Amire80: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/js/ext.uls.displaysettings.js 
b/resources/js/ext.uls.displaysettings.js
index b368044..26deb53 100644
--- a/resources/js/ext.uls.displaysettings.js
+++ b/resources/js/ext.uls.displaysettings.js
@@ -113,11 +113,9 @@
                        this.$parent.$settingsPanel.empty();
                        this.$webfonts = $( 'body' ).data( 'webfonts' );
                        this.$parent.$settingsPanel.append( this.$template );
-                       this.disableApplyButton();
                        this.prepareLanguages();
                        this.prepareUIFonts();
                        this.prepareContentFonts();
-                       $.i18n().locale = this.uiLanguage;
                        this.i18n();
                        this.$webfonts.refresh();
                        this.listen();
@@ -622,14 +620,48 @@
                 * Cancel the changes done by user for display settings
                 */
                cancel: function () {
-                       if ( !this.dirty ) {
+                       var displaySettings = this,
+                               origUILanguage = this.getUILanguage();
+
+                       if ( !displaySettings.dirty ) {
+                               // Nothing changed
                                return;
                        }
+
                        // Reload preferences
-                       mw.webfonts.preferences = $.extend( true, {}, 
this.savedRegistry );
+                       mw.webfonts.preferences = $.extend( true, {}, 
displaySettings.savedRegistry );
+                       if ( displaySettings.$webfonts ) {
+                               displaySettings.$webfonts.refresh();
+                       }
+
+                       if ( $.i18n().locale !== origUILanguage ) {
+                               // restore UI localization for display settings 
panel
+                               $.i18n().locale = origUILanguage;
+                               this.i18n();
+                       }
+
+                       // Clear the dirty bit
+                       displaySettings.dirty = false;
+                       displaySettings.disableApplyButton();
+
                        // Restore content and UI language
-                       this.uiLanguage = this.getUILanguage();
-                       this.contentLanguage = this.getContentLanguage();
+                       displaySettings.uiLanguage = 
displaySettings.getUILanguage();
+                       displaySettings.contentLanguage = 
displaySettings.getContentLanguage();
+
+                       // Restore the font dropdowns
+                       displaySettings.prepareUIFonts();
+                       displaySettings.prepareContentFonts();
+
+                       // Restore the visual state of selected language button
+                       displaySettings.$template.find( 'div.uls-ui-languages 
button.button' ).each( function () {
+                               var $button = $( this );
+
+                               if ( $button.attr( 'lang' ) === 
displaySettings.uiLanguage ) {
+                                       $button.addClass( 'down' );
+                               } else {
+                                       $button.removeClass( 'down' );
+                               }
+                       } );
                }
        };
 
diff --git a/resources/js/ext.uls.inputsettings.js 
b/resources/js/ext.uls.inputsettings.js
index 81bafbc..5afedae 100644
--- a/resources/js/ext.uls.inputsettings.js
+++ b/resources/js/ext.uls.inputsettings.js
@@ -75,6 +75,7 @@
                this.contentLanguage = this.getContentLanguage();
                this.$imes = null;
                this.$parent = $parent;
+               this.dirty = false;
                this.savedRegistry = $.extend( true, {}, 
$.ime.preferences.registry );
        }
 
@@ -87,10 +88,11 @@
                 */
                render: function () {
                        var $enabledOnly;
-                       this.dirty = false;
+
                        this.$parent.$settingsPanel.empty();
                        this.$imes = $( 'body' ).data( 'ime' );
                        this.$parent.$settingsPanel.append( this.$template );
+
                        $enabledOnly = this.$template.find( '.enabled-only' );
                        // ime system is lazy loaded, make sure it is 
initialized
                        mw.ime.init();
@@ -104,7 +106,6 @@
                        this.prepareLanguages();
                        this.prepareToggleButton();
                        this.$template.i18n();
-                       this.disableApplyButton();
                        $( 'body' ).data( 'webfonts' ).refresh();
                        this.listen();
                },
@@ -453,6 +454,8 @@
 
                        inputSettings.$template.find( 
'button.uls-input-settings-cancel' ).on( 'click', function () {
                                inputSettings.cancel();
+                               // Redraw the panel according to the state
+                               inputSettings.render();
                                inputSettings.close();
                        } );
 
@@ -566,10 +569,12 @@
                        if ( !this.dirty ) {
                                return;
                        }
+                       this.dirty = false;
+                       this.disableApplyButton();
+
                        // Reload preferences
                        $.ime.preferences.registry = $.extend( true, {}, 
this.savedRegistry );
-                       this.uiLanguage = this.getInterfaceLanguage();
-                       this.contentLanguage = this.getContentLanguage();
+
                        // Restore the state of IME
                        if ( $.ime.preferences.isEnabled() ) {
                                mw.ime.setup();
diff --git a/resources/js/ext.uls.languagesettings.js 
b/resources/js/ext.uls.languagesettings.js
index 02bfafb..b921fe2 100644
--- a/resources/js/ext.uls.languagesettings.js
+++ b/resources/js/ext.uls.languagesettings.js
@@ -173,7 +173,7 @@
 
                        // Every time we show this window, make sure the current
                        // settings panels is upto date. So just click on 
active menu item.
-                       this.$window.find( '.settings-menu-items > .active' 
).click();
+                       this.$window.find( '.input-settings-block.active' 
).click();
                        this.position();
                        this.visible();
                },

-- 
To view, visit https://gerrit.wikimedia.org/r/81216
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7e14d73d0d726a3253e8c6e6bdf5066230d8454c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to