Fix Bug 39686 - Cancel button in settings should go to the previous context
* Add an onClose option for language settings * Add a close method to language settings and display settings * some documentation and cleanup Change-Id: I3040e0740bd8a9f9f7d3ad508a3003415a24e7a9
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
* @licence MIT License
|
* @licence MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
( function ( $, mw, window, undefined ) {
|
( function( $, mw, undefined ) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var template = '<div class="row"><div class="twelve columns"><h3>Display settings</h3></div></div>'
|
var template = '<div class="row"><div class="twelve columns"><h3>Display settings</h3></div></div>'
|
||||||
@@ -193,9 +193,6 @@
|
|||||||
* @returns String Current UI language
|
* @returns String Current UI language
|
||||||
*/
|
*/
|
||||||
getUILanguage: function () {
|
getUILanguage: function () {
|
||||||
if ( !window.mw ) {
|
|
||||||
return window.navigator.language || window.navigator.userLanguage;
|
|
||||||
}
|
|
||||||
return mw.config.get( 'wgUserLanguage' );
|
return mw.config.get( 'wgUserLanguage' );
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -286,8 +283,7 @@
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
this.$template.find( 'button.uls-settings-close' ).on( 'click', function () {
|
this.$template.find( 'button.uls-settings-close' ).on( 'click', function () {
|
||||||
// FIXME This should actually go to the previous context than just hiding.
|
that.close();
|
||||||
that.hide();
|
|
||||||
} );
|
} );
|
||||||
|
|
||||||
this.$template.find( '#webfonts-enable-checkbox' ).on( 'click', function () {
|
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 () {
|
hide: function () {
|
||||||
this.$parent.hide();
|
this.$parent.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the language settings window.
|
||||||
|
* Depending on the context, actions vary.
|
||||||
|
*/
|
||||||
|
close: function () {
|
||||||
|
this.$parent.close();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for save preferences
|
* Callback for save preferences
|
||||||
*/
|
*/
|
||||||
@@ -360,6 +365,5 @@
|
|||||||
$.fn.languagesettings.modules = $.extend( $.fn.languagesettings.modules, {
|
$.fn.languagesettings.modules = $.extend( $.fn.languagesettings.modules, {
|
||||||
display: DisplaySettings
|
display: DisplaySettings
|
||||||
} );
|
} );
|
||||||
|
} ) ( jQuery, mediaWiki );
|
||||||
}( jQuery, mediaWiki, window ) );
|
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,10 @@
|
|||||||
uls.$menu.find( "div#settings-block" ).append( $displaySettings );
|
uls.$menu.find( "div#settings-block" ).append( $displaySettings );
|
||||||
var position = uls.position();
|
var position = uls.position();
|
||||||
$displaySettings.languagesettings( {
|
$displaySettings.languagesettings( {
|
||||||
|
defaultModule: $.fn.languagesettings.modules['display'],
|
||||||
|
onClose: function () {
|
||||||
|
uls.show();
|
||||||
|
},
|
||||||
top: position.top,
|
top: position.top,
|
||||||
left: position.left
|
left: position.left
|
||||||
} );
|
} );
|
||||||
|
|||||||
@@ -139,12 +139,28 @@
|
|||||||
this.$window.show();
|
this.$window.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide this window.
|
||||||
|
* Will be used when moving to a different context and
|
||||||
|
* need coming back.
|
||||||
|
*/
|
||||||
hide: function() {
|
hide: function() {
|
||||||
this.shown = false;
|
this.shown = false;
|
||||||
this.$window.hide();
|
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 ) {
|
if ( !this.shown ) {
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
@@ -168,12 +184,11 @@
|
|||||||
|
|
||||||
$.fn.languagesettings.modules = {};
|
$.fn.languagesettings.modules = {};
|
||||||
$.fn.languagesettings.defaults = {
|
$.fn.languagesettings.defaults = {
|
||||||
settings: {},
|
|
||||||
template: windowTemplate,
|
template: windowTemplate,
|
||||||
modules: {},
|
|
||||||
defaultModule: false,
|
defaultModule: false,
|
||||||
top: null,
|
onClose: null, // An onClose event handler.
|
||||||
left: null
|
top: null, // Top position of this window
|
||||||
|
left: null // Left position of this window
|
||||||
};
|
};
|
||||||
|
|
||||||
$.fn.languagesettings.Constructor = LanguageSettings;
|
$.fn.languagesettings.Constructor = LanguageSettings;
|
||||||
|
|||||||
Reference in New Issue
Block a user