Merge "Fire the ime-enable/disable hook upon saving the preferences"

This commit is contained in:
jenkins-bot
2013-08-20 08:55:24 +00:00
committed by Gerrit Code Review
3 changed files with 16 additions and 7 deletions

View File

@@ -110,16 +110,18 @@
/**
* Log IME disabling
* @param {string} context Where the setting was changed.
*/
disableIME: function () {
this.log( { action: 'ime-disable' } );
disableIME: function ( context ) {
this.log( { action: 'ime-disable', context: context } );
},
/**
* Log IME enabling
* @param {string} context Where the setting was changed.
*/
enableIME: function () {
this.log( { action: 'ime-enable' } );
enableIME: function ( context ) {
this.log( { action: 'ime-enable', context: context } );
},
/**

View File

@@ -81,13 +81,11 @@
disable: function () {
this.registry.isDirty = true;
this.registry.enable = false;
mw.hook( 'mw.uls.ime.disable' ).fire();
},
enable: function () {
this.registry.isDirty = true;
this.registry.enable = true;
mw.hook( 'mw.uls.ime.enable' ).fire();
},
isEnabled: function () {
@@ -152,6 +150,7 @@
$.ime.preferences.save( function () {
mw.ime.disable();
imeNotification();
mw.hook( 'mw.uls.ime.disable' ).fire( 'menu' );
} );
e.stopPropagation();
} );

View File

@@ -528,12 +528,20 @@
* Handle the apply button press
*/
apply: function () {
var inputSettings = this;
var toggleHookName,
inputSettings = this;
mw.hook( 'mw.uls.ime.change' ).fire(
$.ime.preferences.getIM( $.ime.preferences.getLanguage() )
);
if ( inputSettings.savedRegistry.enable !== $.ime.preferences.isEnabled() ) {
toggleHookName = $.ime.preferences.isEnabled() ?
'mw.uls.ime.enable' :
'mw.uls.ime.disable';
mw.hook( toggleHookName ).fire( 'inputsettings' );
}
// Save the preferences
$.ime.preferences.save( function ( result ) {
// closure for not losing the scope