| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Scrollable thumbnail ribbon at the bottom of the Gallery in the Slide mode. | 8 * Scrollable thumbnail ribbon at the bottom of the Gallery in the Slide mode. |
| 9 * | 9 * |
| 10 * @param {Document} document Document. | 10 * @param {Document} document Document. |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 * | 293 * |
| 294 * @param {number} index Item index. | 294 * @param {number} index Item index. |
| 295 * @return {Element} Newly created element. | 295 * @return {Element} Newly created element. |
| 296 * @private | 296 * @private |
| 297 */ | 297 */ |
| 298 Ribbon.prototype.renderThumbnail_ = function(index) { | 298 Ribbon.prototype.renderThumbnail_ = function(index) { |
| 299 var item = this.dataModel_.item(index); | 299 var item = this.dataModel_.item(index); |
| 300 var url = item.getUrl(); | 300 var url = item.getUrl(); |
| 301 | 301 |
| 302 var cached = this.renderCache_[url]; | 302 var cached = this.renderCache_[url]; |
| 303 if (cached) | 303 if (cached) { |
| 304 var img = cached.querySelector('img'); |
| 305 if (img) |
| 306 img.classList.add('cached'); |
| 304 return cached; | 307 return cached; |
| 308 } |
| 305 | 309 |
| 306 var thumbnail = this.ownerDocument.createElement('div'); | 310 var thumbnail = this.ownerDocument.createElement('div'); |
| 307 thumbnail.className = 'ribbon-image'; | 311 thumbnail.className = 'ribbon-image'; |
| 308 thumbnail.addEventListener('click', function() { | 312 thumbnail.addEventListener('click', function() { |
| 309 var index = this.dataModel_.indexOf(item); | 313 var index = this.dataModel_.indexOf(item); |
| 310 this.selectionModel_.unselectAll(); | 314 this.selectionModel_.unselectAll(); |
| 311 this.selectionModel_.setIndexSelected(index, true); | 315 this.selectionModel_.setIndexSelected(index, true); |
| 312 }.bind(this)); | 316 }.bind(this)); |
| 313 | 317 |
| 314 util.createChild(thumbnail, 'image-wrapper'); | 318 util.createChild(thumbnail, 'image-wrapper'); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 * @param {string} oldUrl Old url. | 365 * @param {string} oldUrl Old url. |
| 362 * @param {string} newUrl New url. | 366 * @param {string} newUrl New url. |
| 363 * @private | 367 * @private |
| 364 */ | 368 */ |
| 365 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { | 369 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { |
| 366 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { | 370 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { |
| 367 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; | 371 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; |
| 368 delete this.renderCache_[oldUrl]; | 372 delete this.renderCache_[oldUrl]; |
| 369 } | 373 } |
| 370 }; | 374 }; |
| OLD | NEW |