OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' | 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' |
8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; | 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; |
9 | 9 |
10 // If directory files changes too often, don't rescan directory more than once | 10 // If directory files changes too often, don't rescan directory more than once |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 onDone(); | 568 onDone(); |
569 } | 569 } |
570 } | 570 } |
571 | 571 |
572 function onEntryFound(entry) { | 572 function onEntryFound(entry) { |
573 if (entry) { | 573 if (entry) { |
574 entriesToEnumerate++; | 574 entriesToEnumerate++; |
575 var path = entry.fullPath; | 575 var path = entry.fullPath; |
576 if (path == ARCHIVE_DIRECTORY || path == REMOVABLE_DIRECTORY) { | 576 if (path == ARCHIVE_DIRECTORY || path == REMOVABLE_DIRECTORY) { |
577 // All removable devices and mounted archives are considered | 577 // All removable devices and mounted archives are considered |
578 // roots, and are shown in the sidebar. | 578 // roots. |
579 util.forEachDirEntry(entry, onRootFound); | 579 util.forEachDirEntry(entry, onRootFound); |
580 } else { | 580 } else { |
581 onRootFound(entry); | 581 onRootFound(entry); |
582 onRootFound(null); | 582 onRootFound(null); |
583 } | 583 } |
584 } else { | 584 } else { |
585 allEntriesFound = true; | 585 allEntriesFound = true; |
586 if (entriesToEnumerate == 0) | 586 if (entriesToEnumerate == 0) |
587 onDone(); | 587 onDone(); |
588 } | 588 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 'keyup', this.onFilenameInputKeyUp_.bind(this)); | 756 'keyup', this.onFilenameInputKeyUp_.bind(this)); |
757 this.filenameInput_.addEventListener( | 757 this.filenameInput_.addEventListener( |
758 'focus', this.onFilenameInputFocus_.bind(this)); | 758 'focus', this.onFilenameInputFocus_.bind(this)); |
759 | 759 |
760 var listContainer = this.dialogDom_.querySelector('.list-container'); | 760 var listContainer = this.dialogDom_.querySelector('.list-container'); |
761 listContainer.addEventListener('keydown', this.onListKeyDown_.bind(this)); | 761 listContainer.addEventListener('keydown', this.onListKeyDown_.bind(this)); |
762 listContainer.addEventListener('keypress', this.onListKeyPress_.bind(this)); | 762 listContainer.addEventListener('keypress', this.onListKeyPress_.bind(this)); |
763 this.okButton_.addEventListener('click', this.onOk_.bind(this)); | 763 this.okButton_.addEventListener('click', this.onOk_.bind(this)); |
764 this.cancelButton_.addEventListener('click', this.onCancel_.bind(this)); | 764 this.cancelButton_.addEventListener('click', this.onCancel_.bind(this)); |
765 | 765 |
766 this.dialogDom_.querySelector('div.open-sidebar').addEventListener( | |
767 'click', this.onToggleSidebar_.bind(this)); | |
768 this.dialogDom_.querySelector('div.close-sidebar').addEventListener( | |
769 'click', this.onToggleSidebar_.bind(this)); | |
770 this.dialogContainer_ = this.dialogDom_.querySelector('.dialog-container'); | 766 this.dialogContainer_ = this.dialogDom_.querySelector('.dialog-container'); |
771 | 767 |
772 this.dialogDom_.querySelector('button.detail-view').addEventListener( | 768 this.dialogDom_.querySelector('button.detail-view').addEventListener( |
773 'click', this.onDetailViewButtonClick_.bind(this)); | 769 'click', this.onDetailViewButtonClick_.bind(this)); |
774 this.dialogDom_.querySelector('button.thumbnail-view').addEventListener( | 770 this.dialogDom_.querySelector('button.thumbnail-view').addEventListener( |
775 'click', this.onThumbnailViewButtonClick_.bind(this)); | 771 'click', this.onThumbnailViewButtonClick_.bind(this)); |
776 | 772 |
777 this.dialogDom_.ownerDocument.defaultView.addEventListener( | 773 this.dialogDom_.ownerDocument.defaultView.addEventListener( |
778 'resize', this.onResize_.bind(this)); | 774 'resize', this.onResize_.bind(this)); |
779 | 775 |
(...skipping 2878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3658 var selectionEnd = input.value.lastIndexOf('.'); | 3654 var selectionEnd = input.value.lastIndexOf('.'); |
3659 if (selectionEnd == -1) { | 3655 if (selectionEnd == -1) { |
3660 input.select(); | 3656 input.select(); |
3661 } else { | 3657 } else { |
3662 input.selectionStart = 0; | 3658 input.selectionStart = 0; |
3663 input.selectionEnd = selectionEnd; | 3659 input.selectionEnd = selectionEnd; |
3664 } | 3660 } |
3665 }, 0); | 3661 }, 0); |
3666 }; | 3662 }; |
3667 | 3663 |
3668 FileManager.prototype.onToggleSidebar_ = function(event) { | |
3669 if (this.dialogContainer_.hasAttribute('sidebar')) { | |
3670 this.dialogContainer_.removeAttribute('sidebar'); | |
3671 } else { | |
3672 this.dialogContainer_.setAttribute('sidebar', 'sidebar'); | |
3673 } | |
3674 // TODO(dgozman): make table header css-resizable. | |
3675 setTimeout(this.onResize_.bind(this), 300); | |
3676 }; | |
3677 | |
3678 FileManager.prototype.onNewFolderCommand_ = function(event) { | 3664 FileManager.prototype.onNewFolderCommand_ = function(event) { |
3679 var self = this; | 3665 var self = this; |
3680 | 3666 |
3681 function onNameSelected(name) { | 3667 function onNameSelected(name) { |
3682 var valid = self.validateFileName_(name, function() { | 3668 var valid = self.validateFileName_(name, function() { |
3683 promptForName(name); | 3669 promptForName(name); |
3684 }); | 3670 }); |
3685 | 3671 |
3686 if (!valid) { | 3672 if (!valid) { |
3687 // Validation failed. User will be prompted for a new name after they | 3673 // Validation failed. User will be prompted for a new name after they |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4153 }); | 4139 }); |
4154 }, onError); | 4140 }, onError); |
4155 | 4141 |
4156 function onError(err) { | 4142 function onError(err) { |
4157 console.log('Error while checking free space: ' + err); | 4143 console.log('Error while checking free space: ' + err); |
4158 setTimeout(doCheck, 1000 * 60); | 4144 setTimeout(doCheck, 1000 * 60); |
4159 } | 4145 } |
4160 } | 4146 } |
4161 } | 4147 } |
4162 })(); | 4148 })(); |
OLD | NEW |