PageSourceSearch

https://eletronet.com/wp-content/themes/eletronet/assets/js/imprensa.js?ver=1787507410

js eletronet.com collected 2026-09-25 06:51:41 UTC 5,742 bytes, 164 lines download raw bytes

1/* Sala de Imprensa / Perguntas Frequentes.
2   - Accordion do Q&A (mesmo comportamento do inst.js).
3   - Liderança: lista interativa (hover/clique troca o painel de detalhe). */
4(function () {
5	'use strict';
6
7	/* ---- Accordion (mesmo comportamento do institucional) ---- */
8	function initAccordions(root) {
9		root.querySelectorAll('[data-acc]').forEach(function (btn) {
10			btn.addEventListener('click', function () {
11				var item = btn.closest('.inst-acc-item');
12				if (!item) return;
13				var open = item.classList.contains('is-open');
14				var group = item.parentElement;
15				group.querySelectorAll('.inst-acc-item').forEach(function (it) {
16					it.classList.remove('is-open');
17					var b = it.querySelector('[data-acc]');
18					if (b) b.setAttribute('aria-expanded', 'false');
19				});
20				if (!open) {
21					item.classList.add('is-open');
22					btn.setAttribute('aria-expanded', 'true');
23				}
24			});
25		});
26	}
27
28	/* ---- Liderança: lista interativa (tabs) ---- */
29	function initLeadership(root) {
30		root.querySelectorAll('[data-lead]').forEach(function (wrap) {
31			var tabs = wrap.querySelectorAll('[data-lead-tab]');
32			var panels = wrap.querySelectorAll('[data-lead-panel]');
33			if (!tabs.length) return;
34
35			function activate(idx) {
36				tabs.forEach(function (t) {
37					var on = t.getAttribute('data-lead-tab') === String(idx);
38					t.classList.toggle('is-active', on);
39					t.setAttribute('aria-selected', on ? 'true' : 'false');
40				});
41				panels.forEach(function (pnl) {
42					var on = pnl.getAttribute('data-lead-panel') === String(idx);
43					pnl.classList.toggle('is-active', on);
44					pnl.setAttribute('aria-hidden', on ? 'false' : 'true');
45				});
46			}
47
48			tabs.forEach(function (tab) {
49				var idx = tab.getAttribute('data-lead-tab');
50				tab.addEventListener('click', function () { activate(idx); });
51				// Hover no desktop (ponteiro fino), como na referência.
52				tab.addEventListener('mouseenter', function () {
53					if (window.matchMedia('(hover: hover) and (pointer: fine)').matches) {
54						activate(idx);
55					}
56				});
57				tab.addEventListener('focus', function () { activate(idx); });
58			});
59		});
60	}
61
62	/* ---- Lottie decorativo (espiral do hero e loop do contato) ----
63	   Mesma inicialização do blog-hero.js/inst.js, que não carregam aqui. */
64	function initLottie(root) {
65		if (!window.lottie) return;
66		var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
67		// Só o hero e o loop do contato-Planin; a seção .sec-contato do tema
68		// tem lottie próprio, inicializado pelo bundle-global.
69		root.querySelectorAll('.blog-hero [data-lottie], .inst-axia [data-lottie]').forEach(function (el) {
70			if (el.dataset.lottieInit) return;
71			el.dataset.lottieInit = '1';
72			var a = window.lottie.loadAnimation({
73				container: el,
74				renderer: 'svg',
75				loop: !reduceMotion,
76				autoplay: false,
77				path: el.getAttribute('data-lottie-src'),
78				rendererSettings: { preserveAspectRatio: 'xMidYMid meet' },
79			});
80			if (reduceMotion) {
81				a.addEventListener('DOMLoaded', function () { a.goToAndStop(0, true); });
82			} else {
83				new IntersectionObserver(function (entries) {
84					if (entries[0].isIntersecting) { a.play(); } else { a.pause(); }
85				}, { threshold: 0.1 }).observe(el);
86			}
87		});
88	}
89
90	/* ---- Dados de destaque: slide (dots) no mobile ---- */
91	function initDadosSlide(root) {
92		var track = root.querySelector('[data-dados-track]');
93		if (!track) return;
94		var dots = root.querySelectorAll('[data-dado-dot]');
95		var pages = track.querySelectorAll('.imprensa-dados__page');
96		if (!dots.length || !pages.length) return;
97
98		dots.forEach(function (dot) {
99			dot.addEventListener('click', function () {
100				var idx = parseInt(dot.getAttribute('data-dado-dot'), 10) || 0;
101				var target = pages[idx];
102				if (target) track.scrollTo({ left: target.offsetLeft - pages[0].offsetLeft, behavior: 'smooth' });
103			});
104		});
105
106		track.addEventListener('scroll', function () {
107			var idx = Math.round(track.scrollLeft / track.clientWidth);
108			dots.forEach(function (d, i) { d.classList.toggle('is-active', i === idx); });
109		}, { passive: true });
110	}
111
112	/* ---- "Voltar" dinâmico: volta de onde o usuário veio (mesma origem);
113	   senão mantém o fallback do href (Home). Ex.: FAQ é acessível pela Home
114	   e pela Sala de Imprensa. ---- */
115	function initDynamicBack(root) {
116		root.querySelectorAll('[data-back-dynamic]').forEach(function (el) {
117			var ref = document.referrer;
118			if (!ref) return;
119			try {
120				var u = new URL(ref);
121				if (u.origin === window.location.origin && u.pathname !== window.location.pathname) {
122					el.setAttribute('href', ref);
123				}
124			} catch (e) {}
125		});
126	}
127
128	/* ---- Menu fixo (blog-nav-fixo): aparece ao rolar além da metade do hero.
129	   Mesmo comportamento do blog-nav-fixo.js, que não carrega nestas páginas. */
130	function initNavFixo() {
131		var nav = document.getElementById('blog-nav-fixo');
132		var header = document.querySelector('.blog-hero');
133		if (!nav || !header) return;
134		function update() {
135			var half = header.offsetTop + header.offsetHeight / 2;
136			if (window.scrollY >= half) {
137				nav.classList.add('is-visible');
138				nav.setAttribute('aria-hidden', 'false');
139				nav.removeAttribute('inert');
140			} else {
141				nav.classList.remove('is-visible');
142				nav.setAttribute('aria-hidden', 'true');
143				nav.setAttribute('inert', '');
144			}
145		}
146		window.addEventListener('scroll', update, { passive: true });
147		update();
148	}
149
150	function init(root) {
151		initAccordions(root);
152		initLeadership(root);
153		initLottie(root);
154		initDadosSlide(root);
155		initDynamicBack(root);
156		initNavFixo();
157	}
158
159	if (document.readyState === 'loading') {
160		document.addEventListener('DOMContentLoaded', function () { init(document); });
161	} else {
162		init(document);
163	}
164})();

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.