Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Side by Side Diff: ui/webui/resources/js/cr/ui/overlay.js

Issue 2104103002: Convert Event#keyIdentifier (deprecated) to Event#key (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch file manager test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/webui/resources/js/cr/ui/menu_item.js ('k') | ui/webui/resources/js/cr/ui/tabs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 Provides dialog-like behaviors for the tracing UI. 6 * @fileoverview Provides dialog-like behaviors for the tracing UI.
7 */ 7 */
8 cr.define('cr.ui.overlay', function() { 8 cr.define('cr.ui.overlay', function() {
9 /** 9 /**
10 * Gets the top, visible overlay. It makes the assumption that if multiple 10 * Gets the top, visible overlay. It makes the assumption that if multiple
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 * Makes initializations which must hook at the document level. 43 * Makes initializations which must hook at the document level.
44 */ 44 */
45 function globalInitialization() { 45 function globalInitialization() {
46 if (!globallyInitialized) { 46 if (!globallyInitialized) {
47 document.addEventListener('keydown', function(e) { 47 document.addEventListener('keydown', function(e) {
48 var overlay = getTopOverlay(); 48 var overlay = getTopOverlay();
49 if (!overlay) 49 if (!overlay)
50 return; 50 return;
51 51
52 // Close the overlay on escape. 52 // Close the overlay on escape.
53 if (e.keyIdentifier == 'U+001B') 53 if (e.key == 'Escape')
54 cr.dispatchSimpleEvent(overlay, 'cancelOverlay'); 54 cr.dispatchSimpleEvent(overlay, 'cancelOverlay');
55 55
56 // Execute the overlay's default button on enter, unless focus is on an 56 // Execute the overlay's default button on enter, unless focus is on an
57 // element that has standard behavior for the enter key. 57 // element that has standard behavior for the enter key.
58 var forbiddenTagNames = /^(A|BUTTON|SELECT|TEXTAREA)$/; 58 var forbiddenTagNames = /^(A|BUTTON|SELECT|TEXTAREA)$/;
59 if (e.keyIdentifier == 'Enter' && 59 if (e.key == 'Enter' &&
60 !forbiddenTagNames.test(document.activeElement.tagName)) { 60 !forbiddenTagNames.test(document.activeElement.tagName)) {
61 var button = getDefaultButton(overlay); 61 var button = getDefaultButton(overlay);
62 if (button) { 62 if (button) {
63 button.click(); 63 button.click();
64 // Executing the default button may result in focus moving to a 64 // Executing the default button may result in focus moving to a
65 // different button. Calling preventDefault is necessary to not have 65 // different button. Calling preventDefault is necessary to not have
66 // that button execute as well. 66 // that button execute as well.
67 e.preventDefault(); 67 e.preventDefault();
68 } 68 }
69 } 69 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 e.target.classList.remove('pulse'); 131 e.target.classList.remove('pulse');
132 }); 132 });
133 } 133 }
134 134
135 return { 135 return {
136 getDefaultButton: getDefaultButton, 136 getDefaultButton: getDefaultButton,
137 globalInitialization: globalInitialization, 137 globalInitialization: globalInitialization,
138 setupOverlay: setupOverlay, 138 setupOverlay: setupOverlay,
139 }; 139 };
140 }); 140 });
OLDNEW
« no previous file with comments | « ui/webui/resources/js/cr/ui/menu_item.js ('k') | ui/webui/resources/js/cr/ui/tabs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698