1 /*****************************************************************************
2 * Copyright (c) 2016 Max Breitenfeldt and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Apache License, Version 2.0
6 * which accompanies this distribution, and is available at
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *****************************************************************************/
13 function sendEventToForm(event) {
14 $('#starttimepicker').data("DateTimePicker").date(event.start);
15 $('#endtimepicker').data("DateTimePicker").date(event.end);
18 var calendarOptions = {
21 left: 'prev,next today',
23 right: 'agendaWeek,month'
25 timezone: user_timezone, // set in booking_calendar.html
27 slotDuration: '00:60:00',
28 slotLabelFormat: "HH:mm",
35 eventLimit: true, // allow "more" link when too many events
36 timeFormat: 'H(:mm)', // uppercase H for 24-hour clock
40 // selectHelper is only working in the agendaWeek view, this is a workaround:
41 // if an event is selected, the existing selection is removed and a temporary event is added
43 select: function (start, end) {
44 if (tmpevent != undefined) {
45 $('#calendar').fullCalendar('removeEvents', tmpevent.id);
46 $('#calendar').fullCalendar('rerenderEvents');
49 // the times need to be converted here to make them show up in the agendaWeek view if they
50 // are created in the month view. If they are not converted, the tmpevent will only show
51 // up in the (deactivated) allDaySlot
52 start = moment(start);
56 id: '537818f62bc63518ece15338fb86c8be',
63 $('#calendar').fullCalendar('renderEvent', tmpevent, true);
64 sendEventToForm(tmpevent);
67 eventClick: function (event) {
68 if (tmpevent != undefined) {
69 if (event.id != tmpevent.id) {
70 $('#calendar').fullCalendar('removeEvents', tmpevent.id);
71 $('#calendar').fullCalendar('rerenderEvents');
76 // tmpevent is deleted if a real event is clicked, load event details
77 if (tmpevent == undefined) {
78 var booking_detail_url = booking_detail_prefix + event.id;
81 url: booking_detail_url,
83 success: function (data) {
84 $('#booking_detail_content').html(data);
86 failure: function (data) {
87 alert('Error loading booking details');
90 $('#booking_detail_modal').modal('show');
94 eventDrop: function (event) {
95 sendEventToForm(event);
98 eventResize: function (event) {
99 sendEventToForm(event);