OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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'; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 /** | 46 /** |
47 * Flatten the keysets which represents a keyboard layout. It has two steps: | 47 * Flatten the keysets which represents a keyboard layout. It has two steps: |
48 * 1) Replace all kb-key-import elements with imported document that associated | 48 * 1) Replace all kb-key-import elements with imported document that associated |
49 * with linkid. | 49 * with linkid. |
50 * 2) Replace all kb-key-sequence elements with generated DOM structures. | 50 * 2) Replace all kb-key-sequence elements with generated DOM structures. |
51 * @param {!Document} content Document to process. | 51 * @param {!Document} content Document to process. |
52 */ | 52 */ |
53 function flattenKeysets(content) { | 53 function flattenKeysets(content) { |
54 var importedContent = importHTML(content); | 54 var importedContent = importHTML(content); |
55 expandHTML(importedContent); | 55 expandHTML(importedContent); |
56 var rows = importedContent.querySelectorAll('kb-row'); | |
57 for (var i = 0 ; i < rows.length; i++) { | |
58 var allKeys = rows[i].children; | |
59 for (var j = 0; j< allKeys.length; j++) { | |
60 var weight = allKeys[j].getAttribute('weight'); | |
61 if (weight) { | |
62 allKeys[j].style.webkitBoxFlex = weight; | |
63 } | |
kevers
2014/01/17 18:50:30
nit: Remove brackets.
rsadam
2014/01/17 19:12:33
Done.
| |
64 } | |
65 } | |
56 return importedContent; | 66 return importedContent; |
57 } | 67 } |
58 | 68 |
59 addEventListener('resize', onResize); | 69 addEventListener('resize', onResize); |
60 | 70 |
61 addEventListener('load', onResize); | 71 addEventListener('load', onResize); |
62 | 72 |
63 // Prevents all default actions of touch. Keyboard should use its own gesture | 73 // Prevents all default actions of touch. Keyboard should use its own gesture |
64 // recognizer. | 74 // recognizer. |
65 addEventListener('touchstart', function(e) { e.preventDefault() }); | 75 addEventListener('touchstart', function(e) { e.preventDefault() }); |
66 addEventListener('touchend', function(e) { e.preventDefault() }); | 76 addEventListener('touchend', function(e) { e.preventDefault() }); |
67 addEventListener('touchmove', function(e) { e.preventDefault() }); | 77 addEventListener('touchmove', function(e) { e.preventDefault() }); |
OLD | NEW |