Chromium Code Reviews| 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 * Scrollable thumbnail ribbon at the bottom of the Gallery in the Slide mode. | 6 * Scrollable thumbnail ribbon at the bottom of the Gallery in the Slide mode. |
| 7 * | 7 * |
| 8 * @param {!Document} document Document. | 8 * @param {!Document} document Document. |
| 9 * @param {!cr.ui.ArrayDataModel} dataModel Data model. | 9 * @param {!cr.ui.ArrayDataModel} dataModel Data model. |
| 10 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. | 10 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 } | 169 } |
| 170 | 170 |
| 171 var persistentNodes = this.querySelectorAll('.ribbon-image:not([vanishing])'); | 171 var persistentNodes = this.querySelectorAll('.ribbon-image:not([vanishing])'); |
| 172 if (this.lastVisibleIndex_ < this.dataModel_.length) { // Not at the end. | 172 if (this.lastVisibleIndex_ < this.dataModel_.length) { // Not at the end. |
| 173 var lastNode = persistentNodes[persistentNodes.length - 1]; | 173 var lastNode = persistentNodes[persistentNodes.length - 1]; |
| 174 if (lastNode.nextSibling) { | 174 if (lastNode.nextSibling) { |
| 175 // Pull back a vanishing node from the right. | 175 // Pull back a vanishing node from the right. |
| 176 lastNode.nextSibling.removeAttribute('vanishing'); | 176 lastNode.nextSibling.removeAttribute('vanishing'); |
| 177 } else { | 177 } else { |
| 178 // Push a new item at the right end. | 178 // Push a new item at the right end. |
| 179 this.appendChild(this.renderThumbnail_(this.lastVisibleIndex_)); | 179 var element = this.renderThumbnail_(this.lastVisibleIndex_); |
| 180 element.style.marginLeft = '0'; | |
|
yoshiki
2015/04/06 07:40:38
nit: Should we apply a class, instead of assigning
hirono
2015/04/06 07:48:08
Yes! Done
| |
| 181 this.appendChild(element); | |
| 180 } | 182 } |
| 181 } else { | 183 } else { |
| 182 // No items to the right, move the window to the left. | 184 // No items to the right, move the window to the left. |
| 183 this.lastVisibleIndex_--; | 185 this.lastVisibleIndex_--; |
| 184 if (this.firstVisibleIndex_) { | 186 if (this.firstVisibleIndex_) { |
| 185 this.firstVisibleIndex_--; | 187 this.firstVisibleIndex_--; |
| 186 var firstNode = persistentNodes[0]; | 188 var firstNode = persistentNodes[0]; |
| 187 if (firstNode.previousSibling) { | 189 if (firstNode.previousSibling) { |
| 188 // Pull back a vanishing node from the left. | 190 // Pull back a vanishing node from the left. |
| 189 firstNode.previousSibling.removeAttribute('vanishing'); | 191 firstNode.previousSibling.removeAttribute('vanishing'); |
| 190 } else { | 192 } else { |
| 191 // Push a new item at the left end. | 193 // Push a new item at the left end. |
| 192 var newThumbnail = this.renderThumbnail_(this.firstVisibleIndex_); | 194 if (this.firstVisibleIndex_ < this.dataModel_.length) { |
| 193 newThumbnail.style.marginLeft = -(this.clientHeight - 2) + 'px'; | 195 var newThumbnail = this.renderThumbnail_(this.firstVisibleIndex_); |
| 194 this.insertBefore(newThumbnail, this.firstChild); | 196 newThumbnail.style.marginLeft = -(this.clientHeight - 2) + 'px'; |
| 195 setTimeout(function() { | 197 this.insertBefore(newThumbnail, this.firstChild); |
| 196 newThumbnail.style.marginLeft = '0'; | 198 setTimeout(function() { |
| 197 }, 0); | 199 newThumbnail.style.marginLeft = '0'; |
| 200 }, 0); | |
| 201 } | |
| 198 } | 202 } |
| 199 } | 203 } |
| 200 } | 204 } |
| 201 | 205 |
| 202 var removed = false; | 206 var removed = false; |
| 203 for (var i = 0; i < event.removed.length; i++) { | 207 for (var i = 0; i < event.removed.length; i++) { |
| 204 var removedDom = this.renderCache_[event.removed[i].getEntry().toURL()]; | 208 var removedDom = this.renderCache_[event.removed[i].getEntry().toURL()]; |
| 205 if (removedDom) { | 209 if (removedDom) { |
| 206 removedDom.removeAttribute('selected'); | 210 removedDom.removeAttribute('selected'); |
| 207 removedDom.setAttribute('vanishing', 'smooth'); | 211 removedDom.setAttribute('vanishing', 'smooth'); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 }; | 393 }; |
| 390 | 394 |
| 391 /** | 395 /** |
| 392 * Set the thumbnail image. | 396 * Set the thumbnail image. |
| 393 * | 397 * |
| 394 * @param {!Element} thumbnail Thumbnail element. | 398 * @param {!Element} thumbnail Thumbnail element. |
| 395 * @param {!Gallery.Item} item Gallery item. | 399 * @param {!Gallery.Item} item Gallery item. |
| 396 * @private | 400 * @private |
| 397 */ | 401 */ |
| 398 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) { | 402 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) { |
| 403 if (!item.getThumbnailMetadataItem()) | |
| 404 return; | |
| 399 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) { | 405 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) { |
| 400 var loader = new ThumbnailLoader( | 406 var loader = new ThumbnailLoader( |
| 401 item.getEntry(), | 407 item.getEntry(), |
| 402 ThumbnailLoader.LoaderType.IMAGE, | 408 ThumbnailLoader.LoaderType.IMAGE, |
| 403 metadataList[0]); | 409 metadataList[0]); |
| 404 loader.load( | 410 loader.load( |
| 405 thumbnail.querySelector('.image-wrapper'), | 411 thumbnail.querySelector('.image-wrapper'), |
| 406 ThumbnailLoader.FillMode.FILL /* fill */, | 412 ThumbnailLoader.FillMode.FILL /* fill */, |
| 407 ThumbnailLoader.OptimizationMode.NEVER_DISCARD); | 413 ThumbnailLoader.OptimizationMode.NEVER_DISCARD); |
| 408 }); | 414 }); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 430 * @param {string} oldUrl Old url. | 436 * @param {string} oldUrl Old url. |
| 431 * @param {string} newUrl New url. | 437 * @param {string} newUrl New url. |
| 432 * @private | 438 * @private |
| 433 */ | 439 */ |
| 434 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { | 440 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { |
| 435 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { | 441 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { |
| 436 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; | 442 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; |
| 437 delete this.renderCache_[oldUrl]; | 443 delete this.renderCache_[oldUrl]; |
| 438 } | 444 } |
| 439 }; | 445 }; |
| OLD | NEW |