X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-utils.js;h=f5440c7b3d7236b2d822d09137c103452deb00c1;hb=4d3672ff9d8739616db354bfb736fc2c52b71766;hp=e2af0b78ee126d89280cb5a4041c12d92ac61d6f;hpb=6a4587ace91189585976885b489d3e85eb51ee98;p=dygraphs.git diff --git a/dygraph-utils.js b/dygraph-utils.js index e2af0b7..f5440c7 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -136,13 +136,27 @@ Dygraph.getContext = function(canvas) { * @param { Function } fn The function to call on the event. The function takes * one parameter: the event object. */ -Dygraph.prototype.addEvent = function addEvent(elem, type, fn) { +Dygraph.addEvent = function addEvent(elem, type, fn) { if (elem.addEventListener) { elem.addEventListener(type, fn, false); } else { elem[type+fn] = function(){fn(window.event);}; elem.attachEvent('on'+type, elem[type+fn]); } +}; + +/** + * @private + * Add an event handler. This event handler is kept until the graph is + * destroyed with a call to graph.destroy(). + * + * @param { DOM element } elem The element to add the event to. + * @param { String } type The type of the event, e.g. 'click' or 'mousemove'. + * @param { Function } fn The function to call on the event. The function takes + * one parameter: the event object. + */ +Dygraph.prototype.addEvent = function addEvent(elem, type, fn) { + Dygraph.addEvent(elem, type, fn); this.registeredEvents_.push({ elem : elem, type : type, fn : fn }); }; @@ -155,7 +169,7 @@ Dygraph.prototype.addEvent = function addEvent(elem, type, fn) { * @param { Function } fn The function to call on the event. The function takes * one parameter: the event object. */ -Dygraph.prototype.removeEvent = function addEvent(elem, type, fn) { +Dygraph.removeEvent = function addEvent(elem, type, fn) { if (elem.removeEventListener) { elem.removeEventListener(type, fn, false); } else {