59 lines
2.0 KiB
JavaScript
59 lines
2.0 KiB
JavaScript
// Funzione goBack
|
|
window.goBack = function () {
|
|
console.log("goBack");
|
|
history.back();
|
|
};
|
|
|
|
// Funzione per aggiungere tabindex ai bottoni
|
|
function addTabindexToButtons() {
|
|
document.querySelectorAll('button.custom-plus-button').forEach(btn => {
|
|
if (!btn.hasAttribute('tabindex')) {
|
|
btn.setAttribute('tabindex', '0');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Funzione per monitorare la classe expanded e aggiungere ah-calendar-m
|
|
function monitorExpandedClass(mutations) {
|
|
mutations.forEach(function (mutation) {
|
|
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
|
const target = mutation.target;
|
|
|
|
if (target.classList.contains('week-slider') && target.classList.contains('expanded')) {
|
|
const appointments = document.querySelector('.appointments');
|
|
if (appointments) {
|
|
appointments.classList.add('ah-calendar-m');
|
|
console.log('Classe "ah-calendar-m" aggiunta a .appointments');
|
|
}
|
|
}
|
|
// Rimuovi la classe quando expanded viene rimossa
|
|
else if (target.classList.contains('week-slider') && !target.classList.contains('expanded')) {
|
|
const appointments = document.querySelector('.appointments');
|
|
if (appointments) {
|
|
appointments.classList.remove('ah-calendar-m');
|
|
console.log('Classe "ah-calendar-m" rimossa da .appointments');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Esegui la funzione tabindex inizialmente
|
|
addTabindexToButtons();
|
|
|
|
// Observer combinato per entrambe le funzionalità
|
|
const observer = new MutationObserver((mutations) => {
|
|
// Aggiungi tabindex ai nuovi bottoni
|
|
addTabindexToButtons();
|
|
|
|
// Monitora le classi expanded
|
|
monitorExpandedClass(mutations);
|
|
});
|
|
|
|
// Osserva sia i cambiamenti nel DOM che gli attributi
|
|
observer.observe(document.body, {
|
|
childList: true,
|
|
subtree: true,
|
|
attributes: true,
|
|
attributeFilter: ['class']
|
|
}); |