var conteudo = document.querySelector('#conteudo'); const dropdownAno = document.querySelectorAll('.card-despesa .dropdown-menu .dropdown-item'); const dropdownMenu = document.querySelector('.card-despesa #anoDespesa'); const navbarLink = document.querySelectorAll('#navbar-1 .nav-item a:not(.no-link), #card-ut a.p-inst'); const cards = document.querySelector('.cards'); const barTopo = document.querySelectorAll("#acessibilidade a, #mapa-site a"); const funcoes = document.querySelectorAll("[data-funcao]"); const night_mode = document.getElementById("night-mode"); const msgContent = document.querySelector('.content-msg'); const btnCTAs = document.querySelectorAll('.CTAs a'); import outorga from "./outorga.js"; // Acesso rápido aos links do navbar-1 var intervalo, secretId=0; if(typeof scGlobalAppl !== "undefined") { if(scGlobalAppl.indexOf("|") !== -1) { const arr = scGlobalAppl.split("|"); scGlobalAppl = arr[0]; secretId = arr[1]; } } $(document).ready(function() { const link = document.getElementById(scGlobalAppl); if(link) { handleNavbar(link); } oaoDestaque(1); var movTop = document.querySelector('.move-top'); window.addEventListener('scroll', function(e) { let navBar = document.getElementById('navbar-2'); let content = document.getElementById('conteudo'); // Fixa o mega-menu if(navBar) { // navBar.classList.toggle('fixed-nav', window.scrollY > navBar.offsetTop); } // Ativo o butão que vai para o topo if(movTop) movTop.classList.toggle('active', window.scrollY > content.offsetTop); }); if(movTop) movTop.addEventListener('click', (e) => scrollSuave("body")); acessoDiretoOutrosAtosOficiais(); scrollCanal(); }); function fetchAPI(el, parm='') { const href = el.getAttribute('href'); if (href !== '#') { const url = '..'+href+href+'.php?id='+parm; $(".content-load").fadeIn("slow"); return fetch(url).then(response => response.text()); } } // Butão do slide btnCTAs.forEach((ctas) => { ctas.addEventListener('click', function(event) { const href = ctas.getAttribute('href'); const target = ctas.getAttribute('target'); const parm = ctas.hasAttribute('data-parm') ? ctas.getAttribute('data-parm') : ''; if (href !== '#' && href !== '' && target !== '_blank') { event.preventDefault(); const link = '../'+href+'/'+href+'.php?'+parm; $(".content-load").fadeIn("slow"); fetch(link).then(response => response.text()).then(data => { conteudo.innerHTML = data; if(href == 'p_filtro_grafico_acesso') { // Anima números const numero = document.querySelector('.numero-acesso > span'); const texto = document.querySelector('.numero-acesso > p'); if(numero) { animaNumeros(numero); } // Ativa o bootstrap-select //$('#anoFiltroGfc').selectpicker(); // Atualiza o grafico const anoAcesso = document.querySelector('#anoFiltroGfc'); if(anoAcesso) { anoAcesso.addEventListener('change', function(event) { const ano = this.options[this.selectedIndex].value; texto.innerHTML = (ano) ? "N\u00famero de acessos em "+ano : "N\u00famero de acessos nos \u00faltimos 12 meses: "; // Atualiza total de acessos fetch('../p_total_acesso/p_total_acesso.php?anoAcesso='+ano).then(response => response.text()).then(data => { numero.innerText = data; if(numero) { animaNumeros(numero); } }); const iframe = document.querySelector('#conteudo-grafico > iframe'); const srcIframe = `../p_grafico_acesso/p_grafico_acesso.php?acAno=${ano}`; iframe.setAttribute("src", srcIframe); }); } } $(".content-load").fadeOut("slow"); }); } verifica_sessao(); }); }); // Fetch megamenu barTopo.forEach((links) => { links.addEventListener('click', function(event) { event.preventDefault(); fetchAPI(this).then(data => { conteudo.innerHTML = data; setFontCookie(); const mapaMenu = document.querySelectorAll('.mapa-menu-item a'); handleClickMegaMenu(mapaMenu); $(".content-load").fadeOut("slow"); }); verifica_sessao(); }); }); function handleNavbar(link) { scrollSuave("#conteudo"); fetchAPI(link).then(data => { conteudo.innerHTML = data; // Acesso rápido as secretarias if(secretId > 0) { const secret = document.querySelector('[data-unidade="'+secretId+'"]'); handleUnidades(secret, secretId); } // Roda a função cartaServicos if(link.getAttribute('href').includes('p_carta_servicos')) { cartaServicos(); } setFontCookie(); const secretLink = document.querySelectorAll('[data-unidade]'); secretLink.forEach((link) => { link.addEventListener('click', function(event) { event.preventDefault(); handleUnidades(link, this.dataset.unidade); verifica_sessao(); }); }); $(".content-load").fadeOut("slow"); }); } function handleClick(event) { event.preventDefault(); document.querySelector('#institucional-info').style.display = 'none'; fadeIn('#institucional'); verifica_sessao(); } function handleUnidades(link, parm) { fetchAPI(link, parm).then(data => { const info = document.querySelector('#institucional-info'); info.innerHTML = data; setFontCookie(); info.style.display = 'block'; document.querySelector('#institucional').style.display = 'none'; document.querySelector('#institucional-info .breadcrumb-item.active span').innerText = link.innerText; $(".content-load").fadeOut("slow"); const breadcrumb = document.querySelector('#institucional-info .breadcrumb .breadcrumb-item:nth-child(2) a'); breadcrumb.addEventListener('click', handleClick); // Copia o link dereto const bcopy = document.getElementById("btn-copy"); bcopy.addEventListener("click", (e) => { let textoCopiado = document.getElementById("link"); textoCopiado.select(); textoCopiado.setSelectionRange(0, 99999); document.execCommand("copy"); Swal.fire({ title: 'Link copiado com sucesso.', toast: true, position: 'top-end', type: 'success', showConfirmButton: false, timer: 3000 }) }); }); } navbarLink.forEach((link) => { link.addEventListener('click', (event) => { event.preventDefault(); handleNavbar(link); verifica_sessao(); }); }); // Seleciona o elemento function elementFuncao(elem) { return document.querySelector(elem); } // Preenche o elemento com valor da função function dadosFuncao(ano) { const url = '../p_api_funcao/p_api_funcao.php?id='+ano; $(".content-load").fadeIn("slow"); fetch(url).then(response => response.json()) .then(data =>{ Object.entries(data).forEach((fc,key) => { const img = elementFuncao('[data-key="'+key+'"]'); const h3 = elementFuncao('[data-key="'+key+'"] h3'); const span = elementFuncao('[data-key="'+key+'"] span'); if (img) { img.style.backgroundImage = "url('"+fc[1].url+"/"+fc[1].funcao+".jpg')"; img.setAttribute("data-funcao",fc[1].funcao); } if (h3) {h3.innerText = fc[1].titulo;} if (span) {span.innerText = fc[1].valor;} }); $(".content-load").fadeOut("slow"); }); } // adiciona o avento click no campo ano da despesa dropdownAno.forEach((item) => { item.addEventListener('click', function(event) { event.preventDefault(); msgContent.style.margin = '50rem auto 0 auto'; const anoDespesa = this.innerText.trim(); dropdownMenu.innerText = anoDespesa; dadosFuncao(anoDespesa); verifica_sessao(); }); }); // Menu Principal document.addEventListener("keydown", function(e) { const modalShow = document.querySelector('.modal.show'); const linkAtalho = document.querySelector('[id^="item"] a[data-atalho="'+e.which+'"]'); const linkNavbar = document.querySelector('#navbar-1 a[data-atalho="'+e.which+'"]'); if ((e.shiftKey) && (linkAtalho) && !modalShow) { const target = linkAtalho.getAttribute("target"); const urlElem = linkAtalho.getAttribute("href"); if(target === "_blank") { window.open(urlElem); }else { linksMegaMenu(linkAtalho); } }else if((e.shiftKey) && (linkNavbar) && !modalShow) { const targetNav = linkNavbar.getAttribute("target"); const urlElemNav = linkNavbar.getAttribute("href"); if(targetNav === "_blank") { window.open(urlElemNav); }else { handleNavbar(linkNavbar); } } verifica_sessao(); }); // Adiciona o evento click aos links function handleClickMegaMenu(links) { let href; links.forEach((el) => { if(el.getAttribute("id") == 75) href = el.getAttribute("href"); el.addEventListener('click', function(event) { linksMegaMenu(this); verifica_sessao(); }); }); // Verefica no top do site existe o butão contracheque const eleCchq = document.querySelector("#cchq > a"); if(eleCchq) eleCchq.setAttribute("href", href); } // Faz a requisição das informações function linksMegaMenu(link) { const target = link.getAttribute('target'); if(target != "_blank") { event.preventDefault(); const href = link.getAttribute('href'); const linkID = link.getAttribute('id'); const filtro = link.getAttribute('data-filtro'); let texto = link.hasAttribute('data-titulo') ? link.getAttribute('data-titulo') : link.innerText; if(filtro && filtro.includes('|') && !href) { Swal.fire({ title: 'Nenhum registro encontrado.', toast: true, position: 'top-end', type: 'warning', showConfirmButton: false, timer: 3000 }) } if(link.hasAttribute('data-mlateral')) { document.querySelector('#ml').checked = false; texto = 'Ouvidoria - '+texto; } if(+linkID === 80102) { scrollSuave("#conteudo"); outorga(); } else if (+linkID === 49) { fetchOutroAtosOficiais(); } else if (href === '/p_glossario') { handleNavbar(link); } else { let url = "../p_iframe_conteudo/p_iframe_conteudo.php"; switch (href) { case "menu_licitacao": url = "../menu_licitacao/menu_licitacao.php"; break; case "cacs_fundeb": url = "../cacs_fundeb/cacs_fundeb.php"; break; case "renuncias_fiscais": url = "../renuncias_fiscais/renuncias_fiscais.php"; break; } $(".content-load").fadeIn("slow"); fetch(url, { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: `url=${href}&titulo=${texto}&idItem=${linkID}&_target=${target}&filLink=${filtro}` }).then(r => r.text()).then(r => { conteudo.innerHTML = r; if (texto.length > 40) { document.querySelector('.conteudo-header nav') .setAttribute("style", "position: initial;display: flex;justify-content: flex-end;margin-top: 10px;"); } linksMenuLicitacao(); linksOutrosAtosOficiais(); breadcrumbMegaMenu(); $(".content-load").fadeOut("slow"); scrollSuave("#navbar-2"); }); } } } // Lista os links do menu const megaMenu = document.querySelectorAll('[id^="item"] a:not(.nav-link), #card-ut a:not(.p-inst), #fale-conosco, .menu-lateral a.list-group-item:not(.link_externo), [id^="canal"] a:not(.link-externo)'); handleClickMegaMenu(megaMenu); // Scroll suave function scrollSuave(elem) { const top = document.querySelector(elem).offsetTop; window.scroll({top: top, behavior: "smooth"}); } // FETCH DESPESA POR FUNCAO // function fetchFuncaoGD(funcao, ano, mes = "") { const url = `../p_despesa_detalhada_gd/p_despesa_detalhada_gd.php?fc=${funcao}&ano=${ano}&mes=${mes}`; scrollSuave("#conteudo"); $(".content-load").fadeIn("slow"); fetch(url).then(resp => resp.text()).then(resp => { conteudo.innerHTML = resp; const funcao = document.querySelector(".gd-total").getAttribute("data-id"); fetchSelectYear(funcao); fetchSelectMonth(funcao, ano); // $('.gd-select').selectpicker('render'); $(".content-load").fadeOut("slow"); }); } // Adiciona evento a cada funcao funcoes.forEach((fc) => { fc.addEventListener("click", function(event){ event.preventDefault(); msgContent.style.marginTop = "12rem"; const ano = document.querySelector('button[id="anoDespesa"]').innerText.trim(); const funcao = this.getAttribute("data-funcao"); fetchFuncaoGD(funcao, ano); verifica_sessao(); }); }); // Faz o fetch change ano function fetchSelectYear(funcao, mes) { const selectAno = document.getElementById("gdAno"); const anoFiltro = selectAno.getAttribute("data-ano"); if (anoFiltro) selectAno.value = anoFiltro; selectAno.addEventListener("change", function() { const ano = this.options[this.selectedIndex].value; fetchFuncaoGD(funcao, ano, mes); }); } // Faz o fetch change mes function fetchSelectMonth(funcao, ano) { const selectMes = document.getElementById("gdMes"); const mesFiltro = selectMes.getAttribute("data-mes"); if (mesFiltro) selectMes.value = mesFiltro; selectMes.addEventListener("change", function() { const mes = this.options[this.selectedIndex].value; fetchFuncaoGD(funcao, ano, mes); verifica_sessao(); }); } // Adiciona scroll suave //'#navbar-2' const acess_key = ['#conteudo','#megamenu-5','#footer','#navbar-covid','#navbar']; acess_key.forEach((ele) => { const elementKey = document.querySelector(ele); if(elementKey) { elementKey.addEventListener("click", function(event) { if (ele === '#conteudo') { if (event.target === event.currentTarget) scrollSuave(ele); }else { if(ele === '#megamenu-5') { document.getElementById('search').focus(); } scrollSuave(ele); } }); } verifica_sessao(); }); function acessoDiretoOutrosAtosOficiais() { // [id|link|title|app] let doc = document.getElementById("iddoc").value; let dados = doc.split("|"); if(dados.includes("cs")) { // Carta de Serviço fetchCartaServicos(); }else if(dados.includes("cacs")) { // CACS-FUNDEB // fetchCacsFundeb(false); }else if(doc) { // LINK DO MEGAMENU if(+dados[0] === 49) { fetchOutroAtosOficiais(); }else { scrollSuave("#conteudo"); const titulo = dados[2], linkID = dados[3] == "of" ? 99+dados[0] : dados[0], href = dados[1], url = parseInt(dados[0]) === 47 ? '../menu_licitacao/menu_licitacao.php' : '../p_iframe_conteudo/p_iframe_conteudo.php'; fetch(url, { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: `url=${href}&titulo=${titulo}&idItem=${linkID}&_target=_self&filLink=${dados[0]}` }).then(r => r.text()).then(r => { conteudo.innerHTML = r; if (titulo.length > 40) { document.querySelector('.conteudo-header nav') .setAttribute("style", "position: initial;display: flex;justify-content: flex-end;margin-top: 10px;"); } if(parseInt(dados[0]) === 47) linksMenuLicitacao(); breadcrumbMegaMenu(); }); } } } // ------------------------------------------------------- // // Hero Slider // ------------------------------------------------------ // if(document.querySelector(".hero-slider")) { var swiper = new Swiper('.hero-slider', { slidesPerView: 1, spaceBetween: 0, speed: 600, autoplay: { delay: 10000, }, pagination: { el: '.swiper-pagination', clickable: true } }); } // ------------------------------------------------------- // // Events Slider // ------------------------------------------------------ // if(document.querySelector(".events-slider")) { var swiper = new Swiper('.events-slider', { slidesPerView: 2, spaceBetween: 30, breakpoints: { 991: { slidesPerView: 1 } }, pagination: { el: '.swiper-pagination', clickable: true, dynamicBullets: true } }); } // ------------------------------------------------------- // // Testimonials Slider // ------------------------------------------------------ // if(document.querySelector(".testimonials-slider")) { var swiper = new Swiper('.testimonials-slider', { slidesPerView: 1, spaceBetween: 0, pagination: { el: '.swiper-pagination', clickable: true, dynamicBullets: true } }); } // Anima numeros function animaNumeros(elem) { let total = +elem.innerText; const inscremento = Math.ceil(total / 100); let start = 0; const timer = setInterval(() => { start = start + inscremento; elem.innerText = start; if(start > total) { elem.innerText = total; clearInterval(timer); } }, 40 * Math.random()); } // Faça sua pesquisa const pesquisa = document.querySelectorAll('.banner-finance li[data-lista]'); pesquisa.forEach((menu) => { menu.addEventListener('click', function(event) { const menuID = this.getAttribute('id'); const dataLista = this.getAttribute('data-lista'); const dataTexto = this.innerText.trim(); const btn = document.getElementById(dataLista); btn.innerText = dataTexto; btn.setAttribute('data-filtro', menuID); verifica_sessao(); }); }); const btnPesq = document.getElementById('btn-pesquisa'); if(btnPesq) { btnPesq.addEventListener('click', function(event) { event.preventDefault(); const ano = document.getElementById('ano').getAttribute('data-filtro'); const rec = document.getElementById('credito').getAttribute('data-filtro'); const url = '../p_receita_filtro_banner/p_receita_filtro_banner.php?codrec='+rec+'&anorec='+ano; scrollSuave(".header"); $(".content-load").fadeIn("slow"); fetch(url).then(resp => resp.text()).then(resp => { conteudo.innerHTML = resp; $(".content-load").fadeOut("slow"); filtroReceitaBanner(); const seta = document.querySelectorAll("#receita-banner .seta"); seta.forEach((ele) => { ele.addEventListener('click', function(e) { const id = ele.getAttribute('href'); this.classList.toggle('seta-b'); this.parentNode.style.transition = "background-color 0.5s"; this.parentNode.style.backgroundColor = this.classList.contains('seta-b') ? "rgb(221, 229, 230)" : "#fff"; }); }); }); verifica_sessao(); }); } function filtroReceitaBanner() { const anoRec = document.getElementById('anorec'); const mesRec = document.getElementById('rMes'); anoRec.addEventListener('change', function(event) { const ano = this.options[this.selectedIndex].value; fetch('../meses_receita_via_ajax/meses_receita_via_ajax.php', { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: `idAno=${ano}` }).then(res => res.text()).then(res => { mesRec.innerHTML = res; }); }); const formFiltro = document.querySelector("#rec-filtro form"); if(formFiltro) { formFiltro.addEventListener('submit', function(event) { event.preventDefault(); const codigo = document.getElementById('codrec').value; fetch('../p_receita_filtro_banner/p_receita_filtro_banner.php?codrec='+codigo, { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: `anorec=${anoRec.value}&rMes=${mesRec.value}` }).then(res => res.text()).then(res => { conteudo.innerHTML = res; filtroReceitaBanner(); }); verifica_sessao(); }); } } // CARTA DE SERVIÇOS function fetchCartaServicos() { $(".content-load").fadeIn("slow"); scrollSuave("#conteudo"); fetch('../p_carta_servicos/p_carta_servicos.php') .then(resposta => resposta.text()) .then(resposta => { conteudo.innerHTML = resposta; cartaServicos(); $(".content-load").fadeOut("slow"); }); } function fechServicos(elem) { const container = document.getElementById('container-servicos'); const id = elem.getAttribute('id'); const busca = id == 'form-pesq-cs' ? elem.elements["busca"].value : ''; $(".content-load").fadeIn("slow"); scrollSuave("#conteudo"); fetch('../p_carta_servicos_info/p_carta_servicos_info.php?', { method: 'POST', headers: {'Content-Type':'application/x-www-form-urlencoded'}, body: `orgao_id=${id}&pesq=${busca}` }).then(resposta => resposta.text()).then(resposta => { container.innerHTML = resposta; // adiciona evento aos links do menu const orgaosCS = document.querySelectorAll('#menu-cs .list-group-item, #pag-sv a[id^="pag-"]'); orgaosCS.forEach((orgs) => { orgs.addEventListener('click', function(event) { event.preventDefault(); fechServicos(orgs); verifica_sessao(); }); }); $(".content-load").fadeOut("slow"); // Adiciona avaliação na base de dados const formAvaliacao = document.querySelectorAll('[id^="form-rating-"]'); formAvaliacao.forEach((form) => { const idServico = form.dataset.formservico; const modal = document.querySelector(`.modal-${idServico}`); const starsList = document.querySelectorAll(`.stars[data-servico="${idServico}"]`); const tab1 = modal.querySelector(`#pills-etapa1-${idServico}-tab`); form.addEventListener('submit', async (event) => { event.preventDefault(); const formData = new FormData(form); const starChecked = [...form.querySelectorAll('input[name="star"]')].find(star => star.checked); formData.append('idServico', idServico); if (starChecked) { try { const data = await fetch('../add_estrelas/add_estrelas.php', { method: 'POST', mode: 'cors', body: formData }); const resposta = await data.json(); starsList.forEach(lista => { let estralas = lista.querySelectorAll('[data-star]'); [...estralas].map(estrela => estrela.classList.remove('active')); for(let i = 1; i <= parseInt(resposta.media); i++) { lista.querySelector(`[data-star="${i}"]`).classList.add('active'); } }); if (resposta.message === 'success') { modal.querySelector('#star-avg').innerText = resposta.media; modal.querySelector('#star-quantity').innerText = resposta.quantidade + (parseInt(resposta.quantidade) > 1 ? ' Avaliações' : ' Avaliação'); Swal.fire('','Avaliação realizada com sucesso.','success'); form.reset(); } else { Swal.fire('Aviso','Oops!, Não foi possível realizar sua solicitação.','warning'); } } catch (error) { Swal.fire('Error','Oops!, Não foi possível realizar sua solicitação.','error'); } } else { Swal.fire('Atenção','Por favor, informe a quantidade de estrelas.','warning'); } }); }); }); } function cartaServicos() { // adiciona evento clique no botão home const btnHome = document.getElementById('btn-voltar-cs'); btnHome.addEventListener('click', function(event) { event.preventDefault(); fetchCartaServicos(); verifica_sessao(); }); // adiciona evento submit ao formulario de busca const btnPesq = document.getElementById('form-pesq-cs'); btnPesq.addEventListener('submit', function(event) { event.preventDefault(); fechServicos(btnPesq); verifica_sessao(); }); // adiciona evento aos links do menu const orgaosCS = document.querySelectorAll('#carta-servicos .link-cs, #menu-cs .list-group-item, #lista-servicos'); orgaosCS.forEach((orgs) => { orgs.addEventListener('click', function(event) { event.preventDefault(); fechServicos(orgs); verifica_sessao(); }); }); } // EXIBE O RESULTADO DA BUSCA $('#search-form').submit(function(e){ e.preventDefault(); const busca = $("#search").val(); const covid = this.getAttribute("data-covid"); const dados = { palavra : busca, covidB : covid } $(".content-load").css("display", "flex").fadeIn("slow"); $.post('../pt-busca/pt-busca.php', dados, function(retorna) { $("#conteudo").html(retorna); const tabLic = document.querySelectorAll("#conteudo #nav-tab a"); tabLic.forEach(tab => { tab.addEventListener("click", function(e) { e.preventDefault(); const href = this.getAttribute("href"); if(href === "#nav-emp" || href === "#nav-lic") { setTimeout(function() { const iframeTab = document.querySelector("#conteudo #nav-tabContent "+href+" .iframe-tab"); const iDocument = iframeTab.contentDocument.body || iframeTab.contentWindow.document.body; if(iDocument) { const heightBody = parseInt(iDocument.scrollHeight) + 50; iframeTab.style.height = heightBody+"px"; }else { iframeTab.setAttribute("scrolling", "yes"); } }, 1000); } verifica_sessao(); }); }); $(".content-load").fadeOut("slow"); }); }); function verifica_sessao() { if(typeof _tempo !== 'undefined') { var sessao = _tempo; clearInterval(intervalo); intervalo = setInterval(() => { sessao--; if(sessao <= 1) { window.location.href = "../p_index_entidades/p_index_entidades.php?municipio=" + _municipio; } },60000); } } function oaoDestaque(pagina) { $(".content-load").fadeIn("slow"); $.get( "../oaoDestaque/oaoDestaque.php", {pagina: pagina}, function( data ) { $( "#oaoDestaque" ).html( data ); // adiciona evento aos links const nav = document.querySelectorAll('#oaoDestaque a[id^="pag-"]'); nav.forEach((orgs) => { orgs.addEventListener('click', function(event) { event.preventDefault(); const pag = this.getAttribute("id").split('-')[1]; oaoDestaque(pag); verifica_sessao(); }); }); $(".content-load").fadeOut("slow"); scrollCanal(); }); } function breadcrumbMegaMenu() { const mega = document.querySelector(".mega-menu a"), nLink = document.querySelector(".breadcrumb .breadcrumb-link a"); if(nLink) { nLink.addEventListener("click", function(e) { e.preventDefault(); linksMegaMenu(this); }); } if(mega) { mega.addEventListener("click", function(e) { e.preventDefault(); $(".content-load").fadeIn("slow"); const idmenu = this.getAttribute("id"); fetch(`../megamenu/megamenu.php?idItem=${idmenu}`).then(res => res.text()).then(mgmn => { conteudo.innerHTML = mgmn; const megaMenu = document.querySelectorAll("#mgmn li a"); handleClickMegaMenu(megaMenu); $(".content-load").fadeOut("slow"); }); }); } } async function fetchOutroAtosOficiais() { $(".content-load").fadeIn("slow"); const resposta = await fetch("../selecionarAtosOficiais/selecionarAtosOficiais.php"), dados = await resposta.text(); if(resposta.ok) { $(".content-load").fadeOut("slow"); conteudo.innerHTML = dados; breadcrumbMegaMenu(); linksOutrosAtosOficiais(); scrollSuave("#conteudo"); } } function linksOutrosAtosOficiais() { const links = document.querySelectorAll("#myTabContent .list-group-item a, #r-fiscais .row .col a"); links.forEach((link) => { link.addEventListener("click", function(e) { e.preventDefault(); linksMegaMenu(this); }) }) } // MENU LICITAÇÃO function linksMenuLicitacao() { const links = document.querySelectorAll("#area-licitacao .row .col a, .cacs-lic"); if(links) { links.forEach((link) => { link.addEventListener("click", async function(e) { if (this.id == 10) { e.preventDefault(); const datasetAnos = JSON.parse(this.dataset.anos); if(datasetAnos.length > 0){ const anos = datasetAnos; let options = {0: ''}; for(let ano of anos) { options[ano] = ano; } const { value: anoAta } = await Swal.fire({ title: "Selecione o ano", confirmButtonText: "Avançar", heightAuto: true, allowOutsideClick: false, input: "select", inputOptions: options, inputValidator: (value) => { if (parseInt(value) === 0) { return "O preenchimento é obrigatório!"; } } }); if(parseInt(anoAta) >= 2024) { this.href = '../cons_ata_registro_preco/'; linksMegaMenu(this); return; } } } linksMegaMenu(this); }); }); } } function scrollCanal() { // --- PEGA PARAMENTROS DA URL const urlParams = new URLSearchParams(window.location.search); if (urlParams.has('q') && urlParams.get('q') === 'canal') { const top = document.querySelector('.canal').offsetTop; window.scroll({top, behavior: "smooth"}); } } // --- ACESSIBILIDADE --- // let navigation = document.querySelector('.navigation'); document.querySelector('.menuToggle').onclick = function(){ this.classList.toggle('active'); navigation.classList.toggle('active'); }