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 * |
11 * @param {Element} container Main container element. | 11 * @param {Element} container Main container element. |
12 * @param {Element} content Content container element. | 12 * @param {Element} content Content container element. |
13 * @param {Element} toolbar Toolbar element. | 13 * @param {Element} toolbar Toolbar element. |
14 * @param {ImageEditor.Prompt} prompt Prompt. | 14 * @param {ImageEditor.Prompt} prompt Prompt. |
15 * @param {cr.ui.ArrayDataModel} dataModel Data model. | 15 * @param {cr.ui.ArrayDataModel} dataModel Data model. |
16 * @param {cr.ui.ListSelectionModel} selectionModel Selection model. | 16 * @param {cr.ui.ListSelectionModel} selectionModel Selection model. |
17 * @param {Object} context Context. | 17 * @param {Object} context Context. |
18 * @param {function(function())} toggleMode Function to toggle the Gallery mode. | 18 * @param {function(function())} toggleMode Function to toggle the Gallery mode. |
19 * @param {function(string):string} displayStringFunction String formatting | 19 * @param {function(string):string} displayStringFunction String formatting |
20 * function. | 20 * function. |
21 * @constructor | 21 * @constructor |
22 */ | 22 */ |
23 function SlideMode(container, content, toolbar, prompt, | 23 function SlideMode(container, content, toolbar, prompt, dataModel, |
24 dataModel, selectionModel, context, | 24 selectionModel, context, volumeManager, toggleMode, displayStringFunction) { |
25 toggleMode, displayStringFunction) { | |
26 this.container_ = container; | 25 this.container_ = container; |
27 this.document_ = container.ownerDocument; | 26 this.document_ = container.ownerDocument; |
28 this.content = content; | 27 this.content = content; |
29 this.toolbar_ = toolbar; | 28 this.toolbar_ = toolbar; |
30 this.prompt_ = prompt; | 29 this.prompt_ = prompt; |
31 this.dataModel_ = dataModel; | 30 this.dataModel_ = dataModel; |
32 this.selectionModel_ = selectionModel; | 31 this.selectionModel_ = selectionModel; |
33 this.context_ = context; | 32 this.context_ = context; |
| 33 this.volumeManager_ = volumeManager; |
34 this.metadataCache_ = context.metadataCache; | 34 this.metadataCache_ = context.metadataCache; |
35 this.toggleMode_ = toggleMode; | 35 this.toggleMode_ = toggleMode; |
36 this.displayStringFunction_ = displayStringFunction; | 36 this.displayStringFunction_ = displayStringFunction; |
37 | 37 |
38 this.onSelectionBound_ = this.onSelection_.bind(this); | 38 this.onSelectionBound_ = this.onSelection_.bind(this); |
39 this.onSpliceBound_ = this.onSplice_.bind(this); | 39 this.onSpliceBound_ = this.onSplice_.bind(this); |
40 | 40 |
41 // Unique numeric key, incremented per each load attempt used to discard | 41 // Unique numeric key, incremented per each load attempt used to discard |
42 // old attempts. This can happen especially when changing selection fast or | 42 // old attempts. This can happen especially when changing selection fast or |
43 // Internet connection is slow. | 43 // Internet connection is slow. |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 * Save the current image to a file. | 959 * Save the current image to a file. |
960 * | 960 * |
961 * @param {Gallery.Item} item Item to save the image. | 961 * @param {Gallery.Item} item Item to save the image. |
962 * @param {function} callback Callback. | 962 * @param {function} callback Callback. |
963 * @private | 963 * @private |
964 */ | 964 */ |
965 SlideMode.prototype.saveCurrentImage_ = function(item, callback) { | 965 SlideMode.prototype.saveCurrentImage_ = function(item, callback) { |
966 this.showSpinner_(true); | 966 this.showSpinner_(true); |
967 | 967 |
968 var savedPromise = this.dataModel_.saveItem( | 968 var savedPromise = this.dataModel_.saveItem( |
| 969 this.volumeManager_, |
969 item, | 970 item, |
970 this.imageView_.getCanvas(), | 971 this.imageView_.getCanvas(), |
971 this.shouldOverwriteOriginal_()); | 972 this.shouldOverwriteOriginal_()); |
972 | 973 |
973 savedPromise.catch(function(error) { | 974 savedPromise.catch(function(error) { |
974 // TODO(hirono): Implement write error handling. | 975 // TODO(hirono): Implement write error handling. |
975 // Until then pretend that the save succeeded. | 976 // Until then pretend that the save succeeded. |
976 console.error(error.stack || error); | 977 console.error(error.stack || error); |
977 }).then(function() { | 978 }).then(function() { |
978 this.showSpinner_(false); | 979 this.showSpinner_(false); |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 TouchHandler.prototype.onMouseWheel_ = function(event) { | 1566 TouchHandler.prototype.onMouseWheel_ = function(event) { |
1566 var viewport = this.slideMode_.getViewport(); | 1567 var viewport = this.slideMode_.getViewport(); |
1567 if (!this.enabled_ || !viewport.isZoomed()) | 1568 if (!this.enabled_ || !viewport.isZoomed()) |
1568 return; | 1569 return; |
1569 this.stopOperation(); | 1570 this.stopOperation(); |
1570 viewport.setOffset( | 1571 viewport.setOffset( |
1571 viewport.getOffsetX() + event.wheelDeltaX, | 1572 viewport.getOffsetX() + event.wheelDeltaX, |
1572 viewport.getOffsetY() + event.wheelDeltaY); | 1573 viewport.getOffsetY() + event.wheelDeltaY); |
1573 this.slideMode_.applyViewportChange(); | 1574 this.slideMode_.applyViewportChange(); |
1574 }; | 1575 }; |
OLD | NEW |