File size: 1,278 Bytes
4c8e01e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// ===== MODAL DE INSTRUCCIONES =====

function initializeModal() {
    const modal = document.getElementById('instructionsModal');
    const helpBtn = document.getElementById('helpBtn');
    const closeBtn = document.querySelector('.close');
    
    if (!modal || !helpBtn || !closeBtn) return;
    
    // Abrir modal
    helpBtn.addEventListener('click', function() {
        modal.style.display = 'block';
        document.body.style.overflow = 'hidden';
    });
    
    // Cerrar modal con X
    closeBtn.addEventListener('click', function() {
        modal.style.display = 'none';
        document.body.style.overflow = 'auto';
    });
    
    // Cerrar modal clickeando fuera
    window.addEventListener('click', function(event) {
        if (event.target === modal) {
            modal.style.display = 'none';
            document.body.style.overflow = 'auto';
        }
    });
    
    // Cerrar con tecla ESC
    document.addEventListener('keydown', function(event) {
        if (event.key === 'Escape' && modal.style.display === 'block') {
            modal.style.display = 'none';
            document.body.style.overflow = 'auto';
        }
    });
}

// Hacer función global para que pueda ser llamada desde otros JS
window.initializeModal = initializeModal;