OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview A simple virtual keyboard implementation. | 6 * @fileoverview A simple virtual keyboard implementation. |
7 */ | 7 */ |
8 | 8 |
9 /** | 9 /** |
10 * The keyboard layout name currently in use. | 10 * The keyboard layout name currently in use. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 * @param {Element} The DOM Element to which keyboard is appended. | 118 * @param {Element} The DOM Element to which keyboard is appended. |
119 * @return {void} | 119 * @return {void} |
120 */ | 120 */ |
121 function initKeyboard(layout, element) { | 121 function initKeyboard(layout, element) { |
122 var keyboard = KEYBOARDS[layout]; | 122 var keyboard = KEYBOARDS[layout]; |
123 if (!keyboard || keyboard['keyboardDiv']) { | 123 if (!keyboard || keyboard['keyboardDiv']) { |
124 return; | 124 return; |
125 } | 125 } |
126 var keyboardDiv = document.createElement('div'); | 126 var keyboardDiv = document.createElement('div'); |
127 keyboardDiv.id = getKeyboardId(layout); | 127 keyboardDiv.id = getKeyboardId(layout); |
128 keyboardDiv.className = 'nodisplay'; | 128 keyboardDiv.className = 'keyboard'; |
bryeung
2011/08/03 21:11:42
the keyboard should ideally not be visible until i
mazda
2011/08/04 04:28:50
The keyboard is not visible at least until its nod
bryeung
2011/08/04 04:36:50
Yes: that makes sense. Thanks for the clarificati
| |
129 initRows(layout, keyboardDiv); | 129 initRows(layout, keyboardDiv); |
130 initHandwritingCanvas(layout, keyboardDiv); | 130 initHandwritingCanvas(layout, keyboardDiv); |
131 keyboard['keyboardDiv'] = keyboardDiv; | 131 keyboard['keyboardDiv'] = keyboardDiv; |
132 window.onresize(); | |
132 element.appendChild(keyboardDiv); | 133 element.appendChild(keyboardDiv); |
133 } | 134 } |
134 | 135 |
135 /** | 136 /** |
136 * Resize the keyboard according to the new window size. | 137 * Resize the keyboard according to the new window size. |
137 * @return {void} | 138 * @return {void} |
138 */ | 139 */ |
139 window.onresize = function() { | 140 window.onresize = function() { |
140 var keyboardDiv = document.getElementById(getKeyboardId( | 141 var keyboardDiv = KEYBOARDS[currentKeyboardLayout]['keyboardDiv']; |
141 currentKeyboardLayout)); | |
142 var height = getKeyboardHeight(); | 142 var height = getKeyboardHeight(); |
143 keyboardDiv.style.height = height + 'px'; | 143 keyboardDiv.style.height = height + 'px'; |
144 var mainDiv = document.getElementById('main'); | 144 var mainDiv = document.getElementById('main'); |
145 mainDiv.style.width = Math.floor(getKeyboardAspect() * height) + 'px'; | 145 mainDiv.style.width = Math.floor(getKeyboardAspect() * height) + 'px'; |
146 var rowsLength = KEYBOARDS[currentKeyboardLayout]['rows'].length; | 146 var rowsLength = KEYBOARDS[currentKeyboardLayout]['rows'].length; |
147 keyboardDiv.style.fontSize = (height / kFontSizeRatio / rowsLength) + 'px'; | 147 keyboardDiv.style.fontSize = (height / kFontSizeRatio / rowsLength) + 'px'; |
148 updateIme(); | 148 updateIme(); |
149 } | 149 } |
150 | 150 |
151 /** | 151 /** |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 if (canvas !== undefined) { | 205 if (canvas !== undefined) { |
206 if (!visible) { | 206 if (!visible) { |
207 canvas.clear(); | 207 canvas.clear(); |
208 } | 208 } |
209 } | 209 } |
210 if (visible) { | 210 if (visible) { |
211 window.onresize(); | 211 window.onresize(); |
212 } | 212 } |
213 }); | 213 }); |
214 } | 214 } |
OLD | NEW |