| 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 /** | 5 /** |
| 6 * Namespace for keyboard utility functions. | 6 * Namespace for keyboard utility functions. |
| 7 */ | 7 */ |
| 8 var keyboard = {}; | 8 var keyboard = {}; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 // This file also gets embedded inside of the CfM/hotrod enrollment webview. | 78 // This file also gets embedded inside of the CfM/hotrod enrollment webview. |
| 79 // Events will bubble down into the webview, which means that the event | 79 // Events will bubble down into the webview, which means that the event |
| 80 // handler from the webui will steal the events meant for the webview. So we | 80 // handler from the webui will steal the events meant for the webview. So we |
| 81 // have to disable the webui handler if the active element is the webview. | 81 // have to disable the webui handler if the active element is the webview. |
| 82 // | 82 // |
| 83 // $ is defined differently depending on how this file gets executed; we have | 83 // $ is defined differently depending on how this file gets executed; we have |
| 84 // to use document.getElementById to get consistent behavior. | 84 // to use document.getElementById to get consistent behavior. |
| 85 // | 85 // |
| 86 // See crbug.com/543865. | 86 // See crbug.com/543865. |
| 87 /* eslint-disable no-restricted-properties */ |
| 87 if (document.activeElement === | 88 if (document.activeElement === |
| 88 document.getElementById('oauth-enroll-auth-view')) | 89 document.getElementById('oauth-enroll-auth-view')) { |
| 89 return; | 90 return; |
| 91 } |
| 92 /* eslint-enable no-restricted-properties */ |
| 90 | 93 |
| 91 // If we are in networks list dropdown container, let network_dropdown.js | 94 // If we are in networks list dropdown container, let network_dropdown.js |
| 92 // handle keyboard events. | 95 // handle keyboard events. |
| 93 if (document.activeElement.classList.contains('dropdown-container')) | 96 if (document.activeElement.classList.contains('dropdown-container')) |
| 94 return; | 97 return; |
| 95 | 98 |
| 96 // Do not map arrow key events to tab events if the user is currently | 99 // Do not map arrow key events to tab events if the user is currently |
| 97 // focusing an input element and hits the left or right. | 100 // focusing an input element and hits the left or right. |
| 98 var needsLeftRightKey = | 101 var needsLeftRightKey = |
| 99 (event.key == 'ArrowLeft' || event.key == 'ArrowRight') && | 102 (event.key == 'ArrowLeft' || event.key == 'ArrowRight') && |
| (...skipping 30 matching lines...) Expand all Loading... |
| 130 keyboard.initializeKeyboardFlow = function(injected) { | 133 keyboard.initializeKeyboardFlow = function(injected) { |
| 131 document.addEventListener('keydown', | 134 document.addEventListener('keydown', |
| 132 keyboard.onKeyDown_, true); | 135 keyboard.onKeyDown_, true); |
| 133 document.addEventListener('keypress', | 136 document.addEventListener('keypress', |
| 134 keyboard.onKeyIgnore_, true); | 137 keyboard.onKeyIgnore_, true); |
| 135 document.addEventListener('keyup', | 138 document.addEventListener('keyup', |
| 136 keyboard.onKeyIgnore_, true); | 139 keyboard.onKeyIgnore_, true); |
| 137 if (injected) | 140 if (injected) |
| 138 window.addEventListener('message', keyboard.onInitMessage_); | 141 window.addEventListener('message', keyboard.onInitMessage_); |
| 139 }; | 142 }; |
| OLD | NEW |