Add button to move calendar to a specific date

This commit is contained in:
yflory 2022-09-15 16:33:50 +02:00
parent 6ddfd09805
commit 175fb7e1dc
2 changed files with 25 additions and 1 deletions

View File

@ -327,6 +327,9 @@
fill: @cryptpad_text_col;
}
}
.flatpickr-monthDropdown-month {
background: @cp_flatpickr-bg;
}
}
.flatpickr-current-month {
span.cur-month:hover {

View File

@ -186,6 +186,8 @@ define([
cal.setDate(d);
updateDateRange();
if (cal.getViewName() === 'month') { return; }
// Scroll to correct time
setTimeout(function () {
var h = d.toLocaleTimeString('en-US', { hour12: 0, timeStyle: "short" }).slice(0,2);
@ -1180,6 +1182,7 @@ ICS ==> create a new event with the same UID and a RECURRENCE-ID field (with a v
var goLeft = h('button.fa.fa-chevron-left');
var goRight = h('button.fa.fa-chevron-right');
var goToday = h('button', Messages.calendar_today);
var goDate = h('button.fa.fa-calendar');
$(goLeft).click(function () {
cal.prev();
updateDateRange();
@ -1196,8 +1199,26 @@ ICS ==> create a new event with the same UID and a RECURRENCE-ID field (with a v
updateDateRange();
updateRecurring();
});
$(goDate).click(function () {
var f = Flatpickr(goDate, {
enableTime: false,
defaultDate: APP.calendar.getDate()._date,
//dateFormat: dateFormat,
onChange: function (date) {
date[0].setHours(12);
f.destroy();
APP.moveToDate(+date[0]);
updateDateRange();
updateRecurring();
},
onClose: function () {
setTimeout(f.destroy);
}
});
f.open();
});
APP.toolbar.$bottomL.append(h('div.cp-calendar-browse', [
goLeft, goToday, goRight
goLeft, goToday, goRight, goDate
]));
};