Added an option to link events by an extra property

This commit is contained in:
root 2011-10-20 12:27:34 +02:00
parent 477c2960a8
commit 4f07a74e69

View file

@ -106,6 +106,18 @@ function View(element, calendar, viewName) {
}
// returns all events with a matching propery value
function eventsByProp(property, value)
{
var id, i, len, events = [];
for(id in eventsByID)
for(i=0, len=eventsByID[id].length; i<len; i++)
if (eventsByID[id][i][property] == value)
events.push(eventsByID[id][i]);
return events;
}
/* Event Elements
------------------------------------------------------------------------------*/
@ -179,7 +191,12 @@ function View(element, calendar, viewName) {
function eventDrop(e, event, dayDelta, minuteDelta, allDay, ev, ui) {
var oldAllDay = event.allDay;
var eventId = event._id;
moveEvents(eventsByID[eventId], dayDelta, minuteDelta, allDay);
var prop = opt('eventGroupProperty') || 'id';
if (prop != 'id')
events = eventsByProp(prop, event[prop]);
else
events = eventsByID[eventId];
moveEvents(events, dayDelta, minuteDelta, allDay);
trigger(
'eventDrop',
e,
@ -189,7 +206,7 @@ function View(element, calendar, viewName) {
allDay,
function() {
// TODO: investigate cases where this inverse technique might not work
moveEvents(eventsByID[eventId], -dayDelta, -minuteDelta, oldAllDay);
moveEvents(events, -dayDelta, -minuteDelta, oldAllDay);
reportEventChange(eventId);
},
ev,
@ -201,7 +218,12 @@ function View(element, calendar, viewName) {
function eventResize(e, event, dayDelta, minuteDelta, ev, ui) {
var eventId = event._id;
elongateEvents(eventsByID[eventId], dayDelta, minuteDelta);
var prop = opt('eventGroupProperty') || 'id';
if (prop != 'id')
events = eventsByProp(prop, event[prop]);
else
events = eventsByID[eventId];
elongateEvents(events, dayDelta, minuteDelta);
trigger(
'eventResize',
e,
@ -210,7 +232,7 @@ function View(element, calendar, viewName) {
minuteDelta,
function() {
// TODO: investigate cases where this inverse technique might not work
elongateEvents(eventsByID[eventId], -dayDelta, -minuteDelta);
elongateEvents(events, -dayDelta, -minuteDelta);
reportEventChange(eventId);
},
ev,