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

Side by Side Diff: chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js

Issue 153833005: Files.app: Remove unused ctrl key flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * TODO(dzvorygin): Here we use this hack, since 'hidden' is standard 8 * TODO(dzvorygin): Here we use this hack, since 'hidden' is standard
9 * attribute and we can't use it's setter as usual. 9 * attribute and we can't use it's setter as usual.
10 * @param {boolean} value New value of hidden property. 10 * @param {boolean} value New value of hidden property.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 */ 232 */
233 this.fileManager_ = fileManager; 233 this.fileManager_ = fileManager;
234 234
235 /** 235 /**
236 * Command elements. 236 * Command elements.
237 * @type {Object.<string, cr.ui.Command>} 237 * @type {Object.<string, cr.ui.Command>}
238 * @private 238 * @private
239 */ 239 */
240 this.commands_ = {}; 240 this.commands_ = {};
241 241
242 /**
243 * Whether the ctrl key is pressed or not.
244 * @type {boolean}
245 * @private
246 */
247 this.ctrlKeyPressed_ = false;
248
249 Object.seal(this); 242 Object.seal(this);
250 243
251 // Decorate command tags in the document. 244 // Decorate command tags in the document.
252 var commands = fileManager.document.querySelectorAll('command'); 245 var commands = fileManager.document.querySelectorAll('command');
253 for (var i = 0; i < commands.length; i++) { 246 for (var i = 0; i < commands.length; i++) {
254 cr.ui.Command.decorate(commands[i]); 247 cr.ui.Command.decorate(commands[i]);
255 this.commands_[commands[i].id] = commands[i]; 248 this.commands_[commands[i].id] = commands[i];
256 } 249 }
257 250
258 // Register events. 251 // Register events.
259 fileManager.document.addEventListener('command', this.onCommand_.bind(this)); 252 fileManager.document.addEventListener('command', this.onCommand_.bind(this));
260 fileManager.document.addEventListener('canExecute', 253 fileManager.document.addEventListener('canExecute',
261 this.onCanExecute_.bind(this)); 254 this.onCanExecute_.bind(this));
262 fileManager.document.addEventListener('keydown', this.onKeyDown_.bind(this));
263 fileManager.document.addEventListener('keyup', this.onKeyUp_.bind(this));
264 }; 255 };
265 256
266 /** 257 /**
267 * Updates the availability of all commands. 258 * Updates the availability of all commands.
268 */ 259 */
269 CommandHandler.prototype.updateAvailability = function() { 260 CommandHandler.prototype.updateAvailability = function() {
270 for (var id in this.commands_) { 261 for (var id in this.commands_) {
271 this.commands_[id].canExecuteChange(); 262 this.commands_[id].canExecuteChange();
272 } 263 }
273 }; 264 };
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 * @private 296 * @private
306 */ 297 */
307 CommandHandler.prototype.onCanExecute_ = function(event) { 298 CommandHandler.prototype.onCanExecute_ = function(event) {
308 if (this.shouldIgnoreEvents_()) 299 if (this.shouldIgnoreEvents_())
309 return; 300 return;
310 var handler = CommandHandler.COMMANDS_[event.command.id]; 301 var handler = CommandHandler.COMMANDS_[event.command.id];
311 handler.canExecute.call(this, event, this.fileManager_); 302 handler.canExecute.call(this, event, this.fileManager_);
312 }; 303 };
313 304
314 /** 305 /**
315 * Handle key down event.
316 * @param {Event} event Key down event.
317 * @private
318 */
319 CommandHandler.prototype.onKeyDown_ = function(event) {
320 // 17 is the keycode of Ctrl key and it means the event is not for other keys
321 // with Ctrl modifier but for ctrl key itself.
322 if (util.getKeyModifiers(event) + event.keyCode == 'Ctrl-17') {
323 this.ctrlKeyPressed_ = true;
324 this.updateAvailability();
325 }
326 };
327
328 /**
329 * Handle key up event.
330 * @param {Event} event Key up event.
331 * @private
332 */
333 CommandHandler.prototype.onKeyUp_ = function(event) {
334 // 17 is the keycode of Ctrl key and it means the event is not for other keys
335 // with Ctrl modifier but for ctrl key itself.
336 if (util.getKeyModifiers(event) + event.keyCode == '17') {
337 this.ctrlKeyPressed_ = false;
338 this.updateAvailability();
339 }
340 };
341
342 /**
343 * Commands. 306 * Commands.
344 * @type {Object.<string, Command>} 307 * @type {Object.<string, Command>}
345 * @const 308 * @const
346 * @private 309 * @private
347 */ 310 */
348 CommandHandler.COMMANDS_ = {}; 311 CommandHandler.COMMANDS_ = {};
349 312
350 /** 313 /**
351 * Unmounts external drive. 314 * Unmounts external drive.
352 * @type {Command} 315 * @type {Command}
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 /** 795 /**
833 * Reset the zoom factor. 796 * Reset the zoom factor.
834 * @type {Command} 797 * @type {Command}
835 */ 798 */
836 CommandHandler.COMMANDS_['zoom-reset'] = { 799 CommandHandler.COMMANDS_['zoom-reset'] = {
837 execute: function(event, fileManager) { 800 execute: function(event, fileManager) {
838 chrome.fileBrowserPrivate.zoom('reset'); 801 chrome.fileBrowserPrivate.zoom('reset');
839 }, 802 },
840 canExecute: CommandUtil.canExecuteAlways 803 canExecute: CommandUtil.canExecuteAlways
841 }; 804 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698