fixed some issues
This commit is contained in:
parent
1c8da26bd8
commit
c9497e3afc
@ -211,7 +211,7 @@
|
|||||||
border-color: #cbcbcb;
|
border-color: #cbcbcb;
|
||||||
}
|
}
|
||||||
|
|
||||||
.datepicker-icon:active:focus {
|
.datepicker-icon:hover:active {
|
||||||
background-color: #d4d4d4;
|
background-color: #d4d4d4;
|
||||||
border-color: #aaaaaa;
|
border-color: #aaaaaa;
|
||||||
}
|
}
|
||||||
@ -290,14 +290,19 @@
|
|||||||
document.addEventListener('mousedown', onClickOutside);
|
document.addEventListener('mousedown', onClickOutside);
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleCalendar() {
|
||||||
|
if (calendarPopup.style.display === 'block') {
|
||||||
|
hideCalendar();
|
||||||
|
} else {
|
||||||
|
showCalendar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function hideCalendar() {
|
function hideCalendar() {
|
||||||
// Ripristina la classe view-days quando si chiude il calendario
|
|
||||||
calendarPopup.classList.remove('view-months', 'view-years');
|
|
||||||
calendarPopup.classList.add('view-days');
|
|
||||||
calendarPopup.style.display = 'none';
|
calendarPopup.style.display = 'none';
|
||||||
document.removeEventListener('mousedown', onClickOutside);
|
document.removeEventListener('mousedown', onClickOutside);
|
||||||
// Resetta la vista alla schermata principale
|
|
||||||
view = 'days';
|
|
||||||
if (selectedDate) {
|
if (selectedDate) {
|
||||||
currentDate = new Date(selectedDate);
|
currentDate = new Date(selectedDate);
|
||||||
} else {
|
} else {
|
||||||
@ -305,7 +310,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onClickOutside(e) {
|
function onClickOutside(e) {
|
||||||
if (!calendarPopup.contains(e.target) && e.target !== dateInput) {
|
if (!calendarPopup.contains(e.target) && e.target !== dateInput && e.target !== document.getElementById('calendarIcon')) {
|
||||||
hideCalendar();
|
hideCalendar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,11 +322,7 @@
|
|||||||
if (view === 'days') calendarPopup.classList.add('view-days');
|
if (view === 'days') calendarPopup.classList.add('view-days');
|
||||||
else if (view === 'months') calendarPopup.classList.add('view-months');
|
else if (view === 'months') calendarPopup.classList.add('view-months');
|
||||||
else if (view === 'years') calendarPopup.classList.add('view-years');
|
else if (view === 'years') calendarPopup.classList.add('view-years');
|
||||||
let calendarGridClass = 'calendar-grid';
|
calendarPopup.innerHTML = `<div class='calendar-header'><button id='prevBtn' class="calendar-cell fa fa-chevron-left"></button><div id='monthYear' class="calendar-cell"></div><button id='nextBtn' class="calendar-cell fa fa-chevron-right"></button></div><div class='calendar-grid' id='calendar'></div><div class='calendar-actions'><button id='todayBtn'>Oggi</button><button id='clearBtn'>Cancella</button><button id='confirmBtn'>Conferma</button></div>`;
|
||||||
if (view === 'days') calendarGridClass += ' calendar-days';
|
|
||||||
else if (view === 'months') calendarGridClass += ' calendar-months';
|
|
||||||
else if (view === 'years') calendarGridClass += ' calendar-years';
|
|
||||||
calendarPopup.innerHTML = `<div class='calendar-header'><button id='prevBtn' class="calendar-cell fa fa-chevron-left"></button><div id='monthYear' class="calendar-cell"></div><button id='nextBtn' class="calendar-cell fa fa-chevron-right"></button></div><div class='${calendarGridClass}' id='calendar'></div><div class='calendar-actions'><button id='todayBtn'>Oggi</button><button id='clearBtn'>Cancella</button><button id='confirmBtn'>Conferma</button></div>`;
|
|
||||||
calendarEl = document.getElementById("calendar");
|
calendarEl = document.getElementById("calendar");
|
||||||
monthYearEl = document.getElementById("monthYear");
|
monthYearEl = document.getElementById("monthYear");
|
||||||
if (view === 'days') renderDays();
|
if (view === 'days') renderDays();
|
||||||
@ -547,7 +548,6 @@
|
|||||||
// Inizializza input (opzionale: mostra la data di oggi)
|
// Inizializza input (opzionale: mostra la data di oggi)
|
||||||
dateInput.value = selectedDate ? formatDate(selectedDate, dateFormat) : '';
|
dateInput.value = selectedDate ? formatDate(selectedDate, dateFormat) : '';
|
||||||
// Eventi su input e icona
|
// Eventi su input e icona
|
||||||
document.getElementById('calendarIcon').addEventListener('click', showCalendar);
|
|
||||||
|
|
||||||
// Permetti inserimento manuale della data
|
// Permetti inserimento manuale della data
|
||||||
document.getElementById('dateInput').addEventListener('input', function (e) {
|
document.getElementById('dateInput').addEventListener('input', function (e) {
|
||||||
@ -572,7 +572,7 @@
|
|||||||
// Se non valido, evidenzia errore
|
// Se non valido, evidenzia errore
|
||||||
dateInput.classList.add('input-error');
|
dateInput.classList.add('input-error');
|
||||||
});
|
});
|
||||||
document.getElementById('calendarIcon').addEventListener('click', showCalendar);
|
document.getElementById('calendarIcon').addEventListener('click', toggleCalendar);
|
||||||
// Espone showCalendar globalmente solo se serve (compatibilità)
|
// Espone showCalendar globalmente solo se serve (compatibilità)
|
||||||
window.showCalendar = showCalendar;
|
window.showCalendar = showCalendar;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user