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.i18n.bidi'); |
19 goog.require('goog.ui.Container'); | 19 goog.require('goog.ui.Container'); |
20 goog.require('i18n.input.chrome.inputview.Css'); | 20 goog.require('i18n.input.chrome.inputview.Css'); |
| 21 goog.require('i18n.input.chrome.inputview.GlobalFlags'); |
21 goog.require('i18n.input.chrome.inputview.elements.content.AltDataView'); | 22 goog.require('i18n.input.chrome.inputview.elements.content.AltDataView'); |
22 goog.require('i18n.input.chrome.inputview.elements.content.CandidateView'); | 23 goog.require('i18n.input.chrome.inputview.elements.content.CandidateView'); |
23 goog.require('i18n.input.chrome.inputview.elements.content.EmojiView'); | 24 goog.require('i18n.input.chrome.inputview.elements.content.EmojiView'); |
24 goog.require('i18n.input.chrome.inputview.elements.content.ExpandedCandidateView
'); | 25 goog.require('i18n.input.chrome.inputview.elements.content.ExpandedCandidateView
'); |
25 goog.require('i18n.input.chrome.inputview.elements.content.HandwritingView'); | 26 goog.require('i18n.input.chrome.inputview.elements.content.HandwritingView'); |
26 goog.require('i18n.input.chrome.inputview.elements.content.KeysetView'); | 27 goog.require('i18n.input.chrome.inputview.elements.content.KeysetView'); |
27 goog.require('i18n.input.chrome.inputview.elements.content.MenuView'); | 28 goog.require('i18n.input.chrome.inputview.elements.content.MenuView'); |
| 29 goog.require('i18n.input.chrome.inputview.elements.content.SelectView'); |
| 30 goog.require('i18n.input.chrome.inputview.elements.content.SwipeView'); |
28 goog.require('i18n.input.chrome.inputview.elements.content.VoiceView'); | 31 goog.require('i18n.input.chrome.inputview.elements.content.VoiceView'); |
29 | 32 |
30 | 33 |
31 | 34 |
32 goog.scope(function() { | 35 goog.scope(function() { |
33 var Css = i18n.input.chrome.inputview.Css; | 36 var Css = i18n.input.chrome.inputview.Css; |
34 var EmojiView = i18n.input.chrome.inputview.elements.content.EmojiView; | 37 var EmojiView = i18n.input.chrome.inputview.elements.content.EmojiView; |
35 var HandwritingView = i18n.input.chrome.inputview.elements.content. | 38 var HandwritingView = i18n.input.chrome.inputview.elements.content. |
36 HandwritingView; | 39 HandwritingView; |
37 var KeysetView = i18n.input.chrome.inputview.elements.content.KeysetView; | 40 var KeysetView = i18n.input.chrome.inputview.elements.content.KeysetView; |
38 var SpecNodeName = i18n.input.chrome.inputview.SpecNodeName; | 41 var SpecNodeName = i18n.input.chrome.inputview.SpecNodeName; |
39 var content = i18n.input.chrome.inputview.elements.content; | 42 var content = i18n.input.chrome.inputview.elements.content; |
40 | 43 |
41 | 44 |
42 | 45 |
43 /** | 46 /** |
44 * The keyboard container. | 47 * The keyboard container. |
45 * | 48 * |
46 * @param {!i18n.input.chrome.inputview.Adapter} adapter . | 49 * @param {!i18n.input.chrome.inputview.Adapter} adapter . |
| 50 * @param {!i18n.input.chrome.SoundController} soundController . |
47 * @constructor | 51 * @constructor |
48 * @extends {goog.ui.Container} | 52 * @extends {goog.ui.Container} |
49 */ | 53 */ |
50 i18n.input.chrome.inputview.KeyboardContainer = function(adapter) { | 54 i18n.input.chrome.inputview.KeyboardContainer = |
| 55 function(adapter, soundController) { |
51 goog.base(this); | 56 goog.base(this); |
52 | 57 |
53 /** @type {!content.CandidateView} */ | 58 /** @type {!content.CandidateView} */ |
54 this.candidateView = new content.CandidateView( | 59 this.candidateView = new content.CandidateView( |
55 'candidateView', adapter, this); | 60 'candidateView', adapter, this); |
56 | 61 |
57 /** @type {!content.AltDataView} */ | 62 /** @type {!content.AltDataView} */ |
58 this.altDataView = new content.AltDataView(this); | 63 this.altDataView = new content.AltDataView(this); |
59 | 64 |
| 65 /** @type {!content.SwipeView} */ |
| 66 this.swipeView = new content.SwipeView(adapter, this); |
| 67 |
| 68 /** @type {!content.SelectView} */ |
| 69 this.selectView = new content.SelectView(this); |
| 70 |
60 /** @type {!content.MenuView} */ | 71 /** @type {!content.MenuView} */ |
61 this.menuView = new content.MenuView(this); | 72 this.menuView = new content.MenuView(this); |
62 | 73 |
63 /** @type {!content.VoiceView} */ | 74 /** @type {!content.VoiceView} */ |
64 this.voiceView = new content.VoiceView(this, adapter); | 75 this.voiceView = new content.VoiceView(this, adapter, soundController); |
65 | 76 |
66 /** @type {!content.ExpandedCandidateView} */ | 77 /** @type {!content.ExpandedCandidateView} */ |
67 this.expandedCandidateView = new content.ExpandedCandidateView(this); | 78 this.expandedCandidateView = new content.ExpandedCandidateView(this); |
68 | 79 |
69 /** | 80 /** |
70 * The map of the KeysetViews. | 81 * The map of the KeysetViews. |
71 * Key: keyboard code. | 82 * Key: keyboard code. |
72 * Value: The view object. | 83 * Value: The view object. |
73 * | 84 * |
74 * @type {!Object.<string, !KeysetView>} | 85 * @type {!Object.<string, !KeysetView>} |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 /** @override */ | 130 /** @override */ |
120 KeyboardContainer.prototype.createDom = function() { | 131 KeyboardContainer.prototype.createDom = function() { |
121 goog.base(this, 'createDom'); | 132 goog.base(this, 'createDom'); |
122 | 133 |
123 var elem = this.getElement(); | 134 var elem = this.getElement(); |
124 this.wrapperDiv_ = this.getDomHelper().createDom( | 135 this.wrapperDiv_ = this.getDomHelper().createDom( |
125 goog.dom.TagName.DIV, Css.WRAPPER); | 136 goog.dom.TagName.DIV, Css.WRAPPER); |
126 this.candidateView.render(this.wrapperDiv_); | 137 this.candidateView.render(this.wrapperDiv_); |
127 this.getDomHelper().appendChild(elem, this.wrapperDiv_); | 138 this.getDomHelper().appendChild(elem, this.wrapperDiv_); |
128 this.altDataView.render(); | 139 this.altDataView.render(); |
| 140 this.swipeView.render(); |
| 141 this.selectView.render(); |
129 this.menuView.render(); | 142 this.menuView.render(); |
130 this.voiceView.render(); | 143 this.voiceView.render(); |
131 this.voiceView.setVisible(false); | 144 this.voiceView.setVisible(false); |
132 this.expandedCandidateView.render(this.wrapperDiv_); | 145 this.expandedCandidateView.render(this.wrapperDiv_); |
133 this.expandedCandidateView.setVisible(false); | 146 this.expandedCandidateView.setVisible(false); |
134 goog.dom.classlist.add(elem, Css.CONTAINER); | 147 goog.dom.classlist.add(elem, Css.CONTAINER); |
135 }; | 148 }; |
136 | 149 |
137 | 150 |
138 /** @override */ | 151 /** @override */ |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 282 |
270 var padding = Math.round((width - width * widthPercent) / 2); | 283 var padding = Math.round((width - width * widthPercent) / 2); |
271 var w = width - 2 * padding; | 284 var w = width - 2 * padding; |
272 | 285 |
273 // Reduce height if candidate view is enabled | 286 // Reduce height if candidate view is enabled |
274 h = this.currentKeysetView.disableCandidateView ? h : | 287 h = this.currentKeysetView.disableCandidateView ? h : |
275 h - candidateViewHeight; | 288 h - candidateViewHeight; |
276 | 289 |
277 this.candidateView.setWidthInWeight( | 290 this.candidateView.setWidthInWeight( |
278 this.currentKeysetView.getWidthInWeight()); | 291 this.currentKeysetView.getWidthInWeight()); |
279 var candidateElem = this.candidateView.getElement(); | |
280 candidateElem.style.paddingLeft = candidateElem.style.paddingRight = | |
281 padding + 'px'; | |
282 this.candidateView.resize(w, candidateViewHeight); | 292 this.candidateView.resize(w, candidateViewHeight); |
283 this.currentKeysetView.resize(w, h); | |
284 var currentKeysetViewElem = this.currentKeysetView.getElement(); | |
285 currentKeysetViewElem.style.paddingLeft = currentKeysetViewElem.style. | |
286 paddingRight = padding + 'px'; | |
287 this.expandedCandidateView.resize(w, h); | 293 this.expandedCandidateView.resize(w, h); |
| 294 if (i18n.input.chrome.inputview.GlobalFlags.isQPInputView) { |
| 295 var candidateElem = this.candidateView.getElement(); |
| 296 candidateElem.style.paddingLeft = candidateElem.style.paddingRight = |
| 297 padding + 'px'; |
| 298 this.currentKeysetView.resize(width, h, widthPercent); |
| 299 var expandViewElem = this.expandedCandidateView.getElement(); |
| 300 expandViewElem.style.marginLeft = expandViewElem.style.marginRight = |
| 301 padding + 'px'; |
| 302 } else { |
| 303 this.currentKeysetView.resize(w, h, 1); |
| 304 elem.style.paddingLeft = elem.style.paddingRight = padding + 'px'; |
| 305 } |
288 if (this.expandedCandidateView.isVisible()) { | 306 if (this.expandedCandidateView.isVisible()) { |
289 // Closes the expanded candidate view if it's visible. | 307 // Closes the expanded candidate view if it's visible. |
290 // This is to avoid mis-layout issue for the expanded candidate when screen | 308 // This is to avoid mis-layout issue for the expanded candidate when screen |
291 // is rotated. | 309 // is rotated. |
292 this.expandedCandidateView.state = content.ExpandedCandidateView.State.NONE; | 310 this.expandedCandidateView.state = content.ExpandedCandidateView.State.NONE; |
293 this.candidateView.switchToIcon( | 311 this.candidateView.switchToIcon( |
294 content.CandidateView.IconType.EXPAND_CANDIDATES, true); | 312 content.CandidateView.IconType.EXPAND_CANDIDATES, true); |
295 this.expandedCandidateView.setVisible(false); | 313 this.expandedCandidateView.setVisible(false); |
296 this.currentKeysetView.setVisible(true); | 314 this.currentKeysetView.setVisible(true); |
297 } | 315 } |
298 this.altDataView.resize(screen.width, height); | 316 this.altDataView.resize(screen.width, height); |
| 317 this.swipeView.resize(screen.width, height); |
| 318 this.selectView.resize(screen.width, height); |
299 this.menuView.resize(screen.width, height); | 319 this.menuView.resize(screen.width, height); |
300 this.voiceView.resize(w + padding, height); | 320 this.voiceView.resize(w + padding, height); |
301 }; | 321 }; |
302 | 322 |
303 | 323 |
304 /** @override */ | 324 /** @override */ |
305 KeyboardContainer.prototype.disposeInternal = function() { | 325 KeyboardContainer.prototype.disposeInternal = function() { |
306 goog.dispose(this.candidateView); | 326 goog.dispose(this.candidateView); |
307 goog.dispose(this.altDataView); | 327 goog.dispose(this.altDataView); |
| 328 goog.dispose(this.swipeView); |
| 329 goog.dispose(this.selectView); |
308 goog.dispose(this.menuView); | 330 goog.dispose(this.menuView); |
309 goog.dispose(this.voiceView); | 331 goog.dispose(this.voiceView); |
310 for (var key in this.keysetViewMap) { | 332 for (var key in this.keysetViewMap) { |
311 goog.dispose(this.keysetViewMap[key]); | 333 goog.dispose(this.keysetViewMap[key]); |
312 } | 334 } |
313 | 335 |
314 goog.base(this, 'disposeInternal'); | 336 goog.base(this, 'disposeInternal'); |
315 }; | 337 }; |
316 | 338 |
317 | 339 |
(...skipping 14 matching lines...) Expand all Loading... |
332 /** | 354 /** |
333 * Cleans the stokes. | 355 * Cleans the stokes. |
334 */ | 356 */ |
335 KeyboardContainer.prototype.cleanStroke = function() { | 357 KeyboardContainer.prototype.cleanStroke = function() { |
336 if (this.currentKeysetView) { | 358 if (this.currentKeysetView) { |
337 this.currentKeysetView.cleanStroke(); | 359 this.currentKeysetView.cleanStroke(); |
338 } | 360 } |
339 }; | 361 }; |
340 | 362 |
341 }); // goog.scope | 363 }); // goog.scope |
OLD | NEW |