-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFullcalendar.js
More file actions
86 lines (84 loc) · 3.29 KB
/
Fullcalendar.js
File metadata and controls
86 lines (84 loc) · 3.29 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
var CRUD = CRUD || {};
CRUD.FullCalendar = CRUD.FullCalendar ||
{
glEvents: [],
displayFormUrl: '',
initailizeData: function () {
var date = new Date(),
filterJSON = {
$select: 'id,Title,EventDate,EndDate,Description,fAllDayEvent,fRecurrence,ParticipantsPicker/Id,Author/Id',
$expand: 'ParticipantsPicker/Id,Author/Id',
$filter: "((Author/Id eq " + _spPageContextInfo.userId + " or ParticipantsPicker/Id eq " + _spPageContextInfo.userId + ") and (EndDate ge '" + moment(date).subtract(30, 'days').toISOString() + "'))",
$top: 5000
}
CRUD.execute('getDefaultFormUrl', 'APAC Events', "DefaultDisplayFormUrl")
.success(function (data) {
console.info('data loaded', data);
displayFormUrl = data.d.DefaultDisplayFormUrl;
})
.error(function (error) {
console.error('Error occurred while fetching the data...', error);
alert(JSON.stringify(error));
})
CRUD.execute("getListDataByFilter", 'APAC Events', filterJSON, false)
.success(function (data) {
if (data.d != undefined && data.d.results.length > 0) {
var events = data.d.results;
for (var i = 0; i < events.length; i++) {
// alert(events[i].Title);
var startLocalTime = moment.utc(events[i].EventDate).toDate();
startLocalTime = moment(startLocalTime).format('YYYY-MM-DD HH:mm:ss');
var endLocalTime = moment.utc(events[i].EndDate).toDate();
endLocalTime = moment(endLocalTime).format('YYYY-MM-DD HH:mm:ss');
CRUD.FullCalendar.glEvents.push({
id: events[i].ID,
title: events[i].Title,
start: startLocalTime,
end: endLocalTime,
description: events[i].Description,
allDay: events[i].fAllDayEvent,
isRecurrence: events[i].fRecurrence
});
}
}
//Calender initialization
CRUD.FullCalendar.IntFullCalendar();
})
.error(function (error) {
console.error('Error occurred while fetching the data...', error);
alert(JSON.stringify(error));
})
},
IntFullCalendar: function () {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
displayEventEnd: true, // shows end date
nextDayThreshold: "00:00:00", // When an event's end time spans into another day, the minimum time it must be in order for it to render as if it were on that day
timeFormat: 'h:mma ',
theme: false, // Use JQuery UI theme
fixedWeekCount: false, // If true, the calendar will always be 6 weeks tall. If false, the calendar will have either 4, 5, or 6 weeks, depending on the month.
eventLimit: true, // allow "more" link when too many events
eventClick: CRUD.FullCalendar.goToEvent,
//select: selectDate,
events: CRUD.FullCalendar.glEvents,
height: 420,
//eventDrop: eventDropped,
//eventResize: eventResized,
selectable: true,
selectHelper: true,
editable: false
});
},
goToEvent: function (event) {
document.location.href = displayFormUrl + "?ID=" + event.id + "&Source=" + encodeURIComponent(window.location.href);
}
};