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

Side by Side Diff: chrome/browser/resources/file_manager/foreground/js/photo/gallery.js

Issue 124923002: Fix selecting when opening an image from the download shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a comment. Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * Called from the main frame when unloading. 8 * Called from the main frame when unloading.
9 * @return {string?} User-visible message on null if it is OK to close. 9 * @return {string?} User-visible message on null if it is OK to close.
10 */ 10 */
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 Gallery.prototype.createToolbarButton_ = function(className, title) { 267 Gallery.prototype.createToolbarButton_ = function(className, title) {
268 var button = util.createChild(this.toolbar_, className, 'button'); 268 var button = util.createChild(this.toolbar_, className, 'button');
269 button.title = this.displayStringFunction_(title); 269 button.title = this.displayStringFunction_(title);
270 return button; 270 return button;
271 }; 271 };
272 272
273 /** 273 /**
274 * Loads the content. 274 * Loads the content.
275 * 275 *
276 * @param {Array.<Entry>} entries Array of entries. 276 * @param {Array.<Entry>} entries Array of entries.
277 * @param {Array.<Entry>} selectedEntries Array of selected entries. Must be a 277 * @param {Array.<Entry>} selectedEntries Array of selected entries.
278 * subset of {@code entries}.
279 */ 278 */
280 Gallery.prototype.load = function(entries, selectedEntries) { 279 Gallery.prototype.load = function(entries, selectedEntries) {
281 var items = []; 280 var items = [];
282 for (var index = 0; index < entries.length; ++index) { 281 for (var index = 0; index < entries.length; ++index) {
283 items.push(new Gallery.Item(entries[index])); 282 items.push(new Gallery.Item(entries[index]));
284 } 283 }
285 this.dataModel_.push.apply(this.dataModel_, items); 284 this.dataModel_.push.apply(this.dataModel_, items);
286 285
287 this.selectionModel_.adjustLength(this.dataModel_.length); 286 this.selectionModel_.adjustLength(this.dataModel_.length);
288 287
288 // Comparing Entries by reference is not safe. Therefore we have to use URLs.
289 var entryIndexesByURLs = {};
290 for (var index = 0; index < entries.length; index++) {
291 entryIndexesByURLs[entries[index].toURL()] = index;
292 }
293
289 for (var i = 0; i !== selectedEntries.length; i++) { 294 for (var i = 0; i !== selectedEntries.length; i++) {
290 var selectedIndex = entries.indexOf(selectedEntries[i]); 295 var selectedIndex = entryIndexesByURLs[selectedEntries[i].toURL()];
291 if (selectedIndex >= 0) 296 if (selectedIndex !== undefined)
292 this.selectionModel_.setIndexSelected(selectedIndex, true); 297 this.selectionModel_.setIndexSelected(selectedIndex, true);
293 else 298 else
294 console.error('Cannot select ' + selectedEntries[i]); 299 console.error('Cannot select ' + selectedEntries[i]);
295 } 300 }
296 301
297 if (this.selectionModel_.selectedIndexes.length === 0) 302 if (this.selectionModel_.selectedIndexes.length === 0)
298 this.onSelection_(); 303 this.onSelection_();
299 304
300 var mosaic = this.mosaicMode_ && this.mosaicMode_.getMosaic(); 305 var mosaic = this.mosaicMode_ && this.mosaicMode_.getMosaic();
301 306
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 */ 863 */
859 Gallery.prototype.updateButtons_ = function() { 864 Gallery.prototype.updateButtons_ = function() {
860 if (this.modeButton_) { 865 if (this.modeButton_) {
861 var oppositeMode = 866 var oppositeMode =
862 this.currentMode_ === this.slideMode_ ? this.mosaicMode_ : 867 this.currentMode_ === this.slideMode_ ? this.mosaicMode_ :
863 this.slideMode_; 868 this.slideMode_;
864 this.modeButton_.title = 869 this.modeButton_.title =
865 this.displayStringFunction_(oppositeMode.getTitle()); 870 this.displayStringFunction_(oppositeMode.getTitle());
866 } 871 }
867 }; 872 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698