Created
April 16, 2011 13:33
-
-
Save markjlorenz/923113 to your computer and use it in GitHub Desktop.
applicable sections copied from _renderEvents to _updateEventsInCalendar
This file contains hidden or 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
/* | |
* update the events rendering in the calendar. Add if does not yet exist. | |
*/ | |
_updateEventInCalendar : function (calEvent) { | |
var self = this; | |
self._cleanEvent(calEvent); | |
if (calEvent.id) { | |
self.element.find(".wc-cal-event").each(function() { | |
if ($(this).data("calEvent").id === calEvent.id || $(this).hasClass("wc-new-cal-event")) { | |
$(this).remove(); | |
} | |
}); | |
} | |
var initialStart = new Date(calEvent.start); | |
var initialEnd = new Date(calEvent.end); | |
var maxHour = self.options.businessHours.limitDisplay ? self.options.businessHours.end : 24; | |
var minHour = self.options.businessHours.limitDisplay ? self.options.businessHours.start : 0; | |
var start = new Date(initialStart); | |
var endDay = initialEnd.getDay(); | |
var $weekDays; | |
while( start.getDay() < endDay ){ | |
calEvent.start = start; | |
//end of this virual calEvent is set to the end of the day | |
calEvent.end.setFullYear(start.getFullYear()); | |
calEvent.end.setMonth(start.getMonth()); | |
calEvent.end.setDate(start.getDate()); | |
calEvent.end.setHours(maxHour); | |
calEvent.end.setMinutes(0); | |
calEvent.end.setSeconds(0); | |
if ( ($weekDays = self._findWeekDayForEvent(calEvent, self.element.find(".wc-grid-row-events .wc-day-column-inner"))) ) { | |
$weekDays.each(function(index, weekDay){ | |
var $weekDay = $(weekDay); | |
var $calEvent = self._renderEvent(calEvent, $weekDay); | |
self._adjustForEventCollisions($weekDay, $calEvent, calEvent, calEvent); | |
self._refreshEventDetails(calEvent, $calEvent); | |
self._positionEvent($weekDay, $calEvent); | |
self._adjustOverlappingEvents($weekDay); | |
}); | |
} | |
//start is set to the begin of the new day | |
start.setDate( start.getDate() + 1 ); | |
start.setHours( minHour ); | |
start.setMinutes( 0 ); | |
start.setSeconds( 0 ); | |
} | |
if ( start < initialEnd ) { | |
calEvent.start = start; | |
calEvent.end = initialEnd; | |
if ( ($weekDays = self._findWeekDayForEvent(calEvent, self.element.find(".wc-grid-row-events .wc-day-column-inner"))) ) { | |
$weekDays.each(function(index, weekDay){ | |
var $weekDay = $(weekDay); | |
var $calEvent = self._renderEvent(calEvent, $weekDay); | |
self._adjustForEventCollisions($weekDay, $calEvent, calEvent, calEvent); | |
self._refreshEventDetails(calEvent, $calEvent); | |
self._positionEvent($weekDay, $calEvent); | |
self._adjustOverlappingEvents($weekDay); | |
}); | |
} | |
} | |
calEvent.start = initialStart; | |
}, | |
_updateEventInCalendarORIGINAL : function (calEvent) { | |
var self = this; | |
self._cleanEvent(calEvent); | |
if (calEvent.id) { | |
self.element.find(".wc-cal-event").each(function() { | |
if ($(this).data("calEvent").id === calEvent.id || $(this).hasClass("wc-new-cal-event")) { | |
$(this).remove(); | |
// return false; //not my comment | |
} | |
}); | |
} | |
var $weekDays = self._findWeekDayForEvent(calEvent, self.element.find(".wc-grid-row-events .wc-day-column-inner")); | |
if ($weekDays) { | |
$weekDays.each(function(index, weekDay){ | |
var $weekDay = $(weekDay); | |
var $calEvent = self._renderEvent(calEvent, $weekDay); | |
self._adjustForEventCollisions($weekDay, $calEvent, calEvent, calEvent); | |
self._refreshEventDetails(calEvent, $calEvent); | |
self._positionEvent($weekDay, $calEvent); | |
self._adjustOverlappingEvents($weekDay); | |
}); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment