| 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. |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 if (opt_error) { | 1032 if (opt_error) { |
| 1033 this.errorBanner_.show(/** @type {string} */ (opt_error)); | 1033 this.errorBanner_.show(/** @type {string} */ (opt_error)); |
| 1034 } else { | 1034 } else { |
| 1035 // otherwise try to infer general error | 1035 // otherwise try to infer general error |
| 1036 this.errorBanner_.show('GALLERY_IMAGE_ERROR'); | 1036 this.errorBanner_.show('GALLERY_IMAGE_ERROR'); |
| 1037 } | 1037 } |
| 1038 } else if (loadType === ImageView.LoadType.OFFLINE) { | 1038 } else if (loadType === ImageView.LoadType.OFFLINE) { |
| 1039 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE'); | 1039 this.errorBanner_.show('GALLERY_IMAGE_OFFLINE'); |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('View')); | 1042 metrics.recordUserAction(ImageUtil.getMetricName('View')); |
| 1043 | 1043 |
| 1044 var toMillions = function(number) { | 1044 var toMillions = function(number) { |
| 1045 return Math.round(number / (1000 * 1000)); | 1045 return Math.round(number / (1000 * 1000)); |
| 1046 }; | 1046 }; |
| 1047 | 1047 |
| 1048 var metadata = item.getMetadataItem(); | 1048 var metadata = item.getMetadataItem(); |
| 1049 if (metadata) { | 1049 if (metadata) { |
| 1050 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'), | 1050 metrics.recordSmallCount(ImageUtil.getMetricName('Size.MB'), |
| 1051 toMillions(metadata.size)); | 1051 toMillions(metadata.size)); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 var image = this.imageView_.getImage(); | 1054 var image = this.imageView_.getImage(); |
| 1055 ImageUtil.metrics.recordSmallCount(ImageUtil.getMetricName('Size.MPix'), | 1055 metrics.recordSmallCount(ImageUtil.getMetricName('Size.MPix'), |
| 1056 toMillions(image.width * image.height)); | 1056 toMillions(image.width * image.height)); |
| 1057 | 1057 |
| 1058 var extIndex = entry.name.lastIndexOf('.'); | 1058 var extIndex = entry.name.lastIndexOf('.'); |
| 1059 var ext = extIndex < 0 ? '' : | 1059 var ext = extIndex < 0 ? '' : |
| 1060 entry.name.substr(extIndex + 1).toLowerCase(); | 1060 entry.name.substr(extIndex + 1).toLowerCase(); |
| 1061 if (ext === 'jpeg') ext = 'jpg'; | 1061 if (ext === 'jpeg') ext = 'jpg'; |
| 1062 ImageUtil.metrics.recordEnum( | 1062 metrics.recordEnum( |
| 1063 ImageUtil.getMetricName('FileType'), ext, ImageUtil.FILE_TYPES); | 1063 ImageUtil.getMetricName('FileType'), ext, ImageUtil.FILE_TYPES); |
| 1064 | 1064 |
| 1065 // Enable or disable buttons for editing and printing. | 1065 // Enable or disable buttons for editing and printing. |
| 1066 if (opt_error) { | 1066 if (opt_error) { |
| 1067 this.editButton_.disabled = true; | 1067 this.editButton_.disabled = true; |
| 1068 this.printButton_.disabled = true; | 1068 this.printButton_.disabled = true; |
| 1069 } else { | 1069 } else { |
| 1070 this.editButton_.disabled = false; | 1070 this.editButton_.disabled = false; |
| 1071 this.printButton_.disabled = false; | 1071 this.printButton_.disabled = false; |
| 1072 } | 1072 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 item, | 1311 item, |
| 1312 ImageUtil.ensureCanvas(this.imageView_.getImage()), | 1312 ImageUtil.ensureCanvas(this.imageView_.getImage()), |
| 1313 this.overwriteOriginalCheckbox_.checked); | 1313 this.overwriteOriginalCheckbox_.checked); |
| 1314 | 1314 |
| 1315 savedPromise.then(function() { | 1315 savedPromise.then(function() { |
| 1316 this.showSpinner_(false); | 1316 this.showSpinner_(false); |
| 1317 this.flashSavedLabel_(); | 1317 this.flashSavedLabel_(); |
| 1318 | 1318 |
| 1319 // Record UMA for the first edit. | 1319 // Record UMA for the first edit. |
| 1320 if (this.imageView_.getContentRevision() === 1) | 1320 if (this.imageView_.getContentRevision() === 1) |
| 1321 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('Edit')); | 1321 metrics.recordUserAction(ImageUtil.getMetricName('Edit')); |
| 1322 | 1322 |
| 1323 // Users can change overwrite original setting only if there is no undo | 1323 // Users can change overwrite original setting only if there is no undo |
| 1324 // stack and item is original and writable. | 1324 // stack and item is original and writable. |
| 1325 var ableToChangeOverwriteOriginalSetting = !this.editor_.canUndo() && | 1325 var ableToChangeOverwriteOriginalSetting = !this.editor_.canUndo() && |
| 1326 item.isOriginal() && item.isWritableFile(this.volumeManager_); | 1326 item.isOriginal() && item.isWritableFile(this.volumeManager_); |
| 1327 this.overwriteOriginalCheckbox_.disabled = | 1327 this.overwriteOriginalCheckbox_.disabled = |
| 1328 !ableToChangeOverwriteOriginalSetting; | 1328 !ableToChangeOverwriteOriginalSetting; |
| 1329 | 1329 |
| 1330 callback(); | 1330 callback(); |
| 1331 }.bind(this)).catch(function(error) { | 1331 }.bind(this)).catch(function(error) { |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 /** | 2144 /** |
| 2145 * Handles mouse up events. | 2145 * Handles mouse up events. |
| 2146 * @param {!Event} event Wheel event. | 2146 * @param {!Event} event Wheel event. |
| 2147 * @private | 2147 * @private |
| 2148 */ | 2148 */ |
| 2149 TouchHandler.prototype.onMouseUp_ = function(event) { | 2149 TouchHandler.prototype.onMouseUp_ = function(event) { |
| 2150 if (event.button !== 0) | 2150 if (event.button !== 0) |
| 2151 return; | 2151 return; |
| 2152 this.clickStarted_ = false; | 2152 this.clickStarted_ = false; |
| 2153 }; | 2153 }; |
| OLD | NEW |