From: Dan Vanderkam Date: Fri, 5 Feb 2010 05:51:55 +0000 (-0800) Subject: change for Safari suggested by bearlanding X-Git-Tag: v1.0.0~737 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=5e60386d4e050cefa5dada1d55718225fbd4c32f;p=dygraphs.git change for Safari suggested by bearlanding --- diff --git a/dygraph.js b/dygraph.js index d9c0e27..9611ba9 100644 --- a/dygraph.js +++ b/dygraph.js @@ -431,34 +431,40 @@ Dygraph.prototype.setColors_ = function() { Dygraph.update(this.layoutOptions_, this.attrs_); } -// The following functions are from quirksmode.org +// The following functions are from quirksmode.org with a modification for Safari from +// http://blog.firetree.net/2005/07/04/javascript-find-position/ // http://www.quirksmode.org/js/findpos.html Dygraph.findPosX = function(obj) { var curleft = 0; - if (obj.offsetParent) { - while (obj.offsetParent) { + if(obj.offsetParent) + while(1) + { curleft += obj.offsetLeft; + if(!obj.offsetParent) + break; obj = obj.offsetParent; } - } - else if (obj.x) + else if(obj.x) curleft += obj.x; return curleft; }; Dygraph.findPosY = function(obj) { var curtop = 0; - if (obj.offsetParent) { - while (obj.offsetParent) { + if(obj.offsetParent) + while(1) + { curtop += obj.offsetTop; + if(!obj.offsetParent) + break; obj = obj.offsetParent; } - } - else if (obj.y) + else if(obj.y) curtop += obj.y; return curtop; }; + /** * Create the div that contains information on the selected point(s) * This goes in the top right of the canvas, unless an external div has already