| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * Slide mode displays a single image and has a set of controls to navigate | 6 * Slide mode displays a single image and has a set of controls to navigate |
| 7 * between the images and to edit an image. | 7 * between the images and to edit an image. |
| 8 * | 8 * |
| 9 * @param {!HTMLElement} container Main container element. | 9 * @param {!HTMLElement} container Main container element. |
| 10 * @param {!HTMLElement} content Content container element. | 10 * @param {!HTMLElement} content Content container element. |
| 11 * @param {!HTMLElement} toolbar Toolbar element. | 11 * @param {!HTMLElement} toolbar Toolbar element. |
| 12 * @param {!ImageEditor.Prompt} prompt Prompt. | 12 * @param {!ImageEditor.Prompt} prompt Prompt. |
| 13 * @param {!ErrorBanner} errorBanner Error banner. | 13 * @param {!ErrorBanner} errorBanner Error banner. |
| 14 * @param {!cr.ui.ArrayDataModel} dataModel Data model. | 14 * @param {!cr.ui.ArrayDataModel} dataModel Data model. |
| 15 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. | 15 * @param {!cr.ui.ListSelectionModel} selectionModel Selection model. |
| 16 * @param {!MetadataModel} metadataModel |
| 17 * @param {!ThumbnailModel} thumbnailModel |
| 16 * @param {!Object} context Context. | 18 * @param {!Object} context Context. |
| 17 * @param {!VolumeManager} volumeManager Volume manager. | 19 * @param {!VolumeManager} volumeManager Volume manager. |
| 18 * @param {function(function())} toggleMode Function to toggle the Gallery mode. | 20 * @param {function(function())} toggleMode Function to toggle the Gallery mode. |
| 19 * @param {function(string):string} displayStringFunction String formatting | 21 * @param {function(string):string} displayStringFunction String formatting |
| 20 * function. | 22 * function. |
| 23 |
| 21 * @constructor | 24 * @constructor |
| 22 * @struct | 25 * @struct |
| 23 * @suppress {checkStructDictInheritance} | 26 * @suppress {checkStructDictInheritance} |
| 24 * @extends {cr.EventTarget} | 27 * @extends {cr.EventTarget} |
| 25 */ | 28 */ |
| 26 function SlideMode(container, content, toolbar, prompt, errorBanner, dataModel, | 29 function SlideMode(container, content, toolbar, prompt, errorBanner, dataModel, |
| 27 selectionModel, context, volumeManager, toggleMode, displayStringFunction) { | 30 selectionModel, metadataModel, thumbnailModel, context, volumeManager, |
| 31 toggleMode, displayStringFunction) { |
| 28 /** | 32 /** |
| 29 * @type {!HTMLElement} | 33 * @type {!HTMLElement} |
| 30 * @private | 34 * @private |
| 31 * @const | 35 * @const |
| 32 */ | 36 */ |
| 33 this.container_ = container; | 37 this.container_ = container; |
| 34 | 38 |
| 35 /** | 39 /** |
| 36 * @type {!Document} | 40 * @type {!Document} |
| 37 * @private | 41 * @private |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 * @const | 334 * @const |
| 331 */ | 335 */ |
| 332 this.ribbonSpacer_ = queryRequiredElement(this.toolbar_, '.ribbon-spacer'); | 336 this.ribbonSpacer_ = queryRequiredElement(this.toolbar_, '.ribbon-spacer'); |
| 333 | 337 |
| 334 /** | 338 /** |
| 335 * @type {!Ribbon} | 339 * @type {!Ribbon} |
| 336 * @private | 340 * @private |
| 337 * @const | 341 * @const |
| 338 */ | 342 */ |
| 339 this.ribbon_ = new Ribbon( | 343 this.ribbon_ = new Ribbon( |
| 340 this.document_, this.dataModel_, this.selectionModel_); | 344 this.document_, this.dataModel_, this.selectionModel_, thumbnailModel); |
| 341 this.ribbonSpacer_.appendChild(this.ribbon_); | 345 this.ribbonSpacer_.appendChild(this.ribbon_); |
| 342 | 346 |
| 343 util.createChild(this.container_, 'spinner'); | 347 util.createChild(this.container_, 'spinner'); |
| 344 | 348 |
| 345 /** | 349 /** |
| 346 * @type {!HTMLElement} | 350 * @type {!HTMLElement} |
| 347 * @const | 351 * @const |
| 348 */ | 352 */ |
| 349 var slideShowButton = queryRequiredElement(this.toolbar_, 'button.slideshow'); | 353 var slideShowButton = queryRequiredElement(this.toolbar_, 'button.slideshow'); |
| 350 slideShowButton.title = this.displayStringFunction_('GALLERY_SLIDESHOW'); | 354 slideShowButton.title = this.displayStringFunction_('GALLERY_SLIDESHOW'); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 */ | 425 */ |
| 422 this.viewport_ = new Viewport(); | 426 this.viewport_ = new Viewport(); |
| 423 | 427 |
| 424 /** | 428 /** |
| 425 * @type {!ImageView} | 429 * @type {!ImageView} |
| 426 * @private | 430 * @private |
| 427 * @const | 431 * @const |
| 428 */ | 432 */ |
| 429 this.imageView_ = new ImageView( | 433 this.imageView_ = new ImageView( |
| 430 this.imageContainer_, | 434 this.imageContainer_, |
| 431 this.viewport_); | 435 this.viewport_, |
| 436 metadataModel); |
| 432 | 437 |
| 433 /** | 438 /** |
| 434 * @type {!ImageEditor} | 439 * @type {!ImageEditor} |
| 435 * @private | 440 * @private |
| 436 * @const | 441 * @const |
| 437 */ | 442 */ |
| 438 this.editor_ = new ImageEditor( | 443 this.editor_ = new ImageEditor( |
| 439 this.viewport_, | 444 this.viewport_, |
| 440 this.imageView_, | 445 this.imageView_, |
| 441 this.prompt_, | 446 this.prompt_, |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 * @param {function(number, number)} loadCallback Called when the image is fully | 991 * @param {function(number, number)} loadCallback Called when the image is fully |
| 987 * loaded. | 992 * loaded. |
| 988 * @param {number} loadType Load type. | 993 * @param {number} loadType Load type. |
| 989 * @param {number} delay Delay. | 994 * @param {number} delay Delay. |
| 990 * @param {*=} opt_error Error. | 995 * @param {*=} opt_error Error. |
| 991 * @private | 996 * @private |
| 992 */ | 997 */ |
| 993 SlideMode.prototype.itemLoaded_ = function( | 998 SlideMode.prototype.itemLoaded_ = function( |
| 994 item, loadCallback, loadType, delay, opt_error) { | 999 item, loadCallback, loadType, delay, opt_error) { |
| 995 var entry = item.getEntry(); | 1000 var entry = item.getEntry(); |
| 996 var metadata = item.getMetadata(); | |
| 997 | 1001 |
| 998 this.showSpinner_(false); | 1002 this.showSpinner_(false); |
| 999 if (loadType === ImageView.LoadType.ERROR) { | 1003 if (loadType === ImageView.LoadType.ERROR) { |
| 1000 // if we have a specific error, then display it | 1004 // if we have a specific error, then display it |
| 1001 if (opt_error) { | 1005 if (opt_error) { |
| 1002 this.errorBanner_.show(/** @type {string} */ (opt_error)); | 1006 this.errorBanner_.show(/** @type {string} */ (opt_error)); |
| 1003 } else { | 1007 } else { |
| 1004 // otherwise try to infer general error | 1008 // otherwise try to infer general error |
| 1005 this.errorBanner_.show('GALLERY_IMAGE_ERROR'); | 1009 this.errorBanner_.show('GALLERY_IMAGE_ERROR'); |
| 1006 } | 1010 } |
| 1007 } else if (loadType === ImageView.LoadType.OFFLINE) { | 1011 } else if (loadType === ImageView.LoadType.OFFLINE) { |
| 1008 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE'); | 1012 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE'); |
| 1009 } | 1013 } |
| 1010 | 1014 |
| 1011 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View')); | 1015 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View')); |
| 1012 | 1016 |
| 1013 var toMillions = function(number) { | 1017 var toMillions = function(number) { |
| 1014 return Math.round(number / (1000 * 1000)); | 1018 return Math.round(number / (1000 * 1000)); |
| 1015 }; | 1019 }; |
| 1016 | 1020 |
| 1017 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'), | 1021 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'), |
| 1018 toMillions(metadata.filesystem.size)); | 1022 toMillions(item.getMetadataItem().size)); |
| 1019 | 1023 |
| 1020 var canvas = this.imageView_.getCanvas(); | 1024 var canvas = this.imageView_.getCanvas(); |
| 1021 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MPix'), | 1025 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MPix'), |
| 1022 toMillions(canvas.width * canvas.height)); | 1026 toMillions(canvas.width * canvas.height)); |
| 1023 | 1027 |
| 1024 var extIndex = entry.name.lastIndexOf('.'); | 1028 var extIndex = entry.name.lastIndexOf('.'); |
| 1025 var ext = extIndex < 0 ? '' : | 1029 var ext = extIndex < 0 ? '' : |
| 1026 entry.name.substr(extIndex + 1).toLowerCase(); | 1030 entry.name.substr(extIndex + 1).toLowerCase(); |
| 1027 if (ext === 'jpeg') ext = 'jpg'; | 1031 if (ext === 'jpeg') ext = 'jpg'; |
| 1028 ImageUtil.metrics.recordEnum( | 1032 ImageUtil.metrics.recordEnum( |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1865 var event = assertInstanceof(event, MouseEvent); | 1869 var event = assertInstanceof(event, MouseEvent); |
| 1866 var viewport = this.slideMode_.getViewport(); | 1870 var viewport = this.slideMode_.getViewport(); |
| 1867 if (!this.enabled_ || !viewport.isZoomed()) | 1871 if (!this.enabled_ || !viewport.isZoomed()) |
| 1868 return; | 1872 return; |
| 1869 this.stopOperation(); | 1873 this.stopOperation(); |
| 1870 viewport.setOffset( | 1874 viewport.setOffset( |
| 1871 viewport.getOffsetX() + event.wheelDeltaX, | 1875 viewport.getOffsetX() + event.wheelDeltaX, |
| 1872 viewport.getOffsetY() + event.wheelDeltaY); | 1876 viewport.getOffsetY() + event.wheelDeltaY); |
| 1873 this.slideMode_.applyViewportChange(); | 1877 this.slideMode_.applyViewportChange(); |
| 1874 }; | 1878 }; |
| OLD | NEW |