Created
May 20, 2014 16:31
-
-
Save matthojo/b4fa7f2614f5a2a7f937 to your computer and use it in GitHub Desktop.
CalendarFull stop overlapping 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
function isOverlapping (event){ | |
// "calendar" on line below should ref the element on which fc has been called | |
var array = calendar.fullCalendar('clientEvents'); | |
for(var i in array){ | |
if(event._id !== undefined && array[i]._id == event._id) { | |
continue | |
} else { | |
var arrayEnd = ((array[i].end === null) ? array[i].start.clone().add('days', 1) : array[i].end) | |
, eventEnd = ((event.end === null) ? event.start.clone().add('days', 1) : event.end) | |
if ((array[i].allDay === true && event.start >= array[i].start && event.start < arrayEnd) // If the event is on the same day as an all day event | |
|| (event.allDay === true && array[i].start >= event.start && array[i].start < eventEnd) // If the all day event is on the same day as an event | |
|| (event.allDay === undefined && array[i].start >= event.start && array[i].start < event.end) // if the event is an all day event on the same day as an all day event | |
|| (event.end > array[i].start && event.start < array[i].end) // If event on the same day | |
){ | |
return true; | |
} | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment