undefined Risultati
/* --- FUNZIONI GLOBALI FOLLAKY --- */
// 1. Creazione e Gestione del Pulsante Dinamico
function setupDynamicButton() {
// Crea il pulsante se non esiste
if (!document.getElementById('dynamicActionButton')) {
const btn = document.createElement('div');
btn.id = 'dynamicActionButton';
btn.className = 'is-whatsapp';
btn.innerHTML = 'chat';
document.body.appendChild(btn);
// Azione al click
btn.onclick = function() {
if (btn.classList.contains('is-whatsapp')) {
window.open('https://wa.me/393757770567', '_blank');
} else {
window.scrollTo({top: 0, behavior: 'smooth'});
}
};
}
// Logica di trasformazione allo scroll
window.addEventListener('scroll', () => {
const btn = document.getElementById('dynamicActionButton');
const icon = btn.querySelector('.material-symbols-outlined');
if (window.scrollY > 300) {
if (btn.classList.contains('is-whatsapp')) {
btn.classList.replace('is-whatsapp', 'is-top');
icon.innerText = 'arrow_upward';
}
} else {
if (btn.classList.contains('is-top')) {
btn.classList.replace('is-top', 'is-whatsapp');
icon.innerText = 'chat';
}
}
});
}
// 2. Supporto Multilingua (Fix Lodgify)
function applyTranslations() {
const isEnglish = window.location.pathname.includes('/en/');
document.querySelectorAll('[data-it]').forEach(el => {
el.innerText = isEnglish ? el.getAttribute('data-en') : el.getAttribute('data-it');
});
}
// Avvia tutto al caricamento
window.addEventListener('load', () => {
setupDynamicButton();
applyTranslations();
});