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 {!Window} targetWindow A window which this ribbon is attached to. | 9 * @param {!Window} targetWindow A window which this ribbon is attached to. |
10 * @param {!cr.ui.ArrayDataModel} dataModel Data model. | 10 * @param {!cr.ui.ArrayDataModel} dataModel Data model. |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 }; | 407 }; |
408 | 408 |
409 /** | 409 /** |
410 * Create a DOM element for a thumbnail. | 410 * Create a DOM element for a thumbnail. |
411 * | 411 * |
412 * @param {number} index Item index. | 412 * @param {number} index Item index. |
413 * @return {!Element} Newly created element. | 413 * @return {!Element} Newly created element. |
414 * @private | 414 * @private |
415 */ | 415 */ |
416 Ribbon.prototype.renderThumbnail_ = function(index) { | 416 Ribbon.prototype.renderThumbnail_ = function(index) { |
417 var item = assertInstanceof(this.dataModel_.item(index), Gallery.Item); | 417 var item = assertInstanceof(this.dataModel_.item(index), GalleryItem); |
418 var url = item.getEntry().toURL(); | 418 var url = item.getEntry().toURL(); |
419 | 419 |
420 var cached = this.renderCache_[url]; | 420 var cached = this.renderCache_[url]; |
421 if (cached) { | 421 if (cached) { |
422 var img = cached.querySelector('img'); | 422 var img = cached.querySelector('img'); |
423 if (img) | 423 if (img) |
424 img.classList.add('cached'); | 424 img.classList.add('cached'); |
425 return cached; | 425 return cached; |
426 } | 426 } |
427 | 427 |
(...skipping 17 matching lines...) Expand all Loading... |
445 // Never evict the thumbnails that are currently in the DOM because we rely | 445 // Never evict the thumbnails that are currently in the DOM because we rely |
446 // on this cache to find them by URL. | 446 // on this cache to find them by URL. |
447 this.renderCache_[url] = thumbnail; | 447 this.renderCache_[url] = thumbnail; |
448 return thumbnail; | 448 return thumbnail; |
449 }; | 449 }; |
450 | 450 |
451 /** | 451 /** |
452 * Set the thumbnail image. | 452 * Set the thumbnail image. |
453 * | 453 * |
454 * @param {!Element} thumbnail Thumbnail element. | 454 * @param {!Element} thumbnail Thumbnail element. |
455 * @param {!Gallery.Item} item Gallery item. | 455 * @param {!GalleryItem} item Gallery item. |
456 * @private | 456 * @private |
457 */ | 457 */ |
458 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) { | 458 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) { |
459 thumbnail.setAttribute('title', item.getFileName()); | 459 thumbnail.setAttribute('title', item.getFileName()); |
460 | 460 |
461 if (!item.getThumbnailMetadataItem()) | 461 if (!item.getThumbnailMetadataItem()) |
462 return; | 462 return; |
463 | 463 |
464 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) { | 464 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) { |
465 var loader = new ThumbnailLoader( | 465 var loader = new ThumbnailLoader( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 * @param {string} oldUrl Old url. | 504 * @param {string} oldUrl Old url. |
505 * @param {string} newUrl New url. | 505 * @param {string} newUrl New url. |
506 * @private | 506 * @private |
507 */ | 507 */ |
508 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { | 508 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { |
509 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { | 509 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { |
510 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; | 510 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; |
511 delete this.renderCache_[oldUrl]; | 511 delete this.renderCache_[oldUrl]; |
512 } | 512 } |
513 }; | 513 }; |
OLD | NEW |