diff options
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); |