Permalink
Browse files

bugfixes for 1.5

  • Loading branch information...
1 parent 3dd0572 commit f13a29fac38f66cb6a1bbe3e45d055633545426d @arshaw arshaw committed Mar 20, 2011
View
@@ -114,7 +114,7 @@ function Calendar(element, options, eventSources) {
$(window).unbind('resize', windowResize);
header.destroy();
content.remove();
- element.removeClass('fc fc-rtl fc-ui-widget');
+ element.removeClass('fc fc-rtl ui-widget');
}
View
@@ -4,11 +4,12 @@ fc.sourceFetchers = [];
var ajaxDefaults = {
dataType: 'json',
- cache: true // because we are using the cacheParam option (TODO: deprecate)
+ cache: false
};
var eventGUID = 1;
+
function EventManager(options, _sources) {
var t = this;
@@ -74,8 +75,8 @@ function EventManager(options, _sources) {
if (fetchID == currentFetchID) {
if (events) {
for (var i=0; i<events.length; i++) {
- normalizeEvent(events[i], source);
events[i].source = source;
+ normalizeEvent(events[i]);
}
cache = cache.concat(events);
}
@@ -128,16 +129,12 @@ function EventManager(options, _sources) {
var data = $.extend({}, source.data || {});
var startParam = firstDefined(source.startParam, options.startParam);
var endParam = firstDefined(source.endParam, options.endParam);
- var cacheParam = firstDefined(source.cacheParam, options.cacheParam);
if (startParam) {
data[startParam] = Math.round(+rangeStart / 1000);
}
if (endParam) {
data[endParam] = Math.round(+rangeEnd / 1000);
}
- if (cacheParam) {
- data[cacheParam] = +new Date();
- }
pushLoading();
$.ajax($.extend({}, ajaxDefaults, source, {
data: data,
@@ -158,6 +155,8 @@ function EventManager(options, _sources) {
popLoading();
}
}));
+ }else{
+ callback();
}
}
}
@@ -234,16 +233,20 @@ function EventManager(options, _sources) {
e.allDay = event.allDay;
e.className = event.className;
e.editable = event.editable;
- normalizeEvent(e, e.source);
+ e.color = event.color;
+ e.backgroudColor = event.backgroudColor;
+ e.borderColor = event.borderColor;
+ e.textColor = event.textColor;
+ normalizeEvent(e);
}
}
- normalizeEvent(event, event.source);
+ normalizeEvent(event);
reportEvents(cache);
}
function renderEvent(event, stick) {
- normalizeEvent(event, event.source || stickySource);
+ normalizeEvent(event);
if (!event.source) {
if (stick) {
stickySource.events.push(event);
@@ -321,16 +324,18 @@ function EventManager(options, _sources) {
-----------------------------------------------------------------------------*/
- function normalizeEvent(event, source) {
+ function normalizeEvent(event) {
+ var source = event.source || {};
+ var ignoreTimezone = firstDefined(source.ignoreTimezone, options.ignoreTimezone);
event._id = event._id || (event.id === undefined ? '_fc' + eventGUID++ : event.id + '');
if (event.date) {
if (!event.start) {
event.start = event.date;
}
delete event.date;
}
- event._start = cloneDate(event.start = parseDate(event.start, firstDefined(source.ignoreTimezone, options.ignoreTimezone)));
- event.end = parseDate(event.end, options.ignoreTimezone);
+ event._start = cloneDate(event.start = parseDate(event.start, ignoreTimezone));
+ event.end = parseDate(event.end, ignoreTimezone);
if (event.end && event.end <= event.start) {
event.end = null;
}
@@ -356,7 +361,7 @@ function EventManager(options, _sources) {
function normalizeSource(source) {
if (source.className) {
- // TODO: repeate code, same code for event classNames
+ // TODO: repeat code, same code for event classNames
if (typeof source.className == 'string') {
source.className = source.className.split(/\s+/);
}
@@ -371,7 +376,7 @@ function EventManager(options, _sources) {
function isSourcesEqual(source1, source2) {
- return getSourcePrimitive(source1) == getSourcePrimitive(source2);
+ return source1 && source2 && getSourcePrimitive(source1) == getSourcePrimitive(source2);
}
@@ -156,7 +156,7 @@ function AgendaEventRenderer() {
vsideCache={},
hsideCache={},
key, val,
- titleSpan,
+ contentElement,
height,
slotSegmentContainer = getSlotSegmentContainer(),
rtl, dis, dit,
@@ -245,9 +245,9 @@ function AgendaEventRenderer() {
seg.vsides = val === undefined ? (vsideCache[key] = vsides(eventElement, true)) : val;
val = hsideCache[key];
seg.hsides = val === undefined ? (hsideCache[key] = hsides(eventElement, true)) : val;
- titleSpan = eventElement.find('span.fc-event-title');
- if (titleSpan.length) {
- seg.titleTop = titleSpan[0].offsetTop;
+ contentElement = eventElement.find('div.fc-event-content');
+ if (contentElement.length) {
+ seg.contentTop = contentElement[0].offsetTop;
}
}
}
@@ -260,11 +260,11 @@ function AgendaEventRenderer() {
height = Math.max(0, seg.outerHeight - seg.vsides);
eventElement[0].style.height = height + 'px';
event = seg.event;
- if (seg.titleTop !== undefined && height - seg.titleTop < 10) {
+ if (seg.contentTop !== undefined && height - seg.contentTop < 10) {
// not enough room for title, put it in the time header
- eventElement.find('span.fc-event-time')
+ eventElement.find('div.fc-event-time')
.text(formatDate(event.start, opt('timeFormat')) + ' - ' + event.title);
- eventElement.find('span.fc-event-title')
+ eventElement.find('div.fc-event-title')
.remove();
}
trigger('eventAfterRender', event, event, eventElement);
@@ -289,7 +289,10 @@ function AgendaEventRenderer() {
if (seg.isEnd) {
classes.push('fc-corner-bottom');
}
- classes = classes.concat(event.className, event.source.className);
+ classes = classes.concat(event.className);
+ if (event.source) {
+ classes = classes.concat(event.source.className || []);
+ }
if (url) {
html += "a href='" + htmlEscape(event.url) + "'";
}else{
@@ -335,7 +338,7 @@ function AgendaEventRenderer() {
function bindSlotSeg(event, eventElement, seg) {
- var timeElement = eventElement.find('span.fc-event-time');
+ var timeElement = eventElement.find('div.fc-event-time');
if (isEventDraggable(event)) {
draggableSlotEvent(event, eventElement, timeElement);
}
@@ -516,6 +519,7 @@ function AgendaEventRenderer() {
}else{
// either no change or out-of-bounds (draggable has already reverted)
resetElement();
+ eventElement.css('filter', ''); // clear IE opacity side-effects
eventElement.css(origPosition); // sometimes fast drags make event revert to wrong position
updateTimeText(0);
showEvents(event, eventElement);
View
@@ -179,7 +179,7 @@ function AgendaView(element, calendar, viewName) {
"<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
for (i=0; i<colCnt; i++) {
s +=
- "<th class='fc- fc-col" + i + ' ' + headerClass + "'/>";
+ "<th class='fc- fc-col" + i + ' ' + headerClass + "'/>"; // fc- needed for setDayID
}
s +=
"<th class='fc-agenda-gutter " + headerClass + "'>&nbsp;</th>" +
@@ -190,7 +190,7 @@ function AgendaView(element, calendar, viewName) {
"<th class='fc-agenda-axis " + headerClass + "'>&nbsp;</th>";
for (i=0; i<colCnt; i++) {
s +=
- "<td class='fc- fc-col" + i + ' ' + contentClass + "'>" +
+ "<td class='fc- fc-col" + i + ' ' + contentClass + "'>" + // fc- needed for setDayID
"<div>" +
"<div class='fc-day-content'>" +
"<div style='position:relative'>&nbsp;</div>" +
@@ -434,7 +434,7 @@ function AgendaView(element, calendar, viewName) {
function slotClick(ev) {
- if (!opt('selectable')) { // SelectionManager will worry about dayClick
+ if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
var col = Math.min(colCnt-1, Math.floor((ev.pageX - dayTable.offset().left - axisWidth) / colWidth));
var date = colDate(col);
var rowMatch = this.parentNode.className.match(/fc-slot(\d+)/); // TODO: maybe use data
@@ -702,9 +702,8 @@ function AgendaView(element, calendar, viewName) {
title: '',
start: startDate,
end: endDate,
- className: [],
- editable: false,
- source: {}
+ className: ['fc-select-helper'],
+ editable: false
},
rect
));
View
@@ -118,7 +118,8 @@
filter: alpha(opacity=30);
}
-.fc .ui-draggable-dragging .fc-event-bg {
+.fc .ui-draggable-dragging .fc-event-bg, /* TODO: something nicer like .fc-opacity */
+.fc-select-helper .fc-event-bg {
display: none\9; /* for IE6/7/8. nested opacity filters while dragging don't work */
}
View
@@ -129,7 +129,7 @@ function BasicView(element, calendar, viewName) {
"<tr>";
for (i=0; i<colCnt; i++) {
s +=
- "<th class='fc- " + headerClass + "'/>";
+ "<th class='fc- " + headerClass + "'/>"; // need fc- for setDayID
}
s +=
"</tr>" +
@@ -140,7 +140,7 @@ function BasicView(element, calendar, viewName) {
"<tr class='fc-week" + i + "'>";
for (j=0; j<colCnt; j++) {
s +=
- "<td class='fc- " + contentClass + " fc-day" + (i*colCnt+j) + "'>" +
+ "<td class='fc- " + contentClass + " fc-day" + (i*colCnt+j) + "'>" + // need fc- for setDayID
"<div>" +
(showNumbers ?
"<div class='fc-day-number'/>" :
@@ -182,14 +182,14 @@ function BasicView(element, calendar, viewName) {
function updateCells(firstTime) {
- var optimize = !firstTime && rowCnt > 1;
+ var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating?
var month = t.start.getMonth();
var today = clearTime(new Date());
var cell;
var date;
var row;
- if (!optimize) {
+ if (dowDirty) {
headCells.each(function(i, _cell) {
cell = $(_cell);
date = indexDate(i);
@@ -212,7 +212,7 @@ function BasicView(element, calendar, viewName) {
cell.removeClass(tm + '-state-highlight fc-today');
}
cell.find('div.fc-day-number').text(date.getDate());
- if (!optimize) {
+ if (dowDirty) {
setDayID(cell, date);
}
});
@@ -282,7 +282,7 @@ function BasicView(element, calendar, viewName) {
function dayClick(ev) {
- if (!opt('selectable')) { // SelectionManager will worry about dayClick
+ if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
var index = parseInt(this.className.match(/fc\-day(\d+)/)[1]); // TODO: maybe use .data
var date = indexDate(index);
trigger('dayClick', this, date, true, ev);
@@ -126,7 +126,8 @@ function DayEventRenderer() {
var bounds = allDayBounds();
var minLeft = bounds.left;
var maxLeft = bounds.right;
- var cols = []; // don't really like this system (but have to do this b/c RTL works differently in basic vs agenda)
+ var leftCol;
+ var rightCol;
var left;
var right;
var skinCss;
@@ -146,23 +147,26 @@ function DayEventRenderer() {
if (seg.isEnd) {
classes.push('fc-corner-left');
}
- cols[0] = dayOfWeekCol(seg.end.getDay()-1);
- cols[1] = dayOfWeekCol(seg.start.getDay());
- left = seg.isEnd ? colContentLeft(cols[0]) : minLeft;
- right = seg.isStart ? colContentRight(cols[1]) : maxLeft;
+ leftCol = dayOfWeekCol(seg.end.getDay()-1);
+ rightCol = dayOfWeekCol(seg.start.getDay());
+ left = seg.isEnd ? colContentLeft(leftCol) : minLeft;
+ right = seg.isStart ? colContentRight(rightCol) : maxLeft;
}else{
if (seg.isStart) {
classes.push('fc-corner-left');
}
if (seg.isEnd) {
classes.push('fc-corner-right');
}
- cols[0] = dayOfWeekCol(seg.start.getDay());
- cols[1] = dayOfWeekCol(seg.end.getDay()-1);
- left = seg.isStart ? colContentLeft(cols[0]) : minLeft;
- right = seg.isEnd ? colContentRight(cols[1]) : maxLeft;
+ leftCol = dayOfWeekCol(seg.start.getDay());
+ rightCol = dayOfWeekCol(seg.end.getDay()-1);
+ left = seg.isStart ? colContentLeft(leftCol) : minLeft;
+ right = seg.isEnd ? colContentRight(rightCol) : maxLeft;
+ }
+ classes = classes.concat(event.className);
+ if (event.source) {
+ classes = classes.concat(event.source.className || []);
}
- classes = classes.concat(event.className, event.source.className);
url = event.url;
skinCss = getSkinCss(event, opt);
if (url) {
@@ -197,9 +201,8 @@ function DayEventRenderer() {
"</" + (url ? "a" : "div" ) + ">";
seg.left = left;
seg.outerWidth = right - left;
- cols.sort(cmp); // is this still needed now that cols are always left-to-right?
- seg.startCol = cols[0];
- seg.endCol = cols[1] + 1;
+ seg.startCol = leftCol;
+ seg.endCol = rightCol + 1; // needs to be exclusive
}
return html;
}
@@ -409,7 +412,7 @@ function DayEventRenderer() {
var rowCnt = getRowCnt();
var colCnt = getColCnt();
var dis = rtl ? -1 : 1;
- var dit = rtl ? colCnt : 0;
+ var dit = rtl ? colCnt-1 : 0;
var elementTop = element.css('top');
var dayDelta;
var helpers;
View
@@ -76,7 +76,7 @@ function View(element, calendar, viewName) {
function isEventEditable(event) {
- return firstDefined(event.editable, event.source.editable, opt('editable'));
+ return firstDefined(event.editable, (event.source || {}).editable, opt('editable'));
}
Oops, something went wrong.

0 comments on commit f13a29f

Please sign in to comment.