| 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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 */ | 1256 */ |
| 1257 SlideMode.prototype.saveCurrentImage_ = function(item, callback) { | 1257 SlideMode.prototype.saveCurrentImage_ = function(item, callback) { |
| 1258 this.showSpinner_(true); | 1258 this.showSpinner_(true); |
| 1259 | 1259 |
| 1260 var savedPromise = this.dataModel_.saveItem( | 1260 var savedPromise = this.dataModel_.saveItem( |
| 1261 this.volumeManager_, | 1261 this.volumeManager_, |
| 1262 item, | 1262 item, |
| 1263 this.imageView_.getCanvas(), | 1263 this.imageView_.getCanvas(), |
| 1264 this.shouldOverwriteOriginal_()); | 1264 this.shouldOverwriteOriginal_()); |
| 1265 | 1265 |
| 1266 savedPromise.catch(function(error) { | 1266 savedPromise.then(function() { |
| 1267 // TODO(hirono): Implement write error handling. | |
| 1268 // Until then pretend that the save succeeded. | |
| 1269 console.error(error.stack || error); | |
| 1270 }).then(function() { | |
| 1271 this.showSpinner_(false); | 1267 this.showSpinner_(false); |
| 1272 this.flashSavedLabel_(); | 1268 this.flashSavedLabel_(); |
| 1273 | 1269 |
| 1274 // Allow changing the 'Overwrite original' setting only if the user | 1270 // Allow changing the 'Overwrite original' setting only if the user |
| 1275 // used Undo to restore the original image AND it is not a copy. | 1271 // used Undo to restore the original image AND it is not a copy. |
| 1276 // Otherwise lock the setting in its current state. | 1272 // Otherwise lock the setting in its current state. |
| 1277 var mayChangeOverwrite = !this.editor_.canUndo() && item.isOriginal(); | 1273 var mayChangeOverwrite = !this.editor_.canUndo() && item.isOriginal(); |
| 1278 ImageUtil.setAttribute(this.options_, 'saved', !mayChangeOverwrite); | 1274 ImageUtil.setAttribute(this.options_, 'saved', !mayChangeOverwrite); |
| 1279 | 1275 |
| 1280 // Record UMA for the first edit. | 1276 // Record UMA for the first edit. |
| 1281 if (this.imageView_.getContentRevision() === 1) | 1277 if (this.imageView_.getContentRevision() === 1) |
| 1282 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('Edit')); | 1278 ImageUtil.metrics.recordUserAction(ImageUtil.getMetricName('Edit')); |
| 1283 | 1279 |
| 1284 callback(); | 1280 callback(); |
| 1285 cr.dispatchSimpleEvent(this, 'image-saved'); | |
| 1286 }.bind(this)).catch(function(error) { | 1281 }.bind(this)).catch(function(error) { |
| 1287 console.error(error.stack || error); | 1282 console.error(error.stack || error); |
| 1288 }); | 1283 |
| 1284 this.showSpinner_(false); |
| 1285 this.errorBanner_.show('GALLERY_SAVE_FAILED'); |
| 1286 |
| 1287 callback(); |
| 1288 }.bind(this)); |
| 1289 }; | 1289 }; |
| 1290 | 1290 |
| 1291 /** | 1291 /** |
| 1292 * Flash 'Saved' label briefly to indicate that the image has been saved. | 1292 * Flash 'Saved' label briefly to indicate that the image has been saved. |
| 1293 * @private | 1293 * @private |
| 1294 */ | 1294 */ |
| 1295 SlideMode.prototype.flashSavedLabel_ = function() { | 1295 SlideMode.prototype.flashSavedLabel_ = function() { |
| 1296 var setLabelHighlighted = | 1296 var setLabelHighlighted = |
| 1297 ImageUtil.setAttribute.bind(null, this.savedLabel_, 'highlighted'); | 1297 ImageUtil.setAttribute.bind(null, this.savedLabel_, 'highlighted'); |
| 1298 setTimeout(setLabelHighlighted.bind(null, true), 0); | 1298 setTimeout(setLabelHighlighted.bind(null, true), 0); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 var event = assertInstanceof(event, MouseEvent); | 1862 var event = assertInstanceof(event, MouseEvent); |
| 1863 var viewport = this.slideMode_.getViewport(); | 1863 var viewport = this.slideMode_.getViewport(); |
| 1864 if (!this.enabled_ || !viewport.isZoomed()) | 1864 if (!this.enabled_ || !viewport.isZoomed()) |
| 1865 return; | 1865 return; |
| 1866 this.stopOperation(); | 1866 this.stopOperation(); |
| 1867 viewport.setOffset( | 1867 viewport.setOffset( |
| 1868 viewport.getOffsetX() + event.wheelDeltaX, | 1868 viewport.getOffsetX() + event.wheelDeltaX, |
| 1869 viewport.getOffsetY() + event.wheelDeltaY); | 1869 viewport.getOffsetY() + event.wheelDeltaY); |
| 1870 this.slideMode_.applyViewportChange(); | 1870 this.slideMode_.applyViewportChange(); |
| 1871 }; | 1871 }; |
| OLD | NEW |