console.log("iBahia • 2024 - Mundiware"); // VARIÁVEIS GLOBAIS window.menuAsideContainer ??= document.querySelector(".ib-menuAside"); const lightbox = document.getElementById("lightbox"); const lightboxHolder = document.getElementById("lightbox-image"); const searchInputs = document.querySelectorAll(".ib-searchInput"); const searchImgs = document.querySelectorAll(".ib-searchImg"); // SCRIPTS ADS function loadScripts(scripts) { scripts.forEach((scriptUrl) => { var start = +new Date(); const script = document.createElement("script"); script.src = scriptUrl; script.async = true; script.onload = () => { var end = +new Date(); var time = end - start; console.log(`${scriptUrl} levou ${time}ms para ser carregado`); }; document.head.appendChild(script); }); } window.addEventListener("load", () => { if (typeof noAds === "undefined") { if (typeof noOutbrain === "undefined") { if (window.location.href.indexOf("")) { if ( window.location.href.indexOf("3051124") != -1 || window.location.href.indexOf("colunistas/educacao-xualse") != -1 ) { loadScripts(["https://widgets.outbrain.com/outbrain.js"]); } } } } }); // ABRIR/FECHAR MENU LATERAL window.toggleAsideMenu ??= () => { const body = document.getElementsByTagName('body')[0]; const isActive = menuAsideContainer?.classList?.contains('active'); menuAsideContainer?.classList?.toggle('active'); body.style.overflow = isActive ? 'auto' : 'hidden'; }; // LIGHTBOX GERAL DE IMAGENS const openLightbox = (e) => { lightbox && (() => { lightboxHolder.src = e.src; lightbox.classList.remove("hidden"); document.querySelector("body").style.overflowY = "hidden"; })(); }; const closeLightbox = () => { lightbox && (() => { lightbox.classList.add("hidden"); document.querySelector("body").style.overflowY = "scroll"; })(); }; // FECHAR TODOS OS MODAIS ATIVOS const closeAllModals = () => document.querySelectorAll(".ib-modal").forEach( (modal) => modal && (() => { modal.classList.add("hidden"); document.querySelector("body").classList.remove("stopScroll"); })() ); // FECHAR MODAL AO CLICAR FORA document.querySelectorAll(".ib-modal").forEach((modal) => () => { modal.addEventListener("click", (e) => { if (e.target !== modal.querySelector(".content")) { return; } else { modal.classList.toggle("hidden"); } }); }); var lastScrollTop = window.scrollY || document.documentElement.scrollTop; window.addEventListener("scroll", function(){ var st = window.scrollY || document.documentElement.scrollTop; const headerScrollStatus = document.querySelector(".ib-scroll-header"); if (headerScrollStatus) { if (st < 169){ // Down headerScrollStatus.classList.remove("visible"); } else { // Up headerScrollStatus.classList.add("visible"); }} lastScrollTop = st <= 0 ? 0 : st; // For Mobile or negative scrolling }, false);