Files
publish-assistant/site/assets/js/calendar.js
2026-04-26 12:57:40 +00:00

36 lines
1020 B
JavaScript

import { Calendar } from '@fullcalendar/core'
import dayGridPlugin from '@fullcalendar/daygrid'
import listPlugin from '@fullcalendar/list'
document.addEventListener('DOMContentLoaded', function () {
var el = document.getElementById('pa-calendar')
if (!el) return
var events
try { events = JSON.parse(el.dataset.events || '[]') } catch (_) { events = [] }
var cal = new Calendar(el, {
plugins: [dayGridPlugin, listPlugin],
initialView: 'dayGridMonth',
events: events,
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,listYear'
},
eventClick: function (info) {
if (info.event.url) {
info.jsEvent.preventDefault()
window.location.href = info.event.url
}
},
eventDidMount: function (info) {
var parts = [info.event.title]
var props = info.event.extendedProps || {}
if (props.location) parts.push(props.location)
info.el.title = parts.join(' — ')
}
})
cal.render()
})