File size: 2,317 Bytes
d16df4b
 
 
 
 
 
 
 
 
 
 
e346e9a
 
d16df4b
 
 
 
 
 
 
 
 
e346e9a
d16df4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e346e9a
d16df4b
 
 
 
 
 
 
 
 
 
 
e346e9a
 
d16df4b
 
 
 
 
 
 
 
 
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
72
73
74

/**
 * DocuFlow - Document Management System
 * Shared functionality across all pages
 */

class DocuFlow {
    static init() {
        this.setupMobileMenu();
        this.setupTooltips();
        this.setupModals();
    }

    static setupMobileMenu() {
        const menuButton = document.getElementById('mobile-menu-button');
        if (menuButton) {
            menuButton.addEventListener('click', () => {
                const menu = document.getElementById('mobile-menu');
                menu.classList.toggle('hidden');
            });
        }
    }

    static setupTooltips() {
        const tooltipTriggers = document.querySelectorAll('[data-tooltip]');
        tooltipTriggers.forEach(el => {
            el.addEventListener('mouseenter', this.showTooltip);
            el.addEventListener('mouseleave', this.hideTooltip);
        });
    }

    static showTooltip(e) {
        const tooltipText = this.getAttribute('data-tooltip');
        const tooltip = document.createElement('div');
        tooltip.className = 'absolute z-50 bg-gray-800 text-white text-xs rounded py-1 px-2';
        tooltip.textContent = tooltipText;
        this.appendChild(tooltip);
        this.positionTooltip(tooltip);
    }

    static hideTooltip() {
        const tooltip = this.querySelector('div');
        if (tooltip) this.removeChild(tooltip);
    }

    static positionTooltip(tooltip) {
        const rect = this.getBoundingClientRect();
        tooltip.style.top = `${rect.top + window.scrollY - tooltip.offsetHeight - 5}px`;
        tooltip.style.left = `${rect.left + window.scrollX + (rect.width - tooltip.offsetWidth) / 2}px`;
    }

    static setupModals() {
        document.querySelectorAll('[data-modal-toggle]').forEach(button => {
            button.addEventListener('click', () => {
                const modalId = button.getAttribute('data-modal-toggle');
                const modal = document.getElementById(modalId);
                if (modal) {
                    modal.classList.toggle('hidden');
                }
            });
        });
    }
}

// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
    DocuFlow.init();
    
    // Initialize Feather Icons if available
    if (typeof feather !== 'undefined') {
        feather.replace();
    }
});