Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. |
| 151 * @type {number} | 150 * @type {number} |
| 152 */ | 151 */ |
| 153 Gallery.FADE_TIMEOUT = 3000; | 152 Gallery.FADE_TIMEOUT = 3000; |
| 154 | 153 |
| 155 /** | 154 /** |
| 156 * First time tools fade-out timeout im milliseconds. | 155 * First time tools fade-out timeout im milliseconds. |
| 157 * @type {number} | 156 * @type {number} |
| 158 */ | 157 */ |
| 159 Gallery.FIRST_FADE_TIMEOUT = 1000; | 158 Gallery.FIRST_FADE_TIMEOUT = 1000; |
| 160 | 159 |
| 161 /** | 160 /** |
| 161 * Time until mosaic is initialized in the background. Used to make gallery | |
| 162 * in the slide mode load faster. In miiliseconds. | |
| 163 * @type {number}. | |
|
yoshiki
2013/02/26 08:50:27
@const
mtomasz
2013/02/27 00:55:31
Done.
| |
| 164 */ | |
| 165 Gallery.MOSAIC_BACKGROUND_INIT_DELAY = 1000; | |
| 166 | |
| 167 /** | |
| 162 * Types of metadata Gallery uses (to query the metadata cache). | 168 * Types of metadata Gallery uses (to query the metadata cache). |
| 163 */ | 169 */ |
| 164 Gallery.METADATA_TYPE = 'thumbnail|filesystem|media|streaming'; | 170 Gallery.METADATA_TYPE = 'thumbnail|filesystem|media|streaming'; |
| 165 | 171 |
| 166 /** | 172 /** |
| 167 * Initialize listeners. | 173 * Initialize listeners. |
| 168 * @private | 174 * @private |
| 169 */ | 175 */ |
| 170 | 176 |
| 171 Gallery.prototype.initListeners_ = function() { | 177 Gallery.prototype.initListeners_ = function() { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 this.filenameEdit_.addEventListener('keydown', | 258 this.filenameEdit_.addEventListener('keydown', |
| 253 this.onFilenameEditKeydown_.bind(this)); | 259 this.onFilenameEditKeydown_.bind(this)); |
| 254 | 260 |
| 255 util.createChild(this.toolbar_, 'button-spacer'); | 261 util.createChild(this.toolbar_, 'button-spacer'); |
| 256 | 262 |
| 257 this.prompt_ = new ImageEditor.Prompt( | 263 this.prompt_ = new ImageEditor.Prompt( |
| 258 this.container_, this.displayStringFunction_); | 264 this.container_, this.displayStringFunction_); |
| 259 | 265 |
| 260 var onThumbnailError = this.context_.onThumbnailError || function() {}; | 266 var onThumbnailError = this.context_.onThumbnailError || function() {}; |
| 261 | 267 |
| 262 if (this.context_.allowMosaic) { | 268 this.modeButton_ = util.createChild(this.toolbar_, 'button mode', 'button'); |
| 263 this.modeButton_ = util.createChild(this.toolbar_, 'button mode', 'button'); | 269 this.modeButton_.addEventListener('click', |
| 264 this.modeButton_.addEventListener('click', | 270 this.toggleMode_.bind(this, null)); |
| 265 this.toggleMode_.bind(this, null)); | |
| 266 | 271 |
| 267 this.mosaicMode_ = new MosaicMode(content, | 272 this.mosaicMode_ = new MosaicMode(content, |
| 268 this.dataModel_, this.selectionModel_, this.metadataCache_, | 273 this.dataModel_, this.selectionModel_, this.metadataCache_, |
| 269 this.toggleMode_.bind(this, null), onThumbnailError); | 274 this.toggleMode_.bind(this, null), onThumbnailError); |
| 270 } | |
| 271 | 275 |
| 272 this.slideMode_ = new SlideMode(this.container_, content, | 276 this.slideMode_ = new SlideMode(this.container_, content, |
| 273 this.toolbar_, this.prompt_, | 277 this.toolbar_, this.prompt_, |
| 274 this.dataModel_, this.selectionModel_, this.context_, | 278 this.dataModel_, this.selectionModel_, this.context_, |
| 275 this.toggleMode_.bind(this), onThumbnailError, | 279 this.toggleMode_.bind(this), onThumbnailError, |
| 276 this.displayStringFunction_); | 280 this.displayStringFunction_); |
| 277 this.slideMode_.addEventListener('image-displayed', function() { | 281 this.slideMode_.addEventListener('image-displayed', function() { |
| 278 cr.dispatchSimpleEvent(this, 'image-displayed'); | 282 cr.dispatchSimpleEvent(this, 'image-displayed'); |
| 279 }.bind(this)); | 283 }.bind(this)); |
| 280 this.slideMode_.addEventListener('image-saved', function() { | 284 this.slideMode_.addEventListener('image-saved', function() { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 (this.context_.pageState && | 360 (this.context_.pageState && |
| 357 this.context_.pageState.gallery == 'mosaic'))) { | 361 this.context_.pageState.gallery == 'mosaic'))) { |
| 358 this.setCurrentMode_(this.mosaicMode_); | 362 this.setCurrentMode_(this.mosaicMode_); |
| 359 mosaic.init(); | 363 mosaic.init(); |
| 360 mosaic.show(); | 364 mosaic.show(); |
| 361 this.inactivityWatcher_.check(); // Show the toolbar. | 365 this.inactivityWatcher_.check(); // Show the toolbar. |
| 362 cr.dispatchSimpleEvent(this, 'loaded'); | 366 cr.dispatchSimpleEvent(this, 'loaded'); |
| 363 } else { | 367 } else { |
| 364 this.setCurrentMode_(this.slideMode_); | 368 this.setCurrentMode_(this.slideMode_); |
| 365 var maybeLoadMosaic = function() { | 369 var maybeLoadMosaic = function() { |
| 366 if (mosaic) mosaic.init(); | 370 if (mosaic) |
| 371 mosaic.init(); | |
| 367 cr.dispatchSimpleEvent(this, 'loaded'); | 372 cr.dispatchSimpleEvent(this, 'loaded'); |
| 368 }.bind(this); | 373 }.bind(this); |
| 369 /* TODO: consider nice blow-up animation for the first image */ | 374 /* TODO: consider nice blow-up animation for the first image */ |
| 370 this.slideMode_.enter(null, function() { | 375 this.slideMode_.enter(null, function() { |
| 371 // Flash the toolbar briefly to show it is there. | 376 // Flash the toolbar briefly to show it is there. |
| 372 this.inactivityWatcher_.kick(Gallery.FIRST_FADE_TIMEOUT); | 377 this.inactivityWatcher_.kick(Gallery.FIRST_FADE_TIMEOUT); |
| 373 }.bind(this), | 378 }.bind(this), |
| 374 maybeLoadMosaic); | 379 maybeLoadMosaic); |
| 375 } | 380 } |
| 376 }; | 381 }; |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 Gallery.prototype.updateThumbnails_ = function() { | 889 Gallery.prototype.updateThumbnails_ = function() { |
| 885 if (this.currentMode_ == this.slideMode_) | 890 if (this.currentMode_ == this.slideMode_) |
| 886 this.slideMode_.updateThumbnails(); | 891 this.slideMode_.updateThumbnails(); |
| 887 | 892 |
| 888 if (this.mosaicMode_) { | 893 if (this.mosaicMode_) { |
| 889 var mosaic = this.mosaicMode_.getMosaic(); | 894 var mosaic = this.mosaicMode_.getMosaic(); |
| 890 if (mosaic.isInitialized()) | 895 if (mosaic.isInitialized()) |
| 891 mosaic.reload(); | 896 mosaic.reload(); |
| 892 } | 897 } |
| 893 }; | 898 }; |
| OLD | NEW |