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

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

Issue 10079002: [File Manager] Hide hover state when using keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 8 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 | « chrome/browser/resources/file_manager/css/file_manager.css ('k') | 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 // Setting the src of an img to an empty string can crash the browser, so we 5 // Setting the src of an img to an empty string can crash the browser, so we
6 // use an empty 1x1 gif instead. 6 // use an empty 1x1 gif instead.
7 7
8 /** 8 /**
9 * FileManager constructor. 9 * FileManager constructor.
10 * 10 *
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 this.renameInput_.addEventListener( 670 this.renameInput_.addEventListener(
671 'keydown', this.onRenameInputKeyDown_.bind(this)); 671 'keydown', this.onRenameInputKeyDown_.bind(this));
672 this.renameInput_.addEventListener( 672 this.renameInput_.addEventListener(
673 'blur', this.onRenameInputBlur_.bind(this)); 673 'blur', this.onRenameInputBlur_.bind(this));
674 674
675 this.filenameInput_.addEventListener( 675 this.filenameInput_.addEventListener(
676 'keyup', this.onFilenameInputKeyUp_.bind(this)); 676 'keyup', this.onFilenameInputKeyUp_.bind(this));
677 this.filenameInput_.addEventListener( 677 this.filenameInput_.addEventListener(
678 'focus', this.onFilenameInputFocus_.bind(this)); 678 'focus', this.onFilenameInputFocus_.bind(this));
679 679
680 var listContainer = this.dialogDom_.querySelector('.list-container'); 680 this.listContainer_ = this.dialogDom_.querySelector('.list-container');
681 listContainer.addEventListener('keydown', this.onListKeyDown_.bind(this)); 681 this.listContainer_.addEventListener(
682 listContainer.addEventListener('keypress', this.onListKeyPress_.bind(this)); 682 'keydown', this.onListKeyDown_.bind(this));
683 this.listContainer_.addEventListener(
684 'keypress', this.onListKeyPress_.bind(this));
685 this.listContainer_.addEventListener(
686 'mousemove', this.onListMouseMove_.bind(this));
687
683 this.okButton_.addEventListener('click', this.onOk_.bind(this)); 688 this.okButton_.addEventListener('click', this.onOk_.bind(this));
684 this.cancelButton_.addEventListener('click', this.onCancel_.bind(this)); 689 this.cancelButton_.addEventListener('click', this.onCancel_.bind(this));
685 690
686 this.dialogDom_.querySelector('div.open-sidebar').addEventListener( 691 this.dialogDom_.querySelector('div.open-sidebar').addEventListener(
687 'click', this.onToggleSidebar_.bind(this)); 692 'click', this.onToggleSidebar_.bind(this));
688 this.dialogDom_.querySelector('div.open-sidebar').addEventListener( 693 this.dialogDom_.querySelector('div.open-sidebar').addEventListener(
689 'keypress', this.onToggleSidebarPress_.bind(this)); 694 'keypress', this.onToggleSidebarPress_.bind(this));
690 this.dialogDom_.querySelector('div.close-sidebar').addEventListener( 695 this.dialogDom_.querySelector('div.close-sidebar').addEventListener(
691 'click', this.onToggleSidebar_.bind(this)); 696 'click', this.onToggleSidebar_.bind(this));
692 this.dialogDom_.querySelector('div.close-sidebar').addEventListener( 697 this.dialogDom_.querySelector('div.close-sidebar').addEventListener(
(...skipping 3579 matching lines...) Expand 10 before | Expand all | Expand 10 after
4272 this.onDirectoryAction(this.selection.entries[0]); 4277 this.onDirectoryAction(this.selection.entries[0]);
4273 } else if (this.dispatchSelectionAction_()) { 4278 } else if (this.dispatchSelectionAction_()) {
4274 event.preventDefault(); 4279 event.preventDefault();
4275 } 4280 }
4276 break; 4281 break;
4277 4282
4278 case '46': // Delete. 4283 case '46': // Delete.
4279 handleCommand('delete'); 4284 handleCommand('delete');
4280 break; 4285 break;
4281 } 4286 }
4287
4288 switch (event.keyIdentifier) {
4289 case 'Home':
4290 case 'End':
4291 case 'Up':
4292 case 'Down':
4293 case 'Left':
4294 case 'Right':
4295 // When navigating with keyboard we hide the distracting mouse hover
4296 // highlighting until the user moves the mouse again.
4297 this.listContainer_.classList.add('nohover');
4298 break;
4299 }
4282 }; 4300 };
4283 4301
4284 /** 4302 /**
4285 * KeyPress event handler for the div.list-container element. 4303 * KeyPress event handler for the div.list-container element.
4286 */ 4304 */
4287 FileManager.prototype.onListKeyPress_ = function(event) { 4305 FileManager.prototype.onListKeyPress_ = function(event) {
4288 if (event.srcElement.tagName == 'INPUT') { 4306 if (event.srcElement.tagName == 'INPUT') {
4289 // Ignore keypress handler in the rename input box. 4307 // Ignore keypress handler in the rename input box.
4290 return; 4308 return;
4291 } 4309 }
4292 4310
4293 if (event.ctrlKey || event.metaKey || event.altKey) 4311 if (event.ctrlKey || event.metaKey || event.altKey)
4294 return; 4312 return;
4295 4313
4296 var now = new Date(); 4314 var now = new Date();
4297 var char = String.fromCharCode(event.charCode).toLowerCase(); 4315 var char = String.fromCharCode(event.charCode).toLowerCase();
4298 var text = now - this.textSearchState_.date > 1000 ? '' : 4316 var text = now - this.textSearchState_.date > 1000 ? '' :
4299 this.textSearchState_.text; 4317 this.textSearchState_.text;
4300 this.textSearchState_ = {text: text + char, date: now}; 4318 this.textSearchState_ = {text: text + char, date: now};
4301 4319
4302 this.doTextSearch_(); 4320 this.doTextSearch_();
4303 }; 4321 };
4304 4322
4305 /** 4323 /**
4324 * Mousemove event handler for the div.list-container element.
4325 */
4326 FileManager.prototype.onListMouseMove_ = function(event) {
4327 // The user grabbed the mouse, restore the hover highlighting.
4328 this.listContainer_.classList.remove('nohover');
4329 };
4330
4331 /**
4306 * Performs a 'text search' - selects a first list entry with name 4332 * Performs a 'text search' - selects a first list entry with name
4307 * starting with entered text (case-insensitive). 4333 * starting with entered text (case-insensitive).
4308 */ 4334 */
4309 FileManager.prototype.doTextSearch_ = function() { 4335 FileManager.prototype.doTextSearch_ = function() {
4310 var text = this.textSearchState_.text; 4336 var text = this.textSearchState_.text;
4311 if (!text) 4337 if (!text)
4312 return; 4338 return;
4313 4339
4314 var dm = this.directoryModel_.fileList; 4340 var dm = this.directoryModel_.fileList;
4315 for (var index = 0; index < dm.length; ++index) { 4341 for (var index = 0; index < dm.length; ++index) {
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 4723
4698 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo); 4724 chrome.fileBrowserPrivate.setGDataPreferences(changeInfo);
4699 4725
4700 if (oldValue) { 4726 if (oldValue) {
4701 event.target.removeAttribute('checked'); 4727 event.target.removeAttribute('checked');
4702 } else { 4728 } else {
4703 event.target.setAttribute('checked', 'checked'); 4729 event.target.setAttribute('checked', 'checked');
4704 } 4730 }
4705 }; 4731 };
4706 })(); 4732 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/css/file_manager.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698