| 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 * ImageEditor is the top level object that holds together and connects | 6 * ImageEditor is the top level object that holds together and connects |
| 7 * everything needed for image editing. | 7 * everything needed for image editing. |
| 8 * | 8 * |
| 9 * @param {!Viewport} viewport The viewport. | 9 * @param {!Viewport} viewport The viewport. |
| 10 * @param {!ImageView} imageView The ImageView containing the images to edit. | 10 * @param {!ImageView} imageView The ImageView containing the images to edit. |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 parent, displayStringFunction, opt_updateCallback, opt_showActionButtons) { | 1135 parent, displayStringFunction, opt_updateCallback, opt_showActionButtons) { |
| 1136 this.wrapper_ = parent; | 1136 this.wrapper_ = parent; |
| 1137 this.displayStringFunction_ = displayStringFunction; | 1137 this.displayStringFunction_ = displayStringFunction; |
| 1138 | 1138 |
| 1139 /** | 1139 /** |
| 1140 * @type {?function(Object)} | 1140 * @type {?function(Object)} |
| 1141 * @private | 1141 * @private |
| 1142 */ | 1142 */ |
| 1143 this.updateCallback_ = opt_updateCallback || null; | 1143 this.updateCallback_ = opt_updateCallback || null; |
| 1144 | 1144 |
| 1145 // Create action buttons. | 1145 /** |
| 1146 * @private {!HTMLElement} |
| 1147 */ |
| 1148 this.container_ = /** @type {!HTMLElement} */ (document.createElement('div')); |
| 1149 this.container_.classList.add('container'); |
| 1150 this.wrapper_.appendChild(this.container_); |
| 1151 |
| 1152 // Create action buttons. |
| 1146 if (opt_showActionButtons) { | 1153 if (opt_showActionButtons) { |
| 1147 var actionButtonsLayer = document.createElement('div'); | 1154 var actionButtonsLayer = document.createElement('div'); |
| 1148 actionButtonsLayer.classList.add('action-buttons'); | 1155 actionButtonsLayer.classList.add('action-buttons'); |
| 1149 | 1156 |
| 1150 this.cancelButton_ = ImageEditor.Toolbar.createButton_( | 1157 this.cancelButton_ = ImageEditor.Toolbar.createButton_( |
| 1151 'GALLERY_CANCEL_LABEL', ImageEditor.Toolbar.ButtonType.LABEL_UPPER_CASE, | 1158 'GALLERY_CANCEL_LABEL', ImageEditor.Toolbar.ButtonType.LABEL_UPPER_CASE, |
| 1152 this.onCancelClicked_.bind(this), 'cancel'); | 1159 this.onCancelClicked_.bind(this), 'cancel'); |
| 1153 actionButtonsLayer.appendChild(this.cancelButton_); | 1160 actionButtonsLayer.appendChild(this.cancelButton_); |
| 1154 | 1161 |
| 1155 this.doneButton_ = ImageEditor.Toolbar.createButton_( | 1162 this.doneButton_ = ImageEditor.Toolbar.createButton_( |
| 1156 'GALLERY_DONE', ImageEditor.Toolbar.ButtonType.LABEL_UPPER_CASE, | 1163 'GALLERY_DONE', ImageEditor.Toolbar.ButtonType.LABEL_UPPER_CASE, |
| 1157 this.onDoneClicked_.bind(this), 'done'); | 1164 this.onDoneClicked_.bind(this), 'done'); |
| 1158 actionButtonsLayer.appendChild(this.doneButton_); | 1165 actionButtonsLayer.appendChild(this.doneButton_); |
| 1159 | 1166 |
| 1160 this.wrapper_.appendChild(actionButtonsLayer); | 1167 this.wrapper_.appendChild(actionButtonsLayer); |
| 1161 } | 1168 } |
| 1162 | |
| 1163 /** | |
| 1164 * @private {!HTMLElement} | |
| 1165 */ | |
| 1166 this.container_ = /** @type {!HTMLElement} */ (document.createElement('div')); | |
| 1167 this.container_.classList.add('container'); | |
| 1168 this.wrapper_.appendChild(this.container_); | |
| 1169 }; | 1169 }; |
| 1170 | 1170 |
| 1171 ImageEditor.Toolbar.prototype.__proto__ = cr.EventTarget.prototype; | 1171 ImageEditor.Toolbar.prototype.__proto__ = cr.EventTarget.prototype; |
| 1172 | 1172 |
| 1173 /** | 1173 /** |
| 1174 * Height of the toolbar. | 1174 * Height of the toolbar. |
| 1175 * @const {number} | 1175 * @const {number} |
| 1176 */ | 1176 */ |
| 1177 ImageEditor.Toolbar.HEIGHT = 48; // px | 1177 ImageEditor.Toolbar.HEIGHT = 48; // px |
| 1178 | 1178 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1447 | 1447 |
| 1448 /** | 1448 /** |
| 1449 * Show/hide the toolbar. | 1449 * Show/hide the toolbar. |
| 1450 * @param {boolean} on True if show. | 1450 * @param {boolean} on True if show. |
| 1451 */ | 1451 */ |
| 1452 ImageEditor.Toolbar.prototype.show = function(on) { | 1452 ImageEditor.Toolbar.prototype.show = function(on) { |
| 1453 if (!this.wrapper_.firstChild) | 1453 if (!this.wrapper_.firstChild) |
| 1454 return; // Do not show empty toolbar; | 1454 return; // Do not show empty toolbar; |
| 1455 | 1455 |
| 1456 this.wrapper_.hidden = !on; | 1456 this.wrapper_.hidden = !on; |
| 1457 |
| 1458 // Focus the first input on the toolbar. |
| 1459 if (on) { |
| 1460 var input = this.container_.querySelector( |
| 1461 'button, paper-button, input, paper-input, paper-slider'); |
| 1462 if (input) |
| 1463 input.focus(); |
| 1464 } |
| 1457 }; | 1465 }; |
| 1458 | 1466 |
| 1459 /** A prompt panel for the editor. | 1467 /** A prompt panel for the editor. |
| 1460 * | 1468 * |
| 1461 * @param {!HTMLElement} container Container element. | 1469 * @param {!HTMLElement} container Container element. |
| 1462 * @param {function(string, ...string)} displayStringFunction A formatting | 1470 * @param {function(string, ...string)} displayStringFunction A formatting |
| 1463 * function. | 1471 * function. |
| 1464 * @constructor | 1472 * @constructor |
| 1465 * @struct | 1473 * @struct |
| 1466 */ | 1474 */ |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 | 1604 |
| 1597 /** | 1605 /** |
| 1598 * Hide the prompt. | 1606 * Hide the prompt. |
| 1599 */ | 1607 */ |
| 1600 ImageEditor.Prompt.prototype.hide = function() { | 1608 ImageEditor.Prompt.prototype.hide = function() { |
| 1601 if (!this.prompt_) return; | 1609 if (!this.prompt_) return; |
| 1602 this.prompt_.setAttribute('state', 'fadeout'); | 1610 this.prompt_.setAttribute('state', 'fadeout'); |
| 1603 // Allow some time for the animation to play out. | 1611 // Allow some time for the animation to play out. |
| 1604 this.setTimer(this.reset.bind(this), 500); | 1612 this.setTimer(this.reset.bind(this), 500); |
| 1605 }; | 1613 }; |
| OLD | NEW |