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.KeyboardContainer'); | 14 goog.provide('i18n.input.chrome.inputview.KeyboardContainer'); |
15 | 15 |
16 goog.require('goog.dom.TagName'); | 16 goog.require('goog.dom.TagName'); |
17 goog.require('goog.dom.classlist'); | 17 goog.require('goog.dom.classlist'); |
| 18 goog.require('goog.i18n.bidi'); |
18 goog.require('goog.ui.Container'); | 19 goog.require('goog.ui.Container'); |
19 goog.require('i18n.input.chrome.inputview.Css'); | 20 goog.require('i18n.input.chrome.inputview.Css'); |
20 goog.require('i18n.input.chrome.inputview.elements.content.AltDataView'); | 21 goog.require('i18n.input.chrome.inputview.elements.content.AltDataView'); |
21 goog.require('i18n.input.chrome.inputview.elements.content.CandidateView'); | 22 goog.require('i18n.input.chrome.inputview.elements.content.CandidateView'); |
22 goog.require('i18n.input.chrome.inputview.elements.content.EmojiView'); | 23 goog.require('i18n.input.chrome.inputview.elements.content.EmojiView'); |
23 goog.require('i18n.input.chrome.inputview.elements.content.ExpandedCandidateView
'); | 24 goog.require('i18n.input.chrome.inputview.elements.content.ExpandedCandidateView
'); |
24 goog.require('i18n.input.chrome.inputview.elements.content.HandwritingView'); | 25 goog.require('i18n.input.chrome.inputview.elements.content.HandwritingView'); |
25 goog.require('i18n.input.chrome.inputview.elements.content.KeysetView'); | 26 goog.require('i18n.input.chrome.inputview.elements.content.KeysetView'); |
26 goog.require('i18n.input.chrome.inputview.elements.content.MenuView'); | 27 goog.require('i18n.input.chrome.inputview.elements.content.MenuView'); |
| 28 goog.require('i18n.input.chrome.inputview.elements.content.VoiceView'); |
27 | 29 |
28 | 30 |
29 | 31 |
30 goog.scope(function() { | 32 goog.scope(function() { |
31 var Css = i18n.input.chrome.inputview.Css; | 33 var Css = i18n.input.chrome.inputview.Css; |
32 var EmojiView = i18n.input.chrome.inputview.elements.content.EmojiView; | 34 var EmojiView = i18n.input.chrome.inputview.elements.content.EmojiView; |
33 var HandwritingView = i18n.input.chrome.inputview.elements.content. | 35 var HandwritingView = i18n.input.chrome.inputview.elements.content. |
34 HandwritingView; | 36 HandwritingView; |
35 var KeysetView = i18n.input.chrome.inputview.elements.content.KeysetView; | 37 var KeysetView = i18n.input.chrome.inputview.elements.content.KeysetView; |
36 var SpecNodeName = i18n.input.chrome.inputview.SpecNodeName; | 38 var SpecNodeName = i18n.input.chrome.inputview.SpecNodeName; |
37 var content = i18n.input.chrome.inputview.elements.content; | 39 var content = i18n.input.chrome.inputview.elements.content; |
38 | 40 |
39 | 41 |
40 | 42 |
41 /** | 43 /** |
42 * The keyboard container. | 44 * The keyboard container. |
43 * | 45 * |
44 * @param {i18n.input.chrome.inputview.Adapter=} opt_adapter . | 46 * @param {!i18n.input.chrome.inputview.Adapter} adapter . |
45 * @constructor | 47 * @constructor |
46 * @extends {goog.ui.Container} | 48 * @extends {goog.ui.Container} |
47 */ | 49 */ |
48 i18n.input.chrome.inputview.KeyboardContainer = function(opt_adapter) { | 50 i18n.input.chrome.inputview.KeyboardContainer = function(adapter) { |
49 goog.base(this); | 51 goog.base(this); |
50 | 52 |
51 /** @type {!content.CandidateView} */ | 53 /** @type {!content.CandidateView} */ |
52 this.candidateView = new content.CandidateView('candidateView', this); | 54 this.candidateView = new content.CandidateView( |
| 55 'candidateView', adapter, this); |
53 | 56 |
54 /** @type {!content.AltDataView} */ | 57 /** @type {!content.AltDataView} */ |
55 this.altDataView = new content.AltDataView(this); | 58 this.altDataView = new content.AltDataView(this); |
56 | 59 |
57 /** @type {!content.MenuView} */ | 60 /** @type {!content.MenuView} */ |
58 this.menuView = new content.MenuView(this); | 61 this.menuView = new content.MenuView(this); |
59 | 62 |
| 63 /** @type {!content.VoiceView} */ |
| 64 this.voiceView = new content.VoiceView(this, adapter); |
| 65 |
60 /** @type {!content.ExpandedCandidateView} */ | 66 /** @type {!content.ExpandedCandidateView} */ |
61 this.expandedCandidateView = new content.ExpandedCandidateView(this); | 67 this.expandedCandidateView = new content.ExpandedCandidateView(this); |
62 | 68 |
63 /** | 69 /** |
64 * The map of the KeysetViews. | 70 * The map of the KeysetViews. |
65 * Key: keyboard code. | 71 * Key: keyboard code. |
66 * Value: The view object. | 72 * Value: The view object. |
67 * | 73 * |
68 * @type {!Object.<string, !KeysetView>} | 74 * @type {!Object.<string, !KeysetView>} |
69 */ | 75 */ |
70 this.keysetViewMap = {}; | 76 this.keysetViewMap = {}; |
71 | 77 |
72 /** | 78 /** |
73 * The bus channel to communicate with background. | 79 * The bus channel to communicate with background. |
74 * | 80 * |
75 * @private {i18n.input.chrome.inputview.Adapter} | 81 * @private {!i18n.input.chrome.inputview.Adapter} |
76 */ | 82 */ |
77 this.adapter_ = opt_adapter || null; | 83 this.adapter_ = adapter; |
78 }; | 84 }; |
79 goog.inherits(i18n.input.chrome.inputview.KeyboardContainer, | 85 goog.inherits(i18n.input.chrome.inputview.KeyboardContainer, |
80 goog.ui.Container); | 86 goog.ui.Container); |
81 var KeyboardContainer = i18n.input.chrome.inputview.KeyboardContainer; | 87 var KeyboardContainer = i18n.input.chrome.inputview.KeyboardContainer; |
82 | 88 |
83 | 89 |
84 /** @type {!KeysetView} */ | 90 /** @type {!KeysetView} */ |
85 KeyboardContainer.prototype.currentKeysetView; | 91 KeyboardContainer.prototype.currentKeysetView; |
86 | 92 |
87 | 93 |
(...skipping 26 matching lines...) Expand all Loading... |
114 KeyboardContainer.prototype.createDom = function() { | 120 KeyboardContainer.prototype.createDom = function() { |
115 goog.base(this, 'createDom'); | 121 goog.base(this, 'createDom'); |
116 | 122 |
117 var elem = this.getElement(); | 123 var elem = this.getElement(); |
118 this.wrapperDiv_ = this.getDomHelper().createDom( | 124 this.wrapperDiv_ = this.getDomHelper().createDom( |
119 goog.dom.TagName.DIV, Css.WRAPPER); | 125 goog.dom.TagName.DIV, Css.WRAPPER); |
120 this.candidateView.render(this.wrapperDiv_); | 126 this.candidateView.render(this.wrapperDiv_); |
121 this.getDomHelper().appendChild(elem, this.wrapperDiv_); | 127 this.getDomHelper().appendChild(elem, this.wrapperDiv_); |
122 this.altDataView.render(); | 128 this.altDataView.render(); |
123 this.menuView.render(); | 129 this.menuView.render(); |
| 130 this.voiceView.render(); |
| 131 this.voiceView.setVisible(false); |
124 this.expandedCandidateView.render(this.wrapperDiv_); | 132 this.expandedCandidateView.render(this.wrapperDiv_); |
125 this.expandedCandidateView.setVisible(false); | 133 this.expandedCandidateView.setVisible(false); |
126 goog.dom.classlist.add(elem, Css.CONTAINER); | 134 goog.dom.classlist.add(elem, Css.CONTAINER); |
127 }; | 135 }; |
128 | 136 |
129 | 137 |
130 /** @override */ | 138 /** @override */ |
131 KeyboardContainer.prototype.enterDocument = function() { | 139 KeyboardContainer.prototype.enterDocument = function() { |
132 goog.base(this, 'enterDocument'); | 140 goog.base(this, 'enterDocument'); |
133 | 141 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 if (this.currentKeysetView.isTabStyle()) { | 261 if (this.currentKeysetView.isTabStyle()) { |
254 h = height - 2 * KeyboardContainer.TAB_MARGIN_; | 262 h = height - 2 * KeyboardContainer.TAB_MARGIN_; |
255 wrapperMargin = KeyboardContainer.TAB_MARGIN_; | 263 wrapperMargin = KeyboardContainer.TAB_MARGIN_; |
256 } | 264 } |
257 this.wrapperDiv_.style.marginTop = this.wrapperDiv_.style.marginBottom = | 265 this.wrapperDiv_.style.marginTop = this.wrapperDiv_.style.marginBottom = |
258 wrapperMargin + 'px'; | 266 wrapperMargin + 'px'; |
259 h -= KeyboardContainer.PADDING_BOTTOM_; | 267 h -= KeyboardContainer.PADDING_BOTTOM_; |
260 elem.style.paddingBottom = KeyboardContainer.PADDING_BOTTOM_ + 'px'; | 268 elem.style.paddingBottom = KeyboardContainer.PADDING_BOTTOM_ + 'px'; |
261 | 269 |
262 var padding = Math.round((width - width * widthPercent) / 2); | 270 var padding = Math.round((width - width * widthPercent) / 2); |
263 elem.style.paddingLeft = elem.style.paddingRight = padding + 'px'; | |
264 | |
265 var w = width - 2 * padding; | 271 var w = width - 2 * padding; |
266 | 272 |
267 // Reduce height if candidate view is enabled | 273 // Reduce height if candidate view is enabled |
268 h = this.currentKeysetView.disableCandidateView ? h : | 274 h = this.currentKeysetView.disableCandidateView ? h : |
269 h - candidateViewHeight; | 275 h - candidateViewHeight; |
270 | 276 |
271 this.candidateView.setWidthInWeight( | 277 this.candidateView.setWidthInWeight( |
272 this.currentKeysetView.getWidthInWeight()); | 278 this.currentKeysetView.getWidthInWeight()); |
| 279 var candidateElem = this.candidateView.getElement(); |
| 280 candidateElem.style.paddingLeft = candidateElem.style.paddingRight = |
| 281 padding + 'px'; |
273 this.candidateView.resize(w, candidateViewHeight); | 282 this.candidateView.resize(w, candidateViewHeight); |
274 this.currentKeysetView.resize(w, h); | 283 this.currentKeysetView.resize(w, h); |
| 284 var currentKeysetViewElem = this.currentKeysetView.getElement(); |
| 285 currentKeysetViewElem.style.paddingLeft = currentKeysetViewElem.style. |
| 286 paddingRight = padding + 'px'; |
275 this.expandedCandidateView.resize(w, h); | 287 this.expandedCandidateView.resize(w, h); |
| 288 if (this.expandedCandidateView.isVisible()) { |
| 289 // Closes the expanded candidate view if it's visible. |
| 290 // This is to avoid mis-layout issue for the expanded candidate when screen |
| 291 // is rotated. |
| 292 this.expandedCandidateView.state = content.ExpandedCandidateView.State.NONE; |
| 293 this.candidateView.switchToIcon( |
| 294 content.CandidateView.IconType.EXPAND_CANDIDATES, true); |
| 295 this.expandedCandidateView.setVisible(false); |
| 296 this.currentKeysetView.setVisible(true); |
| 297 } |
276 this.altDataView.resize(screen.width, height); | 298 this.altDataView.resize(screen.width, height); |
277 this.menuView.resize(screen.width, height); | 299 this.menuView.resize(screen.width, height); |
| 300 this.voiceView.resize(w + padding, height); |
278 }; | 301 }; |
279 | 302 |
280 | 303 |
281 /** @override */ | 304 /** @override */ |
282 KeyboardContainer.prototype.disposeInternal = function() { | 305 KeyboardContainer.prototype.disposeInternal = function() { |
283 goog.dispose(this.candidateView); | 306 goog.dispose(this.candidateView); |
284 goog.dispose(this.altDataView); | 307 goog.dispose(this.altDataView); |
285 goog.dispose(this.menuView); | 308 goog.dispose(this.menuView); |
| 309 goog.dispose(this.voiceView); |
286 for (var key in this.keysetViewMap) { | 310 for (var key in this.keysetViewMap) { |
287 goog.dispose(this.keysetViewMap[key]); | 311 goog.dispose(this.keysetViewMap[key]); |
288 } | 312 } |
289 | 313 |
290 goog.base(this, 'disposeInternal'); | 314 goog.base(this, 'disposeInternal'); |
291 }; | 315 }; |
292 | 316 |
293 | 317 |
294 /** | 318 /** |
295 * Whether there are strokes on canvas. | 319 * Whether there are strokes on canvas. |
(...skipping 12 matching lines...) Expand all Loading... |
308 /** | 332 /** |
309 * Cleans the stokes. | 333 * Cleans the stokes. |
310 */ | 334 */ |
311 KeyboardContainer.prototype.cleanStroke = function() { | 335 KeyboardContainer.prototype.cleanStroke = function() { |
312 if (this.currentKeysetView) { | 336 if (this.currentKeysetView) { |
313 this.currentKeysetView.cleanStroke(); | 337 this.currentKeysetView.cleanStroke(); |
314 } | 338 } |
315 }; | 339 }; |
316 | 340 |
317 }); // goog.scope | 341 }); // goog.scope |
OLD | NEW |