From 0d9bbd811333ff5fdb080908d8cc2597da083253 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Mon, 26 Aug 2013 15:27:12 +0530 Subject: [PATCH] Make the behavior of close button same as cancel button Bug: 53255 Change-Id: If27a770c531d78538c70dd86199f1791b1171c2d --- resources/js/ext.uls.displaysettings.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/resources/js/ext.uls.displaysettings.js b/resources/js/ext.uls.displaysettings.js index 8023b586..26deb539 100644 --- a/resources/js/ext.uls.displaysettings.js +++ b/resources/js/ext.uls.displaysettings.js @@ -506,8 +506,6 @@ displaySettings.$template.find( 'button.uls-display-settings-cancel' ).on( 'click', function () { displaySettings.cancel(); - displaySettings.prepareUIFonts(); - displaySettings.prepareContentFonts(); displaySettings.close(); } ); @@ -566,13 +564,6 @@ * Depending on the context, actions vary. */ close: function () { - var origUILanguage = this.getUILanguage(); - - if ( $.i18n().locale !== origUILanguage ) { - // restore UI localization for display settings panel - $.i18n().locale = origUILanguage; - this.i18n(); - } this.$parent.close(); }, @@ -629,7 +620,8 @@ * Cancel the changes done by user for display settings */ cancel: function () { - var displaySettings = this; + var displaySettings = this, + origUILanguage = this.getUILanguage(); if ( !displaySettings.dirty ) { // Nothing changed @@ -642,6 +634,12 @@ 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(); @@ -650,6 +648,10 @@ 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 );