PageSourceSearch

https://www.accademiamoda.it/wp-content/themes/iuad-theme/src/js/custom/open-day-accordion.js?ver=1.0.0

js accademiamoda.it collected 2026-10-04 13:24:24 UTC 2,952 bytes, 73 lines download raw bytes

1/**
2 * Open Day Accordion
3 * Gestisce l'apertura/chiusura degli accordion per le date Open Day
4 */
5
6document.addEventListener('DOMContentLoaded', function() {
7    const accordionHeaders = document.querySelectorAll('.open_day_list .accordion-header');
8    
9    if (accordionHeaders.length === 0) {
10        return;
11    }
12    
13    accordionHeaders.forEach(header => {
14        header.addEventListener('click', function() {
15            const targetId = this.getAttribute('data-accordion-target');
16            const accordionItem = this.closest('.accordion-item');
17            const icon = this.querySelector('.accordion-icon');
18            
19            // Cerca il content nel contesto dell'offcanvas/container parent
20            // invece di usare getElementById che trova sempre il primo nel DOM
21            const parentOffcanvas = this.closest('.secondary-offcanvas');
22            const parentContainer = this.closest('.open_day_list');
23            
24            let content = null;
25            if (parentOffcanvas) {
26                // Cerca dentro l'offcanvas parent
27                content = parentOffcanvas.querySelector('#' + targetId);
28            } else if (parentContainer) {
29                // Cerca dentro il container della lista
30                content = parentContainer.querySelector('#' + targetId);
31            }
32            
33            // Fallback: cerca globalmente
34            if (!content) {
35                content = document.getElementById(targetId);
36            }
37            
38            if (!content) return;
39            
40            // Chiudi tutti gli altri accordion NELLO STESSO CONTESTO
41            const accordionContext = parentOffcanvas || parentContainer || document;
42            accordionContext.querySelectorAll('.accordion-item').forEach(item => {
43                if (item !== accordionItem) {
44                    item.classList.remove('active');
45                    const otherContent = item.querySelector('.accordion-content');
46                    const otherIcon = item.querySelector('.accordion-icon');
47                    if (otherContent) {
48                        otherContent.style.maxHeight = null;
49                    }
50                    if (otherIcon) {
51                        otherIcon.style.transform = 'rotate(0deg)';
52                    }
53                }
54            });
55            
56            // Toggle dell'accordion corrente
57            const isActive = accordionItem.classList.contains('active');
58            
59            if (isActive) {
60                // Chiudi
61                accordionItem.classList.remove('active');
62                content.style.maxHeight = null;
63                icon.style.transform = 'rotate(0deg)';
64            } else {
65                // Apri
66                accordionItem.classList.add('active');
67                content.style.maxHeight = content.scrollHeight + 'px';
68                icon.style.transform = 'rotate(180deg)';
69            }
70        });
71    });
72});
73

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.