Web de Gure Ametsa Bi Lagun en WordPress para Dokploy
- Docker Compose (WordPress + MariaDB) listo para Dokploy, con instalación automática por etapas: idiomas, páginas, menús y plugins recomendados. - Web bilingüe castellano / euskera con Polylang. - Tema propio «gure-ametsa»: diseño inspirado en Beargrass Animal Rescue, personalizable desde Apariencia → Personalizar (paletas, tipografías, secciones de portada ordenables) y patrones de bloques propios. - Plugin mu «gure-ametsa-core»: animales en adopción con ficha y filtros, carrusel y formulario de contacto/adopción. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
64
wp-content/themes/gure-ametsa/assets/js/main.js
Normal file
64
wp-content/themes/gure-ametsa/assets/js/main.js
Normal file
@@ -0,0 +1,64 @@
|
||||
( 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();
|
||||
} );
|
||||
} )();
|
||||
Reference in New Issue
Block a user