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
|
<?php
elgg_load_js('elgg.full_calendar');
// TODO: is there an easy way to avoid embedding JS?
?>
<script>
handleEventClick = function(event) {
if (event.url) {
window.location.href = event.url;
return false;
}
};
handleEventDrop = function(event,dayDelta,minuteDelta,allDay,revertFunc) {
if (!confirm("Are you sure about this change?")) {
revertFunc();
} else {
elgg.action('event_calendar/modify_full_calendar',
{
data: {event_guid: event.guid,dayDelta: dayDelta, minuteDelta: minuteDelta},
success: function (res) {
var success = res.success;
var msg = res.message;
if (!success) {
elgg.register_error(msg,2000);
revertFunc()
}
}
}
);
}
};
getISODate = function(d) {
var year = d.getFullYear();
var month = d.getMonth()+1;
month = month < 10 ? '0' + month : month;
var day = d.getDay()+1;
day = day < 10 ? '0' + day : day;
return year +"-"+month+"-"+day;
}
handleGetEvents = function(start, end, callback) {
var start_date = getISODate(start);
var end_date = getISODate(end);
var url = "event_calendar/get_fullcalendar_events/"+start_date+"/"+end_date+"/<?php echo $vars['filter']; ?>/<?php echo $vars['group_guid']; ?>";
elgg.getJSON(url, {success:
function(events) {
callback(events);
}
});
}
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
month: <?php echo date('n',strtotime($vars['start_date']))-1; ?>,
ignoreTimezone: true,
editable: true,
slotMinutes: 15,
eventDrop: handleEventDrop,
eventClick: handleEventClick,
events: handleGetEvents
});
});
</script>
<div id='calendar'></div>
|