Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1099 from timdream/keyboard-settingslistener

Fix #1096
  • Loading branch information...
commit 6910b54cbbf7c748f078e1036b9b36e448cf53d7 2 parents 4911bb3 + d6477c4
@andreasgal authored
Showing with 20 additions and 23 deletions.
  1. +20 −23 apps/homescreen/js/keyboard.js
View
43 apps/homescreen/js/keyboard.js
@@ -36,47 +36,44 @@ const IMEManager = {
'arabic': ['ar']
},
- enableSettingGroups: function enableSettingGroups(theKey) {
+ enableSetting: function km_enableSetting(theKey) {
if (this.settingGroups.indexOf(theKey) === -1)
this.settingGroups.push(theKey);
- this.keyboards = [];
- for (var key in this.keyboardSettingGroups) {
- if (this.settingGroups.indexOf(key) === -1)
- continue;
- this.keyboards = this.keyboards.concat(this.keyboardSettingGroups[key]);
- }
-
- if (this.keyboards.indexOf(this.currentKeyboard) === -1)
- this.currentKeyboard = this.keyboards[0];
-
- this.keyboards.forEach((function loadIMEngines(name) {
- this.loadKeyboard(name);
- }).bind(this));
+ this.updateSettings();
},
- disableSettingGroups: function enableSettingGroups(theKey) {
+ disableSetting: function km_disableSetting(theKey) {
var i = this.settingGroups.indexOf(theKey);
- if (i === -1)
+ if (i === -1) {
+ this.updateSettings();
return;
+ }
this.settingGroups = [].concat(
this.settingGroups.slice(0, i),
this.settingGroups.slice(i + 1, this.settingGroups.length));
+ this.updateSettings();
+ },
+
+ updateSettings: function km_updateSettings() {
this.keyboards = [];
for (var key in this.keyboardSettingGroups) {
- if (this.settingGroups.indexOf(key) !== -1)
- this.keyboards = this.keyboards.concat(
- this.keyboardSettingGroups[key]);
+ if (this.settingGroups.indexOf(key) === -1)
+ continue;
+ this.keyboards = this.keyboards.concat(this.keyboardSettingGroups[key]);
}
if (!this.keyboards.length)
- this.keyboards = [].concat(this.keyboardSettingGroups['english'],
- this.keyboardSettingGroups['zhuyin']);
+ this.keyboards = [].concat(this.keyboardSettingGroups['english']);
if (this.keyboards.indexOf(this.currentKeyboard) === -1)
this.currentKeyboard = this.keyboards[0];
+
+ this.keyboards.forEach((function loadIMEngines(name) {
+ this.loadKeyboard(name);
+ }).bind(this));
},
currentType: 'text',
@@ -422,9 +419,9 @@ const IMEManager = {
'keyboard.layouts.' + key, false,
function(value) {
if (value)
- self.enableSettingGroups(key);
+ self.enableSetting(key);
else
- self.disableSettingGroups(key);
+ self.disableSetting(key);
}
);
})(key);
Please sign in to comment.
Something went wrong with that request. Please try again.