Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(734)

Side by Side Diff: third_party/google_input_tools/src/chrome/os/inputview/controller.js

Issue 828063007: Uprev Google Input Tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update extensions schema. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved. 1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License. 2 // limitations under the License.
3 // See the License for the specific language governing permissions and 3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS, 5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software 6 // Unless required by applicable law or agreed to in writing, software
7 // 7 //
8 // http://www.apache.org/licenses/LICENSE-2.0 8 // http://www.apache.org/licenses/LICENSE-2.0
9 // 9 //
10 // You may obtain a copy of the License at 10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License. 11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License"); 12 // Licensed under the Apache License, Version 2.0 (the "License");
13 // 13 //
14 goog.provide('i18n.input.chrome.inputview.Controller'); 14 goog.provide('i18n.input.chrome.inputview.Controller');
15 15
16 goog.require('goog.Disposable'); 16 goog.require('goog.Disposable');
17 goog.require('goog.Timer'); 17 goog.require('goog.Timer');
18 goog.require('goog.array'); 18 goog.require('goog.array');
19 goog.require('goog.async.Delay'); 19 goog.require('goog.async.Delay');
20 goog.require('goog.dom');
21 goog.require('goog.dom.classlist'); 20 goog.require('goog.dom.classlist');
21 goog.require('goog.events.Event');
22 goog.require('goog.events.EventHandler'); 22 goog.require('goog.events.EventHandler');
23 goog.require('goog.events.EventType'); 23 goog.require('goog.events.EventType');
24 goog.require('goog.i18n.bidi'); 24 goog.require('goog.i18n.bidi');
25 goog.require('goog.object'); 25 goog.require('goog.object');
26 goog.require('i18n.input.chrome.DataSource'); 26 goog.require('i18n.input.chrome.DataSource');
27 goog.require('i18n.input.chrome.Statistics'); 27 goog.require('i18n.input.chrome.Statistics');
28 goog.require('i18n.input.chrome.inputview.Adapter'); 28 goog.require('i18n.input.chrome.inputview.Adapter');
29 goog.require('i18n.input.chrome.inputview.CandidatesInfo'); 29 goog.require('i18n.input.chrome.inputview.CandidatesInfo');
30 goog.require('i18n.input.chrome.inputview.ConditionName'); 30 goog.require('i18n.input.chrome.inputview.ConditionName');
31 goog.require('i18n.input.chrome.inputview.Css'); 31 goog.require('i18n.input.chrome.inputview.Css');
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 i18n.input.chrome.inputview.events.EventType.CONTEXT_BLUR, 453 i18n.input.chrome.inputview.events.EventType.CONTEXT_BLUR,
454 this.onContextBlur_). 454 this.onContextBlur_).
455 listen(this.adapter_, 455 listen(this.adapter_,
456 i18n.input.chrome.inputview.events.EventType.VISIBILITY_CHANGE, 456 i18n.input.chrome.inputview.events.EventType.VISIBILITY_CHANGE,
457 this.onVisibilityChange_). 457 this.onVisibilityChange_).
458 listen(this.adapter_, 458 listen(this.adapter_,
459 i18n.input.chrome.inputview.events.EventType.SETTINGS_READY, 459 i18n.input.chrome.inputview.events.EventType.SETTINGS_READY,
460 this.onSettingsReady_). 460 this.onSettingsReady_).
461 listen(this.adapter_, Type.UPDATE_SETTINGS, this.onUpdateSettings_). 461 listen(this.adapter_, Type.UPDATE_SETTINGS, this.onUpdateSettings_).
462 listen(this.adapter_, Type.FRONT_TOGGLE_LANGUAGE_STATE, 462 listen(this.adapter_, Type.FRONT_TOGGLE_LANGUAGE_STATE,
463 this.onUpdateToggleLanguateState_); 463 this.onUpdateToggleLanguateState_).
464 listen(this.adapter_, Type.VOICE_STATE_CHANGE, this.onVoiceStateChange_);
464 }; 465 };
465 466
466 467
468 /**
469 * Handler for voice module state change.
470 *
471 * @param {!i18n.input.chrome.message.Event} e .
472 * @private
473 */
474 Controller.prototype.onVoiceStateChange_ = function(e) {
475 var elem = this.container_.getElement();
476 if (!e.msg[Name.VOICE_STATE]) {
477 this.container_.candidateView.switchToIcon(
478 CandidateView.IconType.VOICE, true);
479 this.container_.voiceView.stop();
480 }
481 };
482
483
484 /**
485 * Sets the default keyset for context types.
486 *
487 * @param {string} newKeyset .
488 * @private
489 */
490 Controller.prototype.setDefaultKeyset_ = function(newKeyset) {
491 var keysetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_];
492 for (var context in keysetMap) {
493 if (context != ContextType.DEFAULT &&
494 keysetMap[context] == keysetMap[ContextType.DEFAULT]) {
495 keysetMap[context] = newKeyset;
496 }
497 }
498 keysetMap[ContextType.DEFAULT] = this.initialKeyset_ = newKeyset;
499 };
500
501
467 /** 502 /**
468 * Callback for updating settings. 503 * Callback for updating settings.
469 * 504 *
470 * @param {!i18n.input.chrome.message.Event} e . 505 * @param {!i18n.input.chrome.message.Event} e .
471 * @private 506 * @private
472 */ 507 */
473 Controller.prototype.onUpdateSettings_ = function(e) { 508 Controller.prototype.onUpdateSettings_ = function(e) {
474 var settings = this.model_.settings; 509 var settings = this.model_.settings;
475 if (goog.isDef(e.msg['autoSpace'])) { 510 if (goog.isDef(e.msg['autoSpace'])) {
476 settings.autoSpace = e.msg['autoSpace']; 511 settings.autoSpace = e.msg['autoSpace'];
477 } 512 }
478 if (goog.isDef(e.msg['autoCapital'])) { 513 if (goog.isDef(e.msg['autoCapital'])) {
479 settings.autoCapital = e.msg['autoCapital']; 514 settings.autoCapital = e.msg['autoCapital'];
480 } 515 }
481 if (goog.isDef(e.msg['candidatesNavigation'])) { 516 if (goog.isDef(e.msg['candidatesNavigation'])) {
482 settings.candidatesNavigation = e.msg['candidatesNavigation']; 517 settings.candidatesNavigation = e.msg['candidatesNavigation'];
483 } 518 }
484 if (goog.isDef(e.msg[Name.KEYSET])) { 519 if (goog.isDef(e.msg[Name.KEYSET])) {
485 this.contextTypeToKeysetMap_[this.currentInputMethod_][ 520 this.setDefaultKeyset_(e.msg[Name.KEYSET]);
486 ContextType.DEFAULT] = this.initialKeyset_ = e.msg[Name.KEYSET];
487 } 521 }
488 if (goog.isDef(e.msg['enableLongPress'])) { 522 if (goog.isDef(e.msg['enableLongPress'])) {
489 settings.enableLongPress = e.msg['enableLongPress']; 523 settings.enableLongPress = e.msg['enableLongPress'];
490 } 524 }
491 if (goog.isDef(e.msg['doubleSpacePeriod'])) { 525 if (goog.isDef(e.msg['doubleSpacePeriod'])) {
492 settings.doubleSpacePeriod = e.msg['doubleSpacePeriod']; 526 settings.doubleSpacePeriod = e.msg['doubleSpacePeriod'];
493 } 527 }
494 if (goog.isDef(e.msg['soundOnKeypress'])) { 528 if (goog.isDef(e.msg['soundOnKeypress'])) {
495 settings.soundOnKeypress = e.msg['soundOnKeypress']; 529 settings.soundOnKeypress = e.msg['soundOnKeypress'];
496 this.soundController_.setEnabled(settings.soundOnKeypress); 530 this.soundController_.setEnabled(settings.soundOnKeypress);
497 } 531 }
498 this.perfTracker_.tick(PerfTracker.TickName.BACKGROUND_SETTINGS_FETCHED); 532 this.perfTracker_.tick(PerfTracker.TickName.BACKGROUND_SETTINGS_FETCHED);
499 this.model_.stateManager.contextType = this.adapter_.contextType; 533 this.model_.stateManager.contextType = this.adapter_.contextType;
500 this.switchToKeyset(this.getActiveKeyset_()); 534 this.maybeCreateViews_();
501 }; 535 };
502 536
503 537
504 /** 538 /**
505 * Callback for setting ready. 539 * Callback for setting ready.
506 * 540 *
507 * @private 541 * @private
508 */ 542 */
509 Controller.prototype.onSettingsReady_ = function() { 543 Controller.prototype.onSettingsReady_ = function() {
510 if (this.isSettingReady) { 544 if (this.isSettingReady) {
511 return; 545 return;
512 } 546 }
513 547
514 this.isSettingReady = true; 548 this.isSettingReady = true;
515 var keysetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_]; 549 var keysetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_];
550 var newKeyset = '';
516 if (this.adapter_.isA11yMode) { 551 if (this.adapter_.isA11yMode) {
517 keysetMap[ContextType.PASSWORD] = keysetMap[ContextType.DEFAULT] = 552 newKeyset = util.getConfigName(keysetMap[ContextType.DEFAULT]);
518 util.getConfigName(keysetMap[ContextType.DEFAULT]);
519 } else { 553 } else {
520 var preferredKeyset = /** @type {string} */ (this.model_.settings. 554 newKeyset = /** @type {string} */ (this.model_.settings.
521 getPreference(util.getConfigName(keysetMap[ContextType.DEFAULT]))); 555 getPreference(util.getConfigName(keysetMap[ContextType.DEFAULT])));
522 if (preferredKeyset) {
523 keysetMap[ContextType.PASSWORD] = keysetMap[ContextType.DEFAULT] =
524 preferredKeyset;
525 }
526 } 556 }
527 if (!this.adapter_.isExperimental && keysetMap[ContextType.DEFAULT] == 557 if (!this.adapter_.isExperimental && keysetMap[ContextType.DEFAULT] ==
528 'zhuyin.compact.qwerty') { 558 'zhuyin.compact.qwerty') {
529 keysetMap[ContextType.DEFAULT] = 'zhuyin'; 559 newKeyset = 'zhuyin';
530 } 560 }
531 this.initialKeyset_ = keysetMap[ContextType.DEFAULT]; 561 if (newKeyset) {
562 this.setDefaultKeyset_(newKeyset);
563 }
564 // Loads resources in case the default keyset is changed.
565 this.loadAllResources_();
532 this.maybeCreateViews_(); 566 this.maybeCreateViews_();
533 }; 567 };
534 568
535 569
536 /** 570 /**
537 * Gets the data for spatial module. 571 * Gets the data for spatial module.
538 * 572 *
539 * @param {!content.SoftKey} key . 573 * @param {!content.SoftKey} key .
540 * @param {number} x The x-offset of the touch point. 574 * @param {number} x The x-offset of the touch point.
541 * @param {number} y The y-offset of the touch point. 575 * @param {number} y The y-offset of the touch point.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 767
734 768
735 /** 769 /**
736 * Handles the pointer action. 770 * Handles the pointer action.
737 * 771 *
738 * @param {!i18n.input.chrome.inputview.elements.Element} view The view. 772 * @param {!i18n.input.chrome.inputview.elements.Element} view The view.
739 * @param {!i18n.input.chrome.inputview.events.PointerEvent} e . 773 * @param {!i18n.input.chrome.inputview.events.PointerEvent} e .
740 * @private 774 * @private
741 */ 775 */
742 Controller.prototype.handlePointerAction_ = function(view, e) { 776 Controller.prototype.handlePointerAction_ = function(view, e) {
777 // Listen for DOUBLE_CLICK as well to capture secondary taps on the spacebar.
778 if (e.type == EventType.POINTER_UP || e.type == EventType.DOUBLE_CLICK) {
779 this.recordStatsForClosing_(
780 'InputMethod.VirtualKeyboard.TapCount', 1, 4095, 4096);
781 }
782
743 if (e.type == i18n.input.chrome.inputview.events.EventType.SWIPE) { 783 if (e.type == i18n.input.chrome.inputview.events.EventType.SWIPE) {
744 e = /** @type {!i18n.input.chrome.inputview.events.SwipeEvent} */ (e); 784 e = /** @type {!i18n.input.chrome.inputview.events.SwipeEvent} */ (e);
745 this.handleSwipeAction_(view, e); 785 this.handleSwipeAction_(view, e);
746 } 786 }
747 switch (view.type) { 787 switch (view.type) {
748 case ElementType.BACK_BUTTON: 788 case ElementType.BACK_BUTTON:
749 if (e.type == EventType.POINTER_OUT || e.type == EventType.POINTER_UP) { 789 if (e.type == EventType.POINTER_OUT || e.type == EventType.POINTER_UP) {
750 view.setHighlighted(false); 790 view.setHighlighted(false);
751 } else if (e.type == EventType.POINTER_DOWN || 791 } else if (e.type == EventType.POINTER_DOWN ||
752 e.type == EventType.POINTER_OVER) { 792 e.type == EventType.POINTER_OVER) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 } 847 }
808 view.hide(); 848 view.hide();
809 this.clearUnstickyState_(); 849 this.clearUnstickyState_();
810 this.soundController_.onKeyUp(view.type); 850 this.soundController_.onKeyUp(view.type);
811 } 851 }
812 return; 852 return;
813 853
814 case ElementType.MENU_ITEM: 854 case ElementType.MENU_ITEM:
815 view = /** @type {!content.MenuItem} */ (view); 855 view = /** @type {!content.MenuItem} */ (view);
816 if (e.type == EventType.CLICK) { 856 if (e.type == EventType.CLICK) {
817 this.resetAll_();
818 this.executeCommand_.apply(this, view.getCommand()); 857 this.executeCommand_.apply(this, view.getCommand());
819 this.container_.menuView.hide(); 858 this.container_.menuView.hide();
820 this.soundController_.onKeyUp(view.type); 859 this.soundController_.onKeyUp(view.type);
860 this.resetAll_();
821 } 861 }
822 view.setHighlighted(e.type == EventType.POINTER_DOWN || 862 view.setHighlighted(e.type == EventType.POINTER_DOWN ||
823 e.type == EventType.POINTER_OVER); 863 e.type == EventType.POINTER_OVER);
824 // TODO: Add chrome vox support. 864 // TODO: Add chrome vox support.
825 return; 865 return;
826 866
827 case ElementType.MENU_VIEW: 867 case ElementType.MENU_VIEW:
828 view = /** @type {!MenuView} */ (view); 868 view = /** @type {!MenuView} */ (view);
829 869
830 if (e.type == EventType.POINTER_DOWN && 870 if (e.type == EventType.POINTER_DOWN &&
831 e.target == view.getCoverElement()) { 871 e.target == view.getCoverElement()) {
832 view.hide(); 872 view.hide();
833 } 873 }
834 return; 874 return;
835 875
836 case ElementType.EMOJI_KEY: 876 case ElementType.EMOJI_KEY:
837 if (e.type == EventType.POINTER_UP) { 877 if (e.type == EventType.CLICK) {
838 if (!this.container_.currentKeysetView.isDragging && view.text != '') { 878 if (!this.container_.currentKeysetView.isDragging && view.text != '') {
839 this.adapter_.commitText(view.text); 879 this.adapter_.commitText(view.text);
840 this.soundController_.onKeyUp(view.type); 880 this.soundController_.onKeyUp(view.type);
841 } 881 }
842 } 882 }
843 return; 883 return;
844 884
845 case ElementType.HWT_PRIVACY_GOT_IT: 885 case ElementType.HWT_PRIVACY_GOT_IT:
846 this.adapter_.sendHwtPrivacyConfirmMessage(); 886 // Broadcasts the handwriting privacy confirmed message to let canvas
887 // view handle it.
888 this.adapter_.dispatchEvent(new goog.events.Event(
889 Type.HWT_PRIVACY_GOT_IT));
890 return;
891
892 case ElementType.VOICE_PRIVACY_GOT_IT:
893 // Broadcasts the voice privacy confirmed message to let voice
894 // view handle it.
895 this.adapter_.dispatchEvent(new goog.events.Event(
896 Type.VOICE_PRIVACY_GOT_IT));
897 return;
898
899 case ElementType.VOICE_BTN:
900 if (e.type == EventType.CLICK) {
901 this.container_.candidateView.switchToIcon(
902 CandidateView.IconType.VOICE, false);
903 this.container_.voiceView.start();
904 }
905 return;
906
907
908 case ElementType.VOICE_VIEW:
909 if (e.type == EventType.POINTER_UP) {
910 this.adapter_.sendVoiceViewStateChange(false);
911 this.container_.candidateView.switchToIcon(
912 CandidateView.IconType.VOICE, true);
913 this.container_.voiceView.stop();
914 }
847 return; 915 return;
848 916
849 case ElementType.SOFT_KEY_VIEW: 917 case ElementType.SOFT_KEY_VIEW:
850 // Delegates the events on the soft key view to its soft key. 918 // Delegates the events on the soft key view to its soft key.
851 view = /** @type {!i18n.input.chrome.inputview.elements.layout. 919 view = /** @type {!i18n.input.chrome.inputview.elements.layout.
852 SoftKeyView} */ (view); 920 SoftKeyView} */ (view);
853 if (!view.softKey) { 921 if (!view.softKey) {
854 return; 922 return;
855 } 923 }
856 view = view.softKey; 924 view = view.softKey;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 break; 961 break;
894 case ElementType.CANDIDATES_PAGE_DOWN: 962 case ElementType.CANDIDATES_PAGE_DOWN:
895 if (e.type == EventType.POINTER_UP) { 963 if (e.type == EventType.POINTER_UP) {
896 this.container_.expandedCandidateView.pageDown(); 964 this.container_.expandedCandidateView.pageDown();
897 } 965 }
898 break; 966 break;
899 case ElementType.CHARACTER_KEY: 967 case ElementType.CHARACTER_KEY:
900 key = /** @type {!content.CharacterKey} */ (softKey); 968 key = /** @type {!content.CharacterKey} */ (softKey);
901 if (e.type == EventType.LONG_PRESS) { 969 if (e.type == EventType.LONG_PRESS) {
902 this.container_.altDataView.show( 970 this.container_.altDataView.show(
903 key, goog.i18n.bidi.isRtlLanguage(this.languageCode_), 971 key, goog.i18n.bidi.isRtlLanguage(this.languageCode_));
904 this.adapter_.isExperimental);
905 } else if (e.type == EventType.POINTER_UP) { 972 } else if (e.type == EventType.POINTER_UP) {
906 this.model_.stateManager.triggerChording(); 973 this.model_.stateManager.triggerChording();
907 var ch = key.getActiveCharacter(); 974 var ch = key.getActiveCharacter();
908 this.adapter_.sendKeyDownAndUpEvent(ch, key.id, key.keyCode, 975 this.adapter_.sendKeyDownAndUpEvent(ch, key.id, key.keyCode,
909 this.getSpatialData_(key, e.x, e.y)); 976 this.getSpatialData_(key, e.x, e.y));
910 this.clearUnstickyState_(); 977 this.clearUnstickyState_();
911 key.flickerredCharacter = ''; 978 key.flickerredCharacter = '';
912 } 979 }
913 break; 980 break;
914 981
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 util.getConfigName(key.toKeyset), 1106 util.getConfigName(key.toKeyset),
1040 key.toKeyset); 1107 key.toKeyset);
1041 } 1108 }
1042 } 1109 }
1043 break; 1110 break;
1044 1111
1045 case ElementType.COMPACT_KEY: 1112 case ElementType.COMPACT_KEY:
1046 key = /** @type {!content.CompactKey} */ (softKey); 1113 key = /** @type {!content.CompactKey} */ (softKey);
1047 if (e.type == EventType.LONG_PRESS) { 1114 if (e.type == EventType.LONG_PRESS) {
1048 this.container_.altDataView.show( 1115 this.container_.altDataView.show(
1049 key, goog.i18n.bidi.isRtlLanguage(this.languageCode_), 1116 key, goog.i18n.bidi.isRtlLanguage(this.languageCode_));
1050 this.adapter_.isExperimental);
1051 } else if (e.type == EventType.POINTER_UP) { 1117 } else if (e.type == EventType.POINTER_UP) {
1052 this.model_.stateManager.triggerChording(); 1118 this.model_.stateManager.triggerChording();
1053 var ch = key.getActiveCharacter(); 1119 var ch = key.getActiveCharacter();
1054 if (ch.length == 1) { 1120 if (ch.length == 1) {
1055 this.adapter_.sendKeyDownAndUpEvent(key.getActiveCharacter(), '', 0, 1121 this.adapter_.sendKeyDownAndUpEvent(key.getActiveCharacter(), '', 0,
1056 this.getSpatialData_(key, e.x, e.y)); 1122 this.getSpatialData_(key, e.x, e.y));
1057 } else if (ch.length > 1) { 1123 } else if (ch.length > 1) {
1058 // Some compact keys contains more than 1 characters, such as '.com', 1124 // Some compact keys contains more than 1 characters, such as '.com',
1059 // 'http://', etc. Those keys should trigger a direct commit text 1125 // 'http://', etc. Those keys should trigger a direct commit text
1060 // instead of key events. 1126 // instead of key events.
1061 this.adapter_.commitText(ch); 1127 this.adapter_.commitText(ch);
1062 } 1128 }
1063 this.clearUnstickyState_(); 1129 this.clearUnstickyState_();
1064 key.flickerredCharacter = ''; 1130 key.flickerredCharacter = '';
1065 } 1131 }
1066 break; 1132 break;
1067 1133
1068 case ElementType.HIDE_KEYBOARD_KEY: 1134 case ElementType.HIDE_KEYBOARD_KEY:
1069 var defaultKeyset = this.getActiveKeyset_(); 1135 var defaultKeyset = this.getActiveKeyset_();
1070 if (e.type == EventType.POINTER_UP) { 1136 if (e.type == EventType.POINTER_UP) {
1071 this.adapter_.hideKeyboard(); 1137 this.adapter_.hideKeyboard();
1072 } 1138 if (this.currentKeyset_ != defaultKeyset) {
1073 if (this.currentKeyset_ != defaultKeyset) { 1139 this.switchToKeyset(defaultKeyset);
1074 this.switchToKeyset(defaultKeyset); 1140 }
1075 } 1141 }
1076 break; 1142 break;
1077 1143
1078 case ElementType.MENU_KEY: 1144 case ElementType.MENU_KEY:
1079 key = /** @type {!content.MenuKey} */ (softKey); 1145 key = /** @type {!content.MenuKey} */ (softKey);
1080 if (e.type == EventType.POINTER_DOWN) { 1146 if (e.type == EventType.POINTER_DOWN) {
1081 var isCompact = this.currentKeyset_.indexOf('compact') != -1; 1147 var isCompact = this.currentKeyset_.indexOf('compact') != -1;
1082 // Gets the default full keyboard instead of default keyset because 1148 // Gets the default full keyboard instead of default keyset because
1083 // the default keyset can be a compact keyset which would cause problem 1149 // the default keyset can be a compact keyset which would cause problem
1084 // in MenuView.show(). 1150 // in MenuView.show().
1085 var defaultFullKeyset = this.initialKeyset_.split(/\./)[0]; 1151 var defaultFullKeyset = this.initialKeyset_.split(/\./)[0];
1086 var enableCompact = !this.adapter_.isA11yMode && goog.array.contains( 1152 var enableCompact = !this.adapter_.isA11yMode && goog.array.contains(
1087 util.KEYSETS_HAVE_COMPACT, defaultFullKeyset); 1153 util.KEYSETS_HAVE_COMPACT, defaultFullKeyset);
1088 if (defaultFullKeyset == 'zhuyin' && !this.adapter_.isExperimental || 1154 if (defaultFullKeyset == 'zhuyin' && !this.adapter_.isExperimental ||
1089 this.languageCode_ == 'ko') { 1155 this.languageCode_ == 'ko') {
1090 // Hides 'switch to compact' for zhuyin when not in experimental env. 1156 // Hides 'switch to compact' for zhuyin when not in experimental env.
1091 enableCompact = false; 1157 enableCompact = false;
1092 } 1158 }
1093 var self = this; 1159 var self = this;
1094 var hasHwt = !this.adapter_.isPasswordBox() && 1160 var hasHwt = !this.adapter_.isPasswordBox() &&
1095 !Controller.DISABLE_HWT && goog.object.contains( 1161 !Controller.DISABLE_HWT && goog.object.contains(
1096 InputToolCode, this.getHwtInputToolCode_()) && 1162 InputToolCode, this.getHwtInputToolCode_());
1097 this.languageCode_ != 'ko';
1098 var hasEmoji = !this.adapter_.isPasswordBox(); 1163 var hasEmoji = !this.adapter_.isPasswordBox();
1099 var enableSettings = this.shouldEnableSettings() && 1164 var enableSettings = this.shouldEnableSettings() &&
1100 !!window.inputview && !!inputview.openSettings; 1165 !!window.inputview && !!inputview.openSettings;
1101 this.adapter_.getInputMethods(function(inputMethods) { 1166 this.adapter_.getInputMethods(function(inputMethods) {
1102 this.container_.menuView.show(key, defaultFullKeyset, isCompact, 1167 this.container_.menuView.show(key, defaultFullKeyset, isCompact,
1103 enableCompact, this.currentInputMethod_, inputMethods, hasHwt, 1168 enableCompact, this.currentInputMethod_, inputMethods, hasHwt,
1104 enableSettings, hasEmoji); 1169 enableSettings, hasEmoji);
1105 }.bind(this)); 1170 }.bind(this));
1106 } 1171 }
1107 break; 1172 break;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 Controller.prototype.resetAll_ = function() { 1279 Controller.prototype.resetAll_ = function() {
1215 this.clearCandidates_(); 1280 this.clearCandidates_();
1216 this.container_.cleanStroke(); 1281 this.container_.cleanStroke();
1217 this.model_.stateManager.reset(); 1282 this.model_.stateManager.reset();
1218 this.container_.update(); 1283 this.container_.update();
1219 this.updateContextModifierState_(); 1284 this.updateContextModifierState_();
1220 this.deadKey_ = ''; 1285 this.deadKey_ = '';
1221 this.resize(); 1286 this.resize();
1222 this.container_.expandedCandidateView.close(); 1287 this.container_.expandedCandidateView.close();
1223 this.container_.menuView.hide(); 1288 this.container_.menuView.hide();
1289 this.container_.altDataView.hide();
1224 }; 1290 };
1225 1291
1226 1292
1227 /** 1293 /**
1228 * Callback when the context is changed. 1294 * Callback when the context is changed.
1229 * 1295 *
1230 * @private 1296 * @private
1231 */ 1297 */
1232 Controller.prototype.onContextFocus_ = function() { 1298 Controller.prototype.onContextFocus_ = function() {
1233 this.resetAll_(); 1299 this.resetAll_();
(...skipping 24 matching lines...) Expand all
1258 } 1324 }
1259 }; 1325 };
1260 1326
1261 1327
1262 /** 1328 /**
1263 * Callback for Context blurs. 1329 * Callback for Context blurs.
1264 * 1330 *
1265 * @private 1331 * @private
1266 */ 1332 */
1267 Controller.prototype.onContextBlur_ = function() { 1333 Controller.prototype.onContextBlur_ = function() {
1268 this.clearCandidates_();
1269 this.container_.cleanStroke(); 1334 this.container_.cleanStroke();
1270 this.deadKey_ = ''; 1335 this.deadKey_ = '';
1271 this.container_.menuView.hide(); 1336 this.container_.menuView.hide();
1272 }; 1337 };
1273 1338
1274 1339
1275 /** 1340 /**
1276 * Backspace key is down. 1341 * Backspace key is down.
1277 * 1342 *
1278 * @private 1343 * @private
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 */ 1494 */
1430 Controller.prototype.clearCandidates_ = function() { 1495 Controller.prototype.clearCandidates_ = function() {
1431 this.candidatesInfo_ = i18n.input.chrome.inputview.CandidatesInfo.getEmpty(); 1496 this.candidatesInfo_ = i18n.input.chrome.inputview.CandidatesInfo.getEmpty();
1432 this.container_.candidateView.clearCandidates(); 1497 this.container_.candidateView.clearCandidates();
1433 this.container_.expandedCandidateView.close(); 1498 this.container_.expandedCandidateView.close();
1434 this.container_.expandedCandidateView.state = ExpandedCandidateView.State. 1499 this.container_.expandedCandidateView.state = ExpandedCandidateView.State.
1435 NONE; 1500 NONE;
1436 if (this.container_.currentKeysetView) { 1501 if (this.container_.currentKeysetView) {
1437 this.container_.currentKeysetView.setVisible(true); 1502 this.container_.currentKeysetView.setVisible(true);
1438 } 1503 }
1439 this.container_.candidateView.switchToIcon(CandidateView.IconType.BACK, 1504 if (this.currentKeyset_ == Controller.HANDWRITING_VIEW_CODE_) {
1440 Controller.HANDWRITING_VIEW_CODE_ == this.currentKeyset_); 1505 this.container_.candidateView.switchToIcon(
1506 CandidateView.IconType.BACK, true);
1507 } else {
1508 this.container_.candidateView.switchToIcon(CandidateView.IconType.VOICE,
1509 this.currentKeyset_ != Controller.EMOJI_VIEW_CODE_ &&
1510 this.adapter_.isExperimental);
1511 }
1441 }; 1512 };
1442 1513
1443 1514
1444 /** 1515 /**
1445 * Callback when the layout is loaded. 1516 * Callback when the layout is loaded.
1446 * 1517 *
1447 * @param {!i18n.input.chrome.inputview.events.LayoutLoadedEvent} e The event. 1518 * @param {!i18n.input.chrome.inputview.events.LayoutLoadedEvent} e The event.
1448 * @private 1519 * @private
1449 */ 1520 */
1450 Controller.prototype.onLayoutLoaded_ = function(e) { 1521 Controller.prototype.onLayoutLoaded_ = function(e) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1495 /** 1566 /**
1496 * Creates the whole view. 1567 * Creates the whole view.
1497 * 1568 *
1498 * @private 1569 * @private
1499 */ 1570 */
1500 Controller.prototype.maybeCreateViews_ = function() { 1571 Controller.prototype.maybeCreateViews_ = function() {
1501 if (!this.isSettingReady) { 1572 if (!this.isSettingReady) {
1502 return; 1573 return;
1503 } 1574 }
1504 1575
1505 var activeKeyset = this.getActiveKeyset_(); 1576 // Emoji is temp keyset which is delay loaded. So active keyset can be 'us'
1577 // while current keyset is 'emoji'. To make sure delay load can work
1578 // correctly, here need to create/switch to 'emoji' instead of 'us'.
1579 var activeKeyset = (this.currentKeyset_ == Controller.EMOJI_VIEW_CODE_) ?
1580 this.currentKeyset_ : this.getActiveKeyset_();
1506 var remappedActiveKeyset = this.getRemappedKeyset_(activeKeyset); 1581 var remappedActiveKeyset = this.getRemappedKeyset_(activeKeyset);
1582 var created = false;
1507 if (this.keysetDataMap_[remappedActiveKeyset]) { 1583 if (this.keysetDataMap_[remappedActiveKeyset]) {
1508 this.createView_(remappedActiveKeyset); 1584 this.createView_(remappedActiveKeyset);
1509 this.switchToKeyset(activeKeyset); 1585 this.switchToKeyset(activeKeyset);
1586 created = true;
1510 } 1587 }
1511 // Async creating the non-active keysets to reduce the latency of showing the 1588 // Async creating the non-active keysets to reduce the latency of showing the
1512 // active keyset. 1589 // active keyset.
1513 goog.Timer.callOnce((function() { 1590 var keyLen = Object.keys(this.keysetDataMap_).length;
1514 for (var keyset in this.keysetDataMap_) { 1591 if (created && keyLen > 1 || !created && keyLen > 0) {
1515 if (keyset != remappedActiveKeyset) { 1592 goog.Timer.callOnce((function() {
1593 for (var keyset in this.keysetDataMap_) {
1516 this.createView_(keyset); 1594 this.createView_(keyset);
1517 } 1595 }
1518 } 1596 }).bind(this));
1519 }).bind(this)); 1597 }
1520 }; 1598 };
1521 1599
1522 1600
1523 /** 1601 /**
1524 * Switch to a specific keyboard. 1602 * Switch to a specific keyboard.
1525 * 1603 *
1526 * @param {string} keyset The keyset name. 1604 * @param {string} keyset The keyset name.
1527 */ 1605 */
1528 Controller.prototype.switchToKeyset = function(keyset) { 1606 Controller.prototype.switchToKeyset = function(keyset) {
1529 if (!this.isSettingReady || this.adapter_.isSwitching()) { 1607 if (!this.isSettingReady || this.adapter_.isSwitching()) {
1530 return; 1608 return;
1531 } 1609 }
1532 1610
1533 var contextType = this.adapter_.contextType; 1611 var contextType = this.adapter_.contextType;
1534 var lastKeysetView = this.container_.currentKeysetView; 1612 var lastKeysetView = this.container_.currentKeysetView;
1535 var ret = this.container_.switchToKeyset(this.getRemappedKeyset_(keyset), 1613 var ret = this.container_.switchToKeyset(this.getRemappedKeyset_(keyset),
1536 this.title_, this.adapter_.isPasswordBox(), this.adapter_.isA11yMode, 1614 this.title_, this.adapter_.isPasswordBox(), this.adapter_.isA11yMode,
1537 keyset, this.contextTypeToLastKeysetMap_[contextType] || 1615 keyset, this.contextTypeToLastKeysetMap_[contextType] ||
1538 this.getActiveKeyset_(), this.languageCode_); 1616 this.getActiveKeyset_(), this.languageCode_);
1539 1617
1540 if (ret) { 1618 if (ret) {
1541 if (!this.isSubKeyset_(this.currentKeyset_, keyset) && 1619 if (!this.isSubKeyset_(this.currentKeyset_, keyset) &&
1542 keyset != Controller.EMOJI_VIEW_CODE_) { 1620 keyset != Controller.EMOJI_VIEW_CODE_) {
1543 // If it is the sub keyset switching, or emoji, don't record it. 1621 // If it is the sub keyset switching, or emoji, don't record it.
1544 // Update the keyset of current context type. 1622 // Update the keyset of current context type.
1545 this.contextTypeToKeysetMap_[this.currentInputMethod_][contextType] = 1623 this.contextTypeToKeysetMap_[this.currentInputMethod_][contextType] =
1546 keyset; 1624 keyset;
1547 } 1625 }
1548 this.updateLanguageState_(this.currentKeyset_, keyset); 1626 this.updateLanguageState_(this.currentKeyset_, keyset);
1627 this.currentKeyset_ = keyset;
1549 this.resize(Controller.DEV); 1628 this.resize(Controller.DEV);
1550 this.statistics_.recordLayout(keyset, this.adapter_.isA11yMode); 1629 this.statistics_.recordLayout(keyset, this.adapter_.isA11yMode);
1551 this.currentKeyset_ = keyset;
1552 this.perfTracker_.tick(PerfTracker.TickName.KEYBOARD_SHOWN); 1630 this.perfTracker_.tick(PerfTracker.TickName.KEYBOARD_SHOWN);
1553 this.perfTracker_.stop(); 1631 this.perfTracker_.stop();
1554 } else { 1632 } else {
1555 // Sets the current keyset for delay switching. 1633 // Sets the current keyset for delay switching.
1556 this.contextTypeToKeysetMap_[this.currentInputMethod_][contextType] = 1634 this.currentKeyset_ = keyset;
1557 this.currentKeyset_ = keyset; 1635 if (keyset != Controller.EMOJI_VIEW_CODE_) { // Emoji is temp keyset.
1636 this.contextTypeToKeysetMap_[this.currentInputMethod_][contextType] =
1637 keyset;
1638 }
1558 this.loadResource_(keyset); 1639 this.loadResource_(keyset);
1559 } 1640 }
1560 }; 1641 };
1561 1642
1562 1643
1563 /** 1644 /**
1564 * Callback when the configuration is loaded. 1645 * Callback when the configuration is loaded.
1565 * 1646 *
1566 * @param {!i18n.input.chrome.inputview.events.ConfigLoadedEvent} e The event. 1647 * @param {!i18n.input.chrome.inputview.events.ConfigLoadedEvent} e The event.
1567 * @private 1648 * @private
1568 */ 1649 */
1569 Controller.prototype.onConfigLoaded_ = function(e) { 1650 Controller.prototype.onConfigLoaded_ = function(e) {
1570 if (this.isDisposed()) { 1651 if (this.isDisposed()) {
1571 return; 1652 return;
1572 } 1653 }
1573 var data = e.data; 1654 var data = e.data;
1574 var keyboardCode = data[i18n.input.chrome.inputview.SpecNodeName.ID]; 1655 var keyboardCode = data[i18n.input.chrome.inputview.SpecNodeName.ID];
1575 this.keysetDataMap_[keyboardCode] = data; 1656 this.keysetDataMap_[keyboardCode] = data;
1576 this.perfTracker_.tick(PerfTracker.TickName.KEYSET_LOADED); 1657 this.perfTracker_.tick(PerfTracker.TickName.KEYSET_LOADED);
1577 var context = data[i18n.input.chrome.inputview.SpecNodeName.ON_CONTEXT]; 1658 var context = data[i18n.input.chrome.inputview.SpecNodeName.ON_CONTEXT];
1578 if (context && !this.adapter_.isA11yMode) { 1659 if (context && !this.adapter_.isA11yMode) {
1579 var keySetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_]; 1660 var keySetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_];
1580 if (!keySetMap) { 1661 if (!keySetMap) {
1581 keySetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_] = {}; 1662 keySetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_] = {};
1582 } 1663 }
1583 keySetMap[context] = keyboardCode; 1664 keySetMap[context] = keyboardCode;
1584 } 1665 }
1585 1666
1586 var layoutId = data[i18n.input.chrome.inputview.SpecNodeName.LAYOUT]; 1667 var layoutId = data[i18n.input.chrome.inputview.SpecNodeName.LAYOUT];
1668 if (this.adapter_.isQPInputView && layoutId == 'compactkbd-qwerty') {
1669 layoutId = 'm-' + layoutId;
1670 data[i18n.input.chrome.inputview.SpecNodeName.LAYOUT] = layoutId;
1671 }
1587 var layoutData = this.layoutDataMap_[layoutId]; 1672 var layoutData = this.layoutDataMap_[layoutId];
1588 if (layoutData) { 1673 if (layoutData) {
1589 this.maybeCreateViews_(); 1674 this.maybeCreateViews_();
1590 } else { 1675 } else {
1591 this.model_.loadLayout(data[i18n.input.chrome.inputview.SpecNodeName. 1676 this.model_.loadLayout(layoutId);
1592 LAYOUT]);
1593 } 1677 }
1594 }; 1678 };
1595 1679
1596 1680
1597 /** 1681 /**
1598 * Resizes the whole UI. 1682 * Resizes the whole UI.
1599 * 1683 *
1600 * @param {boolean=} opt_ignoreWindowResize . 1684 * @param {boolean=} opt_ignoreWindowResize .
1601 */ 1685 */
1602 Controller.prototype.resize = function(opt_ignoreWindowResize) { 1686 Controller.prototype.resize = function(opt_ignoreWindowResize) {
1603 var height; 1687 var height;
1604 var widthPercent; 1688 var widthPercent;
1605 var candidateViewHeight; 1689 var candidateViewHeight;
1606 var isHorizontal = screen.width > screen.height; 1690 var isLandScape = screen.width > screen.height;
1691 if (isLandScape) {
1692 goog.dom.classlist.addRemove(this.container_.getElement(),
1693 Css.PORTRAIT, Css.LANDSCAPE);
1694 } else {
1695 goog.dom.classlist.addRemove(this.container_.getElement(),
1696 Css.LANDSCAPE, Css.PORTRAIT);
1697 }
1607 var isWideScreen = (Math.min(screen.width, screen.height) / Math.max( 1698 var isWideScreen = (Math.min(screen.width, screen.height) / Math.max(
1608 screen.width, screen.height)) < 0.6; 1699 screen.width, screen.height)) < 0.6;
1609 this.model_.stateManager.covariance.update(isWideScreen, isHorizontal, 1700 this.model_.stateManager.covariance.update(isWideScreen, isLandScape,
1610 this.adapter_.isA11yMode); 1701 this.adapter_.isA11yMode);
1611 if (this.adapter_.isA11yMode) { 1702 if (this.adapter_.isA11yMode) {
1612 height = SizeSpec.A11Y_HEIGHT; 1703 height = SizeSpec.A11Y_HEIGHT;
1613 widthPercent = screen.width > screen.height ? SizeSpec.A11Y_WIDTH_PERCENT. 1704 widthPercent = screen.width > screen.height ? SizeSpec.A11Y_WIDTH_PERCENT.
1614 LANDSCAPE : SizeSpec.A11Y_WIDTH_PERCENT.PORTRAIT; 1705 LANDSCAPE : SizeSpec.A11Y_WIDTH_PERCENT.PORTRAIT;
1615 candidateViewHeight = SizeSpec.A11Y_CANDIDATE_VIEW_HEIGHT; 1706 candidateViewHeight = SizeSpec.A11Y_CANDIDATE_VIEW_HEIGHT;
1616 } else { 1707 } else {
1617 var keyset = this.keysetDataMap_[this.currentKeyset_]; 1708 var keyset = this.keysetDataMap_[this.currentKeyset_];
1618 var layout = keyset && keyset[SpecNodeName.LAYOUT]; 1709 var layout = keyset && keyset[SpecNodeName.LAYOUT];
1619 var data = layout && this.layoutDataMap_[layout]; 1710 var data = layout && this.layoutDataMap_[layout];
1620 var spec = data && data[SpecNodeName.WIDTH_PERCENT] || 1711 var spec = data && data[SpecNodeName.WIDTH_PERCENT] ||
1621 SizeSpec.NON_A11Y_WIDTH_PERCENT; 1712 SizeSpec.NON_A11Y_WIDTH_PERCENT;
1622 height = SizeSpec.NON_A11Y_HEIGHT; 1713 height = SizeSpec.NON_A11Y_HEIGHT;
1623 if (isHorizontal) { 1714 if (isLandScape) {
1624 if (isWideScreen) { 1715 if (isWideScreen) {
1625 widthPercent = spec.LANDSCAPE_WIDE_SCREEN; 1716 widthPercent = spec['LANDSCAPE_WIDE_SCREEN'];
1626 } else { 1717 } else {
1627 widthPercent = spec.LANDSCAPE; 1718 widthPercent = spec['LANDSCAPE'];
1628 } 1719 }
1629 } else { 1720 } else {
1630 widthPercent = spec.PORTRAIT; 1721 widthPercent = spec['PORTRAIT'];
1631 } 1722 }
1632 candidateViewHeight = SizeSpec.NON_A11Y_CANDIDATE_VIEW_HEIGHT; 1723 candidateViewHeight = SizeSpec.NON_A11Y_CANDIDATE_VIEW_HEIGHT;
1633 } 1724 }
1634 1725
1635 var viewportSize = goog.dom.getViewportSize(); 1726 if (window.innerHeight != height && !opt_ignoreWindowResize) {
1636 if (viewportSize.height != height && !opt_ignoreWindowResize) {
1637 if (this.lastResizeHeight_ != height) { 1727 if (this.lastResizeHeight_ != height) {
1638 this.lastResizeHeight_ = height; 1728 this.lastResizeHeight_ = height;
1639 window.resizeTo(screen.width, height); 1729 window.resizeTo(screen.width, height);
1640 } 1730 }
1641 return; 1731 return;
1642 } 1732 }
1643 1733
1644 this.container_.resize(screen.width, height, widthPercent, 1734 this.container_.resize(screen.width, height, widthPercent,
1645 candidateViewHeight); 1735 candidateViewHeight);
1646 if (this.container_.currentKeysetView) { 1736 if (this.container_.currentKeysetView) {
(...skipping 19 matching lines...) Expand all
1666 1756
1667 /** 1757 /**
1668 * Gets the remapped keyset. 1758 * Gets the remapped keyset.
1669 * 1759 *
1670 * @param {string} keyset . 1760 * @param {string} keyset .
1671 * @return {string} The remapped keyset. 1761 * @return {string} The remapped keyset.
1672 * @private 1762 * @private
1673 */ 1763 */
1674 Controller.prototype.getRemappedKeyset_ = function(keyset) { 1764 Controller.prototype.getRemappedKeyset_ = function(keyset) {
1675 if (goog.array.contains(util.KEYSETS_USE_US, keyset)) { 1765 if (goog.array.contains(util.KEYSETS_USE_US, keyset)) {
1676 return 'us'; 1766 return 'us-ltr';
1677 } 1767 }
1678 var match = keyset.match(/^(.*)-rtl$/); 1768 var match = keyset.match(/^(.*)-rtl$/);
1679 if (match && goog.array.contains(util.KEYSETS_USE_US, match[1])) { 1769 if (match && goog.array.contains(util.KEYSETS_USE_US, match[1])) {
1680 return 'us-rtl'; 1770 return 'us-rtl';
1681 } 1771 }
1682 return keyset; 1772 return keyset;
1683 }; 1773 };
1684 1774
1685 1775
1686 /** 1776 /**
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 this.perfTracker_.restart(); 1812 this.perfTracker_.restart();
1723 this.adapter_.getCurrentInputMethod(function(currentInputMethod) { 1813 this.adapter_.getCurrentInputMethod(function(currentInputMethod) {
1724 // TODO: remove this hack as soon as the manifest is fixed in chromium. 1814 // TODO: remove this hack as soon as the manifest is fixed in chromium.
1725 if (languageCode == 'ko') { 1815 if (languageCode == 'ko') {
1726 if (currentInputMethod.indexOf('hangul_2set') > 0) { 1816 if (currentInputMethod.indexOf('hangul_2set') > 0) {
1727 keyset = 'm17n:ko_2set'; 1817 keyset = 'm17n:ko_2set';
1728 } 1818 }
1729 } 1819 }
1730 this.languageCode_ = languageCode; 1820 this.languageCode_ = languageCode;
1731 this.currentInputMethod_ = currentInputMethod; 1821 this.currentInputMethod_ = currentInputMethod;
1732 var keySetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_]; 1822 var keySetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_] = {};
1733 if (!keySetMap) {
1734 keySetMap = this.contextTypeToKeysetMap_[this.currentInputMethod_] = {};
1735 }
1736 keySetMap[ContextType.PASSWORD] = passwordLayout; 1823 keySetMap[ContextType.PASSWORD] = passwordLayout;
1737 keySetMap[ContextType.DEFAULT] = keyset; 1824 keySetMap[ContextType.DEFAULT] = keyset;
1738 1825
1739 this.initialKeyset_ = keyset; 1826 this.initialKeyset_ = keyset;
1740 this.title_ = title; 1827 this.title_ = title;
1741 this.isSettingReady = false; 1828 this.isSettingReady = false;
1742 this.model_.settings = new i18n.input.chrome.inputview.Settings(); 1829 this.model_.settings = new i18n.input.chrome.inputview.Settings();
1743 this.model_.stateManager.isEnMode = false; 1830 this.model_.stateManager.isEnMode = false;
1744 this.adapter_.initialize(languageCode ? languageCode.split('-')[0] : ''); 1831 this.adapter_.initialize(languageCode ? languageCode.split('-')[0] : '');
1745 this.loadAllResources_(); 1832 this.loadAllResources_();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 Controller.prototype.updateLanguageState_ = 1912 Controller.prototype.updateLanguageState_ =
1826 function(fromRawKeyset, toRawKeyset) { 1913 function(fromRawKeyset, toRawKeyset) {
1827 var toggle = false; 1914 var toggle = false;
1828 var toggleState = false; 1915 var toggleState = false;
1829 if (fromRawKeyset != toRawKeyset) { 1916 if (fromRawKeyset != toRawKeyset) {
1830 // Deal with the switch logic to/from English within the compact layout. 1917 // Deal with the switch logic to/from English within the compact layout.
1831 if (fromRawKeyset.indexOf('en.compact') * 1918 if (fromRawKeyset.indexOf('en.compact') *
1832 toRawKeyset.indexOf('en.compact') < 0) { // Switches between non-en/en. 1919 toRawKeyset.indexOf('en.compact') < 0) { // Switches between non-en/en.
1833 toggle = true; 1920 toggle = true;
1834 toggleState = toRawKeyset.indexOf('en.compact') == -1; 1921 toggleState = toRawKeyset.indexOf('en.compact') == -1;
1835 } else if (goog.array.contains(util.KEYSETS_HAVE_EN_SWTICHER, 1922 } else if (fromRawKeyset.indexOf(toRawKeyset) == 0 &&
1836 toRawKeyset) && 1923 fromRawKeyset.indexOf('.compact') > 0 &&
1837 fromRawKeyset.indexOf(toRawKeyset) == 0 && 1924 goog.array.contains(util.KEYSETS_HAVE_EN_SWTICHER, toRawKeyset) ||
1838 fromRawKeyset.indexOf('.compact') > 0 || 1925 fromRawKeyset && toRawKeyset.indexOf(fromRawKeyset) == 0 &&
1839 fromRawKeyset && toRawKeyset.indexOf(fromRawKeyset) == 0 && 1926 toRawKeyset.indexOf('.compact') > 0) {
1840 toRawKeyset.indexOf('.compact') > 0) {
1841 // Switch between full/compact layouts, reset the default button and 1927 // Switch between full/compact layouts, reset the default button and
1842 // language. 1928 // language.
1843 toggle = true; 1929 toggle = true;
1844 toggleState = true; 1930 toggleState = true;
1845 } 1931 }
1846 } 1932 }
1847 if (toggle) { 1933 if (toggle) {
1848 this.adapter_.toggleLanguageState(toggleState); 1934 this.adapter_.toggleLanguageState(toggleState);
1849 this.model_.stateManager.isEnMode = !toggleState; 1935 this.model_.stateManager.isEnMode = !toggleState;
1850 this.container_.currentKeysetView.update(); 1936 this.container_.currentKeysetView.update();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 toKeyset = this.currentKeyset_.replace('compact', 'en.compact'); 1984 toKeyset = this.currentKeyset_.replace('compact', 'en.compact');
1899 } 1985 }
1900 } 1986 }
1901 if (toKeyset) { 1987 if (toKeyset) {
1902 this.resetAll_(); 1988 this.resetAll_();
1903 this.switchToKeyset(toKeyset); 1989 this.switchToKeyset(toKeyset);
1904 } 1990 }
1905 } 1991 }
1906 }; 1992 };
1907 }); // goog.scope 1993 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698