diff --git a/resources/css/ext.uls.languagesettings.css b/resources/css/ext.uls.languagesettings.css index 7c5e61f5..b7a1b94c 100644 --- a/resources/css/ext.uls.languagesettings.css +++ b/resources/css/ext.uls.languagesettings.css @@ -92,7 +92,7 @@ background-color: #F5F5F5; } -#languagesettings-settings-panel .language-settings-buttons { +.language-settings-buttons { border-top: 1px solid #F0F0F0; margin-top: 25px; padding: 15px; diff --git a/resources/js/ext.uls.displaysettings.js b/resources/js/ext.uls.displaysettings.js index 3b7e6583..cfcbe45e 100644 --- a/resources/js/ext.uls.displaysettings.js +++ b/resources/js/ext.uls.displaysettings.js @@ -78,19 +78,9 @@ + '' // End font selectors - + '' // End font settings section + + ''; // End font settings section - // Separator - + '
' - // Apply and Cancel buttons - + '' - + ''; function DisplaySettings( $parent ) { this.name = $.i18n( 'ext-uls-display-settings-title-short' ); @@ -452,8 +442,7 @@ * i18n this settings panel */ i18n: function () { - this.$template.i18n(); - + this.$parent.i18n(); this.$template.find( '#ui-font-selector-label strong' ) .text( $.i18n( 'ext-uls-webfonts-select-for', $.uls.data.getAutonym( this.uiLanguage ) ) ); this.$template.find( '#content-font-selector-label strong' ) @@ -485,11 +474,11 @@ */ markDirty: function () { this.dirty = true; - this.$template.find( '#uls-displaysettings-apply' ).removeAttr( 'disabled' ); + this.$parent.$window.find( 'button.uls-settings-apply' ).removeAttr( 'disabled' ); }, disableApplyButton: function () { - this.$template.find( '#uls-displaysettings-apply' ).prop( 'disabled', true ); + this.$parent.$window.find( 'button.uls-settings-apply' ).prop( 'disabled', true ); }, /** @@ -503,15 +492,6 @@ // TODO all these repeated selectors can be placed in object constructor. - displaySettings.$template.find( '#uls-displaysettings-apply' ).on( 'click', function () { - displaySettings.apply(); - } ); - - displaySettings.$template.find( 'button.uls-display-settings-cancel' ).on( 'click', function () { - displaySettings.cancel(); - displaySettings.close(); - } ); - $uiFontSelector.on( 'change', function () { displaySettings.markDirty(); mw.webfonts.preferences.setFont( displaySettings.uiLanguage, @@ -551,7 +531,6 @@ } ); - mw.hook( 'mw.uls.settings.cancel' ).add( $.proxy( this.cancel, this ) ); }, /** @@ -624,6 +603,7 @@ */ cancel: function () { if ( !this.dirty ) { + this.close(); return; } // Reload preferences @@ -637,6 +617,7 @@ // Restore content and UI language this.uiLanguage = this.getUILanguage(); this.contentLanguage = this.getContentLanguage(); + this.close(); } }; diff --git a/resources/js/ext.uls.inputsettings.js b/resources/js/ext.uls.inputsettings.js index 81bafbc8..c5f8808f 100644 --- a/resources/js/ext.uls.inputsettings.js +++ b/resources/js/ext.uls.inputsettings.js @@ -53,18 +53,6 @@ + '' - + '' - - // Separator - + '' - - // Apply and Cancel buttons - + '' + ''; function InputSettings( $parent ) { @@ -76,6 +64,8 @@ this.$imes = null; this.$parent = $parent; this.savedRegistry = $.extend( true, {}, $.ime.preferences.registry ); + // ime system is lazy loaded, make sure it is initialized + mw.ime.init(); } InputSettings.prototype = { @@ -92,8 +82,6 @@ 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(); if ( $.ime.preferences.isEnabled() ) { $enabledOnly.removeClass( 'hide' ); } else { @@ -103,8 +91,7 @@ this.prepareLanguages(); this.prepareToggleButton(); - this.$template.i18n(); - this.disableApplyButton(); + this.$parent.i18n(); $( 'body' ).data( 'webfonts' ).refresh(); this.listen(); }, @@ -115,11 +102,11 @@ */ markDirty: function () { this.dirty = true; - this.$template.find( 'button.uls-input-settings-apply' ).prop( 'disabled', false ); + this.$parent.$window.find( 'button.uls-settings-apply' ).prop( 'disabled', false ); }, disableApplyButton: function () { - this.$template.find( 'button.uls-input-settings-apply' ).prop( 'disabled', true ); + this.$parent.$window.find( 'button.uls-settings-apply' ).prop( 'disabled', true ); }, prepareInputmethods: function ( language ) { @@ -446,16 +433,6 @@ $imeListContainer = this.$template.find( '.uls-input-settings-inputmethods-list' ); - // Apply and close buttons - inputSettings.$template.find( 'button.uls-input-settings-apply' ).on( 'click', function () { - inputSettings.apply(); - } ); - - inputSettings.$template.find( 'button.uls-input-settings-cancel' ).on( 'click', function () { - inputSettings.cancel(); - inputSettings.close(); - } ); - $imeListContainer.on( 'change', 'input:radio[name=ime]:checked', function () { inputSettings.markDirty(); $.ime.preferences.setIM( $( this ).val() ); @@ -472,7 +449,6 @@ } } ); - mw.hook( 'mw.uls.settings.cancel' ).add( $.proxy( this.cancel, this ) ); }, /** @@ -564,6 +540,7 @@ */ cancel: function () { if ( !this.dirty ) { + this.close(); return; } // Reload preferences @@ -576,6 +553,7 @@ } else { mw.ime.disable(); } + this.close(); } }; diff --git a/resources/js/ext.uls.languagesettings.js b/resources/js/ext.uls.languagesettings.js index 02bfafb2..6e408154 100644 --- a/resources/js/ext.uls.languagesettings.js +++ b/resources/js/ext.uls.languagesettings.js @@ -20,7 +20,7 @@ ( function ( $, mw ) { 'use strict'; - var closeRow, settingsMenu, settingsPanel, windowTemplate, panelsRow; + var closeRow, settingsMenu, settingsPanel, windowTemplate, panelsRow, buttonsRow; closeRow = '