| 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 var g_slideshow_data = null; | 10 var g_slideshow_data = null; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 this.onFileTaskExecute_.bind(this)); | 132 this.onFileTaskExecute_.bind(this)); |
| 133 | 133 |
| 134 this.initCommands_(); | 134 this.initCommands_(); |
| 135 this.initDom_(); | 135 this.initDom_(); |
| 136 this.initDialogType_(); | 136 this.initDialogType_(); |
| 137 this.setupCurrentDirectory_(); | 137 this.setupCurrentDirectory_(); |
| 138 | 138 |
| 139 this.summarizeSelection_(); | 139 this.summarizeSelection_(); |
| 140 this.updatePreview_(); | 140 this.updatePreview_(); |
| 141 | 141 |
| 142 this.dataModel_.sort('cachedMtime_'); |
| 143 |
| 142 this.refocus(); | 144 this.refocus(); |
| 143 | 145 |
| 144 // Pass all URLs to the metadata reader until we have a correct filter. | 146 // Pass all URLs to the metadata reader until we have a correct filter. |
| 145 this.metadataUrlFilter_ = /.*/; | 147 this.metadataUrlFilter_ = /.*/; |
| 146 | 148 |
| 147 this.metadataReader_ = new Worker('js/metadata_dispatcher.js'); | 149 this.metadataReader_ = new Worker('js/metadata_dispatcher.js'); |
| 148 this.metadataReader_.onmessage = this.onMetadataMessage_.bind(this); | 150 this.metadataReader_.onmessage = this.onMetadataMessage_.bind(this); |
| 149 this.metadataReader_.postMessage({verb: 'init'}); | 151 this.metadataReader_.postMessage({verb: 'init'}); |
| 150 // Initialization is not complete until the Worker sends back the | 152 // Initialization is not complete until the Worker sends back the |
| 151 // 'initialized' message. See below. | 153 // 'initialized' message. See below. |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 | 630 |
| 629 this.dataModel_ = new cr.ui.ArrayDataModel([]); | 631 this.dataModel_ = new cr.ui.ArrayDataModel([]); |
| 630 var collator = this.collator_; | 632 var collator = this.collator_; |
| 631 this.dataModel_.setCompareFunction('name', function(a, b) { | 633 this.dataModel_.setCompareFunction('name', function(a, b) { |
| 632 return collator.compare(a.name, b.name); | 634 return collator.compare(a.name, b.name); |
| 633 }); | 635 }); |
| 634 this.dataModel_.setCompareFunction('cachedMtime_', | 636 this.dataModel_.setCompareFunction('cachedMtime_', |
| 635 this.compareMtime_.bind(this)); | 637 this.compareMtime_.bind(this)); |
| 636 this.dataModel_.setCompareFunction('cachedSize_', | 638 this.dataModel_.setCompareFunction('cachedSize_', |
| 637 this.compareSize_.bind(this)); | 639 this.compareSize_.bind(this)); |
| 638 this.dataModel_.sort('cachedMtime_'); | |
| 639 this.dataModel_.prepareSort = this.prepareSort_.bind(this); | 640 this.dataModel_.prepareSort = this.prepareSort_.bind(this); |
| 640 | 641 |
| 641 if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE || | 642 if (this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FILE || |
| 642 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FOLDER || | 643 this.dialogType_ == FileManager.DialogType.SELECT_OPEN_FOLDER || |
| 643 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { | 644 this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { |
| 644 this.selectionModelClass_ = cr.ui.ListSingleSelectionModel; | 645 this.selectionModelClass_ = cr.ui.ListSingleSelectionModel; |
| 645 } else { | 646 } else { |
| 646 this.selectionModelClass_ = cr.ui.ListSelectionModel; | 647 this.selectionModelClass_ = cr.ui.ListSelectionModel; |
| 647 } | 648 } |
| 648 | 649 |
| 649 this.initTable_(); | 650 this.initTable_(); |
| 650 this.initGrid_(); | 651 this.initGrid_(); |
| 651 | 652 |
| 652 this.setListType(FileManager.ListType.DETAIL); | 653 this.setListType(FileManager.ListType.DETAIL); |
| 653 | 654 |
| 654 this.onResize_(); | 655 this.onResize_(); |
| 655 this.dialogDom_.style.opacity = '1'; | 656 this.dialogDom_.style.opacity = '1'; |
| 656 | 657 |
| 657 this.textSearchState_ = {text: '', date: new Date()}; | 658 this.textSearchState_ = {text: '', date: new Date()}; |
| 658 }; | 659 }; |
| 659 | 660 |
| 660 /** | 661 /** |
| 661 * Compare by mtime first, then by name. | 662 * Compare by mtime first, then by name. |
| 662 */ | 663 */ |
| 663 FileManager.prototype.compareMtime_ = function(a, b) { | 664 FileManager.prototype.compareMtime_ = function(a, b) { |
| 664 if (a.cachedMtime_ > b.cachedMtime) | 665 if (a.cachedMtime_ > b.cachedMtime_) |
| 665 return 1; | 666 return 1; |
| 666 | 667 |
| 667 if (a.cachedMtime_ < b.cachedMtime) | 668 if (a.cachedMtime_ < b.cachedMtime_) |
| 668 return -1; | 669 return -1; |
| 669 | 670 |
| 670 return this.collator_.compare(a.name, b.name); | 671 return this.collator_.compare(a.name, b.name); |
| 671 }; | 672 }; |
| 672 | 673 |
| 673 /** | 674 /** |
| 674 * Compare by size first, then by name. | 675 * Compare by size first, then by name. |
| 675 */ | 676 */ |
| 676 FileManager.prototype.compareSize_ = function(a, b) { | 677 FileManager.prototype.compareSize_ = function(a, b) { |
| 677 if (a.cachedSize_ > b.cachedSize) | 678 if (a.cachedSize_ > b.cachedSize_) |
| 678 return 1; | 679 return 1; |
| 679 | 680 |
| 680 if (a.cachedSize_ < b.cachedSize) | 681 if (a.cachedSize_ < b.cachedSize_) |
| 681 return -1; | 682 return -1; |
| 682 | 683 |
| 683 return this.collator_.compare(a.name, b.name); | 684 return this.collator_.compare(a.name, b.name); |
| 684 }; | 685 }; |
| 685 | 686 |
| 686 FileManager.prototype.refocus = function() { | 687 FileManager.prototype.refocus = function() { |
| 687 this.document_.querySelector('[tabindex="0"]').focus(); | 688 this.document_.querySelector('[tabindex="0"]').focus(); |
| 688 }; | 689 }; |
| 689 | 690 |
| 690 FileManager.prototype.showButter = function(message, opt_options) { | 691 FileManager.prototype.showButter = function(message, opt_options) { |
| (...skipping 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3145 | 3146 |
| 3146 if (msg) { | 3147 if (msg) { |
| 3147 console.log('no no no'); | 3148 console.log('no no no'); |
| 3148 this.alert.show(msg, onAccept); | 3149 this.alert.show(msg, onAccept); |
| 3149 return false; | 3150 return false; |
| 3150 } | 3151 } |
| 3151 | 3152 |
| 3152 return true; | 3153 return true; |
| 3153 }; | 3154 }; |
| 3154 })(); | 3155 })(); |
| OLD | NEW |