Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
v1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Nov 23, 2009
1 parent d1bc5dc commit 23d9932
Show file tree
Hide file tree
Showing 16 changed files with 247 additions and 156 deletions.
8 changes: 8 additions & 0 deletions changelog.txt
@@ -1,4 +1,12 @@

version 1.4.1 (10/31/09)
- can exclude weekends with new 'weekends' option
- gcal feed 'currentTimezone' option
- bugfixes
- year/month/date option sometimes wouldn't set correctly (depending on current date)
- daylight savings issue caused agenda views to start at 1am (for BST users)
- cleanup of gcal.js code

version 1.4 (10/19/09)
- agendaWeek and agendaDay views
- added some options for agenda views:
Expand Down
21 changes: 20 additions & 1 deletion docs/google-calendar.txt
Expand Up @@ -45,5 +45,24 @@ Here is a list of available options:
* **className** - CSS class to attach to each event from this Google Calendar

* **editable** - whether to allow dragging/resizing (default: ``false``)

* **currentTimezone** - a string like "America/Chicago". Consult http://php.net/manual/en/timezones.php for a full list.

See *gcal.html* in the *examples* directory for a complete example.
See *gcal.html* in the *examples* directory for a complete example.


Timezones Gotchas
-----------------

Sometimes it can be confusing as to why FullCalendar displays event times differently
than the Google Calendar interface. There are the two factors involved in this:

* **the calendar's timezone**, accessed through "Calendar settings" after clicking the arrow next to the calendar's name

* **your Google Account's timezone**, accessed through the "Settings" link at the top right
of the Google Calendar screen (near the "Sign out" link)

When both timezones are the same, you should have no problems. When they are different, FullCalendar will display
times in the *calendar's* timezone. Thus, times will be different than what you see in the Google Calendar interface
because they are being adjusted to the GMT of the calendar. The solution is to use the ``currentTimezone`` option.
If this is set to the same timezone as your Google Account, all dates should appear consistent.
3 changes: 3 additions & 0 deletions docs/index.txt
Expand Up @@ -81,6 +81,9 @@ Basic Options
**allDayDefault**: Boolean, *Default*: ``true``
Determines the default value for each :ref:`CalEvent's <CalEvent>` ``allDay`` property,
when it is unspecified.

**weekends**: Boolean, *Default*: ``true``
Whether to include Saturday/Sunday columns in any of the views.

