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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/photo/gallery.js
diff --git a/chrome/browser/resources/file_manager/js/photo/gallery.js b/chrome/browser/resources/file_manager/js/photo/gallery.js
index 5a453074cc7376647b2cefe2a18a9b7bcc39dc95..c38c3d3012df95efed52d6b57f1f980f086cbce6 100644
--- a/chrome/browser/resources/file_manager/js/photo/gallery.js
+++ b/chrome/browser/resources/file_manager/js/photo/gallery.js
@@ -335,12 +335,6 @@ Gallery.prototype.createToolbarButton_ = function(clazz, title) {
* @param {Array.<string>} selectedUrls Array of selected urls.
*/
Gallery.prototype.load = function(urls, selectedUrls) {
- if (!this.mosaicMode_ && selectedUrls.length > 1) {
- // If the mosaic is disabled revert to the old multiple selection behavior.
- urls = selectedUrls; // Only show the items selected in the file list.
- selectedUrls = selectedUrls.slice(0, 1); // Force single selection.
- }
-
var items = [];
for (var index = 0; index < urls.length; ++index) {
items.push(new Gallery.Item(urls[index]));
@@ -361,10 +355,20 @@ Gallery.prototype.load = function(urls, selectedUrls) {
this.onSelection_();
var mosaic = this.mosaicMode_ && this.mosaicMode_.getMosaic();
- if (mosaic &&
- (selectedUrls.length != 1 ||
- (this.context_.pageState &&
- this.context_.pageState.gallery == 'mosaic'))) {
+
+ // Mosaic view should show up if most of the selected files are images.
+ var imagesCount = 0;
+ for (var i = 0; i != selectedUrls.length; i++) {
+ if (FileType.getMediaType(selectedUrls[i]) == 'image')
+ imagesCount++;
+ }
+ var mostlyImages = imagesCount > (selectedUrls.length / 2.0);
+
+ var forcedMosaic = (this.context_.pageState &&
+ this.context_.pageState.gallery == 'mosaic');
+
+ var showMosaic = (mostlyImages && selectedUrls.length > 1) || forcedMosaic;
+ if (mosaic && showMosaic) {
this.setCurrentMode_(this.mosaicMode_);
mosaic.init();
mosaic.show();
« 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