Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added support for external hooks for event binding and dispatching.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez authored and kborchers committed Oct 31, 2013
1 parent e5bb088 commit adfbfd5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

(function(scope) {
scope = scope || {};
scope.external = scope.external || {};
var target = {
shadow: function(inEl) {
if (inEl) {
Expand Down
13 changes: 8 additions & 5 deletions src/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
es.unregister.call(es, element);
}
},
contains: scope.external.contains || function(container, contained) {
return container.contains(contained);
},
// EVENTS
down: function(inEvent) {
this.fireEvent('pointerdown', inEvent);
Expand Down Expand Up @@ -161,13 +164,13 @@
this.fireEvent('pointercancel', inEvent);
},
leaveOut: function(event) {
if (!event.target.contains(event.relatedTarget)) {
if (!this.contains(event.target, event.relatedTarget)) {
this.leave(event);
}
this.out(event);
},
enterOver: function(event) {
if (!event.target.contains(event.relatedTarget)) {
if (!this.contains(event.target, event.relatedTarget)) {
this.enter(event);
}
this.over(event);
Expand Down Expand Up @@ -199,10 +202,10 @@
this.removeEvent(target, e);
}, this);
},
addEvent: function(target, eventName) {
addEvent: scope.external.addEvent || function(target, eventName) {
target.addEventListener(eventName, this.boundHandler);
},
removeEvent: function(target, eventName) {
removeEvent: scope.external.removeEvent || function(target, eventName) {
target.removeEventListener(eventName, this.boundHandler);
},
// EVENT CREATION AND TRACKING
Expand Down Expand Up @@ -282,7 +285,7 @@
* @param {Event} inEvent The event to be dispatched.
* @return {Boolean} True if an event handler returns true, false otherwise.
*/
dispatchEvent: function(inEvent) {
dispatchEvent: scope.external.dispatchEvent || function(inEvent) {
var t = this.getTarget(inEvent);
if (t) {
return t.dispatchEvent(inEvent);
Expand Down

0 comments on commit adfbfd5

Please sign in to comment.