PageSourceSearch

https://trioeclipses.es/themes/custom/b5subtheme/js/mapa.js?tlensb

js trioeclipses.es collected 2026-10-04 00:26:09 UTC 4,324 bytes, 109 lines download raw bytes

1(function (Drupal) {
2
3    Drupal.behaviors.mapaCcaa = {
4        attach: function (context) {
5
6            const section = context.querySelector('#mapa-ccaa');
7            if (!section) return;
8
9            const regions = section.querySelectorAll('.ccaa');
10            const tooltip = context.querySelector('#map-tooltip');
11
12            const panel = context.querySelector('#ccaa-panel');
13            const panelTitle = context.querySelector('#ccaa-title');
14            const panelDesc = context.querySelector('#ccaa-description');
15            const panelClose = context.querySelector('#ccaa-close');
16
17            const buttons = section.querySelectorAll('.map-btn');
18
19            const dataByYear = {
20                "2026": {
21                    total: ["galicia", "asturias", "cantabria", "paisv", "navarra", "rioja", "castillal", "madrid", "castillam", "aragon", "cataluna", "valenciana", "baleares"],
22                    anular: [],
23                    parcial: ["extremadura", "murcia", "andalucia", "canarias", "ceuta", "melilla"]
24                },
25                "2027": {
26                    total: ["andalucia", "ceuta", "melilla"],
27                    anular: [],
28                    parcial: ["galicia", "asturias", "cantabria", "paisv", "navarra", "rioja", "castillal", "madrid", "castillam", "aragon", "cataluna", "valenciana", "baleares", "extremadura", "murcia", "canarias"]
29                },
30                "2028": {
31                    total: [],
32                    anular: ["castillam", "extremadura", "aragon", "cataluna", "andalucia", "valenciana", "murcia", "baleares"],
33                    parcial: []
34                }
35            };
36
37            const ccaaInfoMap = {};
38
39            context.querySelectorAll('.ccaa-info').forEach(el => {
40                const key = el.dataset.ccaa;
41                if (key) {
42                    ccaaInfoMap[key] = {
43                        title: el.dataset.title || null,
44                        content: el.innerHTML
45                    };
46                }
47            });
48
49            function clearStates() {
50                regions.forEach(r => r.classList.remove('total', 'anular', 'parcial'));
51            }
52
53            function applyYear(year) {
54                clearStates();
55                const cfg = dataByYear[year];
56                Object.keys(cfg).forEach(type => {
57                    cfg[type].forEach(id => {
58                        const el = context.getElementById(id);
59                        if (el) el.classList.add(type);
60                    });
61                });
62            }
63
64            buttons.forEach(btn => {
65                btn.addEventListener('click', () => {
66                    buttons.forEach(b => b.classList.remove('active'));
67                    btn.classList.add('active');
68                    applyYear(btn.dataset.year);
69                });
70            });
71
72            regions.forEach(region => {
73                const label = region.getAttribute('aria-label');
74
75                region.addEventListener('mouseenter', () => {
76                    tooltip.textContent = label;
77                    tooltip.classList.add('visible');
78                });
79
80                region.addEventListener('mousemove', e => {
81                    tooltip.style.left = e.clientX + 'px';
82                    tooltip.style.top = e.clientY + 'px';
83                });
84                region.addEventListener('mouseleave', () => {
85                    tooltip.classList.remove('visible');
86                });
87
88                region.addEventListener('click', () => {
89                    const id = region.id;
90                    const data = ccaaInfoMap[id];
91
92                    panelTitle.textContent = data?.title || label || id;
93                    panelDesc.innerHTML = data?.content || "Información próximamente disponible.";
94
95                    panel.classList.add('open');
96                    panel.setAttribute('aria-hidden', 'false');
97                });
98            });
99
100            panelClose.addEventListener('click', () => {
101                panel.classList.remove('open');
102                panel.setAttribute('aria-hidden', 'true');
103            });
104
105            applyYear("2026");
106        }
107    };
108
109})(Drupal);

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.