diff --git a/resources/js/ext.uls.displaysettings.js b/resources/js/ext.uls.displaysettings.js
index 31ed9b2d..329997b0 100644
--- a/resources/js/ext.uls.displaysettings.js
+++ b/resources/js/ext.uls.displaysettings.js
@@ -17,7 +17,7 @@
* @licence MIT License
*/
-( function ( $, mw, window, undefined ) {
+( function( $, mw, undefined ) {
"use strict";
var template = '
'
@@ -193,9 +193,6 @@
* @returns String Current UI language
*/
getUILanguage: function () {
- if ( !window.mw ) {
- return window.navigator.language || window.navigator.userLanguage;
- }
return mw.config.get( 'wgUserLanguage' );
},
@@ -286,8 +283,7 @@
} );
this.$template.find( 'button.uls-settings-close' ).on( 'click', function () {
- // FIXME This should actually go to the previous context than just hiding.
- that.hide();
+ that.close();
} );
this.$template.find( '#webfonts-enable-checkbox' ).on( 'click', function () {
@@ -319,12 +315,21 @@
},
/**
- * Hide this window.2
+ * Hide this window.
+ * Used while navigating to language selector and need coming back
*/
hide: function () {
this.$parent.hide();
},
+ /**
+ * Close the language settings window.
+ * Depending on the context, actions vary.
+ */
+ close: function () {
+ this.$parent.close();
+ },
+
/**
* Callback for save preferences
*/
@@ -360,6 +365,5 @@
$.fn.languagesettings.modules = $.extend( $.fn.languagesettings.modules, {
display: DisplaySettings
} );
-
-}( jQuery, mediaWiki, window ) );
+} ) ( jQuery, mediaWiki );
diff --git a/resources/js/ext.uls.init.js b/resources/js/ext.uls.init.js
index 6631a15f..b4628fbc 100644
--- a/resources/js/ext.uls.init.js
+++ b/resources/js/ext.uls.init.js
@@ -110,6 +110,10 @@
uls.$menu.find( "div#settings-block" ).append( $displaySettings );
var position = uls.position();
$displaySettings.languagesettings( {
+ defaultModule: $.fn.languagesettings.modules['display'],
+ onClose: function () {
+ uls.show();
+ },
top: position.top,
left: position.left
} );
diff --git a/resources/js/ext.uls.languagesettings.js b/resources/js/ext.uls.languagesettings.js
index a30f6701..76b2b46a 100644
--- a/resources/js/ext.uls.languagesettings.js
+++ b/resources/js/ext.uls.languagesettings.js
@@ -139,12 +139,28 @@
this.$window.show();
},
+ /**
+ * Hide this window.
+ * Will be used when moving to a different context and
+ * need coming back.
+ */
hide: function() {
this.shown = false;
this.$window.hide();
},
- click: function ( e ) {
+ /**
+ * Close this language settings window, and
+ * call onClose if defined from the previous context.
+ */
+ close: function() {
+ this.hide();
+ if ( this.options.onClose ) {
+ this.options.onClose();
+ }
+ },
+
+ click: function( e ) {
if ( !this.shown ) {
this.show();
}
@@ -168,12 +184,11 @@
$.fn.languagesettings.modules = {};
$.fn.languagesettings.defaults = {
- settings: {},
template: windowTemplate,
- modules: {},
defaultModule: false,
- top: null,
- left: null
+ onClose: null, // An onClose event handler.
+ top: null, // Top position of this window
+ left: null // Left position of this window
};
$.fn.languagesettings.Constructor = LanguageSettings;