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

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

Issue 12316118: Enabled Mosaic view on each volume. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. 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
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 urls.sort(); 130 urls.sort();
131 Gallery.getFileBrowserPrivate().getStrings(function(strings) { 131 Gallery.getFileBrowserPrivate().getStrings(function(strings) {
132 loadTimeData.data = strings; 132 loadTimeData.data = strings;
133 var context = { 133 var context = {
134 readonlyDirName: null, 134 readonlyDirName: null,
135 curDirEntry: currentDir, 135 curDirEntry: currentDir,
136 saveDirEntry: null, 136 saveDirEntry: null,
137 metadataCache: MetadataCache.createFull(), 137 metadataCache: MetadataCache.createFull(),
138 pageState: pageState, 138 pageState: pageState,
139 onClose: onClose, 139 onClose: onClose,
140 allowMosaic: true, /* For debugging purposes */
141 displayStringFunction: strf 140 displayStringFunction: strf
142 }; 141 };
143 Gallery.open(context, urls, selectedUrls); 142 Gallery.open(context, urls, selectedUrls);
144 if (opt_callback) opt_callback(); 143 if (opt_callback) opt_callback();
145 }); 144 });
146 } 145 }
147 }; 146 };
148 147
149 /** 148 /**
150 * Tools fade-out timeout im milliseconds. 149 * Tools fade-out timeout im milliseconds.
150 * @const
151 * @type {number} 151 * @type {number}
152 */ 152 */
153 Gallery.FADE_TIMEOUT = 3000; 153 Gallery.FADE_TIMEOUT = 3000;
154 154
155 /** 155 /**
156 * First time tools fade-out timeout im milliseconds. 156 * First time tools fade-out timeout im milliseconds.
157 * @const
157 * @type {number} 158 * @type {number}
158 */ 159 */
159 Gallery.FIRST_FADE_TIMEOUT = 1000; 160 Gallery.FIRST_FADE_TIMEOUT = 1000;
160 161
161 /** 162 /**
163 * Time until mosaic is initialized in the background. Used to make gallery
164 * in the slide mode load faster. In miiliseconds.
165 * @const
166 * @type {number}
167 */
168 Gallery.MOSAIC_BACKGROUND_INIT_DELAY = 1000;
169
170 /**
162 * Types of metadata Gallery uses (to query the metadata cache). 171 * Types of metadata Gallery uses (to query the metadata cache).
172 * @const
173 * @type {string}
163 */ 174 */
164 Gallery.METADATA_TYPE = 'thumbnail|filesystem|media|streaming'; 175 Gallery.METADATA_TYPE = 'thumbnail|filesystem|media|streaming';
165 176
166 /** 177 /**
167 * Initialize listeners. 178 * Initialize listeners.
168 * @private 179 * @private
169 */ 180 */
170
171 Gallery.prototype.initListeners_ = function() { 181 Gallery.prototype.initListeners_ = function() {
172 if (!util.TEST_HARNESS) 182 if (!util.TEST_HARNESS)
173 this.document_.oncontextmenu = function(e) { e.preventDefault(); }; 183 this.document_.oncontextmenu = function(e) { e.preventDefault(); };
174 184
175 this.keyDownBound_ = this.onKeyDown_.bind(this); 185 this.keyDownBound_ = this.onKeyDown_.bind(this);
176 this.document_.body.addEventListener('keydown', this.keyDownBound_); 186 this.document_.body.addEventListener('keydown', this.keyDownBound_);
177 187
178 this.inactivityWatcher_ = new MouseInactivityWatcher( 188 this.inactivityWatcher_ = new MouseInactivityWatcher(
179 this.container_, Gallery.FADE_TIMEOUT, this.hasActiveTool.bind(this)); 189 this.container_, Gallery.FADE_TIMEOUT, this.hasActiveTool.bind(this));
180 190
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 this.filenameEdit_.addEventListener('keydown', 262 this.filenameEdit_.addEventListener('keydown',
253 this.onFilenameEditKeydown_.bind(this)); 263 this.onFilenameEditKeydown_.bind(this));
254 264
255 util.createChild(this.toolbar_, 'button-spacer'); 265 util.createChild(this.toolbar_, 'button-spacer');
256 266
257 this.prompt_ = new ImageEditor.Prompt( 267 this.prompt_ = new ImageEditor.Prompt(
258 this.container_, this.displayStringFunction_); 268 this.container_, this.displayStringFunction_);
259 269
260 var onThumbnailError = this.context_.onThumbnailError || function() {}; 270 var onThumbnailError = this.context_.onThumbnailError || function() {};
261 271
262 if (this.context_.allowMosaic) { 272 this.modeButton_ = util.createChild(this.toolbar_, 'button mode', 'button');
263 this.modeButton_ = util.createChild(this.toolbar_, 'button mode', 'button'); 273 this.modeButton_.addEventListener('click',
264 this.modeButton_.addEventListener('click', 274 this.toggleMode_.bind(this, null));
265 this.toggleMode_.bind(this, null));
266 275
267 this.mosaicMode_ = new MosaicMode(content, 276 this.mosaicMode_ = new MosaicMode(content,
268 this.dataModel_, this.selectionModel_, this.metadataCache_, 277 this.dataModel_, this.selectionModel_, this.metadataCache_,
269 this.toggleMode_.bind(this, null), onThumbnailError); 278 this.toggleMode_.bind(this, null), onThumbnailError);
270 }
271 279
272 this.slideMode_ = new SlideMode(this.container_, content, 280 this.slideMode_ = new SlideMode(this.container_, content,
273 this.toolbar_, this.prompt_, 281 this.toolbar_, this.prompt_,
274 this.dataModel_, this.selectionModel_, this.context_, 282 this.dataModel_, this.selectionModel_, this.context_,
275 this.toggleMode_.bind(this), onThumbnailError, 283 this.toggleMode_.bind(this), onThumbnailError,
276 this.displayStringFunction_); 284 this.displayStringFunction_);
277 this.slideMode_.addEventListener('image-displayed', function() { 285 this.slideMode_.addEventListener('image-displayed', function() {
278 cr.dispatchSimpleEvent(this, 'image-displayed'); 286 cr.dispatchSimpleEvent(this, 'image-displayed');
279 }.bind(this)); 287 }.bind(this));
280 this.slideMode_.addEventListener('image-saved', function() { 288 this.slideMode_.addEventListener('image-saved', function() {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 (this.context_.pageState && 364 (this.context_.pageState &&
357 this.context_.pageState.gallery == 'mosaic'))) { 365 this.context_.pageState.gallery == 'mosaic'))) {
358 this.setCurrentMode_(this.mosaicMode_); 366 this.setCurrentMode_(this.mosaicMode_);
359 mosaic.init(); 367 mosaic.init();
360 mosaic.show(); 368 mosaic.show();
361 this.inactivityWatcher_.check(); // Show the toolbar. 369 this.inactivityWatcher_.check(); // Show the toolbar.
362 cr.dispatchSimpleEvent(this, 'loaded'); 370 cr.dispatchSimpleEvent(this, 'loaded');
363 } else { 371 } else {
364 this.setCurrentMode_(this.slideMode_); 372 this.setCurrentMode_(this.slideMode_);
365 var maybeLoadMosaic = function() { 373 var maybeLoadMosaic = function() {
366 if (mosaic) mosaic.init(); 374 if (mosaic)
375 mosaic.init();
367 cr.dispatchSimpleEvent(this, 'loaded'); 376 cr.dispatchSimpleEvent(this, 'loaded');
368 }.bind(this); 377 }.bind(this);
369 /* TODO: consider nice blow-up animation for the first image */ 378 /* TODO: consider nice blow-up animation for the first image */
370 this.slideMode_.enter(null, function() { 379 this.slideMode_.enter(null, function() {
371 // Flash the toolbar briefly to show it is there. 380 // Flash the toolbar briefly to show it is there.
372 this.inactivityWatcher_.kick(Gallery.FIRST_FADE_TIMEOUT); 381 this.inactivityWatcher_.kick(Gallery.FIRST_FADE_TIMEOUT);
373 }.bind(this), 382 }.bind(this),
374 maybeLoadMosaic); 383 maybeLoadMosaic);
375 } 384 }
376 }; 385 };
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 Gallery.prototype.updateThumbnails_ = function() { 893 Gallery.prototype.updateThumbnails_ = function() {
885 if (this.currentMode_ == this.slideMode_) 894 if (this.currentMode_ == this.slideMode_)
886 this.slideMode_.updateThumbnails(); 895 this.slideMode_.updateThumbnails();
887 896
888 if (this.mosaicMode_) { 897 if (this.mosaicMode_) {
889 var mosaic = this.mosaicMode_.getMosaic(); 898 var mosaic = this.mosaicMode_.getMosaic();
890 if (mosaic.isInitialized()) 899 if (mosaic.isInitialized())
891 mosaic.reload(); 900 mosaic.reload();
892 } 901 }
893 }; 902 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698