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 * @param {!Element} container Content container. | 6 * @param {!Element} container Content container. |
7 * @param {!ErrorBanner} errorBanner Error banner. | 7 * @param {!ErrorBanner} errorBanner Error banner. |
8 * @param {!cr.ui.ArrayDataModel} dataModel Data model. | 8 * @param {!cr.ui.ArrayDataModel} dataModel Data model. |
9 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. | 9 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. |
10 * @param {!VolumeManager} volumeManager Volume manager. | 10 * @param {!VolumeManager} volumeManager Volume manager. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 if (!document.activeElement || | 61 if (!document.activeElement || |
62 document.activeElement.localName !== 'button') { | 62 document.activeElement.localName !== 'button') { |
63 this.toggleMode_(); | 63 this.toggleMode_(); |
64 event.preventDefault(); | 64 event.preventDefault(); |
65 } | 65 } |
66 return; | 66 return; |
67 } | 67 } |
68 this.mosaic_.onKeyDown(event); | 68 this.mosaic_.onKeyDown(event); |
69 }; | 69 }; |
70 | 70 |
| 71 /** |
| 72 * Enters the debug mode. |
| 73 */ |
| 74 MosaicMode.prototype.debugMe = function() { |
| 75 this.mosaic_.debugMe(); |
| 76 }; |
| 77 |
71 //////////////////////////////////////////////////////////////////////////////// | 78 //////////////////////////////////////////////////////////////////////////////// |
72 | 79 |
73 /** | 80 /** |
74 * Mosaic control. | 81 * Mosaic control. |
75 * | 82 * |
76 * @param {!Document} document Document. | 83 * @param {!Document} document Document. |
77 * @param {!ErrorBanner} errorBanner Error banner. | 84 * @param {!ErrorBanner} errorBanner Error banner. |
78 * @param {!cr.ui.ArrayDataModel} dataModel Data model. | 85 * @param {!cr.ui.ArrayDataModel} dataModel Data model. |
79 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. | 86 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. |
80 * @param {!VolumeManager} volumeManager Volume manager. | 87 * @param {!VolumeManager} volumeManager Volume manager. |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 }; | 733 }; |
727 | 734 |
728 /** | 735 /** |
729 * @return {number} Item count | 736 * @return {number} Item count |
730 * @private | 737 * @private |
731 */ | 738 */ |
732 Mosaic.prototype.getItemCount_ = function() { | 739 Mosaic.prototype.getItemCount_ = function() { |
733 return this.dataModel_.length; | 740 return this.dataModel_.length; |
734 }; | 741 }; |
735 | 742 |
| 743 /** |
| 744 * Enters the debug me. |
| 745 */ |
| 746 Mosaic.prototype.debugMe = function() { |
| 747 this.classList.add('debug-me'); |
| 748 }; |
| 749 |
736 //////////////////////////////////////////////////////////////////////////////// | 750 //////////////////////////////////////////////////////////////////////////////// |
737 | 751 |
738 /** | 752 /** |
739 * Creates a selection controller that is to be used with grid. | 753 * Creates a selection controller that is to be used with grid. |
740 * @param {!cr.ui.ListSelectionModel} selectionModel The selection model to | 754 * @param {!cr.ui.ListSelectionModel} selectionModel The selection model to |
741 * interact with. | 755 * interact with. |
742 * @param {!Mosaic.Layout} layoutModel The layout model to use. | 756 * @param {!Mosaic.Layout} layoutModel The layout model to use. |
743 * @constructor | 757 * @constructor |
744 * @struct | 758 * @struct |
745 * @extends {cr.ui.ListSelectionController} | 759 * @extends {cr.ui.ListSelectionController} |
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2131 // specified loader. | 2145 // specified loader. |
2132 var finalizeLoader = function(mode, success, loader) { | 2146 var finalizeLoader = function(mode, success, loader) { |
2133 if (success && this.wrapper_) { | 2147 if (success && this.wrapper_) { |
2134 // Show the fade-in animation only when previously there was no image | 2148 // Show the fade-in animation only when previously there was no image |
2135 // attached in this tile. | 2149 // attached in this tile. |
2136 if (!this.imageLoaded_ && !this.imagePreloaded_) | 2150 if (!this.imageLoaded_ && !this.imagePreloaded_) |
2137 this.wrapper_.classList.add('animated'); | 2151 this.wrapper_.classList.add('animated'); |
2138 else | 2152 else |
2139 this.wrapper_.classList.remove('animated'); | 2153 this.wrapper_.classList.remove('animated'); |
2140 } | 2154 } |
| 2155 |
| 2156 // Add debug mode classes. |
| 2157 this.wrapper_.classList.remove('load-target-content-metadata'); |
| 2158 this.wrapper_.classList.remove('load-target-external-metadata'); |
| 2159 this.wrapper_.classList.remove('load-target-file-entry'); |
| 2160 switch (loader.getLoadTarget()) { |
| 2161 case ThumbnailLoader.LoadTarget.CONTENT_METADATA: |
| 2162 this.wrapper_.classList.add('load-target-content-metadata'); |
| 2163 break; |
| 2164 case ThumbnailLoader.LoadTarget.EXTERNAL_METADATA: |
| 2165 this.wrapper_.classList.add('load-target-external-metadata'); |
| 2166 break; |
| 2167 case ThumbnailLoader.LoadTarget.FILE_ENTRY: |
| 2168 this.wrapper_.classList.add('load-target-file-entry'); |
| 2169 break; |
| 2170 } |
2141 loader.attachImage(this.wrapper_, ThumbnailLoader.FillMode.OVER_FILL); | 2171 loader.attachImage(this.wrapper_, ThumbnailLoader.FillMode.OVER_FILL); |
2142 onImageLoaded(success); | 2172 onImageLoaded(success); |
| 2173 |
2143 switch (mode) { | 2174 switch (mode) { |
2144 case Mosaic.Tile.LoadMode.LOW_DPI: | 2175 case Mosaic.Tile.LoadMode.LOW_DPI: |
2145 this.imagePreloading_ = false; | 2176 this.imagePreloading_ = false; |
2146 this.imagePreloaded_ = true; | 2177 this.imagePreloaded_ = true; |
2147 break; | 2178 break; |
2148 case Mosaic.Tile.LoadMode.HIGH_DPI: | 2179 case Mosaic.Tile.LoadMode.HIGH_DPI: |
2149 this.imageLoading_ = false; | 2180 this.imageLoading_ = false; |
2150 this.imageLoaded_ = true; | 2181 this.imageLoaded_ = true; |
2151 break; | 2182 break; |
2152 } | 2183 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_, | 2313 return new ImageRect(this.left_ - this.container_.scrollLeft, this.top_, |
2283 this.width_, this.height_).inflate(-margin, -margin); | 2314 this.width_, this.height_).inflate(-margin, -margin); |
2284 }; | 2315 }; |
2285 | 2316 |
2286 /** | 2317 /** |
2287 * @return {number} X coordinate of the tile center. | 2318 * @return {number} X coordinate of the tile center. |
2288 */ | 2319 */ |
2289 Mosaic.Tile.prototype.getCenterX = function() { | 2320 Mosaic.Tile.prototype.getCenterX = function() { |
2290 return this.left_ + Math.round(this.width_ / 2); | 2321 return this.left_ + Math.round(this.width_ / 2); |
2291 }; | 2322 }; |
OLD | NEW |