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 3057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3713 if (this.dialogType_ != FileManager.DialogType.FULL_PAGE) { | 3713 if (this.dialogType_ != FileManager.DialogType.FULL_PAGE) { |
3714 // If there is nothing else for ESC to do, then cancel the dialog. | 3714 // If there is nothing else for ESC to do, then cancel the dialog. |
3715 event.preventDefault(); | 3715 event.preventDefault(); |
3716 this.cancelButton_.click(); | 3716 this.cancelButton_.click(); |
3717 } | 3717 } |
3718 break; | 3718 break; |
3719 } | 3719 } |
3720 }; | 3720 }; |
3721 | 3721 |
3722 /** | 3722 /** |
3723 * KeyDown event handler for the div.list-container element. | 3723 * KeyDown event handler for the div#list-container element. |
3724 */ | 3724 */ |
3725 FileManager.prototype.onListKeyDown_ = function(event) { | 3725 FileManager.prototype.onListKeyDown_ = function(event) { |
3726 if (event.srcElement.tagName == 'INPUT') { | 3726 if (event.srcElement.tagName == 'INPUT') { |
3727 // Ignore keydown handler in the rename input box. | 3727 // Ignore keydown handler in the rename input box. |
3728 return; | 3728 return; |
3729 } | 3729 } |
3730 | 3730 |
3731 var self = this; | 3731 var self = this; |
3732 function handleCommand(name) { | 3732 function handleCommand(name) { |
3733 var command = self.commands_[name]; | 3733 var command = self.commands_[name]; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3800 case 'Left': | 3800 case 'Left': |
3801 case 'Right': | 3801 case 'Right': |
3802 // When navigating with keyboard we hide the distracting mouse hover | 3802 // When navigating with keyboard we hide the distracting mouse hover |
3803 // highlighting until the user moves the mouse again. | 3803 // highlighting until the user moves the mouse again. |
3804 this.listContainer_.classList.add('nohover'); | 3804 this.listContainer_.classList.add('nohover'); |
3805 break; | 3805 break; |
3806 } | 3806 } |
3807 }; | 3807 }; |
3808 | 3808 |
3809 /** | 3809 /** |
3810 * KeyPress event handler for the div.list-container element. | 3810 * KeyPress event handler for the div#list-container element. |
3811 */ | 3811 */ |
3812 FileManager.prototype.onListKeyPress_ = function(event) { | 3812 FileManager.prototype.onListKeyPress_ = function(event) { |
3813 if (event.srcElement.tagName == 'INPUT') { | 3813 if (event.srcElement.tagName == 'INPUT') { |
3814 // Ignore keypress handler in the rename input box. | 3814 // Ignore keypress handler in the rename input box. |
3815 return; | 3815 return; |
3816 } | 3816 } |
3817 | 3817 |
3818 if (event.ctrlKey || event.metaKey || event.altKey) | 3818 if (event.ctrlKey || event.metaKey || event.altKey) |
3819 return; | 3819 return; |
3820 | 3820 |
3821 var now = new Date(); | 3821 var now = new Date(); |
3822 var char = String.fromCharCode(event.charCode).toLowerCase(); | 3822 var char = String.fromCharCode(event.charCode).toLowerCase(); |
3823 var text = now - this.textSearchState_.date > 1000 ? '' : | 3823 var text = now - this.textSearchState_.date > 1000 ? '' : |
3824 this.textSearchState_.text; | 3824 this.textSearchState_.text; |
3825 this.textSearchState_ = {text: text + char, date: now}; | 3825 this.textSearchState_ = {text: text + char, date: now}; |
3826 | 3826 |
3827 this.doTextSearch_(); | 3827 this.doTextSearch_(); |
3828 }; | 3828 }; |
3829 | 3829 |
3830 /** | 3830 /** |
3831 * Mousemove event handler for the div.list-container element. | 3831 * Mousemove event handler for the div#list-container element. |
3832 */ | 3832 */ |
3833 FileManager.prototype.onListMouseMove_ = function(event) { | 3833 FileManager.prototype.onListMouseMove_ = function(event) { |
3834 // The user grabbed the mouse, restore the hover highlighting. | 3834 // The user grabbed the mouse, restore the hover highlighting. |
3835 this.listContainer_.classList.remove('nohover'); | 3835 this.listContainer_.classList.remove('nohover'); |
3836 }; | 3836 }; |
3837 | 3837 |
3838 /** | 3838 /** |
3839 * Performs a 'text search' - selects a first list entry with name | 3839 * Performs a 'text search' - selects a first list entry with name |
3840 * starting with entered text (case-insensitive). | 3840 * starting with entered text (case-insensitive). |
3841 */ | 3841 */ |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4366 | 4366 |
4367 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); | 4367 this.directoryModel_.addEventListener('scan-completed', maybeShowBanner); |
4368 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner); | 4368 this.directoryModel_.addEventListener('rescan-completed', maybeShowBanner); |
4369 | 4369 |
4370 var style = this.document_.createElement('link'); | 4370 var style = this.document_.createElement('link'); |
4371 style.rel = 'stylesheet'; | 4371 style.rel = 'stylesheet'; |
4372 style.href = 'css/gdrive_welcome.css'; | 4372 style.href = 'css/gdrive_welcome.css'; |
4373 this.document_.head.appendChild(style); | 4373 this.document_.head.appendChild(style); |
4374 }; | 4374 }; |
4375 })(); | 4375 })(); |
OLD | NEW |