From 175fb7e1dc475e754a9611ef8c09d1a5fd62b599 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 15 Sep 2022 16:33:50 +0200 Subject: [PATCH] Add button to move calendar to a specific date --- customize.dist/src/less2/include/forms.less | 3 +++ www/calendar/inner.js | 23 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/customize.dist/src/less2/include/forms.less b/customize.dist/src/less2/include/forms.less index fa51a3c8c..c3c074b45 100644 --- a/customize.dist/src/less2/include/forms.less +++ b/customize.dist/src/less2/include/forms.less @@ -327,6 +327,9 @@ fill: @cryptpad_text_col; } } + .flatpickr-monthDropdown-month { + background: @cp_flatpickr-bg; + } } .flatpickr-current-month { span.cur-month:hover { diff --git a/www/calendar/inner.js b/www/calendar/inner.js index a1a21f9ec..731213ad1 100644 --- a/www/calendar/inner.js +++ b/www/calendar/inner.js @@ -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 ])); };