| 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) { |
| 169 // Ref: dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html | 169 switch(type) { |
| 170 document.addEventListener("webkitvisibilitychange", function() { | 170 case "text": |
| 171 if (document.webkitHidden) { | 171 currentMode = SHIFT_MODE; |
| 172 currentMode = SHIFT_MODE; | 172 break; |
| 173 setMode(currentMode); | 173 case "password": |
| 174 case "search": |
| 175 case "url": |
| 176 currentMode = KEY_MODE; |
| 177 break; |
| 178 case "number": |
| 179 case "tel": |
| 180 currentMode = NUMBER_MODE; |
| 181 break; |
| 182 default: |
| 183 currentMode = KEY_MODE; |
| 184 break; |
| 174 } | 185 } |
| 175 }, false); | 186 setMode(currentMode); |
| 187 }); |
| 176 } | 188 } |
| 177 // TODO(bryeung): would be nice to leave less gutter (without causing | 189 // TODO(bryeung): would be nice to leave less gutter (without causing |
| 178 // rendering issues with floated divs wrapping at some sizes). | 190 // rendering issues with floated divs wrapping at some sizes). |
| 179 | 191 |
| 180 /** | 192 /** |
| 181 * Switch the keyboard layout based on the current URL hash. | 193 * Switch the keyboard layout based on the current URL hash. |
| 182 * @return {void} | 194 * @return {void} |
| 183 */ | 195 */ |
| 184 window.onhashchange = function() { | 196 window.onhashchange = function() { |
| 185 var old_layout = currentKeyboardLayout; | 197 var old_layout = currentKeyboardLayout; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 205 if (canvas !== undefined) { | 217 if (canvas !== undefined) { |
| 206 if (!visible) { | 218 if (!visible) { |
| 207 canvas.clear(); | 219 canvas.clear(); |
| 208 } | 220 } |
| 209 } | 221 } |
| 210 if (visible) { | 222 if (visible) { |
| 211 window.onresize(); | 223 window.onresize(); |
| 212 } | 224 } |
| 213 }); | 225 }); |
| 214 } | 226 } |
| OLD | NEW |