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('i18n.input.chrome.ElementType'); |
| 20 goog.require('i18n.input.chrome.WindowUtil'); |
19 goog.require('i18n.input.chrome.inputview.Css'); | 21 goog.require('i18n.input.chrome.inputview.Css'); |
| 22 goog.require('i18n.input.chrome.inputview.GesturePreviewWindow'); |
20 goog.require('i18n.input.chrome.inputview.elements.Element'); | 23 goog.require('i18n.input.chrome.inputview.elements.Element'); |
21 goog.require('i18n.input.chrome.inputview.elements.ElementType'); | |
22 goog.require('i18n.input.chrome.inputview.elements.content.AltDataView'); | 24 goog.require('i18n.input.chrome.inputview.elements.content.AltDataView'); |
23 goog.require('i18n.input.chrome.inputview.elements.content.CandidateView'); | 25 goog.require('i18n.input.chrome.inputview.elements.content.CandidateView'); |
24 goog.require('i18n.input.chrome.inputview.elements.content.EmojiView'); | 26 goog.require('i18n.input.chrome.inputview.elements.content.EmojiView'); |
25 goog.require('i18n.input.chrome.inputview.elements.content.ExpandedCandidateView
'); | 27 goog.require('i18n.input.chrome.inputview.elements.content.ExpandedCandidateView
'); |
26 goog.require('i18n.input.chrome.inputview.elements.content.FloatingView'); | 28 goog.require('i18n.input.chrome.inputview.elements.content.FloatingView'); |
27 goog.require('i18n.input.chrome.inputview.elements.content.GestureCanvasView'); | 29 goog.require('i18n.input.chrome.inputview.elements.content.GestureCanvasView'); |
28 goog.require('i18n.input.chrome.inputview.elements.content.GesturePreviewView'); | |
29 goog.require('i18n.input.chrome.inputview.elements.content.HandwritingView'); | 30 goog.require('i18n.input.chrome.inputview.elements.content.HandwritingView'); |
30 goog.require('i18n.input.chrome.inputview.elements.content.KeysetView'); | 31 goog.require('i18n.input.chrome.inputview.elements.content.KeysetView'); |
31 goog.require('i18n.input.chrome.inputview.elements.content.MenuView'); | 32 goog.require('i18n.input.chrome.inputview.elements.content.MenuView'); |
32 goog.require('i18n.input.chrome.inputview.elements.content.SelectView'); | 33 goog.require('i18n.input.chrome.inputview.elements.content.SelectView'); |
33 goog.require('i18n.input.chrome.inputview.elements.content.SwipeView'); | 34 goog.require('i18n.input.chrome.inputview.elements.content.SwipeView'); |
34 goog.require('i18n.input.chrome.inputview.elements.content.VoiceView'); | 35 goog.require('i18n.input.chrome.inputview.elements.content.VoiceView'); |
35 | 36 |
36 | 37 |
37 | 38 |
38 goog.scope(function() { | 39 goog.scope(function() { |
39 var Css = i18n.input.chrome.inputview.Css; | 40 var Css = i18n.input.chrome.inputview.Css; |
40 var EmojiView = i18n.input.chrome.inputview.elements.content.EmojiView; | 41 var EmojiView = i18n.input.chrome.inputview.elements.content.EmojiView; |
| 42 var GesturePreviewWindow = i18n.input.chrome.inputview.GesturePreviewWindow; |
41 var HandwritingView = i18n.input.chrome.inputview.elements.content. | 43 var HandwritingView = i18n.input.chrome.inputview.elements.content. |
42 HandwritingView; | 44 HandwritingView; |
43 var KeysetView = i18n.input.chrome.inputview.elements.content.KeysetView; | 45 var KeysetView = i18n.input.chrome.inputview.elements.content.KeysetView; |
44 var content = i18n.input.chrome.inputview.elements.content; | 46 var content = i18n.input.chrome.inputview.elements.content; |
45 var ElementType = i18n.input.chrome.inputview.elements.ElementType; | 47 var ElementType = i18n.input.chrome.ElementType; |
| 48 var WindowUtil = i18n.input.chrome.WindowUtil; |
46 | 49 |
47 | 50 |
48 | 51 |
49 /** | 52 /** |
50 * The keyboard container. | 53 * The keyboard container. |
51 * | 54 * |
52 * @param {!i18n.input.chrome.inputview.Adapter} adapter . | 55 * @param {!i18n.input.chrome.inputview.Adapter} adapter . |
53 * @param {!i18n.input.chrome.sounds.SoundController} soundController . | 56 * @param {!i18n.input.chrome.sounds.SoundController} soundController . |
54 * @param {goog.events.EventTarget=} opt_eventTarget The parent event target. | 57 * @param {goog.events.EventTarget=} opt_eventTarget The parent event target. |
55 * @constructor | 58 * @constructor |
56 * @extends {i18n.input.chrome.inputview.elements.Element} | 59 * @extends {i18n.input.chrome.inputview.elements.Element} |
57 */ | 60 */ |
58 // TODO(bshe): Move this file to elements/content | 61 // TODO(bshe): Move this file to elements/content |
59 i18n.input.chrome.inputview.KeyboardContainer = | 62 i18n.input.chrome.inputview.KeyboardContainer = |
60 function(adapter, soundController, opt_eventTarget) { | 63 function(adapter, soundController, opt_eventTarget) { |
61 goog.base(this, '', ElementType.KEYBOARD_CONTAINER_VIEW, opt_eventTarget); | 64 goog.base(this, '', ElementType.KEYBOARD_CONTAINER_VIEW, opt_eventTarget); |
62 | 65 |
63 /** @type {!content.CandidateView} */ | 66 /** @type {!content.CandidateView} */ |
64 this.candidateView = new content.CandidateView( | 67 this.candidateView = new content.CandidateView( |
65 'candidateView', adapter, this); | 68 'candidateView', adapter, this); |
66 | 69 |
67 /** @type {!content.AltDataView} */ | 70 /** @type {!content.AltDataView} */ |
68 this.altDataView = new content.AltDataView(this); | 71 this.altDataView = new content.AltDataView(this); |
69 | 72 |
70 /** @type {!content.GesturePreviewView} */ | 73 // Create a new window and construct a GesturePreviewWindow with it |
71 this.gesturePreviewView = new content.GesturePreviewView(this); | 74 // once it's ready. |
| 75 WindowUtil.createWindow( |
| 76 function(newWindow) { |
| 77 /** @type {!GesturePreviewWindow} */ |
| 78 this.gesturePreviewWindow = new GesturePreviewWindow(newWindow); |
| 79 }.bind(this)); |
72 | 80 |
73 /** @type {!content.SwipeView} */ | 81 /** @type {!content.SwipeView} */ |
74 this.swipeView = new content.SwipeView(adapter, this.candidateView, this); | 82 this.swipeView = new content.SwipeView(adapter, this.candidateView, this); |
75 | 83 |
76 /** @type {!content.SelectView} */ | 84 /** @type {!content.SelectView} */ |
77 this.selectView = new content.SelectView(this); | 85 this.selectView = new content.SelectView(this); |
78 | 86 |
79 /** @type {!content.MenuView} */ | 87 /** @type {!content.MenuView} */ |
80 this.menuView = new content.MenuView(this); | 88 this.menuView = new content.MenuView(this); |
81 | 89 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 /** @override */ | 162 /** @override */ |
155 KeyboardContainer.prototype.createDom = function() { | 163 KeyboardContainer.prototype.createDom = function() { |
156 goog.base(this, 'createDom'); | 164 goog.base(this, 'createDom'); |
157 | 165 |
158 var elem = this.getElement(); | 166 var elem = this.getElement(); |
159 var dom = this.getDomHelper(); | 167 var dom = this.getDomHelper(); |
160 this.wrapperDiv_ = dom.createDom(goog.dom.TagName.DIV, Css.WRAPPER); | 168 this.wrapperDiv_ = dom.createDom(goog.dom.TagName.DIV, Css.WRAPPER); |
161 this.candidateView.render(this.wrapperDiv_); | 169 this.candidateView.render(this.wrapperDiv_); |
162 dom.appendChild(elem, this.wrapperDiv_); | 170 dom.appendChild(elem, this.wrapperDiv_); |
163 this.altDataView.render(); | 171 this.altDataView.render(); |
164 this.gesturePreviewView.render(); | |
165 this.swipeView.render(); | 172 this.swipeView.render(); |
166 this.selectView.render(); | 173 this.selectView.render(); |
167 this.menuView.render(); | 174 this.menuView.render(); |
168 this.voiceView.render(); | 175 this.voiceView.render(); |
169 this.voiceView.setVisible(false); | 176 this.voiceView.setVisible(false); |
170 this.expandedCandidateView.render(this.wrapperDiv_); | 177 this.expandedCandidateView.render(this.wrapperDiv_); |
171 this.expandedCandidateView.setVisible(false); | 178 this.expandedCandidateView.setVisible(false); |
172 if (this.adapter_.isFloatingVirtualKeyboardEnabled()) { | 179 if (this.adapter_.isFloatingVirtualKeyboardEnabled()) { |
| 180 inputview.setMode('FLOATING'); |
173 this.floatingView = new content.FloatingView(this); | 181 this.floatingView = new content.FloatingView(this); |
174 this.floatingView.render(); | 182 this.floatingView.render(); |
| 183 this.candidateView.setFloatingVKButtonsVisible(true); |
175 } | 184 } |
176 this.gestureCanvasView = new content.GestureCanvasView(this); | 185 this.gestureCanvasView = new content.GestureCanvasView(this); |
177 this.gestureCanvasView.render(this.wrapperDiv_); | 186 this.gestureCanvasView.render(this.wrapperDiv_); |
178 goog.dom.classlist.add(elem, Css.CONTAINER); | 187 goog.dom.classlist.add(elem, Css.CONTAINER); |
179 }; | 188 }; |
180 | 189 |
181 | 190 |
182 /** @override */ | 191 /** @override */ |
183 KeyboardContainer.prototype.update = function() { | 192 KeyboardContainer.prototype.update = function() { |
184 this.currentKeysetView && this.currentKeysetView.update(); | 193 this.currentKeysetView && this.currentKeysetView.update(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // Closes the expanded candidate view if it's visible. | 334 // Closes the expanded candidate view if it's visible. |
326 // This is to avoid mis-layout issue for the expanded candidate when screen | 335 // This is to avoid mis-layout issue for the expanded candidate when screen |
327 // is rotated. | 336 // is rotated. |
328 this.expandedCandidateView.state = content.ExpandedCandidateView.State.NONE; | 337 this.expandedCandidateView.state = content.ExpandedCandidateView.State.NONE; |
329 this.candidateView.switchToIcon( | 338 this.candidateView.switchToIcon( |
330 content.CandidateView.IconType.EXPAND_CANDIDATES, true); | 339 content.CandidateView.IconType.EXPAND_CANDIDATES, true); |
331 this.expandedCandidateView.setVisible(false); | 340 this.expandedCandidateView.setVisible(false); |
332 this.currentKeysetView.setVisible(true); | 341 this.currentKeysetView.setVisible(true); |
333 } | 342 } |
334 this.altDataView.resize(width, height); | 343 this.altDataView.resize(width, height); |
335 this.gesturePreviewView.resize(width, height); | |
336 this.swipeView.resize(width, height); | 344 this.swipeView.resize(width, height); |
337 this.selectView.resize(width, height); | 345 this.selectView.resize(width, height); |
338 this.menuView.resize(width, height); | 346 this.menuView.resize(width, height); |
339 this.voiceView.resize(w + padding, height); | 347 this.voiceView.resize(w + padding, height); |
340 if (this.floatingView) { | 348 if (this.floatingView) { |
341 this.floatingView.resize(width, height); | 349 this.floatingView.resize(width, height); |
342 } | 350 } |
343 this.gestureCanvasView.resize(width, height); | 351 this.gestureCanvasView.resize(width, height); |
344 }; | 352 }; |
345 | 353 |
346 | 354 |
347 /** @override */ | 355 /** @override */ |
348 KeyboardContainer.prototype.disposeInternal = function() { | 356 KeyboardContainer.prototype.disposeInternal = function() { |
349 goog.dispose(this.candidateView); | 357 goog.dispose(this.candidateView); |
350 goog.dispose(this.altDataView); | 358 goog.dispose(this.altDataView); |
351 goog.dispose(this.gesturePreviewView); | 359 goog.dispose(this.gesturePreviewWindow); |
352 goog.dispose(this.swipeView); | 360 goog.dispose(this.swipeView); |
353 goog.dispose(this.selectView); | 361 goog.dispose(this.selectView); |
354 goog.dispose(this.menuView); | 362 goog.dispose(this.menuView); |
355 goog.dispose(this.voiceView); | 363 goog.dispose(this.voiceView); |
356 if (this.floatingView) { | 364 if (this.floatingView) { |
357 goog.dispose(this.floatingView); | 365 goog.dispose(this.floatingView); |
358 } | 366 } |
359 goog.dispose(this.gestureCanvasView); | 367 goog.dispose(this.gestureCanvasView); |
360 for (var key in this.keysetViewMap) { | 368 for (var key in this.keysetViewMap) { |
361 goog.dispose(this.keysetViewMap[key]); | 369 goog.dispose(this.keysetViewMap[key]); |
(...skipping 20 matching lines...) Expand all Loading... |
382 /** | 390 /** |
383 * Cleans the stokes. | 391 * Cleans the stokes. |
384 */ | 392 */ |
385 KeyboardContainer.prototype.cleanStroke = function() { | 393 KeyboardContainer.prototype.cleanStroke = function() { |
386 if (this.currentKeysetView) { | 394 if (this.currentKeysetView) { |
387 this.currentKeysetView.cleanStroke(); | 395 this.currentKeysetView.cleanStroke(); |
388 } | 396 } |
389 }; | 397 }; |
390 | 398 |
391 }); // goog.scope | 399 }); // goog.scope |
OLD | NEW |