X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-utils.js;h=7282c9c4df53e2371a37e0db6657130bd8546899;hb=b941564d6f1d2791c6b9714bd089bd19f4ca67b3;hp=223360b319135d7745f60748d8fd7bb7d3b6643b;hpb=7ad6c698d28d7d0f0770e1f6490f1a9649c64b6f;p=dygraphs.git diff --git a/dygraph-utils.js b/dygraph-utils.js index 223360b..7282c9c 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -192,7 +192,7 @@ Dygraph.addEvent = function addEvent(elem, type, fn) { * on the event. The function takes one parameter: the event object. * @private */ -Dygraph.prototype.addEvent = function(elem, type, fn) { +Dygraph.prototype.addAndTrackEvent = function(elem, type, fn) { Dygraph.addEvent(elem, type, fn); this.registeredEvents_.push({ elem : elem, type : type, fn : fn }); }; @@ -220,6 +220,17 @@ Dygraph.removeEvent = function(elem, type, fn) { } }; +Dygraph.prototype.removeTrackedEvents_ = function() { + if (this.registeredEvents_) { + for (var idx = 0; idx < this.registeredEvents_.length; idx++) { + var reg = this.registeredEvents_[idx]; + Dygraph.removeEvent(reg.elem, reg.type, reg.fn); + } + } + + this.registeredEvents_ = []; +} + /** * Cancels further processing of an event. This is useful to prevent default * browser actions, e.g. highlighting text on a double-click.