Spaces:
Running
Running
File size: 1,015 Bytes
f4e79f0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // Shared functionality can be added here
document.addEventListener('DOMContentLoaded', function() {
// Initialize tooltips for all elements with data-tooltip attribute
const tooltipElements = document.querySelectorAll('[data-tooltip]');
tooltipElements.forEach(el => {
const tooltip = document.createElement('div');
tooltip.className = 'hidden absolute z-50 bg-gray-800 text-white text-xs rounded py-1 px-2';
tooltip.textContent = el.getAttribute('data-tooltip');
document.body.appendChild(tooltip);
el.addEventListener('mouseenter', () => {
const rect = el.getBoundingClientRect();
tooltip.style.left = `${rect.left + rect.width/2 - tooltip.offsetWidth/2}px`;
tooltip.style.top = `${rect.top - tooltip.offsetHeight - 5}px`;
tooltip.classList.remove('hidden');
});
el.addEventListener('mouseleave', () => {
tooltip.classList.add('hidden');
});
});
}); |