OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * Overrided metadata worker's path. | 6 * Overrided metadata worker's path. |
7 * @type {string} | 7 * @type {string} |
8 */ | 8 */ |
9 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; | 9 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; |
10 | 10 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 * @param {!Array<!FileEntry>} selectedEntries Array of selected entries. | 311 * @param {!Array<!FileEntry>} selectedEntries Array of selected entries. |
312 * @private | 312 * @private |
313 */ | 313 */ |
314 Gallery.prototype.loadInternal_ = function(entries, selectedEntries) { | 314 Gallery.prototype.loadInternal_ = function(entries, selectedEntries) { |
315 // Add the entries to data model. | 315 // Add the entries to data model. |
316 var items = []; | 316 var items = []; |
317 for (var i = 0; i < entries.length; i++) { | 317 for (var i = 0; i < entries.length; i++) { |
318 var locationInfo = this.volumeManager_.getLocationInfo(entries[i]); | 318 var locationInfo = this.volumeManager_.getLocationInfo(entries[i]); |
319 if (!locationInfo) // Skip the item, since gone. | 319 if (!locationInfo) // Skip the item, since gone. |
320 return; | 320 return; |
321 items.push(new Gallery.Item( | 321 items.push(new GalleryItem( |
322 entries[i], | 322 entries[i], |
323 locationInfo, | 323 locationInfo, |
324 null, | 324 null, |
325 null, | 325 null, |
326 true)); | 326 true)); |
327 } | 327 } |
328 this.dataModel_.splice(0, this.dataModel_.length); | 328 this.dataModel_.splice(0, this.dataModel_.length); |
329 this.updateThumbnails_(); // Remove the caches. | 329 this.updateThumbnails_(); // Remove the caches. |
330 | 330 |
331 GalleryDataModel.prototype.splice.apply( | 331 GalleryDataModel.prototype.splice.apply( |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 deleteNext(); | 653 deleteNext(); |
654 }.bind(this), | 654 }.bind(this), |
655 function() { | 655 function() { |
656 // Restore the listener after a timeout so that ESC is processed. | 656 // Restore the listener after a timeout so that ESC is processed. |
657 setTimeout(restoreListener, 0); | 657 setTimeout(restoreListener, 0); |
658 }, | 658 }, |
659 null); | 659 null); |
660 }; | 660 }; |
661 | 661 |
662 /** | 662 /** |
663 * @return {!Array<Gallery.Item>} Current selection. | 663 * @return {!Array<GalleryItem>} Current selection. |
664 */ | 664 */ |
665 Gallery.prototype.getSelectedItems = function() { | 665 Gallery.prototype.getSelectedItems = function() { |
666 return this.selectionModel_.selectedIndexes.map( | 666 return this.selectionModel_.selectedIndexes.map( |
667 this.dataModel_.item.bind(this.dataModel_)); | 667 this.dataModel_.item.bind(this.dataModel_)); |
668 }; | 668 }; |
669 | 669 |
670 /** | 670 /** |
671 * @return {!Array<Entry>} Array of currently selected entries. | 671 * @return {!Array<Entry>} Array of currently selected entries. |
672 */ | 672 */ |
673 Gallery.prototype.getSelectedEntries = function() { | 673 Gallery.prototype.getSelectedEntries = function() { |
674 return this.selectionModel_.selectedIndexes.map(function(index) { | 674 return this.selectionModel_.selectedIndexes.map(function(index) { |
675 return this.dataModel_.item(index).getEntry(); | 675 return this.dataModel_.item(index).getEntry(); |
676 }.bind(this)); | 676 }.bind(this)); |
677 }; | 677 }; |
678 | 678 |
679 /** | 679 /** |
680 * @return {?Gallery.Item} Current single selection. | 680 * @return {?GalleryItem} Current single selection. |
681 */ | 681 */ |
682 Gallery.prototype.getSingleSelectedItem = function() { | 682 Gallery.prototype.getSingleSelectedItem = function() { |
683 var items = this.getSelectedItems(); | 683 var items = this.getSelectedItems(); |
684 if (items.length > 1) { | 684 if (items.length > 1) { |
685 console.error('Unexpected multiple selection'); | 685 console.error('Unexpected multiple selection'); |
686 return null; | 686 return null; |
687 } | 687 } |
688 return items[0]; | 688 return items[0]; |
689 }; | 689 }; |
690 | 690 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 */ | 1044 */ |
1045 var initializePromise = | 1045 var initializePromise = |
1046 Promise.all([loadTimeDataPromise, volumeManagerPromise]). | 1046 Promise.all([loadTimeDataPromise, volumeManagerPromise]). |
1047 then(function(args) { | 1047 then(function(args) { |
1048 var volumeManager = args[1]; | 1048 var volumeManager = args[1]; |
1049 gallery = new Gallery(volumeManager); | 1049 gallery = new Gallery(volumeManager); |
1050 }); | 1050 }); |
1051 | 1051 |
1052 // Loads entries. | 1052 // Loads entries. |
1053 initializePromise.then(reload); | 1053 initializePromise.then(reload); |
OLD | NEW |