2013-07-09 01:54:34 +00:00
|
|
|
/* Tooltip rendering model for nvd3 charts.
|
|
|
|
window.nv.models.tooltip is the updated,new way to render tooltips.
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2013-07-09 01:54:34 +00:00
|
|
|
window.nv.tooltip.show is the old tooltip code.
|
|
|
|
window.nv.tooltip.* also has various helper methods.
|
|
|
|
*/
|
2012-05-07 12:53:51 +00:00
|
|
|
(function() {
|
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
window.nv.tooltip = {};
|
|
|
|
|
|
|
|
/* Model which can be instantiated to handle tooltip rendering.
|
2013-07-09 01:54:34 +00:00
|
|
|
Example usage:
|
|
|
|
var tip = nv.models.tooltip().gravity('w').distance(23)
|
|
|
|
.data(myDataObject);
|
|
|
|
|
|
|
|
tip(); //just invoke the returned function to render tooltip.
|
2013-07-02 18:37:54 +00:00
|
|
|
*/
|
|
|
|
window.nv.models.tooltip = function() {
|
2013-07-02 19:25:04 +00:00
|
|
|
var content = null //HTML contents of the tooltip. If null, the content is generated via the data variable.
|
|
|
|
, data = null /* Tooltip data. If data is given in the proper format, a consistent tooltip is generated.
|
|
|
|
Format of data:
|
|
|
|
{
|
|
|
|
key: "Date",
|
2013-07-09 01:54:34 +00:00
|
|
|
value: "August 2009",
|
2013-07-02 19:25:04 +00:00
|
|
|
series: [
|
|
|
|
{
|
|
|
|
key: "Series 1",
|
2013-07-02 21:14:43 +00:00
|
|
|
value: "Value 1",
|
|
|
|
color: "#000"
|
2013-07-02 19:25:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "Series 2",
|
2013-07-02 21:14:43 +00:00
|
|
|
value: "Value 2",
|
|
|
|
color: "#00f"
|
2013-07-02 19:25:04 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
2013-07-04 03:17:08 +00:00
|
|
|
, gravity = 'w' //Can be 'n','s','e','w'. Determines how tooltip is positioned.
|
|
|
|
, distance = 50 //Distance to offset tooltip from the mouse location.
|
|
|
|
, snapDistance = 25 //Tolerance allowed before tooltip is moved from its current position (creates 'snapping' effect)
|
2013-07-02 18:37:54 +00:00
|
|
|
, fixedTop = null //If not null, this fixes the top position of the tooltip.
|
|
|
|
, classes = null //Attaches additional CSS classes to the tooltip DIV that is created.
|
2013-07-08 21:19:10 +00:00
|
|
|
, chartContainer = null //Parent DIV, of the SVG Container that holds the chart.
|
2013-07-02 18:37:54 +00:00
|
|
|
, position = {left: null, top: null} //Relative position of the tooltip inside chartContainer.
|
2013-07-02 20:07:20 +00:00
|
|
|
, enabled = true //True -> tooltips are rendered. False -> don't render tooltips.
|
2013-07-12 21:17:47 +00:00
|
|
|
//Generates a unique id when you create a new tooltip() object
|
|
|
|
, id = "nvtooltip-" + Math.floor(Math.random() * 100000)
|
2013-07-02 18:37:54 +00:00
|
|
|
;
|
|
|
|
|
2013-07-08 15:25:58 +00:00
|
|
|
//Format function for the tooltip values column
|
2013-07-02 20:07:20 +00:00
|
|
|
var valueFormatter = function(d,i) {
|
|
|
|
return d;
|
|
|
|
};
|
|
|
|
|
2013-07-08 15:25:58 +00:00
|
|
|
//Format function for the tooltip header value.
|
|
|
|
var headerFormatter = function(d) {
|
|
|
|
return d;
|
|
|
|
};
|
|
|
|
|
2013-07-09 01:54:34 +00:00
|
|
|
//By default, the tooltip model renders a beautiful table inside a DIV.
|
|
|
|
//You can override this function if a custom tooltip is desired.
|
2013-07-02 19:25:04 +00:00
|
|
|
var contentGenerator = function(d) {
|
|
|
|
if (content != null) return content;
|
|
|
|
|
|
|
|
if (d == null) return '';
|
|
|
|
|
2013-07-08 15:25:58 +00:00
|
|
|
var html = "<table><thead><tr><td colspan='3'><strong class='x-value'>" + headerFormatter(d.value) + "</strong></td></tr></thead><tbody>";
|
2013-07-02 19:25:04 +00:00
|
|
|
if (d.series instanceof Array) {
|
2013-07-02 20:07:20 +00:00
|
|
|
d.series.forEach(function(item, i) {
|
2013-07-09 01:54:34 +00:00
|
|
|
html += "<tr>";
|
2013-07-08 13:36:29 +00:00
|
|
|
html += "<td class='legend-color-guide'><div style='background-color: " + item.color + ";'></div></td>";
|
2013-07-02 21:14:43 +00:00
|
|
|
html += "<td class='key'>" + item.key + ":</td>";
|
2013-07-02 20:07:20 +00:00
|
|
|
html += "<td class='value'>" + valueFormatter(item.value,i) + "</td></tr>";
|
2013-07-02 19:25:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
html += "</tbody></table>";
|
|
|
|
return html;
|
|
|
|
};
|
|
|
|
|
2013-07-03 17:43:32 +00:00
|
|
|
var dataSeriesExists = function(d) {
|
|
|
|
if (d && d.series && d.series.length > 0) return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
//In situations where the chart is in a 'viewBox', re-position the tooltip based on how far chart is zoomed.
|
|
|
|
function convertViewBoxRatio() {
|
|
|
|
if (chartContainer) {
|
2013-07-08 15:25:58 +00:00
|
|
|
var svg = d3.select(chartContainer);
|
2013-07-13 03:33:38 +00:00
|
|
|
if (svg.node().tagName !== "svg") {
|
|
|
|
svg = svg.select("svg");
|
|
|
|
}
|
2013-07-02 18:37:54 +00:00
|
|
|
var viewBox = (svg.node()) ? svg.attr('viewBox') : null;
|
|
|
|
if (viewBox) {
|
|
|
|
viewBox = viewBox.split(' ');
|
|
|
|
var ratio = parseInt(svg.style('width')) / viewBox[2];
|
|
|
|
|
|
|
|
position.left = position.left * ratio;
|
|
|
|
position.top = position.top * ratio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2013-07-04 03:17:08 +00:00
|
|
|
//Creates new tooltip container, or uses existing one on DOM.
|
|
|
|
function getTooltipContainer(newContent) {
|
2013-07-08 21:19:10 +00:00
|
|
|
var body;
|
|
|
|
if (chartContainer)
|
|
|
|
body = d3.select(chartContainer);
|
|
|
|
else
|
|
|
|
body = d3.select("body");
|
2013-07-08 19:06:22 +00:00
|
|
|
|
2013-07-08 21:19:10 +00:00
|
|
|
var container = body.select(".nvtooltip");
|
|
|
|
if (container.node() === null) {
|
2013-07-08 19:38:56 +00:00
|
|
|
//Create new tooltip div if it doesn't exist on DOM.
|
2013-07-08 21:19:10 +00:00
|
|
|
container = body.append("div")
|
2013-07-15 18:13:14 +00:00
|
|
|
.attr("class", "nvtooltip with-3d-shadow " + (classes? classes: "xy-tooltip"))
|
2013-07-12 21:17:47 +00:00
|
|
|
.attr("id",id)
|
2013-07-08 21:19:10 +00:00
|
|
|
;
|
2013-07-04 03:17:08 +00:00
|
|
|
}
|
2013-07-08 21:19:10 +00:00
|
|
|
|
2013-07-04 03:17:08 +00:00
|
|
|
|
2013-07-08 21:19:10 +00:00
|
|
|
container.node().innerHTML = newContent;
|
2013-07-13 03:24:12 +00:00
|
|
|
container.style("top",0).style("left",0).style("opacity",0);
|
2013-07-08 21:19:10 +00:00
|
|
|
return container.node();
|
2013-07-04 03:17:08 +00:00
|
|
|
}
|
2013-07-02 19:25:04 +00:00
|
|
|
|
2013-07-06 20:44:06 +00:00
|
|
|
|
2013-07-06 19:28:05 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
//Draw the tooltip onto the DOM.
|
2013-07-04 03:17:08 +00:00
|
|
|
function nvtooltip() {
|
2013-07-02 20:07:20 +00:00
|
|
|
if (!enabled) return;
|
2013-07-03 17:43:32 +00:00
|
|
|
if (!dataSeriesExists(data)) return;
|
2013-07-02 20:07:20 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
convertViewBoxRatio();
|
2012-05-07 12:53:51 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
var left = position.left;
|
|
|
|
var top = (fixedTop != null) ? fixedTop : position.top;
|
2013-07-08 21:19:10 +00:00
|
|
|
var container = getTooltipContainer(contentGenerator(data));
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
if (chartContainer) {
|
2013-07-08 19:06:22 +00:00
|
|
|
var svgComp = chartContainer.getElementsByTagName("svg")[0];
|
|
|
|
var boundRect = (svgComp) ? svgComp.getBoundingClientRect() : chartContainer.getBoundingClientRect();
|
2013-07-08 21:19:10 +00:00
|
|
|
var svgOffset = {left:0,top:0};
|
|
|
|
if (svgComp) {
|
|
|
|
var svgBound = svgComp.getBoundingClientRect();
|
|
|
|
var chartBound = chartContainer.getBoundingClientRect();
|
|
|
|
svgOffset.top = Math.abs(svgBound.top - chartBound.top);
|
|
|
|
svgOffset.left = Math.abs(svgBound.left - chartBound.left);
|
|
|
|
}
|
|
|
|
left += chartContainer.offsetLeft + svgOffset.left;
|
|
|
|
top += chartContainer.offsetTop + svgOffset.top;
|
2013-07-02 18:37:54 +00:00
|
|
|
}
|
2013-07-02 19:25:04 +00:00
|
|
|
|
2013-07-03 17:43:32 +00:00
|
|
|
if (snapDistance && snapDistance > 0) {
|
|
|
|
top = Math.floor(top/snapDistance) * snapDistance;
|
|
|
|
}
|
|
|
|
|
2013-07-09 01:54:34 +00:00
|
|
|
nv.tooltip.calcTooltipPosition([left,top], gravity, distance, container);
|
2013-07-04 03:17:08 +00:00
|
|
|
return nvtooltip;
|
2013-07-02 18:37:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nvtooltip.content = function(_) {
|
|
|
|
if (!arguments.length) return content;
|
|
|
|
content = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
2013-07-02 19:25:04 +00:00
|
|
|
nvtooltip.contentGenerator = function(_) {
|
|
|
|
if (!arguments.length) return contentGenerator;
|
|
|
|
if (typeof _ === 'function') {
|
|
|
|
contentGenerator = _;
|
|
|
|
}
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
|
|
|
nvtooltip.data = function(_) {
|
|
|
|
if (!arguments.length) return data;
|
|
|
|
data = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
nvtooltip.gravity = function(_) {
|
|
|
|
if (!arguments.length) return gravity;
|
|
|
|
gravity = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
|
|
|
nvtooltip.distance = function(_) {
|
|
|
|
if (!arguments.length) return distance;
|
|
|
|
distance = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
2013-07-03 17:43:32 +00:00
|
|
|
nvtooltip.snapDistance = function(_) {
|
|
|
|
if (!arguments.length) return snapDistance;
|
|
|
|
snapDistance = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
nvtooltip.classes = function(_) {
|
|
|
|
if (!arguments.length) return classes;
|
|
|
|
classes = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
|
|
|
nvtooltip.chartContainer = function(_) {
|
|
|
|
if (!arguments.length) return chartContainer;
|
|
|
|
chartContainer = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
|
|
|
nvtooltip.position = function(_) {
|
|
|
|
if (!arguments.length) return position;
|
|
|
|
position.left = (typeof _.left !== 'undefined') ? _.left : position.left;
|
|
|
|
position.top = (typeof _.top !== 'undefined') ? _.top : position.top;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
|
|
|
nvtooltip.fixedTop = function(_) {
|
|
|
|
if (!arguments.length) return fixedTop;
|
|
|
|
fixedTop = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
2013-07-02 20:07:20 +00:00
|
|
|
nvtooltip.enabled = function(_) {
|
|
|
|
if (!arguments.length) return enabled;
|
|
|
|
enabled = _;
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
|
|
|
nvtooltip.valueFormatter = function(_) {
|
|
|
|
if (!arguments.length) return valueFormatter;
|
|
|
|
if (typeof _ === 'function') {
|
|
|
|
valueFormatter = _;
|
|
|
|
}
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
2013-07-02 18:37:54 +00:00
|
|
|
|
2013-07-08 15:25:58 +00:00
|
|
|
nvtooltip.headerFormatter = function(_) {
|
|
|
|
if (!arguments.length) return headerFormatter;
|
|
|
|
if (typeof _ === 'function') {
|
|
|
|
headerFormatter = _;
|
|
|
|
}
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
|
|
|
|
2013-07-12 21:17:47 +00:00
|
|
|
//id() is a read-only function. You can't use it to set the id.
|
|
|
|
nvtooltip.id = function() {
|
|
|
|
return id;
|
|
|
|
};
|
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
|
|
|
|
return nvtooltip;
|
|
|
|
};
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
|
2013-07-04 03:17:08 +00:00
|
|
|
//Original tooltip.show function. Kept for backward compatibility.
|
|
|
|
nv.tooltip.show = function(pos, content, gravity, dist, parentContainer, classes) {
|
|
|
|
|
|
|
|
//Create new tooltip div if it doesn't exist on DOM.
|
|
|
|
var container = document.createElement('div');
|
2013-07-15 18:13:14 +00:00
|
|
|
container.className = 'nvtooltip with-3d-shadow ' + (classes ? classes : 'xy-tooltip');
|
2013-07-04 03:17:08 +00:00
|
|
|
|
|
|
|
var body = parentContainer;
|
|
|
|
if ( !parentContainer || parentContainer.tagName.match(/g|svg/i)) {
|
|
|
|
//If the parent element is an SVG element, place tooltip in the <body> element.
|
|
|
|
body = document.getElementsByTagName('body')[0];
|
2013-07-03 14:33:48 +00:00
|
|
|
}
|
2013-07-04 03:17:08 +00:00
|
|
|
|
|
|
|
container.style.left = 0;
|
|
|
|
container.style.top = 0;
|
|
|
|
container.style.opacity = 0;
|
2013-07-03 14:33:48 +00:00
|
|
|
container.innerHTML = content;
|
2013-07-04 03:17:08 +00:00
|
|
|
body.appendChild(container);
|
2013-07-03 14:33:48 +00:00
|
|
|
|
|
|
|
nv.tooltip.calcTooltipPosition(pos, gravity, dist, container);
|
|
|
|
};
|
|
|
|
|
2013-07-09 01:54:34 +00:00
|
|
|
//Looks up the ancestry of a DOM element, and returns the first NON-svg node.
|
2013-07-06 20:44:06 +00:00
|
|
|
nv.tooltip.findFirstNonSVGParent = function(Elem) {
|
|
|
|
while(Elem.tagName.match(/^g|svg$/i) !== null) {
|
|
|
|
Elem = Elem.parentNode;
|
|
|
|
}
|
|
|
|
return Elem;
|
|
|
|
};
|
|
|
|
|
2013-07-09 01:54:34 +00:00
|
|
|
//Finds the total offsetTop of a given DOM element.
|
|
|
|
//Looks up the entire ancestry of an element, up to the first relatively positioned element.
|
2013-07-06 18:59:19 +00:00
|
|
|
nv.tooltip.findTotalOffsetTop = function ( Elem, initialTop ) {
|
|
|
|
var offsetTop = initialTop;
|
2013-07-06 19:28:05 +00:00
|
|
|
|
2013-07-06 18:59:19 +00:00
|
|
|
do {
|
|
|
|
if( !isNaN( Elem.offsetTop ) ) {
|
|
|
|
offsetTop += (Elem.offsetTop);
|
|
|
|
}
|
|
|
|
} while( Elem = Elem.offsetParent );
|
|
|
|
return offsetTop;
|
|
|
|
};
|
|
|
|
|
2013-07-09 01:54:34 +00:00
|
|
|
//Finds the total offsetLeft of a given DOM element.
|
|
|
|
//Looks up the entire ancestry of an element, up to the first relatively positioned element.
|
2013-07-06 18:59:19 +00:00
|
|
|
nv.tooltip.findTotalOffsetLeft = function ( Elem, initialLeft) {
|
|
|
|
var offsetLeft = initialLeft;
|
2013-07-06 19:28:05 +00:00
|
|
|
|
2013-07-06 18:59:19 +00:00
|
|
|
do {
|
|
|
|
if( !isNaN( Elem.offsetLeft ) ) {
|
|
|
|
offsetLeft += (Elem.offsetLeft);
|
|
|
|
}
|
|
|
|
} while( Elem = Elem.offsetParent );
|
|
|
|
return offsetLeft;
|
|
|
|
};
|
|
|
|
|
2013-07-03 14:33:48 +00:00
|
|
|
//Global utility function to render a tooltip on the DOM.
|
2013-07-09 01:54:34 +00:00
|
|
|
//pos = [X,Y] coordinates of where to place the tooltip, relative to the SVG chart container.
|
|
|
|
//gravity = how to orient the tooltip
|
|
|
|
//dist = how far away from the mouse to place tooltip
|
|
|
|
//container = tooltip DIV
|
|
|
|
nv.tooltip.calcTooltipPosition = function(pos, gravity, dist, container) {
|
2013-07-03 14:33:48 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
var height = parseInt(container.offsetHeight),
|
|
|
|
width = parseInt(container.offsetWidth),
|
|
|
|
windowWidth = nv.utils.windowSize().width,
|
|
|
|
windowHeight = nv.utils.windowSize().height,
|
2013-07-06 21:12:19 +00:00
|
|
|
scrollTop = window.pageYOffset,
|
|
|
|
scrollLeft = window.pageXOffset,
|
2013-07-02 18:37:54 +00:00
|
|
|
left, top;
|
|
|
|
|
|
|
|
windowHeight = window.innerWidth >= document.body.scrollWidth ? windowHeight : windowHeight - 16;
|
|
|
|
windowWidth = window.innerHeight >= document.body.scrollHeight ? windowWidth : windowWidth - 16;
|
|
|
|
|
2013-07-03 14:33:48 +00:00
|
|
|
gravity = gravity || 's';
|
|
|
|
dist = dist || 20;
|
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
var tooltipTop = function ( Elem ) {
|
2013-07-06 18:59:19 +00:00
|
|
|
return nv.tooltip.findTotalOffsetTop(Elem, top);
|
|
|
|
};
|
2012-11-08 23:39:01 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
var tooltipLeft = function ( Elem ) {
|
2013-07-06 18:59:19 +00:00
|
|
|
return nv.tooltip.findTotalOffsetLeft(Elem,left);
|
|
|
|
};
|
2013-07-02 18:37:54 +00:00
|
|
|
|
|
|
|
switch (gravity) {
|
|
|
|
case 'e':
|
|
|
|
left = pos[0] - width - dist;
|
|
|
|
top = pos[1] - (height / 2);
|
|
|
|
var tLeft = tooltipLeft(container);
|
|
|
|
var tTop = tooltipTop(container);
|
|
|
|
if (tLeft < scrollLeft) left = pos[0] + dist > scrollLeft ? pos[0] + dist : scrollLeft - tLeft + left;
|
|
|
|
if (tTop < scrollTop) top = scrollTop - tTop + top;
|
|
|
|
if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height;
|
|
|
|
break;
|
|
|
|
case 'w':
|
|
|
|
left = pos[0] + dist;
|
|
|
|
top = pos[1] - (height / 2);
|
2013-07-03 17:43:32 +00:00
|
|
|
var tLeft = tooltipLeft(container);
|
|
|
|
var tTop = tooltipTop(container);
|
2013-07-02 18:37:54 +00:00
|
|
|
if (tLeft + width > windowWidth) left = pos[0] - width - dist;
|
|
|
|
if (tTop < scrollTop) top = scrollTop + 5;
|
2013-07-05 01:27:58 +00:00
|
|
|
if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height;
|
2013-07-02 18:37:54 +00:00
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
left = pos[0] - (width / 2) - 5;
|
|
|
|
top = pos[1] + dist;
|
|
|
|
var tLeft = tooltipLeft(container);
|
|
|
|
var tTop = tooltipTop(container);
|
|
|
|
if (tLeft < scrollLeft) left = scrollLeft + 5;
|
|
|
|
if (tLeft + width > windowWidth) left = left - width/2 + 5;
|
|
|
|
if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
left = pos[0] - (width / 2);
|
|
|
|
top = pos[1] - height - dist;
|
|
|
|
var tLeft = tooltipLeft(container);
|
|
|
|
var tTop = tooltipTop(container);
|
|
|
|
if (tLeft < scrollLeft) left = scrollLeft + 5;
|
|
|
|
if (tLeft + width > windowWidth) left = left - width/2 + 5;
|
|
|
|
if (scrollTop > tTop) top = scrollTop;
|
|
|
|
break;
|
2013-07-22 14:45:20 +00:00
|
|
|
case 'none':
|
|
|
|
left = pos[0];
|
|
|
|
top = pos[1] - dist;
|
|
|
|
var tLeft = tooltipLeft(container);
|
|
|
|
var tTop = tooltipTop(container);
|
|
|
|
break;
|
2012-11-08 23:39:01 +00:00
|
|
|
}
|
2012-03-20 23:43:21 +00:00
|
|
|
|
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
container.style.left = left+'px';
|
|
|
|
container.style.top = top+'px';
|
|
|
|
container.style.opacity = 1;
|
2013-07-09 01:54:34 +00:00
|
|
|
container.style.position = 'absolute';
|
2012-05-07 12:53:51 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
return container;
|
|
|
|
};
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
//Global utility function to remove tooltips from the DOM.
|
|
|
|
nv.tooltip.cleanup = function() {
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
// Find the tooltips, mark them for removal by this class (so others cleanups won't find it)
|
|
|
|
var tooltips = document.getElementsByClassName('nvtooltip');
|
|
|
|
var purging = [];
|
|
|
|
while(tooltips.length) {
|
|
|
|
purging.push(tooltips[0]);
|
|
|
|
tooltips[0].style.transitionDelay = '0 !important';
|
|
|
|
tooltips[0].style.opacity = 0;
|
|
|
|
tooltips[0].className = 'nvtooltip-pending-removal';
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(function() {
|
2012-03-20 23:43:21 +00:00
|
|
|
|
2013-07-02 18:37:54 +00:00
|
|
|
while (purging.length) {
|
|
|
|
var removeMe = purging.pop();
|
|
|
|
removeMe.parentNode.removeChild(removeMe);
|
|
|
|
}
|
|
|
|
}, 500);
|
|
|
|
};
|
2012-05-07 12:53:51 +00:00
|
|
|
|
|
|
|
})();
|