X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-utils.js;h=05542044e8e1f885103afac9300af2999d79a5a1;hb=a537fd67fb9c4cf0ed381d781f9e569e79e5d503;hp=086d8f87afd6407375f41a77c96a170c158a62e5;hpb=21ebe38bb1eeae3a7fd73335a411bfd81c66d985;p=dygraphs.git diff --git a/dygraph-utils.js b/dygraph-utils.js index 086d8f8..0554204 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -183,7 +183,7 @@ Dygraph.addEvent = function addEvent(elem, type, fn) { * on the event. The function takes one parameter: the event object. * @private */ -Dygraph.prototype.addEvent = function addEvent(elem, type, fn) { +Dygraph.prototype.addEvent = function(elem, type, fn) { Dygraph.addEvent(elem, type, fn); this.registeredEvents_.push({ elem : elem, type : type, fn : fn }); }; @@ -197,7 +197,7 @@ Dygraph.prototype.addEvent = function addEvent(elem, type, fn) { * on the event. The function takes one parameter: the event object. * @private */ -Dygraph.removeEvent = function addEvent(elem, type, fn) { +Dygraph.removeEvent = function(elem, type, fn) { if (elem.removeEventListener) { elem.removeEventListener(type, fn, false); } else { @@ -291,6 +291,8 @@ Dygraph.findPosX = function(obj) { if(obj.offsetParent) { var copyObj = obj; while(1) { + var borderLeft = getComputedStyle(copyObj).borderLeft || "0"; + curleft += parseInt(borderLeft, 10) ; curleft += copyObj.offsetLeft; if(!copyObj.offsetParent) { break; @@ -322,6 +324,8 @@ Dygraph.findPosY = function(obj) { if(obj.offsetParent) { var copyObj = obj; while(1) { + var borderTop = getComputedStyle(copyObj).borderTop || "0"; + curtop += parseInt(borderTop, 10) ; curtop += copyObj.offsetTop; if(!copyObj.offsetParent) { break; @@ -818,7 +822,7 @@ Dygraph.createIterator = function(array, start, length, opt_predicate) { // From: http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // Should be called with the window context: // Dygraph.requestAnimFrame.call(window, function() {}) -Dygraph.requestAnimFrame = (function(){ +Dygraph.requestAnimFrame = (function() { return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || @@ -843,7 +847,7 @@ Dygraph.requestAnimFrame = (function(){ * @private */ Dygraph.repeatAndCleanup = function(repeatFn, maxFrames, framePeriodInMillis, - cleanupFn) { + cleanupFn) { var frameNumber = 0; var previousFrameNumber; var startTime = new Date().getTime(); @@ -873,7 +877,7 @@ Dygraph.repeatAndCleanup = function(repeatFn, maxFrames, framePeriodInMillis, repeatFn(maxFrameArg); // Ensure final call with maxFrameArg. cleanupFn(); } else { - if (frameDelta != 0) { // Don't call repeatFn with duplicate frames. + if (frameDelta !== 0) { // Don't call repeatFn with duplicate frames. repeatFn(frameNumber); } loop(); @@ -1029,7 +1033,6 @@ Dygraph.regularShape_ = function( delta = delta || Math.PI * 2 / sides; ctx.beginPath(); - var first = true; var initialAngle = rotationRadians; var angle = initialAngle; @@ -1213,3 +1216,20 @@ Dygraph.detectLineDelimiter = function(data) { return null; }; + +/** + * Is one element contained by another? + * @param {Element} containee The contained element. + * @param {Element} container The container element. + * @return {boolean} Whether containee is inside (or equal to) container. + * @private + */ +Dygraph.isElementContainedBy = function(containee, container) { + if (container === null || containee === null) { + return false; + } + while (containee && containee !== container) { + containee = containee.parentNode; + } + return (containee === container); +};