1-night stay
(function() {
console.log(“Script Aire de Barreal v3.0 – Fotos + Selección + Scroll”);
// — 1. FUNCIÓN: ENCENDER FOTOS (Anti-Fideo) —
function encenderFotos() {
var tarjetas = document.querySelectorAll(‘.listing__room’);
tarjetas.forEach(function(tarjeta) {
var enlaceImagen = tarjeta.querySelector(‘.room__image–listing a’);
if (enlaceImagen && enlaceImagen.href) {
var urlOriginal = enlaceImagen.href;
enlaceImagen.style.setProperty(‘background-image’, ‘url(‘ + urlOriginal + ‘)’, ‘important’);
tarjeta.classList.add(‘foto-encendida’);
}
});
}
// — 2. LÓGICA DE SELECCIÓN Y SCROLL —
document.addEventListener(‘click’, function(e) {
var btn = e.target.closest(‘.button–add-to-cart’);
if (btn) {
console.log(“Habitación elegida. Forzando cantidad…”);
var wrapper = btn.closest(‘.add-to-cart-wrapper’);
var inputQty = wrapper ? wrapper.querySelector(‘.room-quantity__input’) : null;
if (inputQty) {
inputQty.value = 1;
if (window.jQuery) {
jQuery(inputQty).val(1).trigger(‘change’);
}
btn.classList.add(‘button–selected’);
setTimeout(function() {
var destino = document.querySelector(‘.hotelier-reservation-button-wrapper’) ||
document.querySelector(‘.hotelier-reservation-button’);
if (destino) {
destino.scrollIntoView({ behavior: ‘smooth’ });
} else {
window.location.hash = ‘reserve-button’;
}
}, 150);
}
}
}, true);
// — 3. EJECUCIÓN Y VIGILANCIA (AJAX) —
// Ejecutar al cargar
encenderFotos();
// Re-ejecutar con pequeños delays por seguridad del plugin
setTimeout(encenderFotos, 1000);
setTimeout(encenderFotos, 2500);
// Vigilante para cuando el usuario cambia fechas (AJAX Mutation)
var observer = new MutationObserver(function(mutations) {
encenderFotos();
});
var container = document.querySelector(‘.hotelier-listing’) || document.body;
observer.observe(container, { childList: true, subtree: true });
})();
