praiadeseselle/site/templates/js/main.js

106 lines
No EOL
2.9 KiB
JavaScript

document.addEventListener("click", function (e)
{
if(e.target.classList.contains("reixa-item"))
{
const src = e.target.getAttribute("src");
const alt = e.target.getAttribute("alt");
const myModal = new bootstrap.Modal(document.getElementById("reixa-modal"))
document.querySelector(".modal-img").src = src;
document.querySelector(".modal-label").innerHTML = alt;
myModal.show();
}
});
document.addEventListener("show.bs.collapse", function (e)
{
e.target.previousElementSibling.classList.add("active");
});
document.addEventListener("hide.bs.collapse", function (e)
{
e.target.previousElementSibling.classList.remove("active");
});
const swiper_galeria = new Swiper("#galeria",
{
slidesPerView: 1,
spaceBetween: 30,
loop: true,
lazy: true,
autoHeight: false,
keyboard: true,
centeredSlides: true,
autoplay:
{
delay: 2500,
disableOnInteraction: false,
pauseOnMouseEnter: true,
},
pagination:
{
el: ".swiper-pagination",
clickable: true,
},
navigation:
{
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
function getLogin(event)
{
event.preventDefault();
grecaptcha.ready(function()
{
grecaptcha.execute('6LexXqYiAAAAACwDpMGIg1OMnAXVJU0VmbEMQUD8', { action: 'submit' }).then(function(token)
{
var form = document.getElementById("inicio-sesion");
var boton_token = document.createElement('input');
boton_token.type = 'hidden';
boton_token.name = 'token';
boton_token.id = 'token';
boton_token.value = token;
var boton_action = document.createElement('input');
boton_action.type = 'hidden';
boton_action.name = 'action';
boton_action.id = 'action';
boton_action.value = 'submit';
form.appendChild(boton_token);
form.appendChild(boton_action);
form.submit();
});;
});
}
function getContact(event)
{
event.preventDefault();
grecaptcha.ready(function()
{
grecaptcha.execute('6LexXqYiAAAAACwDpMGIg1OMnAXVJU0VmbEMQUD8', { action: 'submit' }).then(function(token)
{
var form = document.getElementById("formulario-contacto");
var boton_token = document.createElement('input');
boton_token.type = 'hidden';
boton_token.name = 'token';
boton_token.id = 'token';
boton_token.value = token;
var boton_action = document.createElement('input');
boton_action.type = 'hidden';
boton_action.name = 'action';
boton_action.id = 'action';
boton_action.value = 'submit';
form.appendChild(boton_token);
form.appendChild(boton_action);
form.submit();
});;
});
}