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

Side by Side Diff: ui/webui/resources/js/cr/ui/focus_grid.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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 cr.define('cr.ui', function() { 5 cr.define('cr.ui', function() {
6 /** 6 /**
7 * A class to manage grid of focusable elements in a 2D grid. For example, 7 * A class to manage grid of focusable elements in a 2D grid. For example,
8 * given this grid: 8 * given this grid:
9 * 9 *
10 * focusable [focused] focusable (row: 0, col: 1) 10 * focusable [focused] focusable (row: 0, col: 1)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 this.rows.forEach(function(r) { r.makeActive(r == row); }); 46 this.rows.forEach(function(r) { r.makeActive(r == row); });
47 }, 47 },
48 48
49 /** @override */ 49 /** @override */
50 onKeydown: function(row, e) { 50 onKeydown: function(row, e) {
51 var rowIndex = this.rows.indexOf(row); 51 var rowIndex = this.rows.indexOf(row);
52 assert(rowIndex >= 0); 52 assert(rowIndex >= 0);
53 53
54 var newRow = -1; 54 var newRow = -1;
55 55
56 if (e.keyIdentifier == 'Up') 56 if (e.key == 'ArrowUp')
57 newRow = rowIndex - 1; 57 newRow = rowIndex - 1;
58 else if (e.keyIdentifier == 'Down') 58 else if (e.key == 'ArrowDown')
59 newRow = rowIndex + 1; 59 newRow = rowIndex + 1;
60 else if (e.keyIdentifier == 'PageUp') 60 else if (e.key == 'PageUp')
61 newRow = 0; 61 newRow = 0;
62 else if (e.keyIdentifier == 'PageDown') 62 else if (e.key == 'PageDown')
63 newRow = this.rows.length - 1; 63 newRow = this.rows.length - 1;
64 64
65 var rowToFocus = this.rows[newRow]; 65 var rowToFocus = this.rows[newRow];
66 if (rowToFocus) { 66 if (rowToFocus) {
67 this.ignoreFocusChange_ = true; 67 this.ignoreFocusChange_ = true;
68 rowToFocus.getEquivalentElement(this.lastFocused_).focus(); 68 rowToFocus.getEquivalentElement(this.lastFocused_).focus();
69 e.preventDefault(); 69 e.preventDefault();
70 return true; 70 return true;
71 } 71 }
72 72
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 153 }
154 154
155 this.rows[0].makeActive(true); 155 this.rows[0].makeActive(true);
156 }, 156 },
157 }; 157 };
158 158
159 return { 159 return {
160 FocusGrid: FocusGrid, 160 FocusGrid: FocusGrid,
161 }; 161 };
162 }); 162 });
OLDNEW
« no previous file with comments | « ui/webui/resources/js/cr/ui/context_menu_handler.js ('k') | ui/webui/resources/js/cr/ui/focus_row.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698