document.addEventListener("DOMContentLoaded", function () { const overlay = document.createElement("div"); overlay.className = "eco-search-wait"; const spinner = document.createElement("div"); spinner.className = "eco-search-spinner"; const text = document.createElement("div"); text.className = "eco-search-text"; overlay.appendChild(spinner); overlay.appendChild(text); document.body.appendChild(overlay); function activarLoader(term) { text.innerText = term ? "Ten paciencia !!!\nEstamos buscando “" + term + "” en más de 100.000 productos…" : "Ten paciencia !!!\nEstamos buscando en más de 100.000 productos…"; overlay.style.display = "flex"; } // Formularios normales const searchForms = document.querySelectorAll("form"); searchForms.forEach(form => { form.addEventListener("submit", function () { const input = form.querySelector("input[type='search'], input[name='s']"); const term = input ? input.value.trim() : ""; activarLoader(term); }); }); // Botón móvil Blocksy const mobileButtons = document.querySelectorAll( ".ct-search-modal button[type='submit'], .ct-search-modal .ct-search-button, .ct-search-modal .ct-search-icon" ); mobileButtons.forEach(button => { button.addEventListener("click", function () { const input = document.querySelector( ".ct-search-modal input[type='search'], .ct-search-modal input[name='s']" ); const term = input ? input.value.trim() : ""; activarLoader(term); }); }); // ENTER móvil document.addEventListener("keydown", function (e) { if (e.key === "Enter") { const input = document.querySelector( "input[type='search'], input[name='s'], .ct-search-modal input[type='search'], .ct-search-modal input[name='s']" ); if (input) activarLoader(input.value.trim()); } }); // Si la URL ya tiene ?s= const params = new URLSearchParams(window.location.search); if (params.has("s")) activarLoader(params.get("s").trim()); // Apagar loader al terminar carga window.addEventListener("load", function () { overlay.style.display = "none"; }); }); Aventuras – Página 179 – Libros Eco
0
    0
    Tu cesta
    Ningún producto en la cestaVolver a tienda