diff --git a/codigo-conduta.html b/codigo-conduta.html index b72c0bc..14305af 100644 --- a/codigo-conduta.html +++ b/codigo-conduta.html @@ -10,43 +10,7 @@ - +
diff --git a/faq.html b/faq.html index 98fa741..9c21b3e 100644 --- a/faq.html +++ b/faq.html @@ -10,43 +10,7 @@ - +
diff --git a/index.html b/index.html index 46eb71e..a5a7c3b 100644 --- a/index.html +++ b/index.html @@ -30,56 +30,7 @@ - +
diff --git a/script.js b/script.js index 2183167..aa4090e 100644 --- a/script.js +++ b/script.js @@ -1,85 +1,143 @@ -// Mobile menu toggle -const mobileMenuBtn = document.getElementById('mobile-menu-btn'); -const mobileMenu = document.getElementById('mobile-menu'); - -mobileMenuBtn.addEventListener('click', () => { - mobileMenu.classList.toggle('hidden'); -}); - -// "Evento" dropdown: open by click/keyboard too (complements the CSS hover) -const eventoDropdown = document.querySelector('.dropdown-container'); -if (eventoDropdown) { - const eventoBtn = eventoDropdown.querySelector('#evento-btn'); - - eventoBtn.addEventListener('click', () => { - const isOpen = eventoDropdown.classList.toggle('dropdown-open'); - eventoBtn.setAttribute('aria-expanded', isOpen); - }); +// ===== Navbar compartilhada (partial injetado em #site-navbar) ===== +function initNavbar() { + // Mobile menu toggle + const mobileMenuBtn = document.getElementById('mobile-menu-btn'); + const mobileMenu = document.getElementById('mobile-menu'); + if (mobileMenuBtn && mobileMenu) { + mobileMenuBtn.addEventListener('click', () => { + mobileMenu.classList.toggle('hidden'); + }); + } - // Close when clicking anywhere outside the toggle button (incl. menu items) - document.addEventListener('click', (e) => { - if (!eventoBtn.contains(e.target)) { - eventoDropdown.classList.remove('dropdown-open'); - eventoBtn.setAttribute('aria-expanded', 'false'); - } - }); + // "Evento" dropdown: open by click/keyboard too (complements the CSS hover) + const eventoDropdown = document.querySelector('.dropdown-container'); + if (eventoDropdown) { + const eventoBtn = eventoDropdown.querySelector('#evento-btn'); - document.addEventListener('keydown', (e) => { - if (e.key === 'Escape') { - eventoDropdown.classList.remove('dropdown-open'); - eventoBtn.setAttribute('aria-expanded', 'false'); - } - }); -} + eventoBtn.addEventListener('click', () => { + const isOpen = eventoDropdown.classList.toggle('dropdown-open'); + eventoBtn.setAttribute('aria-expanded', isOpen); + }); -// Smooth scrolling for navigation links -document.querySelectorAll('a[href^="#"]').forEach(anchor => { - anchor.addEventListener('click', function (e) { - e.preventDefault(); - const target = document.querySelector(this.getAttribute('href')); - if (target) { - target.scrollIntoView({ - behavior: 'smooth', - block: 'start' - }); - // Close mobile menu if open - mobileMenu.classList.add('hidden'); - } + // Close when clicking anywhere outside the toggle button (incl. menu items) + document.addEventListener('click', (e) => { + if (!eventoBtn.contains(e.target)) { + eventoDropdown.classList.remove('dropdown-open'); + eventoBtn.setAttribute('aria-expanded', 'false'); + } + }); + + document.addEventListener('keydown', (e) => { + if (e.key === 'Escape') { + eventoDropdown.classList.remove('dropdown-open'); + eventoBtn.setAttribute('aria-expanded', 'false'); + } + }); + } + + // Smooth scrolling for in-page anchors (+ close mobile menu) + document.querySelectorAll('a[href^="#"]').forEach(anchor => { + anchor.addEventListener('click', function (e) { + const target = document.querySelector(this.getAttribute('href')); + if (target) { + e.preventDefault(); + target.scrollIntoView({ behavior: 'smooth', block: 'start' }); + } + if (mobileMenu) mobileMenu.classList.add('hidden'); + }); }); -}); - -// Optional: Auto-scroll carousel -const carousel = document.querySelector('.carousel'); -let isScrolling = false; - -// Intersection Observer for active nav links -const sections = document.querySelectorAll('section[id]'); -const navLinks = document.querySelectorAll('nav a[href^="#"]'); - -const observerOptions = { - root: null, - rootMargin: '-50% 0px -50% 0px', - threshold: 0 -}; - -const observer = new IntersectionObserver((entries) => { - entries.forEach(entry => { - if (entry.isIntersecting) { - navLinks.forEach(link => { - link.classList.remove('nav-link--active'); - if (link.getAttribute('href') === `#${entry.target.id}`) { - link.classList.add('nav-link--active'); + + // Intersection Observer for active nav links + const sections = document.querySelectorAll('section[id]'); + const navLinks = document.querySelectorAll('nav a[href^="#"]'); + if (sections.length && navLinks.length) { + const observer = new IntersectionObserver((entries) => { + entries.forEach(entry => { + if (entry.isIntersecting) { + navLinks.forEach(link => { + link.classList.remove('nav-link--active'); + if (link.getAttribute('href') === `#${entry.target.id}`) { + link.classList.add('nav-link--active'); + } + }); } }); - } - }); -}, observerOptions); + }, { root: null, rootMargin: '-50% 0px -50% 0px', threshold: 0 }); + sections.forEach(section => observer.observe(section)); + } +} + +// Navbar compartilhada — FONTE ÚNICA. Editar só aqui; é injetada em todas +// as páginas (index e subpáginas) no elemento