flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/4] git commit: [flex-asjs] [refs/heads/develop] - add removeEventListener and hasEventListener
Date Fri, 21 Aug 2015 14:19:03 GMT
add removeEventListener and hasEventListener


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/47c94331
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/47c94331
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/47c94331

Branch: refs/heads/develop
Commit: 47c94331c1a34a22d45ea798153628b10297ee37
Parents: 4dcbde2
Author: Alex Harui <aharui@apache.org>
Authored: Thu Aug 20 18:06:35 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Aug 20 18:06:35 2015 -0700

----------------------------------------------------------------------
 .../org/apache/flex/events/EventDispatcher.js   | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/47c94331/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js b/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
index 17ed09a..a26028a 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/events/EventDispatcher.js
@@ -72,3 +72,60 @@ org.apache.flex.events.EventDispatcher.prototype.addEventListener =
 };
 
 
+/**
+ * @override
+ * @export
+ */
+org.apache.flex.events.EventDispatcher.prototype.removeEventListener =
+    function(type, handler, opt_capture, opt_handlerScope) {
+  var source;
+
+  /**
+   *  A bit of a hack, but for 'native' HTML element based controls, we
+   *  want to listen to the 'native' events from the element; for other
+   *  types of controls, we listen to 'custom' events.
+   */
+  source = this;
+  if (this.element && this.element.nodeName &&
+      this.element.nodeName.toLowerCase() !== 'div' &&
+      // we don't use any native img events right now, we wrapthem
+      this.element.nodeName.toLowerCase() !== 'img' &&
+      this.element.nodeName.toLowerCase() !== 'body') {
+    source = this.element;
+  } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
+    // mouse and keyboard events also dispatch off the element.
+    source = this.element;
+  }
+
+  goog.events.unlisten(source, type, handler);
+};
+
+
+/**
+ * @export
+ * @param {string} type The event name.
+ * @return {boolean} True if there is a listener.
+ */
+org.apache.flex.events.EventDispatcher.prototype.hasEventListener =
+    function(type) {
+  var source;
+
+  /**
+   *  A bit of a hack, but for 'native' HTML element based controls, we
+   *  want to listen to the 'native' events from the element; for other
+   *  types of controls, we listen to 'custom' events.
+   */
+  source = this;
+  if (this.element && this.element.nodeName &&
+      this.element.nodeName.toLowerCase() !== 'div' &&
+      // we don't use any native img events right now, we wrapthem
+      this.element.nodeName.toLowerCase() !== 'img' &&
+      this.element.nodeName.toLowerCase() !== 'body') {
+    source = this.element;
+  } else if (org.apache.flex.events.ElementEvents.elementEvents[type]) {
+    // mouse and keyboard events also dispatch off the element.
+    source = this.element;
+  }
+
+  return goog.events.hasListener(source, type);
+};


Mime
View raw message