| OLD | NEW |
| 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.content.ContextlayoutUtil'); | 14 goog.provide('i18n.input.chrome.inputview.content.ContextlayoutUtil'); |
| 15 | 15 |
| 16 goog.require('i18n.input.chrome.inputview.SpecNodeName'); |
| 16 goog.require('i18n.input.chrome.inputview.content.compact.util'); | 17 goog.require('i18n.input.chrome.inputview.content.compact.util'); |
| 17 goog.require('i18n.input.chrome.inputview.content.compact.util.CompactKeysetSpec
'); | 18 goog.require('i18n.input.chrome.inputview.content.compact.util.CompactKeysetSpec
'); |
| 18 goog.require('i18n.input.chrome.message.ContextType'); | 19 goog.require('i18n.input.chrome.message.ContextType'); |
| 19 | 20 |
| 20 goog.scope(function() { | 21 goog.scope(function() { |
| 21 var ContextType = i18n.input.chrome.message.ContextType; | 22 var ContextType = i18n.input.chrome.message.ContextType; |
| 22 var util = i18n.input.chrome.inputview.content.ContextlayoutUtil; | 23 var util = i18n.input.chrome.inputview.content.ContextlayoutUtil; |
| 23 var compact = i18n.input.chrome.inputview.content.compact.util; | 24 var compact = i18n.input.chrome.inputview.content.compact.util; |
| 24 var keysetSpecNode = compact.CompactKeysetSpec; | 25 var keysetSpecNode = compact.CompactKeysetSpec; |
| 26 var SpecNodeName = i18n.input.chrome.inputview.SpecNodeName; |
| 25 | 27 |
| 26 | 28 |
| 27 /** | 29 /** |
| 28 * Generates custom layouts to be displayed on specified input type contexts. | 30 * Generates custom layouts to be displayed on specified input type contexts. |
| 29 * | 31 * |
| 30 * | 32 * |
| 31 * @param {Object.<ContextType, !Object>} inputTypeToKeysetSpecMap Map from | 33 * @param {Object.<ContextType, !Object>} inputTypeToKeysetSpecMap Map from |
| 32 * input types to context-specific keysets. | 34 * input types to context-specific keysets. |
| 33 * @param {!function(!Object): void} onLoaded The function to call once a keyset | 35 * @param {!function(!Object): void} onLoaded The function to call once a keyset |
| 34 * data is ready. | 36 * data is ready. |
| 35 */ | 37 */ |
| 36 util.generateContextLayouts = function(inputTypeToKeysetSpecMap, onLoaded) { | 38 util.generateContextLayouts = function(inputTypeToKeysetSpecMap, onLoaded) { |
| 37 // Creates context-specific keysets. | 39 // Creates context-specific keysets. |
| 38 if (inputTypeToKeysetSpecMap) { | 40 if (inputTypeToKeysetSpecMap) { |
| 39 for (var inputType in inputTypeToKeysetSpecMap) { | 41 for (var inputType in inputTypeToKeysetSpecMap) { |
| 40 var spec = inputTypeToKeysetSpecMap[inputType]; | 42 var spec = inputTypeToKeysetSpecMap[inputType]; |
| 41 var data = compact.createCompactData( | 43 var data = compact.createCompactData( |
| 42 spec, 'compactkbd-k-', 'compactkbd-k-key-'); | 44 spec, 'compactkbd-k-', 'compactkbd-k-key-'); |
| 43 data['id'] = spec[keysetSpecNode.ID]; | 45 data[SpecNodeName.ID] = spec[keysetSpecNode.ID]; |
| 44 data['showMenuKey'] = false; | 46 data[SpecNodeName.SHOW_MENU_KEY] = false; |
| 45 data['noShift'] = true; | 47 data[SpecNodeName.NO_SHIFT] = true; |
| 46 data['onContext'] = inputType; | 48 data[SpecNodeName.ON_CONTEXT] = inputType; |
| 47 onLoaded(data); | 49 onLoaded(data); |
| 48 } | 50 } |
| 49 } | 51 } |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 }); // goog.scope | 54 }); // goog.scope |
| OLD | NEW |