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

Side by Side Diff: chrome/browser/resources/md_bookmarks/command_manager.js

Issue 2929053004: MD Bookmarks: Make shortcuts for select all/deselect all global (Closed)
Patch Set: Fix test flub Created 3 years, 6 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 | « no previous file | chrome/browser/resources/md_bookmarks/constants.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 Element which shows context menus and handles keyboard 6 * @fileoverview Element which shows context menus and handles keyboard
7 * shortcuts. 7 * shortcuts.
8 */ 8 */
9 cr.define('bookmarks', function() { 9 cr.define('bookmarks', function() {
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 this.addShortcut_(Command.EDIT, 'F2', 'Enter'); 68 this.addShortcut_(Command.EDIT, 'F2', 'Enter');
69 this.addShortcut_(Command.COPY, 'Ctrl|c', 'Meta|c'); 69 this.addShortcut_(Command.COPY, 'Ctrl|c', 'Meta|c');
70 this.addShortcut_(Command.DELETE, 'Delete', 'Delete Backspace'); 70 this.addShortcut_(Command.DELETE, 'Delete', 'Delete Backspace');
71 71
72 this.addShortcut_(Command.OPEN, 'Enter', 'Meta|ArrowDown Meta|o'); 72 this.addShortcut_(Command.OPEN, 'Enter', 'Meta|ArrowDown Meta|o');
73 this.addShortcut_(Command.OPEN_NEW_TAB, 'Ctrl|Enter', 'Meta|Enter'); 73 this.addShortcut_(Command.OPEN_NEW_TAB, 'Ctrl|Enter', 'Meta|Enter');
74 this.addShortcut_(Command.OPEN_NEW_WINDOW, 'Shift|Enter'); 74 this.addShortcut_(Command.OPEN_NEW_WINDOW, 'Shift|Enter');
75 75
76 this.addShortcut_(Command.UNDO, 'Ctrl|z', 'Meta|z'); 76 this.addShortcut_(Command.UNDO, 'Ctrl|z', 'Meta|z');
77 this.addShortcut_(Command.REDO, 'Ctrl|y Ctrl|Shift|Z', 'Meta|Shift|Z'); 77 this.addShortcut_(Command.REDO, 'Ctrl|y Ctrl|Shift|Z', 'Meta|Shift|Z');
78
79 this.addShortcut_(Command.SELECT_ALL, 'Ctrl|a', 'Meta|a');
80 this.addShortcut_(Command.DESELECT_ALL, 'Escape');
78 }, 81 },
79 82
80 detached: function() { 83 detached: function() {
81 CommandManager.instance_ = null; 84 CommandManager.instance_ = null;
82 document.removeEventListener('open-item-menu', this.boundOnOpenItemMenu_); 85 document.removeEventListener('open-item-menu', this.boundOnOpenItemMenu_);
83 document.removeEventListener('command-undo', this.boundOnCommandUndo_); 86 document.removeEventListener('command-undo', this.boundOnCommandUndo_);
84 document.removeEventListener('keydown', this.boundOnKeydown_); 87 document.removeEventListener('keydown', this.boundOnKeydown_);
85 }, 88 },
86 89
87 /** 90 /**
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 * @param {!Set<string>} itemIds 125 * @param {!Set<string>} itemIds
123 * @return {boolean} 126 * @return {boolean}
124 */ 127 */
125 canExecute: function(command, itemIds) { 128 canExecute: function(command, itemIds) {
126 switch (command) { 129 switch (command) {
127 case Command.OPEN: 130 case Command.OPEN:
128 return itemIds.size > 0; 131 return itemIds.size > 0;
129 case Command.UNDO: 132 case Command.UNDO:
130 case Command.REDO: 133 case Command.REDO:
131 return this.globalCanEdit_; 134 return this.globalCanEdit_;
135 case Command.SELECT_ALL:
136 case Command.DESELECT_ALL:
137 return true;
132 default: 138 default:
133 return this.isCommandVisible_(command, itemIds) && 139 return this.isCommandVisible_(command, itemIds) &&
134 this.isCommandEnabled_(command, itemIds); 140 this.isCommandEnabled_(command, itemIds);
135 } 141 }
136 }, 142 },
137 143
138 /** 144 /**
139 * @param {Command} command 145 * @param {Command} command
140 * @param {!Set<string>} itemIds 146 * @param {!Set<string>} itemIds
141 * @return {boolean} True if the command should be visible in the context 147 * @return {boolean} True if the command should be visible in the context
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return !node.url; 245 return !node.url;
240 }); 246 });
241 if (isFolder) { 247 if (isFolder) {
242 var folderId = Array.from(itemIds)[0]; 248 var folderId = Array.from(itemIds)[0];
243 this.dispatch( 249 this.dispatch(
244 bookmarks.actions.selectFolder(folderId, state.nodes)); 250 bookmarks.actions.selectFolder(folderId, state.nodes));
245 } else { 251 } else {
246 this.openUrls_(this.expandUrls_(itemIds), command); 252 this.openUrls_(this.expandUrls_(itemIds), command);
247 } 253 }
248 break; 254 break;
255 case Command.SELECT_ALL:
256 var displayedIds = bookmarks.util.getDisplayedList(state);
257 this.dispatch(bookmarks.actions.selectAll(displayedIds, state));
258 break;
259 case Command.DESELECT_ALL:
260 this.dispatch(bookmarks.actions.deselectItems());
261 break;
249 default: 262 default:
250 assert(false); 263 assert(false);
251 } 264 }
252 }, 265 },
253 266
254 /** 267 /**
255 * @param {!Event} e 268 * @param {!Event} e
256 * @param {!Set<string>} itemIds 269 * @param {!Set<string>} itemIds
257 * @return {boolean} True if the event was handled, triggering a keyboard 270 * @return {boolean} True if the event was handled, triggering a keyboard
258 * shortcut. 271 * shortcut.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 507
495 /** @return {!bookmarks.CommandManager} */ 508 /** @return {!bookmarks.CommandManager} */
496 CommandManager.getInstance = function() { 509 CommandManager.getInstance = function() {
497 return assert(CommandManager.instance_); 510 return assert(CommandManager.instance_);
498 }; 511 };
499 512
500 return { 513 return {
501 CommandManager: CommandManager, 514 CommandManager: CommandManager,
502 }; 515 };
503 }); 516 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698