File size: 2,617 Bytes
fee3420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
document.addEventListener('DOMContentLoaded', () => {
    // Check for saved theme preference
    const savedTheme = localStorage.getItem('theme') || 'dark';
    if (savedTheme === 'dark') {
        document.documentElement.classList.add('dark');
    } else {
        document.documentElement.classList.remove('dark');
    }
    
    // Initialize tooltips
    const initTooltips = () => {
        const tooltipElements = document.querySelectorAll('[data-tooltip]');
        
        tooltipElements.forEach(el => {
            const tooltipId = 'tooltip-' + Math.random().toString(36).substr(2, 9);
            const tooltipText = el.getAttribute('data-tooltip');
            
            el.setAttribute('aria-describedby', tooltipId);
            
            const tooltip = document.createElement('div');
            tooltip.id = tooltipId;
            tooltip.className = 'absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm tooltip dark:bg-gray-700';
            tooltip.innerHTML = tooltipText;
            
            document.body.appendChild(tooltip);
            
            const popperInstance = Popper.createPopper(el, tooltip, {
                placement: 'top',
                modifiers: [
                    {
                        name: 'offset',
                        options: {
                            offset: [0, 8],
                        },
                    },
                ],
            });
            
            const showEvents = ['mouseenter', 'focus'];
            const hideEvents = ['mouseleave', 'blur'];
            
            showEvents.forEach(event => {
                el.addEventListener(event, () => {
                    tooltip.setAttribute('data-show', '');
                    popperInstance.update();
                });
            });
            
            hideEvents.forEach(event => {
                el.addEventListener(event, () => {
                    tooltip.removeAttribute('data-show');
                });
            });
        });
    };
    
    // Check if Popper is loaded before initializing tooltips
    const checkPopper = setInterval(() => {
        if (typeof Popper !== 'undefined') {
            clearInterval(checkPopper);
            initTooltips();
        }
    }, 100);
    
    // Add animations to dashboard cards
    const dashboardCards = document.querySelectorAll('.bg-white, .dark\\:bg-gray-800');
    dashboardCards.forEach((card, index) => {
        card.style.animationDelay = `${index * 0.1}s`;
        card.classList.add('slide-up');
    });
});