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

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

Issue 971173002: Gallery: Start to use new metadata model in Gallery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Created 5 years, 9 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.
11 * @param {!ThumbnailModel} thumbnailModel
11 * @extends {HTMLDivElement} 12 * @extends {HTMLDivElement}
12 * @constructor 13 * @constructor
13 * @suppress {checkStructDictInheritance} 14 * @suppress {checkStructDictInheritance}
14 * @struct 15 * @struct
15 */ 16 */
16 function Ribbon(document, dataModel, selectionModel) { 17 function Ribbon(document, dataModel, selectionModel, thumbnailModel) {
17 if (this instanceof Ribbon) { 18 if (this instanceof Ribbon) {
18 return Ribbon.call(/** @type {Ribbon} */ (document.createElement('div')), 19 return Ribbon.call(/** @type {Ribbon} */ (document.createElement('div')),
19 document, dataModel, selectionModel); 20 document, dataModel, selectionModel, thumbnailModel);
20 } 21 }
21 22
22 this.__proto__ = Ribbon.prototype; 23 this.__proto__ = Ribbon.prototype;
23 this.className = 'ribbon'; 24 this.className = 'ribbon';
24 25
25 /** 26 /**
26 * @type {!cr.ui.ArrayDataModel} 27 * @private {!cr.ui.ArrayDataModel}
27 * @private 28 * @const
28 */ 29 */
29 this.dataModel_ = dataModel; 30 this.dataModel_ = dataModel;
30 31
31 /** 32 /**
32 * @type {!cr.ui.ListSelectionModel} 33 * @private {!cr.ui.ListSelectionModel}
33 * @private 34 * @const
34 */ 35 */
35 this.selectionModel_ = selectionModel; 36 this.selectionModel_ = selectionModel;
36 37
37 /** 38 /**
39 * @private {!ThumbnailModel}
40 * @const
41 */
42 this.thumbnailModel_ = thumbnailModel;
43
44 /**
38 * @type {!Object} 45 * @type {!Object}
39 * @private 46 * @private
40 */ 47 */
41 this.renderCache_ = {}; 48 this.renderCache_ = {};
42 49
43 /** 50 /**
44 * @type {number} 51 * @type {number}
45 * @private 52 * @private
46 */ 53 */
47 this.firstVisibleIndex_ = 0; 54 this.firstVisibleIndex_ = 0;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 }; 389 };
383 390
384 /** 391 /**
385 * Set the thumbnail image. 392 * Set the thumbnail image.
386 * 393 *
387 * @param {!Element} thumbnail Thumbnail element. 394 * @param {!Element} thumbnail Thumbnail element.
388 * @param {!Gallery.Item} item Gallery item. 395 * @param {!Gallery.Item} item Gallery item.
389 * @private 396 * @private
390 */ 397 */
391 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) { 398 Ribbon.prototype.setThumbnailImage_ = function(thumbnail, item) {
392 var loader = new ThumbnailLoader( 399 this.thumbnailModel_.get([item.getEntry()]).then(function(metadataList) {
393 item.getEntry(), 400 var loader = new ThumbnailLoader(
394 ThumbnailLoader.LoaderType.IMAGE, 401 item.getEntry(),
395 item.getMetadata()); 402 ThumbnailLoader.LoaderType.IMAGE,
396 loader.load( 403 metadataList[0]);
397 thumbnail.querySelector('.image-wrapper'), 404 loader.load(
398 ThumbnailLoader.FillMode.FILL /* fill */, 405 thumbnail.querySelector('.image-wrapper'),
399 ThumbnailLoader.OptimizationMode.NEVER_DISCARD); 406 ThumbnailLoader.FillMode.FILL /* fill */,
407 ThumbnailLoader.OptimizationMode.NEVER_DISCARD);
408 });
400 }; 409 };
401 410
402 /** 411 /**
403 * Content change handler. 412 * Content change handler.
404 * 413 *
405 * @param {!Event} event Event. 414 * @param {!Event} event Event.
406 * @private 415 * @private
407 */ 416 */
408 Ribbon.prototype.onContentChange_ = function(event) { 417 Ribbon.prototype.onContentChange_ = function(event) {
409 var url = event.item.getEntry().toURL(); 418 var url = event.item.getEntry().toURL();
(...skipping 11 matching lines...) Expand all
421 * @param {string} oldUrl Old url. 430 * @param {string} oldUrl Old url.
422 * @param {string} newUrl New url. 431 * @param {string} newUrl New url.
423 * @private 432 * @private
424 */ 433 */
425 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) { 434 Ribbon.prototype.remapCache_ = function(oldUrl, newUrl) {
426 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) { 435 if (oldUrl != newUrl && (oldUrl in this.renderCache_)) {
427 this.renderCache_[newUrl] = this.renderCache_[oldUrl]; 436 this.renderCache_[newUrl] = this.renderCache_[oldUrl];
428 delete this.renderCache_[oldUrl]; 437 delete this.renderCache_[oldUrl];
429 } 438 }
430 }; 439 };
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