Created
June 14, 2014 22:11
-
-
Save jaredatch/8f834669a50aafc87415 to your computer and use it in GitHub Desktop.
Add past-event and allday-event classes to FullCalendar2 events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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