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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Slide mode displays a single image and has a set of controls to navigate | 8 * Slide mode displays a single image and has a set of controls to navigate |
9 * between the images and to edit an image. | 9 * between the images and to edit an image. |
10 * | 10 * |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 | 743 |
744 loadCallback(loadType, delay); | 744 loadCallback(loadType, delay); |
745 }.bind(this); | 745 }.bind(this); |
746 | 746 |
747 var displayDone = function() { | 747 var displayDone = function() { |
748 cr.dispatchSimpleEvent(this, 'image-displayed'); | 748 cr.dispatchSimpleEvent(this, 'image-displayed'); |
749 displayCallback(); | 749 displayCallback(); |
750 }.bind(this); | 750 }.bind(this); |
751 | 751 |
752 this.editor_.openSession( | 752 this.editor_.openSession( |
753 item, effect, this.saveCurrentImage_.bind(this), displayDone, loadDone); | 753 item, |
| 754 effect, |
| 755 this.saveCurrentImage_.bind(this, item), |
| 756 displayDone, |
| 757 loadDone); |
754 }; | 758 }; |
755 | 759 |
756 /** | 760 /** |
757 * Commit changes to the current item and reset all messages/indicators. | 761 * Commit changes to the current item and reset all messages/indicators. |
758 * | 762 * |
759 * @param {function} callback Callback. | 763 * @param {function} callback Callback. |
760 * @private | 764 * @private |
761 */ | 765 */ |
762 SlideMode.prototype.commitItem_ = function(callback) { | 766 SlideMode.prototype.commitItem_ = function(callback) { |
763 this.showSpinner_(false); | 767 this.showSpinner_(false); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 this.ribbon_.reset(); | 951 this.ribbon_.reset(); |
948 if (this.active_) | 952 if (this.active_) |
949 this.ribbon_.redraw(); | 953 this.ribbon_.redraw(); |
950 }; | 954 }; |
951 | 955 |
952 // Saving | 956 // Saving |
953 | 957 |
954 /** | 958 /** |
955 * Save the current image to a file. | 959 * Save the current image to a file. |
956 * | 960 * |
| 961 * @param {Gallery.Item} item Item to save the image. |
957 * @param {function} callback Callback. | 962 * @param {function} callback Callback. |
958 * @private | 963 * @private |
959 */ | 964 */ |
960 SlideMode.prototype.saveCurrentImage_ = function(callback) { | 965 SlideMode.prototype.saveCurrentImage_ = function(item, callback) { |
961 this.showSpinner_(true); | 966 this.showSpinner_(true); |
962 | 967 |
963 var item = this.getSelectedItem(); | |
964 var savedPromise = this.dataModel_.saveItem( | 968 var savedPromise = this.dataModel_.saveItem( |
965 item, | 969 item, |
966 this.imageView_.getCanvas(), | 970 this.imageView_.getCanvas(), |
967 this.shouldOverwriteOriginal_()); | 971 this.shouldOverwriteOriginal_()); |
968 | 972 |
969 savedPromise.catch(function(error) { | 973 savedPromise.catch(function(error) { |
970 // TODO(hirono): Implement write error handling. | 974 // TODO(hirono): Implement write error handling. |
971 // Until then pretend that the save succeeded. | 975 // Until then pretend that the save succeeded. |
972 console.error(error.stack || error); | 976 console.error(error.stack || error); |
973 }).then(function() { | 977 }).then(function() { |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 else | 1540 else |
1537 viewport.setRotation(this.gestureStartRotation_); | 1541 viewport.setRotation(this.gestureStartRotation_); |
1538 this.slideMode_.applyViewportChange(); | 1542 this.slideMode_.applyViewportChange(); |
1539 break; | 1543 break; |
1540 } | 1544 } |
1541 | 1545 |
1542 // Update the last event. | 1546 // Update the last event. |
1543 this.lastEvent_ = event; | 1547 this.lastEvent_ = event; |
1544 this.lastZoom_ = viewport.getZoom(); | 1548 this.lastZoom_ = viewport.getZoom(); |
1545 }; | 1549 }; |
OLD | NEW |