Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created June 14, 2014 22:11
Show Gist options
  • Save jaredatch/8f834669a50aafc87415 to your computer and use it in GitHub Desktop.
Save jaredatch/8f834669a50aafc87415 to your computer and use it in GitHub Desktop.
Add past-event and allday-event classes to FullCalendar2 events
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
events: 'YOUR-GOOGLE-XML-FEED-URL',
eventClick: function(event) {
window.open(event.url, 'gcalevent', 'width=900,height=600');
return false;
},
eventRender: function(event, element, view) {
var ntoday = new Date().getTime();
var eventEnd = moment( event.end ).valueOf();
var eventStart = moment( event.start ).valueOf();
if (!event.end){
if (eventStart < ntoday){
element.addClass("past-event");
element.children().addClass("past-event");
}
} else {
if (eventEnd < ntoday){
element.addClass("past-event");
element.children().addClass("past-event");
}
}
if ( event.allDay === true ) {
element.addClass("allday-event");
element.children().addClass("allday-event");
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment