1document.addEventListener("DOMContentLoaded", function(event) { 2 3 // Buscador general 4 let btn_buscador_gen = document.getElementById('btn-buscador-general'); 5 let cont_buscador_gen = document.getElementById('contenedor-buscador-general'); 6 let cont_pagina = document.querySelector('.contenido-page, .contenido-archive'); 7 8 if (btn_buscador_gen && cont_buscador_gen) { 9 btn_buscador_gen.addEventListener('click', function (){ 10 cont_buscador_gen.classList.toggle('visible'); 11 if(cont_buscador_gen.classList.contains('visible')){ 12 cont_buscador_gen.querySelector('input[type=search]').focus(); 13 document.querySelector('body').classList.add('menu-abierto'); 14 }else{ 15 document.querySelector('body').classList.remove('menu-abierto'); 16 } 17 }); 18 cont_pagina.addEventListener('click', function (){ 19 if(cont_buscador_gen.classList.contains('visible')){ 20 document.querySelector('body').classList.remove('menu-abierto'); 21 cont_buscador_gen.classList.remove('visible') 22 } 23 }); 24 } 25 26 // Botón para desplegar menú de la cabecera 27 let btn_menu = document.getElementById('btn-menu-desplegable'); 28 let menu_lateral = document.getElementById('nav-menu-principal'); 29 if (typeof(btn_menu) != 'undefined' && btn_menu != null) { 30 btn_menu.addEventListener('click', function(){ 31 this.classList.toggle('abierto'); 32 if(this.classList.contains('abierto')){ 33 menu_lateral.classList.add('abierto'); 34 document.querySelector('body').classList.add('menu-abierto'); 35 }else{ 36 menu_lateral.classList.remove('abierto'); 37 document.querySelector('body').classList.remove('menu-abierto'); 38 } 39 }); 40 } 41 42 // Si la pantalla es mayor de 1152px 43 if (matchMedia('only screen and (min-width: 1152px)').matches) { 44 let elementos_menu_principal = document.querySelectorAll('.menu-item-has-children'); 45 elementos_menu_principal.forEach(function(elemento_menu, index_elemento_menu){ 46 elemento_menu.onmouseover = function(){ 47 document.querySelector('body').classList.add('menu-abierto'); 48 } 49 elemento_menu.onmouseout = function(){ 50 document.querySelector('body').classList.remove('menu-abierto'); 51 } 52 }); 53 } 54 55 // Para abrir los submenus 56 let iconos_submenu = document.querySelectorAll('.icono-mas'); 57 let id_item_menu = 0; 58 iconos_submenu.forEach(function(icono_submenu){ 59 icono_submenu.addEventListener('click', function(event){ 60 event.preventDefault(); 61 icono_submenu.classList.toggle('mas'); 62 icono_submenu.classList.toggle('menos'); 63 id_item_menu = icono_submenu.getAttribute('data-id'); 64 let item_menu_padre = document.getElementById('menu-item-' + id_item_menu); 65 item_menu_padre.querySelector('.sub-menu').classList.toggle('visible'); 66 67 }); 68 }); 69 70 // Botón de abrir el apartado de newsletter en el footer 71 let btn_newsletter = document.getElementById('btn-newsletter'); 72 let cuerpo_newsletter = document.getElementById('cuerpo-newsletter'); 73 if (typeof(btn_newsletter) != 'undefined' && btn_newsletter != null) { 74 btn_newsletter.addEventListener('click', function(){ 75 cuerpo_newsletter.classList.toggle('visible'); 76 }); 77 } 78 79 // Cambiar la disposición del grid 80 let btn_grid_3 = document.getElementById('btn-filtro-col-3'); 81 let btn_grid_4 = document.getElementById('btn-filtro-col-4'); 82 let grid_tiendas = document.getElementById('lilla_posts_wrap'); 83 if (typeof(btn_grid_3) != 'undefined' && btn_grid_3 != null) { 84 btn_grid_3.addEventListener('click', function(){ 85 grid_tiendas.classList.remove('grid-tiendas-4'); 86 btn_grid_3.classList.add('activo'); 87 btn_grid_4.classList.remove('activo'); 88 }); 89 } 90 if (typeof(btn_grid_4) != 'undefined' && btn_grid_4 != null) { 91 btn_grid_4.addEventListener('click', function(){ 92 grid_tiendas.classList.add('grid-tiendas-4'); 93 btn_grid_3.classList.remove('activo'); 94 btn_grid_4.classList.add('activo'); 95 }); 96 } 97 98 // Filtros en grid 99 let btn_abrir_filtros = document.getElementById('btn-filtro-categorias');
100 let contenido_filtros = document.getElementById('popup-filtro-categorias'); 101 let btn_borrar_filtros = document.getElementById('borrar-categorias'); 102 let btn_cerrar_filtros = document.getElementById('btn-ocultar-filtro'); 103 let btn_filrar = document.getElementById('btn-filtrar'); 104 if (typeof(btn_abrir_filtros) != 'undefined' && btn_abrir_filtros != null) { 105 // Abre el popup de los filtros 106 btn_abrir_filtros.addEventListener('click', function(){ 107 contenido_filtros.classList.toggle('abierto'); 108 }); 109 } 110 if (typeof(btn_borrar_filtros) != 'undefined' && btn_borrar_filtros != null) { 111 let inputs_filtros = contenido_filtros.querySelectorAll('input'); 112 // Borra los filtros seleccionados del popup 113 btn_borrar_filtros.addEventListener('click', function(){ 114 inputs_filtros.forEach(function(input){ 115 input.checked = false; 116 }); 117 }); 118 } 119 if(typeof(btn_cerrar_filtros) != 'undefined' && btn_cerrar_filtros != null){ 120 btn_cerrar_filtros.addEventListener('click', function(){ 121 contenido_filtros.classList.toggle('abierto'); 122 }) 123 } 124 if(typeof(btn_filrar) != 'undefined' && btn_filrar != null){ 125 btn_filrar.addEventListener('click', function(){ 126 contenido_filtros.classList.remove('abierto'); 127 }); 128 } 129 130 131 // Quicklinks en móvil 132 // Si es móvil (tiene el elemento con esa clase 133 /* 134 if($('.menu-top-movil').length){ 135 var didScroll; 136 var lastScrollTop = 0; 137 var delta = 5; 138 var navbarHeight = $('.menu-top-movil').outerHeight(); 139 140 $(window).scroll(function(event){ 141 didScroll = true; 142 }); 143 144 setInterval(function() { 145 if (didScroll) { 146 hasScrolled(); 147 didScroll = false; 148 } 149 }, 250); 150 151 function hasScrolled() { 152 var st = $(this).scrollTop(); 153 if(Math.abs(lastScrollTop - st) <= delta) 154 return; 155 156 if(st > 63){ 157 $('.cabecera-general').addClass('nav-up'); 158 $('.menu-top-movil').addClass('nav-up-top') 159 }else{ 160 $('.cabecera-general').removeClass('nav-up'); 161 $('.menu-top-movil').removeClass('nav-up-top') 162 } 163 if (st > lastScrollTop && st > navbarHeight){ 164 $('.menu-top-movil').removeClass('nav-down').addClass('nav-up'); 165 } else { 166 if(st + $(window).height() < $(document).height()) { 167 $('.menu-top-movil').removeClass('nav-up').addClass('nav-down'); 168 } 169 } 170 lastScrollTop = st; 171 } 172 } 173 */ 174 if (document.querySelector('.menu-top-movil')) { 175 let didScroll; 176 let lastScrollTop = 0; 177 const delta = 5; 178 const navbarHeight = document.querySelector('.menu-top-movil').offsetHeight; 179 180 window.addEventListener('scroll', function (event) { 181 didScroll = true; 182 }); 183 184 setInterval(function () { 185 if (didScroll) { 186 hasScrolled(); 187 didScroll = false; 188 } 189 }, 250); 190 191 function hasScrolled() { 192 const st = window.pageYOffset || document.documentElement.scrollTop; 193 if (Math.abs(lastScrollTop - st) <= delta) return; 194 195 if (st > 63) { 196 document.querySelector('.cabecera-general').classList.add('nav-up'); 197 document.querySelector('.menu-top-movil').classList.add('nav-up-top'); 198 } else { 199 document.querySelector('.cabecera-general').classList.remove('nav-up'); 200 document.querySelector('.menu-top-movil').classList.remove('nav-up-top'); 201 } 202 if (st > lastScrollTop && st > navbarHeight) { 203 document.querySelector('.menu-top-movil').classList.remove('nav-down'); 204 document.querySelector('.menu-top-movil').classList.add('nav-up'); 205 } else { 206 if (st + window.innerHeight < document.documentElement.scrollHeight) { 207 document.querySelector('.menu-top-movil').classList.remove('nav-up'); 208 document.querySelector('.menu-top-movil').classList.add('nav-down'); 209 } 210 } 211 lastScrollTop = st; 212 } 213 } 214 215 216 217 var prevScrollpos = window.pageYOffset; 218 window.onscroll = function() { 219 var currentScrollPos = window.pageYOffset; 220 var footer_flotante = document.getElementById("footer-flotante"); 221 if (prevScrollpos > currentScrollPos) { 222 if(typeof(footer_flotante) != 'undefined' && footer_flotante != null){ 223 document.getElementById("footer-flotante").style.bottom = "-58px"; 224 } 225 } else { 226 if(typeof(footer_flotante) != 'undefined' && footer_flotante != null){ 227 document.getElementById("footer-flotante").style.bottom = "0"; 228 } 229 } 230 prevScrollpos = currentScrollPos; 231 } 232 233 const aspectRatio1to1 = document.querySelectorAll('.grid-lilla-inspira .imagen.first, .grid-inspira a .cabecera'); 234 console.log(aspectRatio1to1); 235 function resizeForSquareAppearance(event) { 236 aspectRatio1to1.forEach((element) => { 237 element.style.height = `${element.clientWidth}px`; 238 }) 239 } 240 241 window.addEventListener('resize', resizeForSquareAppearance); 242 resizeForSquareAppearance(); 243 244 245 246});
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.