diff options
author | mahmadi <mahmadi@chromium.org> | 2016-03-08 12:48:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 20:50:09 +0000 |
commit | 6f4764e2f7e015f8fad2ecb2a588ae75728dadb2 (patch) | |
tree | ff6c1a8fa15a297d6ee0efcc7b0e563e364ef906 /ui/webui | |
parent | 202bf4d52e539393a8289f4b014a19ea50721789 (diff) | |
download | chromium_src-6f4764e2f7e015f8fad2ecb2a588ae75728dadb2.zip chromium_src-6f4764e2f7e015f8fad2ecb2a588ae75728dadb2.tar.gz chromium_src-6f4764e2f7e015f8fad2ecb2a588ae75728dadb2.tar.bz2 |
Defines web_ui_listener_behavior on the global namespace Adds it to compiled_resources2.gyp
Review URL: https://codereview.chromium.org/1776473002
Cr-Commit-Position: refs/heads/master@{#379905}
Diffstat (limited to 'ui/webui')
-rw-r--r-- | ui/webui/resources/js/compiled_resources2.gyp | 7 | ||||
-rw-r--r-- | ui/webui/resources/js/web_ui_listener_behavior.js | 64 |
2 files changed, 36 insertions, 35 deletions
diff --git a/ui/webui/resources/js/compiled_resources2.gyp b/ui/webui/resources/js/compiled_resources2.gyp index 1c1e15f..e24ce72 100644 --- a/ui/webui/resources/js/compiled_resources2.gyp +++ b/ui/webui/resources/js/compiled_resources2.gyp @@ -70,5 +70,12 @@ ], 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'], }, + { + 'target_name': 'web_ui_listener_behavior', + 'dependencies': [ + 'cr', + ], + 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'], + }, ], } diff --git a/ui/webui/resources/js/web_ui_listener_behavior.js b/ui/webui/resources/js/web_ui_listener_behavior.js index 0b45d83..d7fc56b 100644 --- a/ui/webui/resources/js/web_ui_listener_behavior.js +++ b/ui/webui/resources/js/web_ui_listener_behavior.js @@ -7,43 +7,37 @@ * automatically remove WebUI listeners when detached. */ -cr.define('settings', function() { - /** @polymerBehavior */ - var WebUIListenerBehavior = { - properties: { - /** - * Holds WebUI listeners that need to be removed when this element is - * destroyed. - * @private {!Array<!WebUIListener>} - */ - webUIListeners_: { - type: Array, - value: function() { return []; }, - }, - }, - +/** @polymerBehavior */ +var WebUIListenerBehavior = { + properties: { /** - * Adds a WebUI listener and registers it for automatic removal when this - * element is detached. - * Note: Do not use this method if you intend to remove this listener - * manually (use cr.addWebUIListener directly instead). - * - * @param {string} eventName The event to listen to. - * @param {!Function} callback The callback run when the event is fired. + * Holds WebUI listeners that need to be removed when this element is + * destroyed. + * @private {!Array<!WebUIListener>} */ - addWebUIListener: function(eventName, callback) { - this.webUIListeners_.push(cr.addWebUIListener(eventName, callback)); + webUIListeners_: { + type: Array, + value: function() { return []; }, }, + }, - /** @override */ - detached: function() { - while (this.webUIListeners_.length > 0) { - cr.removeWebUIListener(this.webUIListeners_.pop()); - } - }, - }; + /** + * Adds a WebUI listener and registers it for automatic removal when this + * element is detached. + * Note: Do not use this method if you intend to remove this listener + * manually (use cr.addWebUIListener directly instead). + * + * @param {string} eventName The event to listen to. + * @param {!Function} callback The callback run when the event is fired. + */ + addWebUIListener: function(eventName, callback) { + this.webUIListeners_.push(cr.addWebUIListener(eventName, callback)); + }, - return { - WebUIListenerBehavior: WebUIListenerBehavior, - }; -}); + /** @override */ + detached: function() { + while (this.webUIListeners_.length > 0) { + cr.removeWebUIListener(this.webUIListeners_.pop()); + } + }, +}; |