Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: ui/file_manager/gallery/js/ribbon.js

Issue 853653004: Gallery: Add items to GalleryDataModel before loading their metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/file_manager/gallery/js/mosaic_mode.js ('k') | ui/file_manager/gallery/js/slide_mode.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // No items to the right, move the window to the left. 182 // No items to the right, move the window to the left.
183 this.lastVisibleIndex_--; 183 this.lastVisibleIndex_--;
184 if (this.firstVisibleIndex_) { 184 if (this.firstVisibleIndex_) {
185 this.firstVisibleIndex_--; 185 this.firstVisibleIndex_--;
186 var firstNode = persistentNodes[0]; 186 var firstNode = persistentNodes[0];
187 if (firstNode.previousSibling) { 187 if (firstNode.previousSibling) {
188 // Pull back a vanishing node from the left. 188 // Pull back a vanishing node from the left.
189 firstNode.previousSibling.removeAttribute('vanishing'); 189 firstNode.previousSibling.removeAttribute('vanishing');
190 } else { 190 } else {
191 // Push a new item at the left end. 191 // Push a new item at the left end.
192 var newThumbnail = this.renderThumbnail_(this.firstVisibleIndex_); 192 if (this.firstVisibleIndex_ < this.dataModel_.length) {
193 newThumbnail.style.marginLeft = -(this.clientHeight - 2) + 'px'; 193 var newThumbnail = this.renderThumbnail_(this.firstVisibleIndex_);
194 this.insertBefore(newThumbnail, this.firstChild); 194 newThumbnail.style.marginLeft = -(this.clientHeight - 2) + 'px';
195 setTimeout(function() { 195 this.insertBefore(newThumbnail, this.firstChild);
196 newThumbnail.style.marginLeft = '0'; 196 setTimeout(function() {
197 }, 0); 197 newThumbnail.style.marginLeft = '0';
198 }, 0);
199 }
198 } 200 }
199 } 201 }
200 } 202 }
201 203
202 var removed = false; 204 var removed = false;
203 for (var i = 0; i < event.removed.length; i++) { 205 for (var i = 0; i < event.removed.length; i++) {
204 var removedDom = this.renderCache_[event.removed[i].getEntry().toURL()]; 206 var removedDom = this.renderCache_[event.removed[i].getEntry().toURL()];
205 if (removedDom) { 207 if (removedDom) {
206 removedDom.removeAttribute('selected'); 208 removedDom.removeAttribute('selected');
207 removedDom.setAttribute('vanishing', 'smooth'); 209 removedDom.setAttribute('vanishing', 'smooth');
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 }; 391 };
390 392
391 /** 393 /**
392 * Set the thumbnail image. 394 * Set the thumbnail image.
393 * 395 *
394 * @param {!Element} thumbnail Thumbnail element. 396 * @param {!Element} thumbnail Thumbnail element.
395 * @param {!Gallery.Item} item Gallery item. 397 * @param {!Gallery.Item} item Gallery item.
396 * @private 398 * @private
397 */ 399 */
398 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) { 400 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) {
401 if (!item.getThumbnailMetadataItem())
402 return;
399 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) { 403 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) {
400 var loader = new ThumbnailLoader( 404 var loader = new ThumbnailLoader(
401 item.getEntry(), 405 item.getEntry(),
402 ThumbnailLoader.LoaderType.IMAGE, 406 ThumbnailLoader.LoaderType.IMAGE,
403 metadataList[0]); 407 metadataList[0]);
404 loader.load( 408 loader.load(
405 thumbnail.querySelector('.image-wrapper'), 409 thumbnail.querySelector('.image-wrapper'),
406 ThumbnailLoader.FillMode.FILL /* fill */, 410 ThumbnailLoader.FillMode.FILL /* fill */,
407 ThumbnailLoader.OptimizationMode.NEVER_DISCARD); 411 ThumbnailLoader.OptimizationMode.NEVER_DISCARD);
408 }); 412 });
(...skipping 21 matching lines...) Expand all
430 * @param {string} oldUrl Old url. 434 * @param {string} oldUrl Old url.
431 * @param {string} newUrl New url. 435 * @param {string} newUrl New url.
432 * @private 436 * @private
433 */ 437 */
434 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { 438 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) {
435 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { 439 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) {
436 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; 440 this.renderCache_[newUrl] = this.renderCache_[oldUrl];
437 delete this.renderCache_[oldUrl]; 441 delete this.renderCache_[oldUrl];
438 } 442 }
439 }; 443 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/mosaic_mode.js ('k') | ui/file_manager/gallery/js/slide_mode.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698