Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / google_input_tools / src / chrome / os / inputview / elements / content / compactkeymodel.js
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
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
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");
13 //
14 goog.provide('i18n.input.chrome.inputview.elements.content.CompactKeyModel');
15
16 goog.require('i18n.input.chrome.inputview.MoreKeysShiftOperation');
17
18
19 goog.scope(function() {
20 var MoreKeysShiftOperation = i18n.input.chrome.inputview.MoreKeysShiftOperation;
21
22
23 /**
24  * The model of compact key.
25  *
26  * @param {number} marginLeftPercent The left margin.
27  * @param {number} marginRightPercent The right margin.
28  * @param {boolean} isGrey Whether it is grey.
29  * @param {!Array.<string>} moreKeys The more keys.
30  * @param {MoreKeysShiftOperation} moreKeysShiftOperation
31  *     The type of opearation when the shift key is down.
32  * @param {string} textOnShift The text to display on shift.
33  * @param {Object.<string, !Object>} textOnContext Map for changing the key
34  *     based on the current input context.
35  * @param {string=} textCssClass The css class for the text.
36  * @param {string=} title Overrides the displayed text on the key.
37  * @constructor
38  * @extends {i18n.input.chrome.inputview.elements.content.FunctionalKey}
39  */
40 i18n.input.chrome.inputview.elements.content.CompactKeyModel =
41     function(marginLeftPercent, marginRightPercent, isGrey, moreKeys,
42     moreKeysShiftOperation, textOnShift, textOnContext, textCssClass, title) {
43
44   /**
45    * The left margin.
46    *
47    * @type {number}
48    */
49   this.marginLeftPercent = marginLeftPercent || 0;
50
51   /**
52    * The right margin.
53    *
54    * @type {number}
55    */
56   this.marginRightPercent = marginRightPercent || 0;
57
58   /**
59    * True if it is grey.
60    *
61    * @type {boolean}
62    */
63   this.isGrey = !!isGrey;
64
65   /**
66    * The more keys array.
67    *
68    * @type {!Array.<string>}
69    */
70   this.moreKeys = moreKeys || [];
71
72   /**
73    * The type of shift operation of moreKeys.
74    *
75    * @type {MoreKeysShiftOperation}
76    */
77   this.moreKeysShiftOperation = moreKeysShiftOperation ?
78       moreKeysShiftOperation : MoreKeysShiftOperation.TO_UPPER_CASE;
79
80   /**
81    * The text when shift is pressed down.
82    *
83    * @type {string}
84    */
85   this.textOnShift = textOnShift;
86
87   /**
88    * The css class for the text.
89    *
90    * @type {string}
91    */
92   this.textCssClass = textCssClass || '';
93
94   /**
95    * Map for changing the key based on the current input context.
96    *
97    * @type {Object.<string, !Object>}
98    */
99   this.textOnContext = textOnContext || {};
100
101   /**
102    * Alternate title for the key. Title is displayed, whereas text is
103    * what is actually committed.
104    */
105   this.title = title || '';
106 };
107 });  // goog.scope
108