| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 Gallery.prototype.onUserAction_ = function() { | 439 Gallery.prototype.onUserAction_ = function() { |
| 440 // Show the toolbar and hide it after the default timeout. | 440 // Show the toolbar and hide it after the default timeout. |
| 441 this.dimmableUIController_.kick(); | 441 this.dimmableUIController_.kick(); |
| 442 }; | 442 }; |
| 443 | 443 |
| 444 /** | 444 /** |
| 445 * Returns the current mode. | 445 * Returns the current mode. |
| 446 * @return {Gallery.Mode} | 446 * @return {Gallery.Mode} |
| 447 */ | 447 */ |
| 448 Gallery.prototype.getCurrentMode = function() { | 448 Gallery.prototype.getCurrentMode = function() { |
| 449 switch (/** @type {(SlideMode|ThumbnailMode)} */ (this.currentMode_)) { | 449 assert(this.currentMode_ === this.slideMode_ || |
| 450 case this.slideMode_: | 450 this.currentMode_ === this.thumbnailMode_); |
| 451 return Gallery.Mode.SLIDE; | 451 return this.currentMode_ === this.slideMode_ ? |
| 452 case this.thumbnailMode_: | 452 Gallery.Mode.SLIDE : Gallery.Mode.THUMBNAIL; |
| 453 return Gallery.Mode.THUMBNAIL; | |
| 454 default: | |
| 455 assertNotReached(); | |
| 456 } | |
| 457 }; | 453 }; |
| 458 | 454 |
| 459 /** | 455 /** |
| 460 * Returns sub mode of current mode. If current mode is not set yet, null is | 456 * Returns sub mode of current mode. If current mode is not set yet, null is |
| 461 * returned. | 457 * returned. |
| 462 * @return {Gallery.SubMode} | 458 * @return {Gallery.SubMode} |
| 463 */ | 459 */ |
| 464 Gallery.prototype.getCurrentSubMode = function() { | 460 Gallery.prototype.getCurrentSubMode = function() { |
| 465 assert(this.currentMode_); | 461 assert(this.currentMode_); |
| 466 return this.currentMode_.getSubMode(); | 462 return this.currentMode_.getSubMode(); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 deleteNext(); | 649 deleteNext(); |
| 654 }.bind(this), | 650 }.bind(this), |
| 655 function() { | 651 function() { |
| 656 // Restore the listener after a timeout so that ESC is processed. | 652 // Restore the listener after a timeout so that ESC is processed. |
| 657 setTimeout(restoreListener, 0); | 653 setTimeout(restoreListener, 0); |
| 658 }, | 654 }, |
| 659 null); | 655 null); |
| 660 }; | 656 }; |
| 661 | 657 |
| 662 /** | 658 /** |
| 663 * @return {!Array<Gallery.Item>} Current selection. | 659 * @return {!Array<GalleryItem>} Current selection. |
| 664 */ | 660 */ |
| 665 Gallery.prototype.getSelectedItems = function() { | 661 Gallery.prototype.getSelectedItems = function() { |
| 666 return this.selectionModel_.selectedIndexes.map( | 662 return this.selectionModel_.selectedIndexes.map( |
| 667 this.dataModel_.item.bind(this.dataModel_)); | 663 this.dataModel_.item.bind(this.dataModel_)); |
| 668 }; | 664 }; |
| 669 | 665 |
| 670 /** | 666 /** |
| 671 * @return {!Array<Entry>} Array of currently selected entries. | 667 * @return {!Array<Entry>} Array of currently selected entries. |
| 672 */ | 668 */ |
| 673 Gallery.prototype.getSelectedEntries = function() { | 669 Gallery.prototype.getSelectedEntries = function() { |
| 674 return this.selectionModel_.selectedIndexes.map(function(index) { | 670 return this.selectionModel_.selectedIndexes.map(function(index) { |
| 675 return this.dataModel_.item(index).getEntry(); | 671 return this.dataModel_.item(index).getEntry(); |
| 676 }.bind(this)); | 672 }.bind(this)); |
| 677 }; | 673 }; |
| 678 | 674 |
| 679 /** | 675 /** |
| 680 * @return {?Gallery.Item} Current single selection. | 676 * @return {?GalleryItem} Current single selection. |
| 681 */ | 677 */ |
| 682 Gallery.prototype.getSingleSelectedItem = function() { | 678 Gallery.prototype.getSingleSelectedItem = function() { |
| 683 var items = this.getSelectedItems(); | 679 var items = this.getSelectedItems(); |
| 684 if (items.length > 1) { | 680 if (items.length > 1) { |
| 685 console.error('Unexpected multiple selection'); | 681 console.error('Unexpected multiple selection'); |
| 686 return null; | 682 return null; |
| 687 } | 683 } |
| 688 return items[0]; | 684 return items[0]; |
| 689 }; | 685 }; |
| 690 | 686 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 */ | 1040 */ |
| 1045 var initializePromise = | 1041 var initializePromise = |
| 1046 Promise.all([loadTimeDataPromise, volumeManagerPromise]). | 1042 Promise.all([loadTimeDataPromise, volumeManagerPromise]). |
| 1047 then(function(args) { | 1043 then(function(args) { |
| 1048 var volumeManager = args[1]; | 1044 var volumeManager = args[1]; |
| 1049 gallery = new Gallery(volumeManager); | 1045 gallery = new Gallery(volumeManager); |
| 1050 }); | 1046 }); |
| 1051 | 1047 |
| 1052 // Loads entries. | 1048 // Loads entries. |
| 1053 initializePromise.then(reload); | 1049 initializePromise.then(reload); |
| OLD | NEW |