| 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 } |
| 64 } |
| 56 return importedContent; | 65 return importedContent; |
| 57 } | 66 } |
| 58 | 67 |
| 59 addEventListener('resize', onResize); | 68 addEventListener('resize', onResize); |
| 60 | 69 |
| 61 addEventListener('load', onResize); | 70 addEventListener('load', onResize); |
| 62 | 71 |
| 63 // Prevents all default actions of touch. Keyboard should use its own gesture | 72 // Prevents all default actions of touch. Keyboard should use its own gesture |
| 64 // recognizer. | 73 // recognizer. |
| 65 addEventListener('touchstart', function(e) { e.preventDefault() }); | 74 addEventListener('touchstart', function(e) { e.preventDefault() }); |
| 66 addEventListener('touchend', function(e) { e.preventDefault() }); | 75 addEventListener('touchend', function(e) { e.preventDefault() }); |
| 67 addEventListener('touchmove', function(e) { e.preventDefault() }); | 76 addEventListener('touchmove', function(e) { e.preventDefault() }); |
| OLD | NEW |