From 33e96f11dbac8a6abd033f9a8d6e22914f587e2d Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 17 Feb 2013 23:24:15 -0500 Subject: [PATCH] A few tweaks to make all tests pass on FF 3.5 --- dygraph-utils.js | 22 ++++++++++++++++------ plugins/axes.js | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dygraph-utils.js b/dygraph-utils.js index aee272c..67cf4f7 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -76,18 +76,28 @@ Dygraph.log = function(severity, message) { } if (typeof(window.console) != 'undefined') { + // In older versions of Firefox, only console.log is defined. + var console = window.console; + var log = function(console, method, msg) { + if (method) { + method.call(console, msg); + } else { + console.log(msg); + } + }; + switch (severity) { case Dygraph.DEBUG: - window.console.debug('dygraphs: ' + message); + log(console, console.debug, 'dygraphs: ' + message); break; case Dygraph.INFO: - window.console.info('dygraphs: ' + message); + log(console, console.info, 'dygraphs: ' + message); break; case Dygraph.WARNING: - window.console.warn('dygraphs: ' + message); + log(console, console.warn, 'dygraphs: ' + message); break; case Dygraph.ERROR: - window.console.error('dygraphs: ' + message); + log(console, console.error, 'dygraphs: ' + message); break; } } @@ -291,7 +301,7 @@ Dygraph.findPosX = function(obj) { if(obj.offsetParent) { var copyObj = obj; while(1) { - var borderLeft = getComputedStyle(copyObj).borderLeft || "0"; + var borderLeft = getComputedStyle(copyObj, null).borderLeft || "0"; curleft += parseInt(borderLeft, 10) ; curleft += copyObj.offsetLeft; if(!copyObj.offsetParent) { @@ -324,7 +334,7 @@ Dygraph.findPosY = function(obj) { if(obj.offsetParent) { var copyObj = obj; while(1) { - var borderTop = getComputedStyle(copyObj).borderTop || "0"; + var borderTop = getComputedStyle(copyObj, null).borderTop || "0"; curtop += parseInt(borderTop, 10) ; curtop += copyObj.offsetTop; if(!copyObj.offsetParent) { diff --git a/plugins/axes.js b/plugins/axes.js index 1e17ff2..f7865c8 100644 --- a/plugins/axes.js +++ b/plugins/axes.js @@ -225,7 +225,7 @@ axes.prototype.willDrawChart = function(e) { var axisX; if (g.getOption('drawAxesAtZero')) { var r = g.toPercentXCoord(0); - if (r > 1 || r < 0) r = 0; + if (r > 1 || r < 0 || isNaN(r)) r = 0; axisX = halfUp(area.x + r * area.w); } else { axisX = halfUp(area.x); -- 2.7.4