/* ---- raiz del diseno (ver preludio en subir_js.py) ---- */ ( function () { var raiz = document.getElementById( 'ah-refocus-root' ); if ( raiz ) { raiz.classList.add( 'refocus-site' ); } } )(); ; /* ---- assets/js/reviews.js ---- */ /** * Carrusel de reseñas: conecta las flechas al scroll horizontal de las tarjetas. * El markup vive en el contenido de la página, así que este script no asume * cuántas reseñas hay: mide el ancho real de una tarjeta en cada movimiento. */ ( function () { 'use strict'; function initCarousel( carousel ) { var track = carousel.querySelector( '.refocus-reviews-cards' ); var arrows = carousel.querySelectorAll( '.refocus-reviews-arrow' ); if ( ! track || arrows.length < 2 ) { return; } var prev = arrows[ 0 ]; var next = arrows[ 1 ]; function step() { var card = track.querySelector( '.refocus-review-card' ); if ( ! card ) { return track.clientWidth; } var styles = window.getComputedStyle( track ); var gap = parseFloat( styles.columnGap || styles.gap ) || 0; return card.getBoundingClientRect().width + gap; } function syncArrows() { var maxScroll = track.scrollWidth - track.clientWidth; prev.disabled = track.scrollLeft <= 1; next.disabled = track.scrollLeft >= maxScroll - 1; } prev.addEventListener( 'click', function () { track.scrollBy( { left: -step(), behavior: 'smooth' } ); } ); next.addEventListener( 'click', function () { track.scrollBy( { left: step(), behavior: 'smooth' } ); } ); track.addEventListener( 'scroll', syncArrows, { passive: true } ); window.addEventListener( 'resize', syncArrows ); syncArrows(); } function init() { var carousels = document.querySelectorAll( '.refocus-reviews-carousel' ); Array.prototype.forEach.call( carousels, initCarousel ); } if ( 'loading' === document.readyState ) { document.addEventListener( 'DOMContentLoaded', init ); } else { init(); } }() );