bugfixes for 1.5

fc-mightydate
Adam Shaw 2011-03-19 18:48:20 -07:00
parent 3dd0572c5c
commit f13a29fac3
18 changed files with 124 additions and 87 deletions

View File

@ -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 File

@ -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,7 +324,9 @@ 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) {
@ -329,8 +334,8 @@ function EventManager(options, _sources) {
}
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);
}

View File

@ -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 File

@ -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 File

@ -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 File

@ -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);

View File

@ -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,10 +147,10 @@ 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');
@ -157,12 +158,15 @@ function DayEventRenderer() {
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 File

@ -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'));
}

View File

@ -1,3 +1,14 @@
/*
* FullCalendar v@VERSION Google Calendar Plugin
*
* Copyright (c) 2011 Adam Shaw
* Dual licensed under the MIT and GPL licenses, located in
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
*
* Date: @DATE
*
*/
(function($) {
@ -11,7 +22,7 @@ var applyAll = fc.applyAll;
fc.sourceNormalizers.push(function(sourceOptions) {
if (sourceOptions.dataType == 'gcal' ||
sourceOptions.dataType === undefined &&
(sourceOptions.url || '').indexOf('http://www.google.com/calendar/feeds/') == 0) {
(sourceOptions.url || '').match(/^(http|https):\/\/www.google.com\/calendar\/feeds\//)) {
sourceOptions.dataType = 'gcal';
if (sourceOptions.editable === undefined) {
sourceOptions.editable = false;
@ -48,8 +59,6 @@ function transformOptions(sourceOptions, start, end) {
data: data,
startParam: false,
endParam: false,
cacheParam: false,
cache: false, // TODO: when we remove cacheParam, we can also remove this
success: function(data) {
var events = [];
if (data.feed.entry) {
@ -94,6 +103,7 @@ function transformOptions(sourceOptions, start, end) {
}
// legacy
fc.gcalFeed = function(url, sourceOptions) {
return $.extend({}, sourceOptions, { url: url, dataType: 'gcal' });
};

View File

@ -303,12 +303,13 @@ function markFirstLast(e) {
function setDayID(cell, date) {
cell.each(function(i, _cell) {
_cell.className = _cell.className.replace(/^fc-\w*/, 'fc-' + dayIDs[date.getDay()]);
// TODO: make a way that doesn't rely on order of classes
});
}
function getSkinCss(event, opt) {
var source = event.source;
var source = event.source || {};
var eventColor = event.color;
var sourceColor = source.color;
var optionColor = opt('eventColor');
@ -329,7 +330,7 @@ function getSkinCss(event, opt) {
var textColor =
event.textColor ||
source.textColor ||
opt('textColor');
opt('eventTextColor');
var statements = [];
if (backgroundColor) {
statements.push('background-color:' + backgroundColor);

View File

@ -13,22 +13,27 @@
center: 'title',
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
},
editable: true,
//editable: true,
eventSources: [
{
url: "http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic",
editable: true,
className: 'holiday'
},
/*
$.fullCalendar.gcalFeed(
"http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic",
{
editable: true,
className: ['holiday']
className: 'holiday'
}
),
$.fullCalendar.gcalFeed(
"http://www.google.com/calendar/feeds/b62ul6i1vvfh9vqabsal835028%40group.calendar.google.com/public/basic", // most recent event in Nov 2009
{
editable: true,
currentTimezone: 'America/Edmonton' // 'America/Los_Angeles' 'America/Los Angeles'
}
)
*/
{
url: "https://www.google.com/calendar/feeds/ht3jlfaac5lfd6263ulfh4tql8%40group.calendar.google.com/public/basic",
currentTimezone: 'America/Edmonton', // 'America/Los_Angeles' 'America/Los Angeles'
editable: true
}
],
eventClick: function(event) {
console.log(event.start);
@ -41,12 +46,8 @@
</script>
<style>
.holiday,
.fc-agenda .holiday .fc-event-time,
.holiday a {
background: green;
border-color: green;
color: yellow;
.holiday * {
color: yellow !important;
}
</style>

View File

@ -2,7 +2,7 @@
<html>
<head>
<link rel='stylesheet' type='text/css' href='lib/fancybox/jquery.fancybox-1.2.6.css' />
<script type='text/javascript' src='../lib/jquery-1.4.4.min.js'></script>
<script type='text/javascript' src='../lib/jquery-1.5.min.js'></script>
<script type='text/javascript' src='lib/fancybox/jquery.fancybox-1.2.6.pack.js'></script>
<script type='text/javascript'>

View File

@ -4,7 +4,7 @@
<style>
/* http://code.google.com/p/fullcalendar/issues/detail?id=193 */
.fc .fc-sat, .fc .fc-sun { background-color:red }
.fc .fc-sat, .fc .fc-sun { background-color:red }
</style>
<script type='text/javascript' src='../src/_loader.js?debug'></script>

View File

@ -11,7 +11,8 @@
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
}
},
theme: true
});
console.log(cal.data('fullCalendar'));

View File

@ -96,6 +96,8 @@
event.title = "repeat yo";
//event.editable = false;
event.url = "http://google.com/";
event.color = 'red';
event.textColor = 'green';
cal.fullCalendar('updateEvent', event);
//console.log(cal.fullCalendar('clientEvents', 2));
}

View File

@ -28,7 +28,7 @@
selectable: true,
selectHelper: true,
weekends: false,
//weekends: false,
height: 700,
//contentHeight: 500,
@ -78,10 +78,18 @@
//},
//isRTL: true,
eventColor: 'green',
eventTextColor: 'yellow',
eventBorderColor: 'black',
//eventBackgroundColor: 'red',
events: [
{
title: 'All Day Event',
start: new Date(y, m, 1)
start: new Date(y, m, 1),
color: 'gray',
//backgroundColor: 'red',
textColor: 'white',
borderColor: '#000'
},
{
title: 'Long Event',

View File

@ -69,7 +69,7 @@
start: new Date(y, m, d, 12, 0),
end: new Date(y, m, d, 14, 0),
allDay: false,
//className: 'yellow-event black-text-event',
//className: 'yellow-event black-text-event'
className: ['yellow-event', 'black-text-event']
},
{
@ -132,8 +132,7 @@
/*
,
startParam: 'mystart',
endParam: 'myend',
cacheParam: 'uniq'
endParam: 'myend'
*/
});
});
@ -141,16 +140,19 @@
</script>
<style>
.red-event a {
background: red;
.red-event,
.red-event .fc-event-skin {
background: red !important;
}
.yellow-event a {
background: yellow;
.yellow-event,
.yellow-event .fc-event-skin {
background: yellow !important;
}
.black-text-event a {
color: #000;
.black-text-event,
.black-text-event .fc-event-skin {
color: #000 !important;
}
button {

View File

@ -19,7 +19,7 @@
$(document).ready(function() {
$('#calendar').fullCalendar({
weekends: false,
//weekends: false,
//defaultView: 'agendaWeek',
header: {