const metrics = document.getElementById("metrics");
const metricCards = document.querySelectorAll(".metric");
metricCards.forEach(function(card) {
card.addEventListener("click", function() {
var thisID = card.getAttribute('id');
metrics.setAttribute("data-active", thisID);
if (card.classList.contains("active")) {
card.classList.remove("active");
metrics.setAttribute("data-active", "none");
// if the cards are in default state the current one should be maximized the rest minimized
} else {
for (var i = 0; i < metricCards.length; i++) {
if (metricCards[i] == card) {
card.classList.add("active");
} else {
metricCards[i].classList.remove("active");
}
}
}
});
});
function getOffset(el) {
const rect = el.getBoundingClientRect();
return {
left: rect.left + window.scrollX,
top: rect.top + window.scrollY,
height: rect.height
};
}
// TOOLTIP SHIT
const toolTips = document.querySelectorAll(".js-tooltip");
toolTips.forEach(function(tooltip) {
tooltip.addEventListener(
"mouseenter",
(event) => {
var tooltipID = event.target.dataset.target;
var activeTooltip = document.getElementById(tooltipID);
activeTooltip.style.opacity = "1";
activeTooltip.style.marginTop = "0px";
},
false,
);
tooltip.addEventListener(
"mouseout",
(event) => {
console.log(event);
var tooltipID = event.target.dataset.target;
var activeTooltip = document.getElementById(tooltipID);
if (!activeTooltip || !activeTooltip.style) {
return
}
activeTooltip.style.opacity = "0";
activeTooltip.style.marginTop = "-10px";
},
false,
);
});
function positionTooltips() {
// this will place the tooltips to the right place
var toolTips = document.querySelectorAll(".js-tooltip");
for (var i = 0; i <...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.