Chromium Code Reviews| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 var mainDiv = document.createElement('div'); | 158 var mainDiv = document.createElement('div'); |
| 159 mainDiv.className = 'main'; | 159 mainDiv.className = 'main'; |
| 160 mainDiv.id = 'main'; | 160 mainDiv.id = 'main'; |
| 161 body.appendChild(mainDiv); | 161 body.appendChild(mainDiv); |
| 162 | 162 |
| 163 initIme(mainDiv); | 163 initIme(mainDiv); |
| 164 initKeyboard(currentKeyboardLayout, mainDiv); | 164 initKeyboard(currentKeyboardLayout, mainDiv); |
| 165 | 165 |
| 166 window.onhashchange(); | 166 window.onhashchange(); |
| 167 | 167 |
| 168 // Restore the keyboard to the default state when it is hidden. | 168 chrome.experimental.input.onTextInputTypeChanged.addListener(function(type) { |
|
mazda
2011/08/04 02:15:36
It might be better to enclose the sentence.
if (c
| |
| 169 // Ref: dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html | 169 var currentMode = KEY_MODE; |
|
bryeung
2011/08/03 22:24:21
don't shadow currentMode: it is a global JS variab
Peng
2011/08/24 15:35:54
Done.
| |
| 170 document.addEventListener("webkitvisibilitychange", function() { | 170 switch(type) { |
|
bryeung
2011/08/03 22:24:21
I think the switch contents should be indented two
Peng
2011/08/24 15:35:54
Done.
| |
| 171 if (document.webkitHidden) { | 171 case "text": |
| 172 currentMode = SHIFT_MODE; | 172 currentMode = SHIFT_MODE; |
| 173 setMode(currentMode); | 173 break; |
| 174 case "password": | |
| 175 case "search": | |
| 176 case "url": | |
| 177 currentMode = KEY_MODE; | |
| 178 break; | |
| 179 case "number": | |
| 180 case "tel": | |
| 181 currentMode = NUMBER_MODE; | |
| 182 break; | |
|
mazda
2011/08/04 02:15:36
It would be better to handle the default case as e
Peng
2011/08/24 15:35:54
Done.
| |
| 174 } | 183 } |
| 175 }, false); | 184 setMode(currentMode); |
| 185 }); | |
| 176 } | 186 } |
| 177 // TODO(bryeung): would be nice to leave less gutter (without causing | 187 // TODO(bryeung): would be nice to leave less gutter (without causing |
| 178 // rendering issues with floated divs wrapping at some sizes). | 188 // rendering issues with floated divs wrapping at some sizes). |
| 179 | 189 |
| 180 /** | 190 /** |
| 181 * Switch the keyboard layout based on the current URL hash. | 191 * Switch the keyboard layout based on the current URL hash. |
| 182 * @return {void} | 192 * @return {void} |
| 183 */ | 193 */ |
| 184 window.onhashchange = function() { | 194 window.onhashchange = function() { |
| 185 var old_layout = currentKeyboardLayout; | 195 var old_layout = currentKeyboardLayout; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 205 if (canvas !== undefined) { | 215 if (canvas !== undefined) { |
| 206 if (!visible) { | 216 if (!visible) { |
| 207 canvas.clear(); | 217 canvas.clear(); |
| 208 } | 218 } |
| 209 } | 219 } |
| 210 if (visible) { | 220 if (visible) { |
| 211 window.onresize(); | 221 window.onresize(); |
| 212 } | 222 } |
| 213 }); | 223 }); |
| 214 } | 224 } |
| OLD | NEW |