replace all w3-include
All checks were successful
Deploy / Deploy to Production (push) Successful in 12s
All checks were successful
Deploy / Deploy to Production (push) Successful in 12s
This commit is contained in:
parent
1570d62287
commit
4642425f43
26 changed files with 283 additions and 80 deletions
|
|
@ -1,51 +1,14 @@
|
|||
function updateLinkInterval(link, interval) {
|
||||
const currentHref = link.getAttribute("href");
|
||||
const newHref = currentHref.replace(
|
||||
/default_interval=[om]/,
|
||||
`default_interval=${interval}`
|
||||
);
|
||||
link.setAttribute("href", newHref);
|
||||
}
|
||||
import { headerToggle, headerScrollVisibility } from './header.js';
|
||||
import { copyLink } from './share.js';
|
||||
import { btnSticky } from './mobile-sticky.js';
|
||||
|
||||
function updateAmountDisplay(link, amount, interval) {
|
||||
const boldText = link.querySelector(".bold");
|
||||
if (!boldText) return;
|
||||
const responsiveMedium = 1080;
|
||||
const responsiveSmall = 768;
|
||||
|
||||
const suffix = interval === "m" ? "€/mois" : "€";
|
||||
boldText.innerHTML = `<span class="amount-value">${amount}</span>${suffix}`;
|
||||
}
|
||||
|
||||
function switchActiveTab(clickedButton, allButtons) {
|
||||
allButtons.forEach((btn) => btn.classList.remove("is-selected"));
|
||||
clickedButton.classList.add("is-selected");
|
||||
}
|
||||
|
||||
function handleDonationIntervalChange(interval) {
|
||||
const donationLinks = document.querySelectorAll(".btn--donation[data-amount]");
|
||||
const freeAmountLink = document.querySelector(".btn--donation:not([data-amount])");
|
||||
|
||||
donationLinks.forEach((link) => {
|
||||
const amount = link.getAttribute("data-amount");
|
||||
updateLinkInterval(link, interval);
|
||||
updateAmountDisplay(link, amount, interval);
|
||||
});
|
||||
|
||||
if (freeAmountLink) {
|
||||
updateLinkInterval(freeAmountLink, interval);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const tabButtons = document.querySelectorAll(".nav--tabs__btn");
|
||||
const donationLinks = document.querySelectorAll(".btn--donation[data-amount]");
|
||||
|
||||
if (tabButtons.length === 0 || donationLinks.length === 0) return;
|
||||
|
||||
tabButtons.forEach((button) => {
|
||||
button.addEventListener("click", function () {
|
||||
const interval = this.getAttribute("data-interval");
|
||||
switchActiveTab(this, tabButtons);
|
||||
handleDonationIntervalChange(interval);
|
||||
});
|
||||
});
|
||||
});
|
||||
window.onload = async function () {
|
||||
console.log("SCRIPT LOADED");
|
||||
headerToggle();
|
||||
headerScrollVisibility();
|
||||
copyLink();
|
||||
btnSticky(responsiveSmall);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue