X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-utils.js;h=9079aaf35429b9b06cf80ed31f28814ffc52355e;hb=c3491213337a0241107430ad15038c2f18fa5789;hp=11a2fba2f76861806fde946af6be631083e9d8ca;hpb=11c253e082a2bfb662230d6b3b9c736924b23c70;p=dygraphs.git diff --git a/dygraph-utils.js b/dygraph-utils.js index 11a2fba..9079aaf 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -79,7 +79,7 @@ Dygraph.log = function(severity, message) { // In older versions of Firefox, only console.log is defined. var console = window.console; var log = function(console, method, msg) { - if (method) { + if (method && typeof(method) == 'function') { method.call(console, msg); } else { console.log(msg); @@ -193,7 +193,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 }); }; @@ -221,6 +221,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.