OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 var onResize = function() { | 5 var onResize = function() { |
6 var x = window.innerWidth; | 6 var x = window.innerWidth; |
7 var y = window.innerHeight; | 7 var y = window.innerHeight; |
8 var height = (x > ASPECT_RATIO * y) ? y : Math.floor(x / ASPECT_RATIO); | 8 var height = (x > ASPECT_RATIO * y) ? y : Math.floor(x / ASPECT_RATIO); |
9 keyboard.style.height = height + 'px'; | 9 keyboard.style.height = height + 'px'; |
10 keyboard.style.width = Math.floor(ASPECT_RATIO * height) + 'px'; | 10 keyboard.style.width = Math.floor(ASPECT_RATIO * height) + 'px'; |
11 keyboard.style.fontSize = (height / FONT_SIZE_RATIO / ROW_LENGTH) + 'px'; | 11 keyboard.style.fontSize = (height / FONT_SIZE_RATIO / ROW_LENGTH) + 'px'; |
12 }; | 12 }; |
13 | 13 |
14 /** | |
15 * Send the given key to chrome. | |
16 */ | |
17 function sendKey(key) { | |
18 var keyIdentifier = key; | |
19 | |
20 // Fix up some keys to their respective identifiers for convenience. | |
21 if (keyIdentifier == ' ') { | |
22 keyIdentifier = 'Spacebar'; | |
23 } | |
24 | |
25 var keyEvent = { | |
26 keyIdentifier: keyIdentifier | |
27 }; | |
28 | |
29 sendKeyEvent(keyEvent); | |
30 }; | |
31 | |
32 addEventListener('WebComponentsReady', function() { | 14 addEventListener('WebComponentsReady', function() { |
33 keyboard.appendChild( | 15 keyboard.appendChild( |
34 keysets.content.body.firstElementChild.createInstance()); | 16 keysets.content.body.firstElementChild.createInstance()); |
35 }); | 17 }); |
36 | 18 |
37 addEventListener('resize', onResize); | 19 addEventListener('resize', onResize); |
38 | 20 |
39 addEventListener('load', onResize); | 21 addEventListener('load', onResize); |
OLD | NEW |