1(function ($) { 2 $("[show_modal_defesas_ajax]").on("submit", function (e) { 3 e.preventDefault(); 4 5 let form = $(this); 6 7 let anoSelecionado = form.find("select[name=ano] option:selected").val(); 8 let titleModal = form.find("[name=titleModal]").val(); 9 let argsToQuery = form.find("[name=argsJson]").val(); 10 11 $(".modal .modal__ano").html(anoSelecionado); 12 $(".modal .padrao-titulo").html(titleModal); 13 14 var args = { 15 anoSelecionado, 16 argsToQuery, 17 }; 18 19 let postsGrid = $("[show_modal_defesas_post_list]"); 20 let uuid_post_list = postsGrid.attr("data-uuid"); 21 let uuid_form = form.attr("data-postList"); 22 23 let uuid = uuid_form ?? uuid_post_list; 24 25 if (!uuid_post_list || !uuid_form) { 26 uuid = uniqid(); 27 postsGrid.attr("data-uuid", uuid); 28 form.attr("data-postList", uuid); 29 } 30 31 // toogleLoadMoreElements(); 32 33 load_defesas(uuid, args); 34 }); 35 36 function toogleLoadMoreElements() { 37 $("[load_more_ajax] button").toggle(); 38 } 39 40 function toogleModalDefesa() { 41 $("[show_modal_defesas_post_list]").toggle(); 42 } 43 44 function load_defesas(uuid, form) { 45 let requestData = { 46 action: "loadDefesasModal", // Necessário para o WordPress identificar a ação 47 args: form, // Argumentos JSON como string 48 }; 49 50 $.ajax({ 51 type: "POST", 52 url: ajax_object.ajax_url, // URL do admin-ajax.php 53 data: requestData, // O jQuery converte isso para x-www-form-urlencoded 54 dataType: "html", // Continuamos esperando HTML como resposta 55 success: function (data) { 56 try { 57 var $data = $(data); 58 59 if ($data.length) { 60 $(`[data-uuid=${uuid}] .conteudo ul`).html($data); 61 console.log("conteúdo retornado."); 62 } else { 63 console.log("Nenhum conteúdo retornado."); 64 } 65 66 toogleModalDefesa(); 67 } catch (error) { 68 console.error("Erro na requisição: ", error); 69 } 70 }, 71 error: function (jqXHR, textStatus, errorThrown) { 72 console.error( 73 "Erro na requisição:", 74 jqXHR.responseText, 75 textStatus, 76 errorThrown 77 ); 78 }, 79 }); 80 } 81 82 function uniqid() { 83 return Math.random().toString(36).substr(2, 9) + "-" + Date.now(); 84 } 85 86 const modalOverlay = document.querySelector( 87 "[show_modal_defesas_post_list].modal-overlay" 88 ); 89 const closeModal = document.querySelector( 90 "[show_modal_defesas_post_list] .closeModal" 91 ); 92 93 if (modalOverlay) { 94 // Close modal functionality 95 closeModal.addEventListener("click", (event) => { 96 event.preventDefault(); 97 modalOverlay.style.display = "none"; 98 }); 99 100 // Fechar modal apenas se clicar no overlay (não na modal em si) 101 modalOverlay.addEventListener("click", (event) => { 102 if (event.target === modalOverlay) { 103 event.preventDefault(); 104 modalOverlay.style.display = "none"; 105 } 106 }); 107 } 108})(jQuery);
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.