diff options
author | Mario <mario@mariovavti.com> | 2024-11-21 09:04:55 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-11-21 09:04:55 +0000 |
commit | 46e66001694fdbddd3972432ddc062e7f618b0a7 (patch) | |
tree | 36c905be55b7643c7858f9cd9c0ea9e9bd4f07d2 /view/tpl | |
parent | 243a2a9bdf686fe46fec4e2214ed47c1571ce91c (diff) | |
download | volse-hubzilla-46e66001694fdbddd3972432ddc062e7f618b0a7.tar.gz volse-hubzilla-46e66001694fdbddd3972432ddc062e7f618b0a7.tar.bz2 volse-hubzilla-46e66001694fdbddd3972432ddc062e7f618b0a7.zip |
mod cal: provide a possibility to link to a specific month or day by passing a fragment
Diffstat (limited to 'view/tpl')
-rw-r--r-- | view/tpl/cal_calendar.tpl | 25 | ||||
-rw-r--r-- | view/tpl/cdav_calendar.tpl | 3 |
2 files changed, 25 insertions, 3 deletions
diff --git a/view/tpl/cal_calendar.tpl b/view/tpl/cal_calendar.tpl index 437cd8363..2e1699f1c 100644 --- a/view/tpl/cal_calendar.tpl +++ b/view/tpl/cal_calendar.tpl @@ -1,8 +1,9 @@ <script> -var calendar; - $(document).ready(function() { - var calendarEl = document.getElementById('calendar'); + let calendarEl = document.getElementById('calendar'); + let fragment = window.location.hash.substring(1); + let view; + calendar = new FullCalendar.Calendar(calendarEl, { eventSources: [ {{$sources}} ], @@ -38,6 +39,24 @@ $(document).ready(function() { calendar.render(); + if (fragment) { + switch (fragment.length) { + // this might have performance issues + // case 4: + // view = 'multiMonthYear'; + // break; + case 7: + view = 'dayGridMonth'; + break; + case 10: + view = 'timeGridDay'; + break; + default: + view = 'dayGridMonth'; + } + calendar.changeView(view, fragment); + } + $('#title').text(calendar.view.title); $('#today-btn').on('click', function() { diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl index 7399a2b59..d046dfc2f 100644 --- a/view/tpl/cdav_calendar.tpl +++ b/view/tpl/cdav_calendar.tpl @@ -366,6 +366,9 @@ $(document).ready(function() { $('#calendar_select').val('channel_calendar').attr('disabled', true); $('#id_title').val(resource.summary); + calendar.changeView('timeGridDay', resource.dtstart); + $('#title').text(calendar.view.title); + // A hack to match with internal workings of fullcalendar. // See https://fullcalendar.io/docs/timeZone#UTC-coercion let start_d = new Date(resource.dtstart); |