| 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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 * A toolbar for the ImageEditor. | 894 * A toolbar for the ImageEditor. |
| 895 * @param {HTMLElement} parent The parent element. | 895 * @param {HTMLElement} parent The parent element. |
| 896 * @param {function} displayStringFunction A string formatting function. | 896 * @param {function} displayStringFunction A string formatting function. |
| 897 * @param {function} updateCallback The callback called when controls change. | 897 * @param {function} updateCallback The callback called when controls change. |
| 898 * @constructor | 898 * @constructor |
| 899 */ | 899 */ |
| 900 ImageEditor.Toolbar = function(parent, displayStringFunction, updateCallback) { | 900 ImageEditor.Toolbar = function(parent, displayStringFunction, updateCallback) { |
| 901 this.wrapper_ = parent; | 901 this.wrapper_ = parent; |
| 902 this.displayStringFunction_ = displayStringFunction; | 902 this.displayStringFunction_ = displayStringFunction; |
| 903 this.updateCallback_ = updateCallback; | 903 this.updateCallback_ = updateCallback; |
| 904 Object.seal(this); |
| 905 }; |
| 906 |
| 907 ImageEditor.Toolbar.prototype = { |
| 908 get element() { |
| 909 return this.wrapper_; |
| 910 } |
| 904 }; | 911 }; |
| 905 | 912 |
| 906 /** | 913 /** |
| 907 * Clear the toolbar. | 914 * Clear the toolbar. |
| 908 */ | 915 */ |
| 909 ImageEditor.Toolbar.prototype.clear = function() { | 916 ImageEditor.Toolbar.prototype.clear = function() { |
| 910 ImageUtil.removeChildren(this.wrapper_); | 917 ImageUtil.removeChildren(this.wrapper_); |
| 911 }; | 918 }; |
| 912 | 919 |
| 913 /** | 920 /** |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 * | 953 * |
| 947 * @param {string} name Button name. | 954 * @param {string} name Button name. |
| 948 * @param {string} title Button title. | 955 * @param {string} title Button title. |
| 949 * @param {function} handler onClick handler. | 956 * @param {function} handler onClick handler. |
| 950 * @param {string=} opt_class Extra class name. | 957 * @param {string=} opt_class Extra class name. |
| 951 * @return {HTMLElement} The added button. | 958 * @return {HTMLElement} The added button. |
| 952 */ | 959 */ |
| 953 ImageEditor.Toolbar.prototype.addButton = function( | 960 ImageEditor.Toolbar.prototype.addButton = function( |
| 954 name, title, handler, opt_class) { | 961 name, title, handler, opt_class) { |
| 955 var button = this.create_('button'); | 962 var button = this.create_('button'); |
| 956 if (opt_class) button.classList.add(opt_class); | 963 if (opt_class) |
| 964 button.classList.add(opt_class); |
| 957 var label = this.create_('span'); | 965 var label = this.create_('span'); |
| 958 label.textContent = this.displayStringFunction_(title); | 966 label.textContent = this.displayStringFunction_(title); |
| 959 button.appendChild(label); | 967 button.appendChild(label); |
| 960 button.label = this.displayStringFunction_(title); | 968 button.label = this.displayStringFunction_(title); |
| 961 button.title = this.displayStringFunction_(title); | 969 button.title = this.displayStringFunction_(title); |
| 962 button.addEventListener('click', handler, false); | 970 button.addEventListener('click', handler, false); |
| 963 return this.add(button); | 971 return this.add(button); |
| 964 }; | 972 }; |
| 965 | 973 |
| 966 /** | 974 /** |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 | 1179 |
| 1172 /** | 1180 /** |
| 1173 * Hide the prompt. | 1181 * Hide the prompt. |
| 1174 */ | 1182 */ |
| 1175 ImageEditor.Prompt.prototype.hide = function() { | 1183 ImageEditor.Prompt.prototype.hide = function() { |
| 1176 if (!this.prompt_) return; | 1184 if (!this.prompt_) return; |
| 1177 this.prompt_.setAttribute('state', 'fadeout'); | 1185 this.prompt_.setAttribute('state', 'fadeout'); |
| 1178 // Allow some time for the animation to play out. | 1186 // Allow some time for the animation to play out. |
| 1179 this.setTimer(this.reset.bind(this), 500); | 1187 this.setTimer(this.reset.bind(this), 500); |
| 1180 }; | 1188 }; |
| OLD | NEW |