- Adopción sin filtros ni etiquetas: acceso a Perros y Gatos, tarjetas de foto y nombre. - Ficha nueva: galería, vídeo, fecha de nacimiento o edad aproximada, carácter, necesidades, convivencia y hogar que buscamos (textos por idioma, datos compartidos). - Estados disponible / en proceso / adoptado y animales destacados. - Botón «Quiero conocerlo/la» con formulario breve (animal incluido) y confirmación. - Botones para compartir cada ficha (WhatsApp, Facebook, copiar enlace). - Portada corta según la propuesta del cliente; donaciones, cifras, etc. ocultas. - Páginas Acoge y Preguntas frecuentes, menú con submenús, sin hotel. - Aviso de cita previa y lista de ayuda material editables desde el panel. - Plugin núcleo dividido en módulos (i18n, animales, formularios, APIs). - Migración 5 idempotente: respeta las páginas editadas por el cliente. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
3.1 KiB
JavaScript
86 lines
3.1 KiB
JavaScript
( function () {
|
|
var toggle = document.querySelector( '.ga-menu-toggle' );
|
|
var nav = document.getElementById( 'ga-nav' );
|
|
if ( toggle && nav ) {
|
|
toggle.addEventListener( 'click', function () {
|
|
var open = nav.classList.toggle( 'is-open' );
|
|
toggle.setAttribute( 'aria-expanded', open ? 'true' : 'false' );
|
|
} );
|
|
document.addEventListener( 'keydown', function ( e ) {
|
|
if ( e.key === 'Escape' && nav.classList.contains( 'is-open' ) ) {
|
|
nav.classList.remove( 'is-open' );
|
|
toggle.setAttribute( 'aria-expanded', 'false' );
|
|
toggle.focus();
|
|
}
|
|
} );
|
|
}
|
|
|
|
// Filtros del listado: los <select> envían el formulario al cambiar.
|
|
document.querySelectorAll( '.ga-filters select' ).forEach( function ( select ) {
|
|
select.addEventListener( 'change', function () {
|
|
select.form.submit();
|
|
} );
|
|
} );
|
|
} )();
|
|
|
|
// Vídeo de portada: se detiene si el usuario prefiere menos movimiento.
|
|
( function () {
|
|
var video = document.querySelector( '.ga-hero__bg video' );
|
|
if ( video && window.matchMedia && window.matchMedia( '(prefers-reduced-motion: reduce)' ).matches ) {
|
|
video.removeAttribute( 'autoplay' );
|
|
video.pause();
|
|
}
|
|
} )();
|
|
|
|
// Carruseles: desplazamiento con botones, ratón/táctil nativo (scroll-snap) y teclado.
|
|
( function () {
|
|
document.querySelectorAll( '[data-ga-carousel]' ).forEach( function ( carousel ) {
|
|
var track = carousel.querySelector( '.ga-carousel__track' );
|
|
var buttons = carousel.querySelectorAll( '.ga-carousel__btn' );
|
|
if ( ! track ) {
|
|
return;
|
|
}
|
|
function update() {
|
|
var max = track.scrollWidth - track.clientWidth - 2;
|
|
buttons[ 0 ].disabled = track.scrollLeft <= 2;
|
|
buttons[ 1 ].disabled = track.scrollLeft >= max;
|
|
carousel.classList.toggle( 'is-static', max <= 0 );
|
|
}
|
|
buttons.forEach( function ( button ) {
|
|
button.addEventListener( 'click', function () {
|
|
track.scrollBy( { left: track.clientWidth * 0.9 * Number( button.dataset.dir ), behavior: 'smooth' } );
|
|
} );
|
|
} );
|
|
track.addEventListener( 'keydown', function ( e ) {
|
|
if ( e.key === 'ArrowRight' || e.key === 'ArrowLeft' ) {
|
|
e.preventDefault();
|
|
track.scrollBy( { left: ( e.key === 'ArrowRight' ? 1 : -1 ) * track.clientWidth * 0.9, behavior: 'smooth' } );
|
|
}
|
|
} );
|
|
track.addEventListener( 'scroll', update, { passive: true } );
|
|
window.addEventListener( 'resize', update );
|
|
update();
|
|
} );
|
|
} )();
|
|
|
|
// Ficha: miniaturas de la galería y copiar enlace.
|
|
( function () {
|
|
var main = document.querySelector( '[data-ga-gallery-main] img' );
|
|
document.querySelectorAll( '.ga-thumbs button' ).forEach( function ( btn ) {
|
|
btn.addEventListener( 'click', function () {
|
|
if ( ! main ) { return; }
|
|
main.src = btn.dataset.full;
|
|
main.removeAttribute( 'srcset' );
|
|
document.querySelectorAll( '.ga-thumbs button' ).forEach( function ( b ) { b.removeAttribute( 'aria-current' ); } );
|
|
btn.setAttribute( 'aria-current', 'true' );
|
|
} );
|
|
} );
|
|
document.querySelectorAll( '[data-copy]' ).forEach( function ( btn ) {
|
|
btn.addEventListener( 'click', function () {
|
|
if ( navigator.clipboard ) {
|
|
navigator.clipboard.writeText( btn.dataset.copy ).then( function () { btn.textContent = btn.dataset.done; } );
|
|
}
|
|
} );
|
|
} );
|
|
} )();
|