**weekMode**: String, *Default*: ``'fixed'``
Determines the number of weeks displayed in a month view.
Expand Down
47 changes: 37 additions & 10 deletions src/agenda.js
Expand Up @@ -23,13 +23,23 @@ views.agendaWeek = function(element, options) {
if (delta) {
addDays(date, delta * 7);
}
var visStart = this.visStart = cloneDate(
this.start = addDays(cloneDate(date), -((date.getDay() - options.firstDay + 7) % 7))
),
visEnd = this.visEnd = cloneDate(
this.end = addDays(cloneDate(visStart), 7)
);
if (!options.weekends) {
skipWeekend(visStart);
skipWeekend(visEnd, -1, true);
}
this.title = formatDates(
this.start = this.visStart = addDays(cloneDate(date), -((date.getDay() - options.firstDay + 7) % 7)),
addDays(cloneDate(this.end = this.visEnd = addDays(cloneDate(this.start), 7)), -1),
visStart,
addDays(cloneDate(visEnd), -1),
this.option('titleFormat'),
options
);
this.renderAgenda(7, this.option('columnFormat'), fetchEvents);
this.renderAgenda(options.weekends ? 7 : 5, this.option('columnFormat'), fetchEvents);
}
});
};
Expand All @@ -39,6 +49,9 @@ views.agendaDay = function(element, options) {
render: function(date, delta, fetchEvents) {
if (delta) {
addDays(date, delta);
if (!options.weekends) {
skipWeekend(date, delta < 0 ? -1 : 1);
}
}
this.title = formatDate(date, this.option('titleFormat'), options);
this.start = this.visStart = cloneDate(date, true);
Expand All @@ -55,6 +68,7 @@ function Agenda(element, options, methods) {
axisWidth, colWidth, slotHeight,
cachedDaySegs, cachedSlotSegs,
tm, firstDay,
nwe, // no weekends (int)
rtl, dis, dit, // day index sign / translate
// ...

Expand Down Expand Up @@ -104,7 +118,8 @@ function Agenda(element, options, methods) {
colCnt = c;

// update option-derived variables
tm = options.theme ? 'ui' : 'fc';
tm = options.theme ? 'ui' : 'fc';
nwe = options.weekends ? 0 : 1;
firstDay = options.firstDay;
if (rtl = options.isRTL) {
dis = -1;
Expand Down Expand Up @@ -136,10 +151,13 @@ function Agenda(element, options, methods) {
tm + '-state-default' +
"'>" + formatDate(d, colFormat, options) + "</th>";
addDays(d, dis);
if (nwe) {
skipWeekend(d, dis);
}
}
s+= "<th class='" + tm + "-state-default'>&nbsp;</th></tr>";
s += "<th class='" + tm + "-state-default'>&nbsp;</th></tr>";
if (options.allDaySlot) {
s+= "<tr class='fc-all-day'>" +
s += "<tr class='fc-all-day'>" +
"<th class='fc-axis fc-leftmost " + tm + "-state-default'>" + options.allDayText + "</th>" +
"<td colspan='" + colCnt + "' class='" + tm + "-state-default'>" +
"<div class='fc-day-content'><div>&nbsp;</div></div></td>" +
Expand All @@ -152,7 +170,7 @@ function Agenda(element, options, methods) {
head.find('td').click(slotClick);

// body
d = new Date(1970, 0, 1);
d = zeroDate();
s = "<table>";
for (i=0; d.getDate() != 2; i++) {
minutes = d.getMinutes();
Expand Down Expand Up @@ -183,6 +201,9 @@ function Agenda(element, options, methods) {
(+d == +today ? tm + '-state-highlight fc-today' : 'fc-not-today') +
"'><div class='fc-day-content'><div>&nbsp;</div></div></td>";
addDays(d, dis);
if (nwe) {
skipWeekend(d, dis);
}
}
s += "</tr></table></div>";
bg = $(s).appendTo(element);
Expand All @@ -196,6 +217,9 @@ function Agenda(element, options, methods) {
$(this).text(formatDate(d, colFormat, options));
this.className = this.className.replace(/^fc-\w+(?= )/, 'fc-' + dayIDs[d.getDay()]);
addDays(d, dis);
if (nwe) {
skipWeekend(d, dis);
}
});

// change classes of background stripes
Expand All @@ -214,6 +238,9 @@ function Agenda(element, options, methods) {
.removeClass(tm + '-state-highlight');
}
addDays(d, dis);
if (nwe) {
skipWeekend(d, dis);
}
});

}
Expand All @@ -226,7 +253,7 @@ function Agenda(element, options, methods) {


function resetScroll() {
var d0 = new Date(1970, 0, 1),
var d0 = zeroDate(),
scrollDate = cloneDate(d0);
scrollDate.setHours(options.firstHour);
var go = function() {
Expand Down Expand Up @@ -394,13 +421,13 @@ function Agenda(element, options, methods) {
}
if (leftRounded) {
className += 'fc-corner-left ';
left = bg.find('td:eq('+(((leftDay-firstDay+colCnt)%colCnt)*dis+dit)+') div div').position().left + axisWidth;
left = bg.find('td:eq('+(((leftDay-Math.max(firstDay,nwe)+colCnt)%colCnt)*dis+dit)+') div div').position().left + axisWidth;
}else{
left = axisWidth;
}
if (rightRounded) {
className += 'fc-corner-right ';
right = bg.find('td:eq('+(((rightDay-firstDay+colCnt)%colCnt)*dis+dit)+') div div');
right = bg.find('td:eq('+(((rightDay-Math.max(firstDay,nwe)+colCnt)%colCnt)*dis+dit)+') div div');
right = right.position().left + right.width() + axisWidth;
}else{
right = axisWidth + bg.width();
Expand Down
81 changes: 41 additions & 40 deletions src/gcal.js
Expand Up @@ -16,49 +16,50 @@
options = options || {};

return function(start, end, callback) {
$.getJSON(feedUrl + "?alt=json-in-script&callback=?",
{
'start-min': $.fullCalendar.formatDate(start, 'u'),
'start-max': $.fullCalendar.formatDate(end, 'u'),
'singleevents': true,
'max-results': 9999
},
function(data) {
var events = [];
if (data.feed.entry) {
$.each(data.feed.entry, function(i, entry) {
var startStr = entry['gd$when'][0]['startTime'],
start = $.fullCalendar.parseDate(startStr),
end = $.fullCalendar.parseDate(entry['gd$when'][0]['endTime']),
allDay = startStr.indexOf('T') == -1,
classNames = [],
url;
$.each(entry.link, function() {
if (this.type == 'text/html') {
url = this.href;
}
});
if (allDay) {
end = new Date(end - 1); // make inclusive
var params = {
'start-min': $.fullCalendar.formatDate(start, 'u'),
'start-max': $.fullCalendar.formatDate(end, 'u'),
'singleevents': true,
'max-results': 9999
};
if (options.currentTimezone) {
params.ctz = options.currentTimezone.replace(' ', '_');
}
$.getJSON(feedUrl + "?alt=json-in-script&callback=?", params, function(data) {
var events = [];
if (data.feed.entry) {
$.each(data.feed.entry, function(i, entry) {
var startStr = entry['gd$when'][0]['startTime'],
start = $.fullCalendar.parseISO8601(startStr, true),
end = $.fullCalendar.parseISO8601(entry['gd$when'][0]['endTime'], true),
allDay = startStr.indexOf('T') == -1,
url;
$.each(entry.link, function() {
if (this.type == 'text/html') {
url = this.href;
}
events.push({
id: entry['gCal$uid']['value'],
title: entry['title']['$t'],
url: url,
start: $.fullCalendar.parseDate(entry['gd$when'][0]['startTime']),
end: end,
allDay: allDay,
location: entry['gd$where'][0]['valueString'],
description: entry['content']['$t'],
className: options.className,
editable: options.editable || false
});
});
}
callback(events);
});
if (allDay) {
$.fullCalendar.addDays(end, -1); // make inclusive
}
events.push({
id: entry['gCal$uid']['value'],
title: entry['title']['$t'],
url: url,
start: start,
end: end,
allDay: allDay,
location: entry['gd$where'][0]['valueString'],
description: entry['content']['$t'],
className: options.className,
editable: options.editable || false
});
});
}
callback(events);
});
}

}

})(jQuery);
})(jQuery);

0 comments on commit 23d9932

Please sign in to comment.