Skip to content
Browse files

removeEvent now automatically extends objects with Event functionality

  • Loading branch information...
1 parent cd856db commit 0f8e7f9a8b8f91d7736e6495d3ce43612e0c255c @eolsson eolsson committed Jul 28, 2011
Showing with 20 additions and 11 deletions.
  1. +20 −11 js/adapters/mootools-adapter.src.js
View
31 js/adapters/mootools-adapter.src.js
@@ -87,7 +87,7 @@ win.HighchartsAdapter = {
}
// stop running animations
- HighchartsAdapter.stop(el);
+ win.HighchartsAdapter.stop(el);
// define and run the effect
effect = new Fx.Morph(
@@ -164,6 +164,21 @@ win.HighchartsAdapter = {
},
/**
+ * Extends an object with Events, if its not done
+ */
+ extendWithEvents: function (el) {
+ // if the addEvent method is not defined, el is a custom Highcharts object
+ // like series or point
+ if (!el.addEvent) {
+ if (el.nodeName) {
+ el = $(el); // a dynamically generated node
+ } else {
+ $extend(el, new Events()); // a custom object
+ }
+ }
+ },
+
+ /**
* Add an event listener
* @param {Object} el HTML element or custom object
* @param {String} type Event type
@@ -176,21 +191,15 @@ win.HighchartsAdapter = {
type = 'beforeunload';
}
- // if the addEvent method is not defined, el is a custom Highcharts object
- // like series or point
- if (!el.addEvent) {
- if (el.nodeName) {
- el = $(el); // a dynamically generated node
- } else {
- $extend(el, new Events()); // a custom object
- }
- }
-
+ win.HighchartsAdapter.extendWithEvents(el);
+
el.addEvent(type, fn);
}
},
removeEvent: function (el, type, fn) {
+ win.HighchartsAdapter.extendWithEvents(el);
+
if (type) {
if (type === 'unload') { // Moo self destructs before custom unload events
type = 'beforeunload';

0 comments on commit 0f8e7f9

Please sign in to comment.
Something went wrong with that request. Please try again.