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

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

Issue 12738005: Launch mosaic view only if most of the selected files are images. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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 util.addPageLoadHandler(function() { 5 util.addPageLoadHandler(function() {
6 if (!location.hash) 6 if (!location.hash)
7 return; 7 return;
8 8
9 var pageState; 9 var pageState;
10 if (location.search) { 10 if (location.search) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 return button; 328 return button;
329 }; 329 };
330 330
331 /** 331 /**
332 * Load the content. 332 * Load the content.
333 * 333 *
334 * @param {Array.<string>} urls Array of urls. 334 * @param {Array.<string>} urls Array of urls.
335 * @param {Array.<string>} selectedUrls Array of selected urls. 335 * @param {Array.<string>} selectedUrls Array of selected urls.
336 */ 336 */
337 Gallery.prototype.load = function(urls, selectedUrls) { 337 Gallery.prototype.load = function(urls, selectedUrls) {
338 if (!this.mosaicMode_ && selectedUrls.length > 1) {
339 // If the mosaic is disabled revert to the old multiple selection behavior.
340 urls = selectedUrls; // Only show the items selected in the file list.
341 selectedUrls = selectedUrls.slice(0, 1); // Force single selection.
342 }
343
344 var items = []; 338 var items = [];
345 for (var index = 0; index < urls.length; ++index) { 339 for (var index = 0; index < urls.length; ++index) {
346 items.push(new Gallery.Item(urls[index])); 340 items.push(new Gallery.Item(urls[index]));
347 } 341 }
348 this.dataModel_.push.apply(this.dataModel_, items); 342 this.dataModel_.push.apply(this.dataModel_, items);
349 343
350 this.selectionModel_.adjustLength(this.dataModel_.length); 344 this.selectionModel_.adjustLength(this.dataModel_.length);
351 345
352 for (var i = 0; i != selectedUrls.length; i++) { 346 for (var i = 0; i != selectedUrls.length; i++) {
353 var selectedIndex = urls.indexOf(selectedUrls[i]); 347 var selectedIndex = urls.indexOf(selectedUrls[i]);
354 if (selectedIndex >= 0) 348 if (selectedIndex >= 0)
355 this.selectionModel_.setIndexSelected(selectedIndex, true); 349 this.selectionModel_.setIndexSelected(selectedIndex, true);
356 else 350 else
357 console.error('Cannot select ' + selectedUrls[i]); 351 console.error('Cannot select ' + selectedUrls[i]);
358 } 352 }
359 353
360 if (this.selectionModel_.selectedIndexes.length == 0) 354 if (this.selectionModel_.selectedIndexes.length == 0)
361 this.onSelection_(); 355 this.onSelection_();
362 356
363 var mosaic = this.mosaicMode_ && this.mosaicMode_.getMosaic(); 357 var mosaic = this.mosaicMode_ && this.mosaicMode_.getMosaic();
364 if (mosaic && 358
365 (selectedUrls.length != 1 || 359 // Mosaic view should show up if most of the selected files are images.
366 (this.context_.pageState && 360 var imagesCount = 0;
367 this.context_.pageState.gallery == 'mosaic'))) { 361 for (var i = 0; i != selectedUrls.length; i++) {
362 if (FileType.getMediaType(selectedUrls[i]) == 'image')
363 imagesCount++;
364 }
365 var mostlyImages = imagesCount > (selectedUrls.length / 2.0);
366
367 var forcedMosaic = (this.context_.pageState &&
368 this.context_.pageState.gallery == 'mosaic');
369
370 var showMosaic = (mostlyImages && selectedUrls.length > 1) || forcedMosaic;
371 if (mosaic && showMosaic) {
368 this.setCurrentMode_(this.mosaicMode_); 372 this.setCurrentMode_(this.mosaicMode_);
369 mosaic.init(); 373 mosaic.init();
370 mosaic.show(); 374 mosaic.show();
371 this.inactivityWatcher_.check(); // Show the toolbar. 375 this.inactivityWatcher_.check(); // Show the toolbar.
372 cr.dispatchSimpleEvent(this, 'loaded'); 376 cr.dispatchSimpleEvent(this, 'loaded');
373 } else { 377 } else {
374 this.setCurrentMode_(this.slideMode_); 378 this.setCurrentMode_(this.slideMode_);
375 var maybeLoadMosaic = function() { 379 var maybeLoadMosaic = function() {
376 if (mosaic) 380 if (mosaic)
377 mosaic.init(); 381 mosaic.init();
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 Gallery.prototype.updateThumbnails_ = function() { 899 Gallery.prototype.updateThumbnails_ = function() {
896 if (this.currentMode_ == this.slideMode_) 900 if (this.currentMode_ == this.slideMode_)
897 this.slideMode_.updateThumbnails(); 901 this.slideMode_.updateThumbnails();
898 902
899 if (this.mosaicMode_) { 903 if (this.mosaicMode_) {
900 var mosaic = this.mosaicMode_.getMosaic(); 904 var mosaic = this.mosaicMode_.getMosaic();
901 if (mosaic.isInitialized()) 905 if (mosaic.isInitialized())
902 mosaic.reload(); 906 mosaic.reload();
903 } 907 }
904 }; 908 };
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