| 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 * ImageEditor is the top level object that holds together and connects | 8 * ImageEditor is the top level object that holds together and connects |
| 9 * everything needed for image editing. | 9 * everything needed for image editing. |
| 10 * | 10 * |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ImageEditor.prototype.openSession = function( | 111 ImageEditor.prototype.openSession = function( |
| 112 item, effect, saveFunction, displayCallback, loadCallback) { | 112 item, effect, saveFunction, displayCallback, loadCallback) { |
| 113 if (this.commandQueue_) | 113 if (this.commandQueue_) |
| 114 throw new Error('Session not closed'); | 114 throw new Error('Session not closed'); |
| 115 | 115 |
| 116 this.lockUI(true); | 116 this.lockUI(true); |
| 117 | 117 |
| 118 var self = this; | 118 var self = this; |
| 119 this.imageView_.load( | 119 this.imageView_.load( |
| 120 item, effect, displayCallback, function(loadType, delay, error) { | 120 item, effect, displayCallback, function(loadType, delay, error) { |
| 121 self.lockUI(false); | 121 self.lockUI(false); |
| 122 self.commandQueue_ = new CommandQueue( | 122 self.commandQueue_ = new CommandQueue( |
| 123 self.container_.ownerDocument, | 123 self.container_.ownerDocument, |
| 124 self.imageView_.getCanvas(), | 124 self.imageView_.getCanvas(), |
| 125 saveFunction); | 125 saveFunction); |
| 126 self.commandQueue_.attachUI( | 126 self.commandQueue_.attachUI( |
| 127 self.getImageView(), self.getPrompt(), self.lockUI.bind(self)); | 127 self.getImageView(), self.getPrompt(), self.lockUI.bind(self)); |
| 128 self.updateUndoRedo(); | 128 self.updateUndoRedo(); |
| 129 loadCallback(loadType, delay, error); | 129 loadCallback(loadType, delay, error); |
| 130 }); | 130 }); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * Close the current image editing session. | 134 * Close the current image editing session. |
| 135 * @param {function} callback Callback. | 135 * @param {function} callback Callback. |
| 136 */ | 136 */ |
| 137 ImageEditor.prototype.closeSession = function(callback) { | 137 ImageEditor.prototype.closeSession = function(callback) { |
| 138 this.getPrompt().hide(); | 138 this.getPrompt().hide(); |
| 139 if (this.imageView_.isLoading()) { | 139 if (this.imageView_.isLoading()) { |
| 140 if (this.commandQueue_) { | 140 if (this.commandQueue_) { |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 /** | 800 /** |
| 801 * Touch move handler. | 801 * Touch move handler. |
| 802 * @param {TouchEvent} e Event. | 802 * @param {TouchEvent} e Event. |
| 803 */ | 803 */ |
| 804 ImageEditor.MouseControl.prototype.onTouchMove = function(e) { | 804 ImageEditor.MouseControl.prototype.onTouchMove = function(e) { |
| 805 var position = this.getTouchPosition_(e); | 805 var position = this.getTouchPosition_(e); |
| 806 if (!position) | 806 if (!position) |
| 807 return; | 807 return; |
| 808 | 808 |
| 809 if (this.touchStartInfo_ && !this.dragHappened_) { | 809 if (this.touchStartInfo_ && !this.dragHappened_) { |
| 810 var tapCircle = new Circle(this.touchStartInfo_.x, this.touchStartInfo_.y, | 810 var tapCircle = new Circle( |
| 811 ImageEditor.MouseControl.MAX_MOVEMENT_FOR_TAP_); | 811 this.touchStartInfo_.x, this.touchStartInfo_.y, |
| 812 ImageEditor.MouseControl.MAX_MOVEMENT_FOR_TAP_); |
| 812 this.dragHappened_ = !tapCircle.inside(position.x, position.y); | 813 this.dragHappened_ = !tapCircle.inside(position.x, position.y); |
| 813 } | 814 } |
| 814 if (this.dragHandler_ && this.dragHappened_) { | 815 if (this.dragHandler_ && this.dragHappened_) { |
| 815 this.dragHandler_(position.x, position.y, e.shiftKey); | 816 this.dragHandler_(position.x, position.y, e.shiftKey); |
| 816 this.lockMouse_(true); | 817 this.lockMouse_(true); |
| 817 } | 818 } |
| 818 }; | 819 }; |
| 819 | 820 |
| 820 /** | 821 /** |
| 821 * Mouse down handler. | 822 * Mouse down handler. |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 self.timer_ = null; | 1122 self.timer_ = null; |
| 1122 callback(); | 1123 callback(); |
| 1123 }, timeout); | 1124 }, timeout); |
| 1124 }; | 1125 }; |
| 1125 | 1126 |
| 1126 /** | 1127 /** |
| 1127 * Show the prompt. | 1128 * Show the prompt. |
| 1128 * | 1129 * |
| 1129 * @param {string} text The prompt text. | 1130 * @param {string} text The prompt text. |
| 1130 * @param {number} timeout Timeout in ms. | 1131 * @param {number} timeout Timeout in ms. |
| 1131 * @param {...Object} var_formatArgs varArgs for the formatting function. | 1132 * @param {...Object} var_args varArgs for the formatting function. |
| 1132 */ | 1133 */ |
| 1133 ImageEditor.Prompt.prototype.show = function(text, timeout, var_formatArgs) { | 1134 ImageEditor.Prompt.prototype.show = function(text, timeout, var_args) { |
| 1134 var args = [text].concat(Array.prototype.slice.call(arguments, 2)); | 1135 var args = [text].concat(Array.prototype.slice.call(arguments, 2)); |
| 1135 var message = this.displayStringFunction_.apply(null, args); | 1136 var message = this.displayStringFunction_.apply(null, args); |
| 1136 this.showStringAt('center', message, timeout); | 1137 this.showStringAt('center', message, timeout); |
| 1137 }; | 1138 }; |
| 1138 | 1139 |
| 1139 /** | 1140 /** |
| 1140 * Show the position at the specific position. | 1141 * Show the position at the specific position. |
| 1141 * | 1142 * |
| 1142 * @param {string} pos The 'pos' attribute value. | 1143 * @param {string} pos The 'pos' attribute value. |
| 1143 * @param {string} text The prompt text. | 1144 * @param {string} text The prompt text. |
| 1144 * @param {number} timeout Timeout in ms. | 1145 * @param {number} timeout Timeout in ms. |
| 1145 * @param {...Object} var_formatArgs varArgs for the formatting function. | 1146 * @param {...Object} var_args varArgs for the formatting function. |
| 1146 */ | 1147 */ |
| 1147 ImageEditor.Prompt.prototype.showAt = function( | 1148 ImageEditor.Prompt.prototype.showAt = function( |
| 1148 pos, text, timeout, var_formatArgs) { | 1149 pos, text, timeout, var_args) { |
| 1149 var args = [text].concat(Array.prototype.slice.call(arguments, 3)); | 1150 var args = [text].concat(Array.prototype.slice.call(arguments, 3)); |
| 1150 var message = this.displayStringFunction_.apply(null, args); | 1151 var message = this.displayStringFunction_.apply(null, args); |
| 1151 this.showStringAt(pos, message, timeout); | 1152 this.showStringAt(pos, message, timeout); |
| 1152 }; | 1153 }; |
| 1153 | 1154 |
| 1154 /** | 1155 /** |
| 1155 * Show the string in the prompt | 1156 * Show the string in the prompt |
| 1156 * | 1157 * |
| 1157 * @param {string} pos The 'pos' attribute value. | 1158 * @param {string} pos The 'pos' attribute value. |
| 1158 * @param {string} text The prompt text. | 1159 * @param {string} text The prompt text. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 | 1195 |
| 1195 /** | 1196 /** |
| 1196 * Hide the prompt. | 1197 * Hide the prompt. |
| 1197 */ | 1198 */ |
| 1198 ImageEditor.Prompt.prototype.hide = function() { | 1199 ImageEditor.Prompt.prototype.hide = function() { |
| 1199 if (!this.prompt_) return; | 1200 if (!this.prompt_) return; |
| 1200 this.prompt_.setAttribute('state', 'fadeout'); | 1201 this.prompt_.setAttribute('state', 'fadeout'); |
| 1201 // Allow some time for the animation to play out. | 1202 // Allow some time for the animation to play out. |
| 1202 this.setTimer(this.reset.bind(this), 500); | 1203 this.setTimer(this.reset.bind(this), 500); |
| 1203 }; | 1204 }; |
| OLD | NEW |