1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
14 goog.provide('i18n.input.chrome.inputview.content.ContextlayoutUtil');
16 goog.require('i18n.input.chrome.inputview.SpecNodeName');
17 goog.require('i18n.input.chrome.inputview.content.compact.util');
18 goog.require('i18n.input.chrome.inputview.content.compact.util.CompactKeysetSpec');
19 goog.require('i18n.input.chrome.message.ContextType');
21 goog.scope(function() {
22 var ContextType = i18n.input.chrome.message.ContextType;
23 var util = i18n.input.chrome.inputview.content.ContextlayoutUtil;
24 var compact = i18n.input.chrome.inputview.content.compact.util;
25 var keysetSpecNode = compact.CompactKeysetSpec;
26 var SpecNodeName = i18n.input.chrome.inputview.SpecNodeName;
30 * Generates custom layouts to be displayed on specified input type contexts.
33 * @param {Object.<ContextType, !Object>} inputTypeToKeysetSpecMap Map from
34 * input types to context-specific keysets.
35 * @param {!function(!Object): void} onLoaded The function to call once a keyset
38 util.generateContextLayouts = function(inputTypeToKeysetSpecMap, onLoaded) {
39 // Creates context-specific keysets.
40 if (inputTypeToKeysetSpecMap) {
41 for (var inputType in inputTypeToKeysetSpecMap) {
42 var spec = inputTypeToKeysetSpecMap[inputType];
43 var data = compact.createCompactData(
44 spec, 'compactkbd-k-', 'compactkbd-k-key-');
45 data[SpecNodeName.ID] = spec[keysetSpecNode.ID];
46 data[SpecNodeName.SHOW_MENU_KEY] = false;
47 data[SpecNodeName.NO_SHIFT] = true;
48 data[SpecNodeName.ON_CONTEXT] = inputType;