2026-03-04 13:39:20 +01:00
|
|
|
|
window.onload = function () {
|
|
|
|
|
|
headerShrink();
|
|
|
|
|
|
initCart();
|
|
|
|
|
|
toggleDonationButton();
|
|
|
|
|
|
videos();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
window.onscroll = function () {
|
|
|
|
|
|
headerShrink();
|
|
|
|
|
|
toggleDonationButton();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function initCart() {
|
|
|
|
|
|
const items = document.querySelectorAll('.store__product .link-block');
|
|
|
|
|
|
const header = document.querySelector('#site-header');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function headerShrink() {
|
|
|
|
|
|
const header = document.getElementById('site-header');
|
|
|
|
|
|
const scrollPosition = window.scrollY || document.documentElement.scrollTop;
|
|
|
|
|
|
|
|
|
|
|
|
if (scrollPosition > 100) {
|
|
|
|
|
|
header.classList.add('is-shrinked');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
header.classList.remove('is-shrinked');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toggleDonationButton() {
|
2026-04-12 08:00:58 +02:00
|
|
|
|
const btn = document.getElementById('donation-cta-mobile');
|
2026-03-04 13:39:20 +01:00
|
|
|
|
const section = document.getElementById('section__donation');
|
|
|
|
|
|
const footer = document.getElementById('site-footer');
|
|
|
|
|
|
|
|
|
|
|
|
if (!btn || !section || !footer) return; // sécurité
|
|
|
|
|
|
|
|
|
|
|
|
const scrollTop = window.scrollY || window.pageYOffset;
|
|
|
|
|
|
const triggerPoint = section.offsetTop + section.offsetHeight / 2;
|
|
|
|
|
|
|
|
|
|
|
|
// 1️⃣ Gestion de la visibilité du bouton
|
|
|
|
|
|
if (scrollTop >= triggerPoint) {
|
|
|
|
|
|
btn.classList.add('is-visible');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
btn.classList.remove('is-visible');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2️⃣ Gestion de la position par rapport au footer
|
|
|
|
|
|
const footerRect = footer.getBoundingClientRect();
|
|
|
|
|
|
const windowHeight = window.innerHeight;
|
|
|
|
|
|
|
|
|
|
|
|
if (footerRect.top < windowHeight) {
|
|
|
|
|
|
const footerVisibleHeight = windowHeight - footerRect.top;
|
|
|
|
|
|
btn.style.bottom = footerVisibleHeight + 'px';
|
|
|
|
|
|
} else {
|
|
|
|
|
|
btn.style.bottom = '0px';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function videos(){
|
|
|
|
|
|
console.log("video");
|
|
|
|
|
|
let section = document.getElementById("section__video");
|
|
|
|
|
|
console.log(section);
|
|
|
|
|
|
|
2026-04-12 08:00:58 +02:00
|
|
|
|
let videoslinks = document.querySelectorAll(".testimony-item");
|
2026-03-04 13:39:20 +01:00
|
|
|
|
videoslinks.forEach(function (video, index) {
|
|
|
|
|
|
|
|
|
|
|
|
video.addEventListener("click", (event) => {
|
|
|
|
|
|
let data = video.getAttribute('data-video');
|
|
|
|
|
|
|
|
|
|
|
|
var div = document.createElement('section');
|
|
|
|
|
|
div.id = "video__fullscreen";
|
|
|
|
|
|
div.innerHTML = '<button id="video__close">✕</button>\
|
|
|
|
|
|
<iframe\
|
|
|
|
|
|
src="' + data + '"\
|
|
|
|
|
|
style="aspect-ratio: 9/16; width: 100%; border: 0"\
|
|
|
|
|
|
allow="autoplay; fullscreen; picture-in-picture"\
|
|
|
|
|
|
allowfullscreen ></iframe>';
|
|
|
|
|
|
document.body.appendChild(div);
|
|
|
|
|
|
document.body.classList.add("is-fullscreen");
|
|
|
|
|
|
|
|
|
|
|
|
let close = document.querySelector("#video__close");
|
2026-04-12 11:08:03 +02:00
|
|
|
|
function closeFullscreen() {
|
2026-03-04 13:39:20 +01:00
|
|
|
|
div.remove();
|
|
|
|
|
|
document.body.classList.remove("is-fullscreen");
|
2026-04-12 11:08:03 +02:00
|
|
|
|
document.removeEventListener("keydown", onEscape);
|
|
|
|
|
|
}
|
|
|
|
|
|
function onEscape(e) {
|
|
|
|
|
|
if (e.key === "Escape") closeFullscreen();
|
|
|
|
|
|
}
|
|
|
|
|
|
close.addEventListener("click", closeFullscreen);
|
|
|
|
|
|
document.addEventListener("keydown", onEscape);
|
2026-03-04 13:39:20 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|