OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Thumbnail Mode. | 6 * Thumbnail Mode. |
7 * @param {!HTMLElement} container A container. | 7 * @param {!HTMLElement} container A container. |
8 * @param {!ErrorBanner} errorBanner Error banner. | 8 * @param {!ErrorBanner} errorBanner Error banner. |
9 * @param {!GalleryDataModel} dataModel Gallery data model. | 9 * @param {!GalleryDataModel} dataModel Gallery data model. |
10 * @param {!cr.ui.ListSelectionModel} selectionModel List selection model. | 10 * @param {!cr.ui.ListSelectionModel} selectionModel List selection model. |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 this.selectionModel_.selectRange(leadIndex, index); | 665 this.selectionModel_.selectRange(leadIndex, index); |
666 } else { | 666 } else { |
667 assertNotReached(); | 667 assertNotReached(); |
668 } | 668 } |
669 | 669 |
670 this.selectionModel_.leadIndex = index; | 670 this.selectionModel_.leadIndex = index; |
671 }; | 671 }; |
672 | 672 |
673 /** | 673 /** |
674 * Inserts an item. | 674 * Inserts an item. |
675 * @param {!Gallery.Item} galleryItem A gallery item. | 675 * @param {!GalleryItem} galleryItem A gallery item. |
676 * @param {!ThumbnailView.Thumbnail} insertBefore A thumbnail before which new | 676 * @param {!ThumbnailView.Thumbnail} insertBefore A thumbnail before which new |
677 * thumbnail is inserted. Set null for adding at the end of the list. | 677 * thumbnail is inserted. Set null for adding at the end of the list. |
678 * @private | 678 * @private |
679 */ | 679 */ |
680 ThumbnailView.prototype.insert_ = function(galleryItem, insertBefore) { | 680 ThumbnailView.prototype.insert_ = function(galleryItem, insertBefore) { |
681 var thumbnail = new ThumbnailView.Thumbnail(galleryItem); | 681 var thumbnail = new ThumbnailView.Thumbnail(galleryItem); |
682 this.thumbnails_[galleryItem.getEntry().toURL()] = thumbnail; | 682 this.thumbnails_[galleryItem.getEntry().toURL()] = thumbnail; |
683 if (insertBefore) { | 683 if (insertBefore) { |
684 this.list_.insertBefore( | 684 this.list_.insertBefore( |
685 thumbnail.getContainer(), insertBefore.getContainer()); | 685 thumbnail.getContainer(), insertBefore.getContainer()); |
686 } else { | 686 } else { |
687 this.list_.appendChild(thumbnail.getContainer()); | 687 this.list_.appendChild(thumbnail.getContainer()); |
688 } | 688 } |
689 | 689 |
690 // Set selection state. | 690 // Set selection state. |
691 var index = this.dataModel_.indexOf(galleryItem); | 691 var index = this.dataModel_.indexOf(galleryItem); |
692 thumbnail.setSelected(this.selectionModel_.getIndexSelected(index)); | 692 thumbnail.setSelected(this.selectionModel_.getIndexSelected(index)); |
693 | 693 |
694 this.updateScrollBar_(); | 694 this.updateScrollBar_(); |
695 }; | 695 }; |
696 | 696 |
697 /** | 697 /** |
698 * Removes an item. | 698 * Removes an item. |
699 * @param {!Gallery.Item} galleryItem A gallery item. | 699 * @param {!GalleryItem} galleryItem A gallery item. |
700 * @private | 700 * @private |
701 */ | 701 */ |
702 ThumbnailView.prototype.remove_ = function(galleryItem) { | 702 ThumbnailView.prototype.remove_ = function(galleryItem) { |
703 var thumbnail = this.thumbnails_[galleryItem.getEntry().toURL()]; | 703 var thumbnail = this.thumbnails_[galleryItem.getEntry().toURL()]; |
704 this.list_.removeChild(thumbnail.getContainer()); | 704 this.list_.removeChild(thumbnail.getContainer()); |
705 delete this.thumbnails_[galleryItem.getEntry().toURL()]; | 705 delete this.thumbnails_[galleryItem.getEntry().toURL()]; |
706 }; | 706 }; |
707 | 707 |
708 /** | 708 /** |
709 * Returns thumbnail instance at specified index. | 709 * Returns thumbnail instance at specified index. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 784 } |
785 | 785 |
786 var index = this.selectionModel_.leadIndex !== -1 ? | 786 var index = this.selectionModel_.leadIndex !== -1 ? |
787 this.selectionModel_.leadIndex : this.selectionModel_.selectedIndex; | 787 this.selectionModel_.leadIndex : this.selectionModel_.selectedIndex; |
788 var thumbnail = this.getThumbnailAt_(index); | 788 var thumbnail = this.getThumbnailAt_(index); |
789 thumbnail.getContainer().focus(); | 789 thumbnail.getContainer().focus(); |
790 }; | 790 }; |
791 | 791 |
792 /** | 792 /** |
793 * Thumbnail. | 793 * Thumbnail. |
794 * @param {!Gallery.Item} galleryItem A gallery item. | 794 * @param {!GalleryItem} galleryItem A gallery item. |
795 * @constructor | 795 * @constructor |
796 * @struct | 796 * @struct |
797 */ | 797 */ |
798 ThumbnailView.Thumbnail = function(galleryItem) { | 798 ThumbnailView.Thumbnail = function(galleryItem) { |
799 /** | 799 /** |
800 * @private {!Gallery.Item} | 800 * @private {!GalleryItem} |
801 */ | 801 */ |
802 this.galleryItem_ = galleryItem; | 802 this.galleryItem_ = galleryItem; |
803 | 803 |
804 /** | 804 /** |
805 * @private {boolean} | 805 * @private {boolean} |
806 */ | 806 */ |
807 this.selected_ = false; | 807 this.selected_ = false; |
808 | 808 |
809 /** | 809 /** |
810 * @private {ThumbnailLoader} | 810 * @private {ThumbnailLoader} |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 | 851 |
852 this.container_.style.height = ThumbnailView.ROW_HEIGHT + 'px'; | 852 this.container_.style.height = ThumbnailView.ROW_HEIGHT + 'px'; |
853 this.container_.getThumbnail = | 853 this.container_.getThumbnail = |
854 function(thumbnail) { return thumbnail; }.bind(null, this); | 854 function(thumbnail) { return thumbnail; }.bind(null, this); |
855 | 855 |
856 this.update(); | 856 this.update(); |
857 }; | 857 }; |
858 | 858 |
859 /** | 859 /** |
860 * Returns a gallery item. | 860 * Returns a gallery item. |
861 * @return {!Gallery.Item} A gallery item. | 861 * @return {!GalleryItem} A gallery item. |
862 */ | 862 */ |
863 ThumbnailView.Thumbnail.prototype.getGalleryItem = function() { | 863 ThumbnailView.Thumbnail.prototype.getGalleryItem = function() { |
864 return this.galleryItem_; | 864 return this.galleryItem_; |
865 }; | 865 }; |
866 | 866 |
867 /** | 867 /** |
868 * Change selection state of this thumbnail. | 868 * Change selection state of this thumbnail. |
869 * @param {boolean} selected True to make this thumbnail selected. | 869 * @param {boolean} selected True to make this thumbnail selected. |
870 */ | 870 */ |
871 ThumbnailView.Thumbnail.prototype.setSelected = function(selected) { | 871 ThumbnailView.Thumbnail.prototype.setSelected = function(selected) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 }; | 1016 }; |
1017 }.bind(this, this.thumbnailLoadRequestId_)) | 1017 }.bind(this, this.thumbnailLoadRequestId_)) |
1018 .catch(function(requestId, error) { | 1018 .catch(function(requestId, error) { |
1019 if (requestId !== this.thumbnailLoadRequestId_) | 1019 if (requestId !== this.thumbnailLoadRequestId_) |
1020 return null; | 1020 return null; |
1021 | 1021 |
1022 this.setError_(error); | 1022 this.setError_(error); |
1023 return null; | 1023 return null; |
1024 }.bind(this, this.thumbnailLoadRequestId_)); | 1024 }.bind(this, this.thumbnailLoadRequestId_)); |
1025 }; | 1025 }; |
OLD | NEW |