OLD | NEW |
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 * FileManager constructor. | 6 * FileManager constructor. |
7 * | 7 * |
8 * FileManager objects encapsulate the functionality of the file selector | 8 * FileManager objects encapsulate the functionality of the file selector |
9 * dialogs, as well as the full screen file manager application (though the | 9 * dialogs, as well as the full screen file manager application (though the |
10 * latter is not yet implemented). | 10 * latter is not yet implemented). |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 this.renameInput_.addEventListener( | 513 this.renameInput_.addEventListener( |
514 'keydown', this.onRenameInputKeyDown_.bind(this)); | 514 'keydown', this.onRenameInputKeyDown_.bind(this)); |
515 this.renameInput_.addEventListener( | 515 this.renameInput_.addEventListener( |
516 'blur', this.onRenameInputBlur_.bind(this)); | 516 'blur', this.onRenameInputBlur_.bind(this)); |
517 | 517 |
518 this.filenameInput_.addEventListener( | 518 this.filenameInput_.addEventListener( |
519 'keyup', this.onFilenameInputKeyUp_.bind(this)); | 519 'keyup', this.onFilenameInputKeyUp_.bind(this)); |
520 this.filenameInput_.addEventListener( | 520 this.filenameInput_.addEventListener( |
521 'focus', this.onFilenameInputFocus_.bind(this)); | 521 'focus', this.onFilenameInputFocus_.bind(this)); |
522 | 522 |
523 this.listContainer_ = this.dialogDom_.querySelector('.list-container'); | 523 this.listContainer_ = this.dialogDom_.querySelector('#list-container'); |
524 this.listContainer_.addEventListener( | 524 this.listContainer_.addEventListener( |
525 'keydown', this.onListKeyDown_.bind(this)); | 525 'keydown', this.onListKeyDown_.bind(this)); |
526 this.listContainer_.addEventListener( | 526 this.listContainer_.addEventListener( |
527 'keypress', this.onListKeyPress_.bind(this)); | 527 'keypress', this.onListKeyPress_.bind(this)); |
528 this.listContainer_.addEventListener( | 528 this.listContainer_.addEventListener( |
529 'mousemove', this.onListMouseMove_.bind(this)); | 529 'mousemove', this.onListMouseMove_.bind(this)); |
530 | 530 |
531 this.okButton_.addEventListener('click', this.onOk_.bind(this)); | 531 this.okButton_.addEventListener('click', this.onOk_.bind(this)); |
532 this.onCancelBound_ = this.onCancel_.bind(this); | 532 this.onCancelBound_ = this.onCancel_.bind(this); |
533 this.cancelButton_.addEventListener('click', this.onCancelBound_); | 533 this.cancelButton_.addEventListener('click', this.onCancelBound_); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 var listType = FileManager.ListType.DETAIL; | 635 var listType = FileManager.ListType.DETAIL; |
636 if (FileManager.DialogType.isModal(this.dialogType_)) | 636 if (FileManager.DialogType.isModal(this.dialogType_)) |
637 listType = window.localStorage['listType-' + this.dialogType_] || | 637 listType = window.localStorage['listType-' + this.dialogType_] || |
638 FileManager.ListType.DETAIL; | 638 FileManager.ListType.DETAIL; |
639 this.setListType(listType); | 639 this.setListType(listType); |
640 | 640 |
641 this.textSearchState_ = {text: '', date: new Date()}; | 641 this.textSearchState_ = {text: '', date: new Date()}; |
642 }; | 642 }; |
643 | 643 |
644 FileManager.prototype.initRootsList_ = function() { | 644 FileManager.prototype.initRootsList_ = function() { |
645 this.rootsList_ = this.dialogDom_.querySelector('.roots-list'); | 645 this.rootsList_ = this.dialogDom_.querySelector('#roots-list'); |
646 cr.ui.List.decorate(this.rootsList_); | 646 cr.ui.List.decorate(this.rootsList_); |
647 this.rootsList_.startBatchUpdates(); | 647 this.rootsList_.startBatchUpdates(); |
648 | 648 |
649 var self = this; | 649 var self = this; |
650 this.rootsList_.itemConstructor = function(entry) { | 650 this.rootsList_.itemConstructor = function(entry) { |
651 return self.renderRoot_(entry); | 651 return self.renderRoot_(entry); |
652 }; | 652 }; |
653 | 653 |
654 this.rootsList_.selectionModel = | 654 this.rootsList_.selectionModel = |
655 this.directoryModel_.getRootsListSelectionModel(); | 655 this.directoryModel_.getRootsListSelectionModel(); |
(...skipping 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3711 if (this.dialogType_ != FileManager.DialogType.FULL_PAGE) { | 3711 if (this.dialogType_ != FileManager.DialogType.FULL_PAGE) { |
3712 // If there is nothing else for ESC to do, then cancel the dialog. | 3712 // If there is nothing else for ESC to do, then cancel the dialog. |
3713 event.preventDefault(); | 3713 event.preventDefault(); |
3714 this.cancelButton_.click(); | 3714 this.cancelButton_.click(); |
3715 } | 3715 } |
3716 break; | 3716 break; |
3717 } | 3717 } |
3718 }; | 3718 }; |
3719 | 3719 |
3720 /** | 3720 /** |
3721 * KeyDown event handler for the div.list-container element. | 3721 * KeyDown event handler for the div#list-container element. |
3722 */ | 3722 */ |
3723 FileManager.prototype.onListKeyDown_ = function(event) { | 3723 FileManager.prototype.onListKeyDown_ = function(event) { |
3724 if (event.srcElement.tagName == 'INPUT') { | 3724 if (event.srcElement.tagName == 'INPUT') { |
3725 // Ignore keydown handler in the rename input box. | 3725 // Ignore keydown handler in the rename input box. |
3726 return; | 3726 return; |
3727 } | 3727 } |
3728 | 3728 |
3729 var self = this; | 3729 var self = this; |
3730 function handleCommand(name) { | 3730 function handleCommand(name) { |
3731 var command = self.commands_[name]; | 3731 var command = self.commands_[name]; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3798 case 'Left': | 3798 case 'Left': |
3799 case 'Right': | 3799 case 'Right': |
3800 // When navigating with keyboard we hide the distracting mouse hover | 3800 // When navigating with keyboard we hide the distracting mouse hover |
3801 // highlighting until the user moves the mouse again. | 3801 // highlighting until the user moves the mouse again. |
3802 this.listContainer_.classList.add('nohover'); | 3802 this.listContainer_.classList.add('nohover'); |
3803 break; | 3803 break; |
3804 } | 3804 } |
3805 }; | 3805 }; |
3806 | 3806 |
3807 /** | 3807 /** |
3808 * KeyPress event handler for the div.list-container element. | 3808 * KeyPress event handler for the div#list-container element. |
3809 */ | 3809 */ |
3810 FileManager.prototype.onListKeyPress_ = function(event) { | 3810 FileManager.prototype.onListKeyPress_ = function(event) { |
3811 if (event.srcElement.tagName == 'INPUT') { | 3811 if (event.srcElement.tagName == 'INPUT') { |
3812 // Ignore keypress handler in the rename input box. | 3812 // Ignore keypress handler in the rename input box. |
3813 return; | 3813 return; |
3814 } | 3814 } |
3815 | 3815 |
3816 if (event.ctrlKey || event.metaKey || event.altKey) | 3816 if (event.ctrlKey || event.metaKey || event.altKey) |
3817 return; | 3817 return; |
3818 | 3818 |
3819 var now = new Date(); | 3819 var now = new Date(); |
3820 var char = String.fromCharCode(event.charCode).toLowerCase(); | 3820 var char = String.fromCharCode(event.charCode).toLowerCase(); |
3821 var text = now - this.textSearchState_.date > 1000 ? '' : | 3821 var text = now - this.textSearchState_.date > 1000 ? '' : |
3822 this.textSearchState_.text; | 3822 this.textSearchState_.text; |
3823 this.textSearchState_ = {text: text + char, date: now}; | 3823 this.textSearchState_ = {text: text + char, date: now}; |
3824 | 3824 |
3825 this.doTextSearch_(); | 3825 this.doTextSearch_(); |
3826 }; | 3826 }; |
3827 | 3827 |
3828 /** | 3828 /** |
3829 * Mousemove event handler for the div.list-container element. | 3829 * Mousemove event handler for the div#list-container element. |
3830 */ | 3830 */ |
3831 FileManager.prototype.onListMouseMove_ = function(event) { | 3831 FileManager.prototype.onListMouseMove_ = function(event) { |
3832 // The user grabbed the mouse, restore the hover highlighting. | 3832 // The user grabbed the mouse, restore the hover highlighting. |
3833 this.listContainer_.classList.remove('nohover'); | 3833 this.listContainer_.classList.remove('nohover'); |
3834 }; | 3834 }; |
3835 | 3835 |
3836 /** | 3836 /** |
3837 * Performs a 'text search' - selects a first list entry with name | 3837 * Performs a 'text search' - selects a first list entry with name |
3838 * starting with entered text (case-insensitive). | 3838 * starting with entered text (case-insensitive). |
3839 */ | 3839 */ |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4360 } | 4360 } |
4361 | 4361 |
4362 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); | 4362 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); |
4363 | 4363 |
4364 var style = this.document_.createElement('link'); | 4364 var style = this.document_.createElement('link'); |
4365 style.rel = 'stylesheet'; | 4365 style.rel = 'stylesheet'; |
4366 style.href = 'css/gdrive_welcome.css'; | 4366 style.href = 'css/gdrive_welcome.css'; |
4367 this.document_.head.appendChild(style); | 4367 this.document_.head.appendChild(style); |
4368 }; | 4368 }; |
4369 })(); | 4369 })(); |
OLD | NEW |