diff --git a/src/widgetfideuram/components/nbp-fid-calendar-generic/nbp-fid-calendar-generic-page.html b/src/widgetfideuram/components/nbp-fid-calendar-generic/nbp-fid-calendar-generic-page.html index 5e0fc61..e8d104d 100644 --- a/src/widgetfideuram/components/nbp-fid-calendar-generic/nbp-fid-calendar-generic-page.html +++ b/src/widgetfideuram/components/nbp-fid-calendar-generic/nbp-fid-calendar-generic-page.html @@ -211,7 +211,7 @@ border-color: #cbcbcb; } - .datepicker-icon:active:focus { + .datepicker-icon:hover:active { background-color: #d4d4d4; border-color: #aaaaaa; } @@ -290,14 +290,19 @@ document.addEventListener('mousedown', onClickOutside); }, 0); } + + function toggleCalendar() { + if (calendarPopup.style.display === 'block') { + hideCalendar(); + } else { + showCalendar(); + } + } + 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'; document.removeEventListener('mousedown', onClickOutside); - // Resetta la vista alla schermata principale - view = 'days'; + if (selectedDate) { currentDate = new Date(selectedDate); } else { @@ -305,7 +310,7 @@ } } 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(); } } @@ -317,11 +322,7 @@ if (view === 'days') calendarPopup.classList.add('view-days'); else if (view === 'months') calendarPopup.classList.add('view-months'); else if (view === 'years') calendarPopup.classList.add('view-years'); - let calendarGridClass = 'calendar-grid'; - if (view === 'days') calendarGridClass += ' calendar-days'; - else if (view === 'months') calendarGridClass += ' calendar-months'; - else if (view === 'years') calendarGridClass += ' calendar-years'; - calendarPopup.innerHTML = `