Repository navigation
Expand file tree
/
Copy pathexample.js
More file actions
55 lines (49 loc) · 2.06 KB
/
Copy pathexample.js
File metadata and controls
55 lines (49 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Calendar } from 'fullcalendar';
import timeGrid from 'fullcalendar/timegrid';
import classic from 'fullcalendar/themes/classic';
import resourceTimeGrid from 'fullcalendar-scheduler/resource-timegrid';
import scrollGrid from 'fullcalendar-scheduler/scrollgrid';
import 'fullcalendar/skeleton.css';
import 'fullcalendar/themes/classic/theme.css';
import 'fullcalendar/themes/classic/palette.css';
const search = new URLSearchParams(window.location.search);
const resourceMode = search.get('resource') === '1';
const originalMode = search.get('original') === '1';
const calendarEl = document.querySelector('#calendar');
const formatSlotTime = (date) =>
`${String(date.getUTCHours()).padStart(2, '0')}:${String(date.getUTCMinutes()).padStart(2, '0')}`;
const calendar = new Calendar(calendarEl, {
plugins: [timeGrid, resourceTimeGrid, scrollGrid, classic],
initialView: resourceMode ? 'resourceTimeGridDay' : 'timeGridDay',
initialDate: '2026-09-12',
timeZone: 'UTC',
slotDuration: '00:15',
slotHeaderInterval: originalMode ? undefined : '00:15',
slotMinTime: '05:45',
slotMaxTime: '22:00',
slotMinHeight: 40,
allDaySlot: false,
dayMinWidth: 200,
expandRows: false,
height: 800,
resources: [{ id: 'one', title: 'Room one' }],
events: [{ id: 'booking', resourceId: 'one', title: 'Example booking', start: '2026-09-12T10:00:00Z', end: '2026-09-12T11:00:00Z' }],
slotHeaderDidMount(info) {
info.el.dataset.slotTime = formatSlotTime(info.date);
},
eventClass: 'calendar-booking',
});
calendar.render();
window.calendar = calendar;
window.calendarExample = { originalMode, resourceMode };
document.querySelector('#mode-note').textContent = originalMode
? 'Original configuration reproduction'
: resourceMode
? 'Resource view evaluation'
: 'Standard view';
document.querySelector('#apply-hours').addEventListener('click', () => {
calendar.batchRendering(() => {
calendar.setOption('slotMinTime', document.querySelector('#opening-time').value);
calendar.setOption('slotMaxTime', document.querySelector('#closing-time').value);
});
});