Merge pull request #238 from kberg/master
[dygraphs.git] / dygraph-utils.js
index 6aa7dfc..035aba6 100644 (file)
@@ -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);
@@ -301,7 +301,11 @@ Dygraph.findPosX = function(obj) {
   if(obj.offsetParent) {
     var copyObj = obj;
     while(1) {
-      var borderLeft = window.getComputedStyle(copyObj, null).borderLeft || "0";
+      // NOTE: the if statement here is for IE8.
+      var borderLeft = "0";
+      if (window.getComputedStyle) {
+        borderLeft = window.getComputedStyle(copyObj, null).borderLeft || "0";
+      }
       curleft += parseInt(borderLeft, 10) ;
       curleft += copyObj.offsetLeft;
       if(!copyObj.offsetParent) {
@@ -334,7 +338,11 @@ Dygraph.findPosY = function(obj) {
   if(obj.offsetParent) {
     var copyObj = obj;
     while(1) {
-      var borderTop = window.getComputedStyle(copyObj, null).borderTop || "0";
+      // NOTE: the if statement here is for IE8.
+      var borderTop = "0";
+      if (window.getComputedStyle) {
+        borderTop = window.getComputedStyle(copyObj, null).borderTop || "0";
+      }
       curtop += parseInt(borderTop, 10) ;
       curtop += copyObj.offsetTop;
       if(!copyObj.offsetParent) {