aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2013-03-02 12:41:39 -0300
committerhellekin <hellekin@cepheide.org>2013-03-02 12:41:39 -0300
commitda191e2432b0853bd33515fb2bc33a0fe50952f9 (patch)
tree4d9957e0faf39d34aa9879604067de67b2344018
parentb4806b8c7188708a6ca505aa54374f49f0da0f51 (diff)
downloadelgg-da191e2432b0853bd33515fb2bc33a0fe50952f9.tar.gz
elgg-da191e2432b0853bd33515fb2bc33a0fe50952f9.tar.bz2
Fix timezone shift (thank you d_urruti)
-rw-r--r--views/default/js/event_calendar/fullcalendar.php1417
1 files changed, 708 insertions, 709 deletions
diff --git a/views/default/js/event_calendar/fullcalendar.php b/views/default/js/event_calendar/fullcalendar.php
index a3cd090a0..d0321f64b 100644
--- a/views/default/js/event_calendar/fullcalendar.php
+++ b/views/default/js/event_calendar/fullcalendar.php
@@ -1,4 +1,3 @@
-
//<script>
/**
* @preserve
@@ -16,7 +15,7 @@
* Date: Mon Feb 6 22:40:40 2012 -0800
*
*/
-
+
(function($, undefined) {
@@ -31,20 +30,20 @@ var defaults = {
right: 'today prev,next'
},
weekends: true,
-
+
// editing
//editable: false,
//disableDragging: false,
//disableResizing: false,
-
+
allDayDefault: true,
ignoreTimezone: true,
-
+
// event ajax
lazyFetching: true,
startParam: 'start',
endParam: 'end',
-
+
// time formats
titleFormat: {
month: 'MMMM yyyy',
@@ -59,7 +58,7 @@ var defaults = {
timeFormat: { // for event elements
'': 'h(:mm)t' // default
},
-
+
// locale
isRTL: false,
firstDay: 0,
@@ -77,19 +76,19 @@ var defaults = {
week: 'week',
day: 'day'
},
-
+
// jquery-ui theming
theme: false,
buttonIcons: {
prev: 'circle-triangle-w',
next: 'circle-triangle-e'
},
-
+
//selectable: false,
unselectAuto: true,
-
+
dropAccept: '*'
-
+
};
// right-to-left defaults
@@ -141,8 +140,8 @@ $.fn.fullCalendar = function(options) {
}
return this;
}
-
-
+
+
// would like to have this logic in EventManager, but needs to happen before options are recursively extended
var eventSources = options.eventSources || [];
delete options.eventSources;
@@ -150,25 +149,25 @@ $.fn.fullCalendar = function(options) {
eventSources.push(options.events);
delete options.events;
}
-
+
options = $.extend(true, {},
defaults,
(options.isRTL || options.isRTL===undefined && defaults.isRTL) ? rtlDefaults : {},
options
);
-
-
+
+
this.each(function(i, _element) {
var element = $(_element);
var calendar = new Calendar(element, options, eventSources);
element.data('fullCalendar', calendar); // TODO: look into memory leak implications
calendar.render();
});
-
-
+
+
return this;
-
+
};
@@ -179,11 +178,11 @@ function setDefaults(d) {
-
+
function Calendar(element, options, eventSources) {
var t = this;
-
-
+
+
// exports
t.options = options;
t.render = render;
@@ -208,14 +207,14 @@ function Calendar(element, options, eventSources) {
t.getView = getView;
t.option = option;
t.trigger = trigger;
-
-
+
+
// imports
EventManager.call(t, options, eventSources);
var isFetchNeeded = t.isFetchNeeded;
var fetchEvents = t.fetchEvents;
-
-
+
+
// locals
var _element = element[0];
var header;
@@ -232,16 +231,16 @@ function Calendar(element, options, eventSources) {
var date = new Date();
var events = [];
var _dragElement;
-
-
-
+
+
+
/* Main Rendering
-----------------------------------------------------------------------------*/
-
-
+
+
setYMD(date, options.year, options.month, options.date);
-
-
+
+
function render(inc) {
if (!content) {
initialRender();
@@ -252,8 +251,8 @@ function Calendar(element, options, eventSources) {
renderView(inc);
}
}
-
-
+
+
function initialRender() {
tm = options.theme ? 'ui' : 'fc';
element.addClass('fc');
@@ -277,8 +276,8 @@ function Calendar(element, options, eventSources) {
lateRender();
}
}
-
-
+
+
// called when we know the calendar couldn't be rendered when it was initialized,
// but we think it's ready now
function lateRender() {
@@ -288,42 +287,42 @@ function Calendar(element, options, eventSources) {
}
},0);
}
-
-
+
+
function destroy() {
$(window).unbind('resize', windowResize);
header.destroy();
content.remove();
element.removeClass('fc fc-rtl ui-widget');
}
-
-
-
+
+
+
function elementVisible() {
return _element.offsetWidth !== 0;
}
-
-
+
+
function bodyVisible() {
return $('body')[0].offsetWidth !== 0;
}
-
-
-
+
+
+
/* View Rendering
-----------------------------------------------------------------------------*/
-
+
// TODO: improve view switching (still weird transition in IE, and FF has whiteout problem)
-
+
function changeView(newViewName) {
if (!currentView || newViewName != currentView.name) {
ignoreWindowResize++; // because setMinHeight might change the height before render (and subsequently setSize) is reached
unselect();
-
+
var oldView = currentView;
var newViewElement;
-
+
if (oldView) {
(oldView.beforeHide || noop)(); // called before changing min-height. if called after, scroll state is reset (in Opera)
setMinHeight(content, content.height());
@@ -332,7 +331,7 @@ function Calendar(element, options, eventSources) {
setMinHeight(content, 1); // needs to be 1 (not 0) for IE7, or else view dimensions miscalculated
}
content.css('overflow', 'hidden');
-
+
currentView = viewInstances[newViewName];
if (currentView) {
currentView.element.show();
@@ -344,39 +343,39 @@ function Calendar(element, options, eventSources) {
t // the calendar object
);
}
-
+
if (oldView) {
header.deactivateButton(oldView.name);
}
header.activateButton(newViewName);
-
+
renderView(); // after height has been set, will make absoluteViewElement's position=relative, then set to null
-
+
content.css('overflow', '');
if (oldView) {
setMinHeight(content, 1);
}
-
+
if (!newViewElement) {
(currentView.afterShow || noop)(); // called after setting min-height/overflow, so in final scroll state (for Opera)
}
-
+
ignoreWindowResize--;
}
}
-
-
-
+
+
+
function renderView(inc) {
if (elementVisible()) {
ignoreWindowResize++; // because renderEvents might temporarily change the height before setSize is reached
unselect();
-
+
if (suggestedViewHeight === undefined) {
calcSize();
}
-
+
var forceEventRender = false;
if (!currentView.start || inc || date < currentView.start || date >= currentView.end) {
// view must render an entire new date range (and refetch/render events)
@@ -397,9 +396,9 @@ function Calendar(element, options, eventSources) {
currentView.sizeDirty = false;
currentView.eventsDirty = false;
updateEvents(forceEventRender);
-
+
elementOuterWidth = element.outerWidth();
-
+
header.updateTitle(currentView.title);
var today = new Date();
if (today >= currentView.start && today < currentView.end) {
@@ -407,18 +406,18 @@ function Calendar(element, options, eventSources) {
}else{
header.enableButton('today');
}
-
+
ignoreWindowResize--;
currentView.trigger('viewDisplay', _element);
}
}
-
-
-
+
+
+
/* Resizing
-----------------------------------------------------------------------------*/
-
-
+
+
function updateSize() {
markSizesDirty();
if (elementVisible()) {
@@ -430,15 +429,15 @@ function Calendar(element, options, eventSources) {
currentView.sizeDirty = false;
}
}
-
-
+
+
function markSizesDirty() {
$.each(viewInstances, function(i, inst) {
inst.sizeDirty = true;
});
}
-
-
+
+
function calcSize() {
if (options.contentHeight) {
suggestedViewHeight = options.contentHeight;
@@ -450,8 +449,8 @@ function Calendar(element, options, eventSources) {
suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
}
}
-
-
+
+
function setSize(dateChanged) { // todo: dateChanged?
ignoreWindowResize++;
currentView.setHeight(suggestedViewHeight, dateChanged);
@@ -462,8 +461,8 @@ function Calendar(element, options, eventSources) {
currentView.setWidth(content.width(), dateChanged);
ignoreWindowResize--;
}
-
-
+
+
function windowResize() {
if (!ignoreWindowResize) {
if (currentView.start) { // view has already been rendered
@@ -484,13 +483,13 @@ function Calendar(element, options, eventSources) {
}
}
}
-
-
-
+
+
+
/* Event Fetching/Rendering
-----------------------------------------------------------------------------*/
-
-
+
+
// fetches events if necessary, rerenders events if necessary (or if forced)
function updateEvents(forceRender) {
if (!options.lazyFetching || isFetchNeeded(currentView.visStart, currentView.visEnd)) {
@@ -500,26 +499,26 @@ function Calendar(element, options, eventSources) {
rerenderEvents();
}
}
-
-
+
+
function refetchEvents() {
fetchEvents(currentView.visStart, currentView.visEnd); // will call reportEvents
}
-
-
+
+
// called when event data arrives
function reportEvents(_events) {
events = _events;
rerenderEvents();
}
-
-
+
+
// called when a single event's data has been changed
function reportEventChange(eventID) {
rerenderEvents(eventID);
}
-
-
+
+
// attempts to rerenderEvents
function rerenderEvents(modifiedEventID) {
markEventsDirty();
@@ -529,65 +528,65 @@ function Calendar(element, options, eventSources) {
currentView.eventsDirty = false;
}
}
-
-
+
+
function markEventsDirty() {
$.each(viewInstances, function(i, inst) {
inst.eventsDirty = true;
});
}
-
+
/* Selection
-----------------------------------------------------------------------------*/
-
+
function select(start, end, allDay) {
currentView.select(start, end, allDay===undefined ? true : allDay);
}
-
+
function unselect() { // safe to be called before renderView
if (currentView) {
currentView.unselect();
}
}
-
-
-
+
+
+
/* Date
-----------------------------------------------------------------------------*/
-
-
+
+
function prev() {
renderView(-1);
}
-
-
+
+
function next() {
renderView(1);
}
-
-
+
+
function prevYear() {
addYears(date, -1);
renderView();
}
-
-
+
+
function nextYear() {
addYears(date, 1);
renderView();
}
-
-
+
+
function today() {
date = new Date();
renderView();
}
-
-
+
+
function gotoDate(year, month, dateOfMonth) {
if (year instanceof Date) {
date = cloneDate(year); // provided 1 argument, a Date
@@ -596,8 +595,8 @@ function Calendar(element, options, eventSources) {
}
renderView();
}
-
-
+
+
function incrementDate(years, months, days) {
if (years !== undefined) {
addYears(date, years);
@@ -610,23 +609,23 @@ function Calendar(element, options, eventSources) {
}
renderView();
}
-
-
+
+
function getDate() {
return cloneDate(date);
}
-
-
-
+
+
+
/* Misc
-----------------------------------------------------------------------------*/
-
-
+
+
function getView() {
return currentView;
}
-
-
+
+
function option(name, value) {
if (value === undefined) {
return options[name];
@@ -636,8 +635,8 @@ function Calendar(element, options, eventSources) {
updateSize();
}
}
-
-
+
+
function trigger(name, thisObj) {
if (options[name]) {
return options[name].apply(
@@ -646,12 +645,12 @@ function Calendar(element, options, eventSources) {
);
}
}
-
-
-
+
+
+
/* External Dragging
------------------------------------------------------------------------*/
-
+
if (options.droppable) {
$(document)
.bind('dragstart', function(ev, ui) {
@@ -672,14 +671,14 @@ function Calendar(element, options, eventSources) {
}
});
}
-
+
}
function Header(calendar, options) {
var t = this;
-
-
+
+
// exports
t.render = render;
t.destroy = destroy;
@@ -688,12 +687,12 @@ function Header(calendar, options) {
t.deactivateButton = deactivateButton;
t.disableButton = disableButton;
t.enableButton = enableButton;
-
-
+
+
// locals
var element = $([]);
var tm;
-
+
function render() {
@@ -710,13 +709,13 @@ function Header(calendar, options) {
return element;
}
}
-
-
+
+
function destroy() {
element.remove();
}
-
-
+
+
function renderSection(position) {
var e = $("<td class='fc-header-" + position + "'/>");
var buttonStr = options.header[position];
@@ -807,32 +806,32 @@ function Header(calendar, options) {
}
return e;
}
-
-
+
+
function updateTitle(html) {
element.find('h2')
.html(html);
}
-
-
+
+
function activateButton(buttonName) {
element.find('span.fc-button-' + buttonName)
.addClass(tm + '-state-active');
}
-
-
+
+
function deactivateButton(buttonName) {
element.find('span.fc-button-' + buttonName)
.removeClass(tm + '-state-active');
}
-
-
+
+
function disableButton(buttonName) {
element.find('span.fc-button-' + buttonName)
.addClass(tm + '-state-disabled');
}
-
-
+
+
function enableButton(buttonName) {
element.find('span.fc-button-' + buttonName)
.removeClass(tm + '-state-disabled');
@@ -854,8 +853,8 @@ var eventGUID = 1;
function EventManager(options, _sources) {
var t = this;
-
-
+
+
// exports
t.isFetchNeeded = isFetchNeeded;
t.fetchEvents = fetchEvents;
@@ -866,14 +865,14 @@ function EventManager(options, _sources) {
t.removeEvents = removeEvents;
t.clientEvents = clientEvents;
t.normalizeEvent = normalizeEvent;
-
-
+
+
// imports
var trigger = t.trigger;
var getView = t.getView;
var reportEvents = t.reportEvents;
-
-
+
+
// locals
var stickySource = { events: [] };
var sources = [ stickySource ];
@@ -882,23 +881,23 @@ function EventManager(options, _sources) {
var pendingSourceCnt = 0;
var loadingLevel = 0;
var cache = [];
-
-
+
+
for (var i=0; i<_sources.length; i++) {
_addEventSource(_sources[i]);
}
-
-
-
+
+
+
/* Fetching
-----------------------------------------------------------------------------*/
-
-
+
+
function isFetchNeeded(start, end) {
return !rangeStart || start < rangeStart || end > rangeEnd;
}
-
-
+
+
function fetchEvents(start, end) {
rangeStart = start;
rangeEnd = end;
@@ -910,8 +909,8 @@ function EventManager(options, _sources) {
fetchEventSource(sources[i], fetchID);
}
}
-
-
+
+
function fetchEventSource(source, fetchID) {
_fetchEventSource(source, function(events) {
if (fetchID == currentFetchID) {
@@ -929,8 +928,8 @@ function EventManager(options, _sources) {
}
});
}
-
-
+
+
function _fetchEventSource(source, callback) {
var i;
var fetchers = fc.sourceFetchers;
@@ -1002,12 +1001,12 @@ function EventManager(options, _sources) {
}
}
}
-
-
-
+
+
+
/* Sources
-----------------------------------------------------------------------------*/
-
+
function addEventSource(source) {
source = _addEventSource(source);
@@ -1016,8 +1015,8 @@ function EventManager(options, _sources) {
fetchEventSource(source, currentFetchID); // will eventually call reportEvents
}
}
-
-
+
+
function _addEventSource(source) {
if ($.isFunction(source) || $.isArray(source)) {
source = { events: source };
@@ -1031,7 +1030,7 @@ function EventManager(options, _sources) {
return source;
}
}
-
+
function removeEventSource(source) {
sources = $.grep(sources, function(src) {
@@ -1043,13 +1042,13 @@ function EventManager(options, _sources) {
});
reportEvents(cache);
}
-
-
-
+
+
+
/* Manipulation
-----------------------------------------------------------------------------*/
-
-
+
+
function updateEvent(event) { // update an existing event
var i, len = cache.length, e,
defaultEventEnd = getView().defaultEventEnd, // getView???
@@ -1085,8 +1084,8 @@ function EventManager(options, _sources) {
normalizeEvent(event);
reportEvents(cache);
}
-
-
+
+
function renderEvent(event, stick) {
normalizeEvent(event);
if (!event.source) {
@@ -1098,8 +1097,8 @@ function EventManager(options, _sources) {
}
reportEvents(cache);
}
-
-
+
+
function removeEvents(filter) {
if (!filter) { // remove all
cache = [];
@@ -1126,8 +1125,8 @@ function EventManager(options, _sources) {
}
reportEvents(cache);
}
-
-
+
+
function clientEvents(filter) {
if ($.isFunction(filter)) {
return $.grep(cache, filter);
@@ -1140,32 +1139,32 @@ function EventManager(options, _sources) {
}
return cache; // else, return all
}
-
-
-
+
+
+
/* Loading State
-----------------------------------------------------------------------------*/
-
-
+
+
function pushLoading() {
if (!loadingLevel++) {
trigger('loading', null, true);
}
}
-
-
+
+
function popLoading() {
if (!--loadingLevel) {
trigger('loading', null, false);
}
}
-
-
-
+
+
+
/* Event Normalization
-----------------------------------------------------------------------------*/
-
-
+
+
function normalizeEvent(event) {
var source = event.source || {};
var ignoreTimezone = firstDefined(source.ignoreTimezone, options.ignoreTimezone);
@@ -1194,13 +1193,13 @@ function EventManager(options, _sources) {
}
// TODO: if there is no start date, return false to indicate an invalid event
}
-
-
-
+
+
+
/* Utils
------------------------------------------------------------------------------*/
-
-
+
+
function normalizeSource(source) {
if (source.className) {
// TODO: repeat code, same code for event classNames
@@ -1215,13 +1214,13 @@ function EventManager(options, _sources) {
normalizers[i](source);
}
}
-
-
+
+
function isSourcesEqual(source1, source2) {
return source1 && source2 && getSourcePrimitive(source1) == getSourcePrimitive(source2);
}
-
-
+
+
function getSourcePrimitive(source) {
return ((typeof source == 'object') ? (source.events || source.url) : '') || source;
}
@@ -1247,7 +1246,7 @@ var dayIDs = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'],
DAY_MS = 86400000,
HOUR_MS = 3600000,
MINUTE_MS = 60000;
-
+
function addYears(d, n, keepTime) {
d.setFullYear(d.getFullYear() + n);
@@ -1310,7 +1309,7 @@ function addMinutes(d, n) {
function clearTime(d) {
d.setHours(0);
d.setMinutes(0);
- d.setSeconds(0);
+ d.setSeconds(0);
d.setMilliseconds(0);
return d;
}
@@ -1558,10 +1557,10 @@ var dateFormatters = {
ss : function(d) { return zeroPad(d.getSeconds()) },
m : function(d) { return d.getMinutes() },
mm : function(d) { return zeroPad(d.getMinutes()) },
- h : function(d) { return d.getHours() % 12 || 12 },
- hh : function(d) { return zeroPad(d.getHours() % 12 || 12) },
- H : function(d) { return d.getHours() },
- HH : function(d) { return zeroPad(d.getHours()) },
+ h : function(d) { return d.getUTCHours() % 12 || 12 },
+ hh : function(d) { return zeroPad(d.getUTCHours() % 12 || 12) },
+ H : function(d) { return d.getUTCHours() },
+ HH : function(d) { return zeroPad(d.getUTCHours()) },
d : function(d) { return d.getDate() },
dd : function(d) { return zeroPad(d.getDate()) },
ddd : function(d,o) { return o.dayNamesShort[d.getDay()] },
@@ -1572,10 +1571,10 @@ var dateFormatters = {
MMMM: function(d,o) { return o.monthNames[d.getMonth()] },
yy : function(d) { return (d.getFullYear()+'').substring(2) },
yyyy: function(d) { return d.getFullYear() },
- t : function(d) { return d.getHours() < 12 ? 'a' : 'p' },
- tt : function(d) { return d.getHours() < 12 ? 'am' : 'pm' },
- T : function(d) { return d.getHours() < 12 ? 'A' : 'P' },
- TT : function(d) { return d.getHours() < 12 ? 'AM' : 'PM' },
+ t : function(d) { return d.getUTCHours() < 12 ? 'a' : 'p' },
+ tt : function(d) { return d.getUTCHours() < 12 ? 'am' : 'pm' },
+ T : function(d) { return d.getUTCHours() < 12 ? 'A' : 'P' },
+ TT : function(d) { return d.getUTCHours() < 12 ? 'AM' : 'PM' },
u : function(d) { return formatDate(d, "yyyy-MM-dd'T'HH:mm:ss'Z'") },
S : function(d) {
var date = d.getDate();
@@ -1660,7 +1659,7 @@ function sliceSegs(events, visEventEnds, start, end) {
msLength: segEnd - segStart
});
}
- }
+ }
return segs.sort(segCmp);
}
@@ -1963,20 +1962,20 @@ fcViews.month = MonthView;
function MonthView(element, calendar) {
var t = this;
-
-
+
+
// exports
t.render = render;
-
-
+
+
// imports
BasicView.call(t, element, calendar, 'month');
var opt = t.opt;
var renderBasic = t.renderBasic;
var formatDate = calendar.formatDate;
-
-
-
+
+
+
function render(date, delta) {
if (delta) {
addMonths(date, delta);
@@ -2007,28 +2006,28 @@ function MonthView(element, calendar) {
t.visEnd = visEnd;
renderBasic(6, rowCnt, nwe ? 5 : 7, true);
}
-
-
+
+
}
fcViews.basicWeek = BasicWeekView;
function BasicWeekView(element, calendar) {
var t = this;
-
-
+
+
// exports
t.render = render;
-
-
+
+
// imports
BasicView.call(t, element, calendar, 'basicWeek');
var opt = t.opt;
var renderBasic = t.renderBasic;
var formatDates = calendar.formatDates;
-
-
-
+
+
+
function render(date, delta) {
if (delta) {
addDays(date, delta * 7);
@@ -2053,8 +2052,8 @@ function BasicWeekView(element, calendar) {
t.visEnd = visEnd;
renderBasic(1, 1, weekends ? 7 : 5, false);
}
-
-
+
+
}
fcViews.basicDay = BasicDayView;
@@ -2064,20 +2063,20 @@ fcViews.basicDay = BasicDayView;
function BasicDayView(element, calendar) {
var t = this;
-
-
+
+
// exports
t.render = render;
-
-
+
+
// imports
BasicView.call(t, element, calendar, 'basicDay');
var opt = t.opt;
var renderBasic = t.renderBasic;
var formatDate = calendar.formatDate;
-
-
-
+
+
+
function render(date, delta) {
if (delta) {
addDays(date, delta);
@@ -2090,8 +2089,8 @@ function BasicDayView(element, calendar) {
t.end = t.visEnd = addDays(cloneDate(t.start), 1);
renderBasic(1, 1, 1, false);
}
-
-
+
+
}
setDefaults({
@@ -2101,8 +2100,8 @@ setDefaults({
function BasicView(element, calendar, viewName) {
var t = this;
-
-
+
+
// exports
t.renderBasic = renderBasic;
t.setHeight = setHeight;
@@ -2128,8 +2127,8 @@ function BasicView(element, calendar, viewName) {
t.getColCnt = function() { return colCnt };
t.getColWidth = function() { return colWidth };
t.getDaySegmentContainer = function() { return daySegmentContainer };
-
-
+
+
// imports
View.call(t, element, calendar, viewName);
OverlayManager.call(t);
@@ -2142,10 +2141,10 @@ function BasicView(element, calendar, viewName) {
var clearOverlays = t.clearOverlays;
var daySelectionMousedown = t.daySelectionMousedown;
var formatDate = calendar.formatDate;
-
-
+
+
// locals
-
+
var head;
var headCells;
var body;
@@ -2154,31 +2153,31 @@ function BasicView(element, calendar, viewName) {
var bodyFirstCells;
var bodyCellTopInners;
var daySegmentContainer;
-
+
var viewWidth;
var viewHeight;
var colWidth;
-
+
var rowCnt, colCnt;
var coordinateGrid;
var hoverListener;
var colContentPositions;
-
+
var rtl, dis, dit;
var firstDay;
var nwe;
var tm;
var colFormat;
-
-
-
+
+
+
/* Rendering
------------------------------------------------------------*/
-
-
+
+
disableTextSelection(element.addClass('fc-grid'));
-
-
+
+
function renderBasic(maxr, r, c, showNumbers) {
rowCnt = r;
colCnt = c;
@@ -2191,9 +2190,9 @@ function BasicView(element, calendar, viewName) {
}
updateCells(firstTime);
}
-
-
-
+
+
+
function updateOptions() {
rtl = opt('isRTL');
if (rtl) {
@@ -2208,16 +2207,16 @@ function BasicView(element, calendar, viewName) {
tm = opt('theme') ? 'ui' : 'fc';
colFormat = opt('columnFormat');
}
-
-
-
+
+
+
function buildSkeleton(maxRowCnt, showNumbers) {
var s;
var headerClass = tm + "-widget-header";
var contentClass = tm + "-widget-content";
var i, j;
var table;
-
+
s =
"<table class='fc-border-separate' style='width:100%' cellspacing='0'>" +
"<thead>" +
@@ -2254,7 +2253,7 @@ function BasicView(element, calendar, viewName) {
"</tbody>" +
"</table>";
table = $(s).appendTo(element);
-
+
head = table.find('thead');
headCells = head.find('th');
body = table.find('tbody');
@@ -2262,20 +2261,20 @@ function BasicView(element, calendar, viewName) {
bodyCells = body.find('td');
bodyFirstCells = bodyCells.filter(':first-child');
bodyCellTopInners = bodyRows.eq(0).find('div.fc-day-content div');
-
+
markFirstLast(head.add(head.find('tr'))); // marks first+last tr/th's
markFirstLast(bodyRows); // marks first+last td's
bodyRows.eq(0).addClass('fc-first'); // fc-last is done in updateCells
-
+
dayBind(bodyCells);
-
+
daySegmentContainer =
$("<div style='position:absolute;z-index:8;top:0;left:0'/>")
.appendTo(element);
}
-
-
-
+
+
+
function updateCells(firstTime) {
var dowDirty = firstTime || rowCnt == 1; // could the cells' day-of-weeks need updating?
var month = t.start.getMonth();
@@ -2283,7 +2282,7 @@ function BasicView(element, calendar, viewName) {
var cell;
var date;
var row;
-
+
if (dowDirty) {
headCells.each(function(i, _cell) {
cell = $(_cell);
@@ -2292,7 +2291,7 @@ function BasicView(element, calendar, viewName) {
setDayID(cell, date);
});
}
-
+
bodyCells.each(function(i, _cell) {
cell = $(_cell);
date = indexDate(i);
@@ -2311,7 +2310,7 @@ function BasicView(element, calendar, viewName) {
setDayID(cell, date);
}
});
-
+
bodyRows.each(function(i, _row) {
row = $(_row);
if (i < rowCnt) {
@@ -2326,24 +2325,24 @@ function BasicView(element, calendar, viewName) {
}
});
}
-
-
-
+
+
+
function setHeight(height) {
viewHeight = height;
-
+
var bodyHeight = viewHeight - head.height();
var rowHeight;
var rowHeightLast;
var cell;
-
+
if (opt('weekMode') == 'variable') {
rowHeight = rowHeightLast = Math.floor(bodyHeight / (rowCnt==1 ? 2 : 6));
}else{
rowHeight = Math.floor(bodyHeight / rowCnt);
rowHeightLast = bodyHeight - rowHeight * (rowCnt-1);
}
-
+
bodyFirstCells.each(function(i, _cell) {
if (i < rowCnt) {
cell = $(_cell);
@@ -2353,29 +2352,29 @@ function BasicView(element, calendar, viewName) {
);
}
});
-
+
}
-
-
+
+
function setWidth(width) {
viewWidth = width;
colContentPositions.clear();
colWidth = Math.floor(viewWidth / colCnt);
setOuterWidth(headCells.slice(0, -1), colWidth);
}
-
-
-
+
+
+
/* Day clicking and binding
-----------------------------------------------------------*/
-
-
+
+
function dayBind(days) {
days.click(dayClick)
.mousedown(daySelectionMousedown);
}
-
-
+
+
function dayClick(ev) {
if (!opt('selectable')) { // if selectable, SelectionManager will worry about dayClick
var index = parseInt(this.className.match(/fc\-day(\d+)/)[1]); // TODO: maybe use .data
@@ -2383,13 +2382,13 @@ function BasicView(element, calendar, viewName) {
trigger('dayClick', this, date, true, ev);
}
}
-
-
-
+
+
+
/* Semi-transparent Overlay Helpers
------------------------------------------------------*/
-
-
+
+
function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive
if (refreshCoordinateGrid) {
coordinateGrid.build();
@@ -2416,46 +2415,46 @@ function BasicView(element, calendar, viewName) {
addDays(rowEnd, 7);
}
}
-
-
+
+
function renderCellOverlay(row0, col0, row1, col1) { // row1,col1 is inclusive
var rect = coordinateGrid.rect(row0, col0, row1, col1, element);
return renderOverlay(rect, element);
}
-
-
-
+
+
+
/* Selection
-----------------------------------------------------------------------*/
-
-
+
+
function defaultSelectionEnd(startDate, allDay) {
return cloneDate(startDate);
}
-
-
+
+
function renderSelection(startDate, endDate, allDay) {
renderDayOverlay(startDate, addDays(cloneDate(endDate), 1), true); // rebuild every time???
}
-
-
+
+
function clearSelection() {
clearOverlays();
}
-
-
+
+
function reportDayClick(date, allDay, ev) {
var cell = dateCell(date);
var _element = bodyCells[cell.row*colCnt + cell.col];
trigger('dayClick', _element, date, allDay, ev);
}
-
-
-
+
+
+
/* External Dragging
-----------------------------------------------------------------------*/
-
-
+
+
function dragStart(_dragElement, ev, ui) {
hoverListener.start(function(cell) {
clearOverlays();
@@ -2464,8 +2463,8 @@ function BasicView(element, calendar, viewName) {
}
}, ev);
}
-
-
+
+
function dragStop(_dragElement, ev, ui) {
var cell = hoverListener.stop();
clearOverlays();
@@ -2474,18 +2473,18 @@ function BasicView(element, calendar, viewName) {
trigger('drop', _dragElement, d, true, ev, ui);
}
}
-
-
-
+
+
+
/* Utilities
--------------------------------------------------------*/
-
-
+
+
function defaultEventEnd(event) {
return cloneDate(event.start);
}
-
-
+
+
coordinateGrid = new CoordinateGrid(function(rows, cols) {
var e, n, p;
headCells.each(function(i, _e) {
@@ -2511,85 +2510,85 @@ function BasicView(element, calendar, viewName) {
});
p[1] = n + e.outerHeight();
});
-
-
+
+
hoverListener = new HoverListener(coordinateGrid);
-
-
+
+
colContentPositions = new HorizontalPositionCache(function(col) {
return bodyCellTopInners.eq(col);
});
-
-
+
+
function colContentLeft(col) {
return colContentPositions.left(col);
}
-
-
+
+
function colContentRight(col) {
return colContentPositions.right(col);
}
-
-
-
-
+
+
+
+
function dateCell(date) {
return {
row: Math.floor(dayDiff(date, t.visStart) / 7),
col: dayOfWeekCol(date.getDay())
};
}
-
-
+
+
function cellDate(cell) {
return _cellDate(cell.row, cell.col);
}
-
-
+
+
function _cellDate(row, col) {
return addDays(cloneDate(t.visStart), row*7 + col*dis+dit);
// what about weekends in middle of week?
}
-
-
+
+
function indexDate(index) {
return _cellDate(Math.floor(index/colCnt), index%colCnt);
}
-
-
+
+
function dayOfWeekCol(dayOfWeek) {
return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt) * dis + dit;
}
-
-
-
-
+
+
+
+
function allDayRow(i) {
return bodyRows.eq(i);
}
-
-
+
+
function allDayBounds(i) {
return {
left: 0,
right: viewWidth
};
}
-
-
+
+
}
function BasicEventRenderer() {
var t = this;
-
-
+
+
// exports
t.renderEvents = renderEvents;
t.compileDaySegs = compileSegs; // for DayEventRenderer
t.clearEvents = clearEvents;
t.bindDaySeg = bindDaySeg;
-
-
+
+
// imports
DayEventRenderer.call(t);
var opt = t.opt;
@@ -2611,25 +2610,25 @@ function BasicEventRenderer() {
var getColCnt = t.getColCnt;
var renderDaySegs = t.renderDaySegs;
var resizableDayEvent = t.resizableDayEvent;
-
-
-
+
+
+
/* Rendering
--------------------------------------------------------------------*/
-
-
+
+
function renderEvents(events, modifiedEventId) {
reportEvents(events);
renderDaySegs(compileSegs(events), modifiedEventId);
}
-
-
+
+
function clearEvents() {
reportEventClear();
getDaySegmentContainer().empty();
}
-
-
+
+
function compileSegs(events) {
var rowCnt = getRowCnt(),
colCnt = getColCnt(),
@@ -2656,8 +2655,8 @@ function BasicEventRenderer() {
}
return segs;
}
-
-
+
+
function bindDaySeg(event, eventElement, seg) {
if (isEventDraggable(event)) {
draggableDayEvent(event, eventElement);
@@ -2668,13 +2667,13 @@ function BasicEventRenderer() {
eventElementHandlers(event, eventElement);
// needs to be after, because resizableDayEvent might stopImmediatePropagation on click
}
-
-
-
+
+
+
/* Dragging
----------------------------------------------------------------------------*/
-
-
+
+
function draggableDayEvent(event, eventElement) {
var hoverListener = getHoverListener();
var dayDelta;
@@ -2724,20 +2723,20 @@ fcViews.agendaWeek = AgendaWeekView;
function AgendaWeekView(element, calendar) {
var t = this;
-
-
+
+
// exports
t.render = render;
-
-
+
+
// imports
AgendaView.call(t, element, calendar, 'agendaWeek');
var opt = t.opt;
var renderAgenda = t.renderAgenda;
var formatDates = calendar.formatDates;
-
-
-
+
+
+
function render(date, delta) {
if (delta) {
addDays(date, delta * 7);
@@ -2762,7 +2761,7 @@ function AgendaWeekView(element, calendar) {
t.visEnd = visEnd;
renderAgenda(weekends ? 7 : 5);
}
-
+
}
@@ -2770,20 +2769,20 @@ fcViews.agendaDay = AgendaDayView;
function AgendaDayView(element, calendar) {
var t = this;
-
-
+
+
// exports
t.render = render;
-
-
+
+
// imports
AgendaView.call(t, element, calendar, 'agendaDay');
var opt = t.opt;
var renderAgenda = t.renderAgenda;
var formatDate = calendar.formatDate;
-
-
-
+
+
+
function render(date, delta) {
if (delta) {
addDays(date, delta);
@@ -2798,7 +2797,7 @@ function AgendaDayView(element, calendar) {
t.end = t.visEnd = end;
renderAgenda(1);
}
-
+
}
@@ -2826,8 +2825,8 @@ setDefaults({
function AgendaView(element, calendar, viewName) {
var t = this;
-
-
+
+
// exports
t.renderAgenda = renderAgenda;
t.setWidth = setWidth;
@@ -2861,8 +2860,8 @@ function AgendaView(element, calendar, viewName) {
t.reportDayClick = reportDayClick; // selection mousedown hack
t.dragStart = dragStart;
t.dragStop = dragStop;
-
-
+
+
// imports
View.call(t, element, calendar, viewName);
OverlayManager.call(t);
@@ -2878,10 +2877,10 @@ function AgendaView(element, calendar, viewName) {
var daySelectionMousedown = t.daySelectionMousedown;
var slotSegHtml = t.slotSegHtml;
var formatDate = calendar.formatDate;
-
-
+
+
// locals
-
+
var dayTable;
var dayHead;
var dayHeadCells;
@@ -2902,7 +2901,7 @@ function AgendaView(element, calendar, viewName) {
var axisFirstCells;
var gutterCells;
var selectionHelper;
-
+
var viewWidth;
var viewHeight;
var axisWidth;
@@ -2910,30 +2909,30 @@ function AgendaView(element, calendar, viewName) {
var gutterWidth;
var slotHeight; // TODO: what if slotHeight changes? (see issue 650)
var savedScrollTop;
-
+
var colCnt;
var slotCnt;
var coordinateGrid;
var hoverListener;
var colContentPositions;
var slotTopCache = {};
-
+
var tm;
var firstDay;
var nwe; // no weekends (int)
var rtl, dis, dit; // day index sign / translate
var minMinute, maxMinute;
var colFormat;
-
-
+
+
/* Rendering
-----------------------------------------------------------------------------*/
-
-
+
+
disableTextSelection(element.addClass('fc-agenda'));
-
-
+
+
function renderAgenda(c) {
colCnt = c;
updateOptions();
@@ -2944,9 +2943,9 @@ function AgendaView(element, calendar, viewName) {
}
updateCells();
}
-
-
-
+
+
+
function updateOptions() {
tm = opt('theme') ? 'ui' : 'fc';
nwe = opt('weekends') ? 0 : 1;
@@ -2962,9 +2961,9 @@ function AgendaView(element, calendar, viewName) {
maxMinute = parseTime(opt('maxTime'));
colFormat = opt('columnFormat');
}
-
-
-
+
+
+
function buildSkeleton() {
var headerClass = tm + "-widget-header";
var contentClass = tm + "-widget-content";
@@ -2974,7 +2973,7 @@ function AgendaView(element, calendar, viewName) {
var maxd;
var minutes;
var slotNormal = opt('slotMinutes') % 15 == 0;
-
+
s =
"<table style='width:100%' class='fc-agenda-days fc-border-separate' cellspacing='0'>" +
"<thead>" +
@@ -3014,23 +3013,23 @@ function AgendaView(element, calendar, viewName) {
dayBodyCellInners = dayBodyCells.find('div.fc-day-content div');
dayBodyFirstCell = dayBodyCells.eq(0);
dayBodyFirstCellStretcher = dayBodyFirstCell.find('> div');
-
+
markFirstLast(dayHead.add(dayHead.find('tr')));
markFirstLast(dayBody.add(dayBody.find('tr')));
-
+
axisFirstCells = dayHead.find('th:first');
gutterCells = dayTable.find('.fc-agenda-gutter');
-
+
slotLayer =
$("<div style='position:absolute;z-index:2;left:0;width:100%'/>")
.appendTo(element);
-
+
if (opt('allDaySlot')) {
-
+
daySegmentContainer =
$("<div style='position:absolute;z-index:8;top:0;left:0'/>")
.appendTo(slotLayer);
-
+
s =
"<table style='width:100%' class='fc-agenda-allday' cellspacing='0'>" +
"<tr>" +
@@ -3043,36 +3042,36 @@ function AgendaView(element, calendar, viewName) {
"</table>";
allDayTable = $(s).appendTo(slotLayer);
allDayRow = allDayTable.find('tr');
-
+
dayBind(allDayRow.find('td'));
-
+
axisFirstCells = axisFirstCells.add(allDayTable.find('th:first'));
gutterCells = gutterCells.add(allDayTable.find('th.fc-agenda-gutter'));
-
+
slotLayer.append(
"<div class='fc-agenda-divider " + headerClass + "'>" +
"<div class='fc-agenda-divider-inner'/>" +
"</div>"
);
-
+
}else{
-
+
daySegmentContainer = $([]); // in jQuery 1.4, we can just do $()
-
+
}
-
+
slotScroller =
$("<div style='position:absolute;width:100%;overflow-x:hidden;overflow-y:auto'/>")
.appendTo(slotLayer);
-
+
slotContent =
$("<div style='position:relative;width:100%;overflow:hidden'/>")
.appendTo(slotScroller);
-
+
slotSegmentContainer =
$("<div style='position:absolute;z-index:8;top:0;left:0'/>")
.appendTo(slotContent);
-
+
s =
"<table class='fc-agenda-slots' style='width:100%' cellspacing='0'>" +
"<tbody>";
@@ -3099,14 +3098,14 @@ function AgendaView(element, calendar, viewName) {
"</table>";
slotTable = $(s).appendTo(slotContent);
slotTableFirstInner = slotTable.find('div:first');
-
+
slotBind(slotTable.find('td'));
-
+
axisFirstCells = axisFirstCells.add(slotTable.find('th:first'));
}
-
-
-
+
+
+
function updateCells() {
var i;
var headCell;
@@ -3126,43 +3125,43 @@ function AgendaView(element, calendar, viewName) {
setDayID(headCell.add(bodyCell), date);
}
}
-
-
-
+
+
+
function setHeight(height, dateChanged) {
if (height === undefined) {
height = viewHeight;
}
viewHeight = height;
slotTopCache = {};
-
+
var headHeight = dayBody.position().top;
var allDayHeight = slotScroller.position().top; // including divider
var bodyHeight = Math.min( // total body height, including borders
height - headHeight, // when scrollbars
slotTable.height() + allDayHeight + 1 // when no scrollbars. +1 for bottom border
);
-
+
dayBodyFirstCellStretcher
.height(bodyHeight - vsides(dayBodyFirstCell));
-
+
slotLayer.css('top', headHeight);
-
+
slotScroller.height(bodyHeight - allDayHeight - 1);
-
+
slotHeight = slotTableFirstInner.height() + 1; // +1 for border
-
+
if (dateChanged) {
resetScroll();
}
}
-
-
-
+
+
+
function setWidth(width) {
viewWidth = width;
colContentPositions.clear();
-
+
axisWidth = 0;
setOuterWidth(
axisFirstCells
@@ -3172,10 +3171,10 @@ function AgendaView(element, calendar, viewName) {
}),
axisWidth
);
-
+
var slotTableWidth = slotScroller[0].clientWidth; // needs to be done after axisWidth (for IE7)
//slotTable.width(slotTableWidth);
-
+
gutterWidth = slotScroller.width() - slotTableWidth;
if (gutterWidth) {
setOuterWidth(gutterCells, gutterWidth);
@@ -3189,11 +3188,11 @@ function AgendaView(element, calendar, viewName) {
.prev()
.addClass('fc-last');
}
-
+
colWidth = Math.floor((slotTableWidth - axisWidth) / colCnt);
setOuterWidth(dayHeadCells.slice(0, -1), colWidth);
}
-
+
function resetScroll() {
@@ -3207,22 +3206,22 @@ function AgendaView(element, calendar, viewName) {
scroll();
setTimeout(scroll, 0); // overrides any previous scroll state made by the browser
}
-
-
+
+
function beforeHide() {
savedScrollTop = slotScroller.scrollTop();
}
-
-
+
+
function afterShow() {
slotScroller.scrollTop(savedScrollTop);
}
-
-
-
+
+
+
/* Slot/Day clicking and binding
-----------------------------------------------------------------------*/
-
+
function dayBind(cells) {
cells.click(slotClick)
@@ -3234,8 +3233,8 @@ function AgendaView(element, calendar, viewName) {
cells.click(slotClick)
.mousedown(slotSelectionMousedown);
}
-
-
+
+
function slotClick(ev) {
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));
@@ -3252,12 +3251,12 @@ function AgendaView(element, calendar, viewName) {
}
}
}
-
-
-
+
+
+
/* Semi-transparent Overlay Helpers
-----------------------------------------------------*/
-
+
function renderDayOverlay(startDate, endDate, refreshCoordinateGrid) { // endDate is exclusive
if (refreshCoordinateGrid) {
@@ -3280,13 +3279,13 @@ function AgendaView(element, calendar, viewName) {
);
}
}
-
-
+
+
function renderCellOverlay(row0, col0, row1, col1) { // only for all-day?
var rect = coordinateGrid.rect(row0, col0, row1, col1, slotLayer);
return renderOverlay(rect, slotLayer);
}
-
+
function renderSlotOverlay(overlayStart, overlayEnd) {
var dayStart = cloneDate(t.visStart);
@@ -3309,13 +3308,13 @@ function AgendaView(element, calendar, viewName) {
addDays(dayEnd, 1);
}
}
-
-
-
+
+
+
/* Coordinate Utilities
-----------------------------------------------------------------------------*/
-
-
+
+
coordinateGrid = new CoordinateGrid(function(rows, cols) {
var e, n, p;
dayHeadCells.each(function(i, _e) {
@@ -3346,36 +3345,36 @@ function AgendaView(element, calendar, viewName) {
]);
}
});
-
-
+
+
hoverListener = new HoverListener(coordinateGrid);
-
-
+
+
colContentPositions = new HorizontalPositionCache(function(col) {
return dayBodyCellInners.eq(col);
});
-
-
+
+
function colContentLeft(col) {
return colContentPositions.left(col);
}
-
-
+
+
function colContentRight(col) {
return colContentPositions.right(col);
}
-
-
-
-
+
+
+
+
function dateCell(date) { // "cell" terminology is now confusing
return {
row: Math.floor(dayDiff(date, t.visStart) / 7),
col: dayOfWeekCol(date.getDay())
};
}
-
-
+
+
function cellDate(cell) {
var d = colDate(cell.col);
var slotIndex = cell.row;
@@ -3387,25 +3386,25 @@ function AgendaView(element, calendar, viewName) {
}
return d;
}
-
-
+
+
function colDate(col) { // returns dates with 00:00:00
return addDays(cloneDate(t.visStart), col*dis+dit);
}
-
-
+
+
function cellIsAllDay(cell) {
return opt('allDaySlot') && !cell.row;
}
-
-
+
+
function dayOfWeekCol(dayOfWeek) {
return ((dayOfWeek - Math.max(firstDay, nwe) + colCnt) % colCnt)*dis+dit;
}
-
-
-
-
+
+
+
+
// get the Y coordinate of the given time on the given day (both Date objects)
function timePosition(day, time) { // both date objects. day holds 00:00 of current day
day = cloneDate(day, true);
@@ -3426,21 +3425,21 @@ function AgendaView(element, calendar, viewName) {
slotTop - 1 + slotHeight * ((minutes % slotMinutes) / slotMinutes)
));
}
-
-
+
+
function allDayBounds() {
return {
left: axisWidth,
right: viewWidth - gutterWidth
}
}
-
-
+
+
function getAllDayRow(index) {
return allDayRow;
}
-
-
+
+
function defaultEventEnd(event) {
var start = cloneDate(event.start);
if (event.allDay) {
@@ -3448,21 +3447,21 @@ function AgendaView(element, calendar, viewName) {
}
return addMinutes(start, opt('defaultEventMinutes'));
}
-
-
-
+
+
+
/* Selection
---------------------------------------------------------------------------------*/
-
-
+
+
function defaultSelectionEnd(startDate, allDay) {
if (allDay) {
return cloneDate(startDate);
}
return addMinutes(cloneDate(startDate), opt('slotMinutes'));
}
-
-
+
+
function renderSelection(startDate, endDate, allDay) { // only for all-day
if (allDay) {
if (opt('allDaySlot')) {
@@ -3472,8 +3471,8 @@ function AgendaView(element, calendar, viewName) {
renderSlotSelection(startDate, endDate);
}
}
-
-
+
+
function renderSlotSelection(startDate, endDate) {
var helperOption = opt('selectHelper');
coordinateGrid.build();
@@ -3524,8 +3523,8 @@ function AgendaView(element, calendar, viewName) {
renderSlotOverlay(startDate, endDate);
}
}
-
-
+
+
function clearSelection() {
clearOverlays();
if (selectionHelper) {
@@ -3533,8 +3532,8 @@ function AgendaView(element, calendar, viewName) {
selectionHelper = null;
}
}
-
-
+
+
function slotSelectionMousedown(ev) {
if (ev.which == 1 && opt('selectable')) { // ev.which==1 means left mouse button
unselect(ev);
@@ -3566,18 +3565,18 @@ function AgendaView(element, calendar, viewName) {
});
}
}
-
-
+
+
function reportDayClick(date, allDay, ev) {
trigger('dayClick', dayBodyCells[dayOfWeekCol(date.getDay())], date, allDay, ev);
}
-
-
-
+
+
+
/* External Dragging
--------------------------------------------------------------------------------*/
-
-
+
+
function dragStart(_dragElement, ev, ui) {
hoverListener.start(function(cell) {
clearOverlays();
@@ -3592,8 +3591,8 @@ function AgendaView(element, calendar, viewName) {
}
}, ev);
}
-
-
+
+
function dragStop(_dragElement, ev, ui) {
var cell = hoverListener.stop();
clearOverlays();
@@ -3607,16 +3606,16 @@ function AgendaView(element, calendar, viewName) {
function AgendaEventRenderer() {
var t = this;
-
-
+
+
// exports
t.renderEvents = renderEvents;
t.compileDaySegs = compileDaySegs; // for DayEventRenderer
t.clearEvents = clearEvents;
t.slotSegHtml = slotSegHtml;
t.bindDaySeg = bindDaySeg;
-
-
+
+
// imports
DayEventRenderer.call(t);
var opt = t.opt;
@@ -3653,12 +3652,12 @@ function AgendaEventRenderer() {
var calendar = t.calendar;
var formatDate = calendar.formatDate;
var formatDates = calendar.formatDates;
-
-
-
+
+
+
/* Rendering
----------------------------------------------------------------------------*/
-
+
function renderEvents(events, modifiedEventId) {
reportEvents(events);
@@ -3678,15 +3677,15 @@ function AgendaEventRenderer() {
}
renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
}
-
-
+
+
function clearEvents() {
reportEventClear();
getDaySegmentContainer().empty();
getSlotSegmentContainer().empty();
}
-
-
+
+
function compileDaySegs(events) {
var levels = stackSegs(sliceSegs(events, $.map(events, exclEndDay), t.visStart, t.visEnd)),
i, levelCnt=levels.length, level,
@@ -3703,8 +3702,8 @@ function AgendaEventRenderer() {
}
return segs;
}
-
-
+
+
function compileSlotSegs(events) {
var colCnt = getColCnt(),
minMinute = getMinMinute(),
@@ -3731,8 +3730,8 @@ function AgendaEventRenderer() {
}
return segs;
}
-
-
+
+
function slotEventEnd(event) {
if (event.end) {
return cloneDate(event.end);
@@ -3740,12 +3739,12 @@ function AgendaEventRenderer() {
return addMinutes(cloneDate(event.start), opt('defaultEventMinutes'));
}
}
-
-
+
+
// renders events in the 'time slots' at the bottom
-
+
function renderSlotSegs(segs, modifiedEventId) {
-
+
var i, segCnt=segs.length, seg,
event,
classes,
@@ -3767,7 +3766,7 @@ function AgendaEventRenderer() {
slotSegmentContainer = getSlotSegmentContainer(),
rtl, dis, dit,
colCnt = getColCnt();
-
+
if (rtl = opt('isRTL')) {
dis = -1;
dit = colCnt - 1;
@@ -3775,7 +3774,7 @@ function AgendaEventRenderer() {
dis = 1;
dit = 0;
}
-
+
// calculate position/dimensions, create html
for (i=0; i<segCnt; i++) {
seg = segs[i];
@@ -3811,7 +3810,7 @@ function AgendaEventRenderer() {
}
slotSegmentContainer[0].innerHTML = html; // faster than html()
eventElements = slotSegmentContainer.children();
-
+
// retrieve elements, run through eventRender callback, bind event handlers
for (i=0; i<segCnt; i++) {
seg = segs[i];
@@ -3840,9 +3839,9 @@ function AgendaEventRenderer() {
reportEventElement(event, eventElement);
}
}
-
+
lazySegBind(slotSegmentContainer, segs, bindSlotSeg);
-
+
// record event sides and title positions
for (i=0; i<segCnt; i++) {
seg = segs[i];
@@ -3857,7 +3856,7 @@ function AgendaEventRenderer() {
}
}
}
-
+
// set all positions/dimensions at once
for (i=0; i<segCnt; i++) {
seg = segs[i];
@@ -3876,10 +3875,10 @@ function AgendaEventRenderer() {
trigger('eventAfterRender', event, event, eventElement);
}
}
-
+
}
-
-
+
+
function slotSegHtml(event, seg) {
var html = "<";
var url = event.url;
@@ -3929,8 +3928,8 @@ function AgendaEventRenderer() {
"</" + (url ? "a" : "div") + ">";
return html;
}
-
-
+
+
function bindDaySeg(event, eventElement, seg) {
if (isEventDraggable(event)) {
draggableDayEvent(event, eventElement, seg.isStart);
@@ -3941,8 +3940,8 @@ function AgendaEventRenderer() {
eventElementHandlers(event, eventElement);
// needs to be after, because resizableDayEvent might stopImmediatePropagation on click
}
-
-
+
+
function bindSlotSeg(event, eventElement, seg) {
var timeElement = eventElement.find('div.fc-event-time');
if (isEventDraggable(event)) {
@@ -3953,15 +3952,15 @@ function AgendaEventRenderer() {
}
eventElementHandlers(event, eventElement);
}
-
-
-
+
+
+
/* Dragging
-----------------------------------------------------------------------------------*/
-
-
+
+
// when event starts out FULL-DAY
-
+
function draggableDayEvent(event, eventElement, isStart) {
var origWidth;
var revert;
@@ -4055,10 +4054,10 @@ function AgendaEventRenderer() {
}
}
}
-
-
+
+
// when event starts out IN TIMESLOTS
-
+
function draggableSlotEvent(event, eventElement, timeElement) {
var origPosition;
var allDay=false;
@@ -4149,13 +4148,13 @@ function AgendaEventRenderer() {
}
}
}
-
-
-
+
+
+
/* Resizing
--------------------------------------------------------------------------------------*/
-
-
+
+
function resizableSlotEvent(event, eventElement, timeElement) {
var slotDelta, prevSlotDelta;
var slotHeight = getSlotHeight();
@@ -4197,7 +4196,7 @@ function AgendaEventRenderer() {
}
});
}
-
+
}
@@ -4223,8 +4222,8 @@ function countForwardSegs(levels) {
function View(element, calendar, viewName) {
var t = this;
-
-
+
+
// exports
t.element = element;
t.calendar = calendar;
@@ -4246,22 +4245,22 @@ function View(element, calendar, viewName) {
// t.title
// t.start, t.end
// t.visStart, t.visEnd
-
-
+
+
// imports
var defaultEventEnd = t.defaultEventEnd;
var normalizeEvent = calendar.normalizeEvent; // in EventManager
var reportEventChange = calendar.reportEventChange;
-
-
+
+
// locals
var eventsByID = {};
var eventElements = [];
var eventElementsByID = {};
var options = calendar.options;
-
-
-
+
+
+
function opt(name, viewNameOverride) {
var v = options[name];
if (typeof v == 'object') {
@@ -4270,42 +4269,42 @@ function View(element, calendar, viewName) {
return v;
}
-
+
function trigger(name, thisObj) {
return calendar.trigger.apply(
calendar,
[name, thisObj || t].concat(Array.prototype.slice.call(arguments, 2), [t])
);
}
-
-
+
+
/*
function setOverflowHidden(bool) {
element.css('overflow', bool ? 'hidden' : '');
}
*/
-
-
+
+
function isEventDraggable(event) {
return isEventEditable(event) && !opt('disableDragging');
}
-
-
+
+
function isEventResizable(event) { // but also need to make sure the seg.isEnd == true
return isEventEditable(event) && !opt('disableResizing');
}
-
-
+
+
function isEventEditable(event) {
return firstDefined(event.editable, (event.source || {}).editable, opt('editable'));
}
-
-
-
+
+
+
/* Event Data
------------------------------------------------------------------------------*/
-
-
+
+
// report when view receives new events
function reportEvents(events) { // events are already normalized at this point
eventsByID = {};
@@ -4319,19 +4318,19 @@ function View(element, calendar, viewName) {
}
}
}
-
-
+
+
// returns a Date object for an event's end
function eventEnd(event) {
return event.end ? cloneDate(event.end) : defaultEventEnd(event);
}
-
-
-
+
+
+
/* Event Elements
------------------------------------------------------------------------------*/
-
-
+
+
// report when view creates an element for an event
function reportEventElement(event, element) {
eventElements.push(element);
@@ -4341,14 +4340,14 @@ function View(element, calendar, viewName) {
eventElementsByID[event._id] = [element];
}
}
-
-
+
+
function reportEventClear() {
eventElements = [];
eventElementsByID = {};
}
-
-
+
+
// attaches eventClick, eventMouseover, eventMouseout
function eventElementHandlers(event, eventElement) {
eventElement
@@ -4369,18 +4368,18 @@ function View(element, calendar, viewName) {
// TODO: don't fire eventMouseover/eventMouseout *while* dragging is occuring (on subject element)
// TODO: same for resizing
}
-
-
+
+
function showEvents(event, exceptElement) {
eachEventElement(event, exceptElement, 'show');
}
-
-
+
+
function hideEvents(event, exceptElement) {
eachEventElement(event, exceptElement, 'hide');
}
-
-
+
+
function eachEventElement(event, exceptElement, funcName) {
var elements = eventElementsByID[event._id],
i, len = elements.length;
@@ -4390,13 +4389,13 @@ function View(element, calendar, viewName) {
}
}
}
-
-
-
+
+
+
/* Event Modification Reporting
---------------------------------------------------------------------------------*/
-
-
+
+
function eventDrop(e, event, dayDelta, minuteDelta, allDay, ev, ui) {
var oldAllDay = event.allDay;
var eventId = event._id;
@@ -4418,8 +4417,8 @@ function View(element, calendar, viewName) {
);
reportEventChange(eventId);
}
-
-
+
+
function eventResize(e, event, dayDelta, minuteDelta, ev, ui) {
var eventId = event._id;
elongateEvents(eventsByID[eventId], dayDelta, minuteDelta);
@@ -4439,13 +4438,13 @@ function View(element, calendar, viewName) {
);
reportEventChange(eventId);
}
-
-
-
+
+
+
/* Event Modification Math
---------------------------------------------------------------------------------*/
-
-
+
+
function moveEvents(events, dayDelta, minuteDelta, allDay) {
minuteDelta = minuteDelta || 0;
for (var e, len=events.length, i=0; i<len; i++) {
@@ -4460,8 +4459,8 @@ function View(element, calendar, viewName) {
normalizeEvent(e, options);
}
}
-
-
+
+
function elongateEvents(events, dayDelta, minuteDelta) {
minuteDelta = minuteDelta || 0;
for (var e, len=events.length, i=0; i<len; i++) {
@@ -4470,19 +4469,19 @@ function View(element, calendar, viewName) {
normalizeEvent(e, options);
}
}
-
+
}
function DayEventRenderer() {
var t = this;
-
+
// exports
t.renderDaySegs = renderDaySegs;
t.resizableDayEvent = resizableDayEvent;
-
-
+
+
// imports
var opt = t.opt;
var trigger = t.trigger;
@@ -4509,13 +4508,13 @@ function DayEventRenderer() {
var renderDayOverlay = t.renderDayOverlay;
var clearOverlays = t.clearOverlays;
var clearSelection = t.clearSelection;
-
-
-
+
+
+
/* Rendering
-----------------------------------------------------------------------------*/
-
-
+
+
function renderDaySegs(segs, modifiedEventId) {
var segmentContainer = getDaySegmentContainer();
var rowDivs;
@@ -4559,8 +4558,8 @@ function DayEventRenderer() {
}
daySegSetTops(segs, getRowTops(rowDivs));
}
-
-
+
+
function renderTempDaySegs(segs, adjustRow, adjustTop) {
var tempContainer = $("<div/>");
var elements;
@@ -4588,8 +4587,8 @@ function DayEventRenderer() {
}
return $(elements);
}
-
-
+
+
function daySegHTML(segs) { // also sets seg.left and seg.outerWidth
var rtl = opt('isRTL');
var i;
@@ -4681,8 +4680,8 @@ function DayEventRenderer() {
}
return html;
}
-
-
+
+
function daySegElementResolve(segs, elements) { // sets seg.element
var i;
var segCnt = segs.length;
@@ -4711,8 +4710,8 @@ function DayEventRenderer() {
}
}
}
-
-
+
+
function daySegElementReport(segs) {
var i;
var segCnt = segs.length;
@@ -4726,8 +4725,8 @@ function DayEventRenderer() {
}
}
}
-
-
+
+
function daySegHandlers(segs, segmentContainer, modifiedEventId) {
var i;
var segCnt = segs.length;
@@ -4749,8 +4748,8 @@ function DayEventRenderer() {
}
lazySegBind(segmentContainer, segs, bindDaySeg);
}
-
-
+
+
function daySegCalcHSides(segs) { // also sets seg.key
var i;
var segCnt = segs.length;
@@ -4772,8 +4771,8 @@ function DayEventRenderer() {
}
}
}
-
-
+
+
function daySegSetWidths(segs) {
var i;
var segCnt = segs.length;
@@ -4787,8 +4786,8 @@ function DayEventRenderer() {
}
}
}
-
-
+
+
function daySegCalcHeights(segs) {
var i;
var segCnt = segs.length;
@@ -4810,8 +4809,8 @@ function DayEventRenderer() {
}
}
}
-
-
+
+
function getRowDivs() {
var i;
var rowCnt = getRowCnt();
@@ -4822,8 +4821,8 @@ function DayEventRenderer() {
}
return rowDivs;
}
-
-
+
+
function getRowTops(rowDivs) {
var i;
var rowCnt = rowDivs.length;
@@ -4833,8 +4832,8 @@ function DayEventRenderer() {
}
return tops;
}
-
-
+
+
function daySegSetTops(segs, rowTops) { // also triggers eventAfterRender
var i;
var segCnt = segs.length;
@@ -4851,19 +4850,19 @@ function DayEventRenderer() {
}
}
}
-
-
-
+
+
+
/* Resizing
-----------------------------------------------------------------------------------*/
-
-
+
+
function resizableDayEvent(event, element, seg) {
var rtl = opt('isRTL');
var direction = rtl ? 'w' : 'e';
var handle = element.find('div.ui-resizable-' + direction);
var isResizing = false;
-
+
// TODO: look into using jquery-ui mouse widget for this stuff
disableTextSelection(element); // prevent native <a> selection for IE
element
@@ -4877,7 +4876,7 @@ function DayEventRenderer() {
// (eventElementHandlers needs to be bound after resizableDayEvent)
}
});
-
+
handle.mousedown(function(ev) {
if (ev.which != 1) {
return; // needs to be left mouse button
@@ -4934,7 +4933,7 @@ function DayEventRenderer() {
renderDayOverlay(event.start, addDays(cloneDate(newEnd), 1)); // coordinate grid already rebuild at hoverListener.start
}
}, ev);
-
+
function mouseup(ev) {
trigger('eventResizeStop', this, event, ev);
$('body').css('cursor', '');
@@ -4945,15 +4944,15 @@ function DayEventRenderer() {
// event redraw will clear helpers
}
// otherwise, the drag handler already restored the old events
-
+
setTimeout(function() { // make this happen after the element's click event
isResizing = false;
},0);
}
-
+
});
}
-
+
}
@@ -4961,23 +4960,23 @@ function DayEventRenderer() {
function SelectionManager() {
var t = this;
-
-
+
+
// exports
t.select = select;
t.unselect = unselect;
t.reportSelection = reportSelection;
t.daySelectionMousedown = daySelectionMousedown;
-
-
+
+
// imports
var opt = t.opt;
var trigger = t.trigger;
var defaultSelectionEnd = t.defaultSelectionEnd;
var renderSelection = t.renderSelection;
var clearSelection = t.clearSelection;
-
-
+
+
// locals
var selected = false;
@@ -4995,7 +4994,7 @@ function SelectionManager() {
unselect(ev);
});
}
-
+
function select(startDate, endDate, allDay) {
unselect();
@@ -5005,8 +5004,8 @@ function SelectionManager() {
renderSelection(startDate, endDate, allDay);
reportSelection(startDate, endDate, allDay);
}
-
-
+
+
function unselect(ev) {
if (selected) {
selected = false;
@@ -5014,14 +5013,14 @@ function SelectionManager() {
trigger('unselect', null, ev);
}
}
-
-
+
+
function reportSelection(startDate, endDate, allDay, ev) {
selected = true;
trigger('select', null, startDate, endDate, allDay, ev);
}
-
-
+
+
function daySelectionMousedown(ev) { // not really a generic manager method, oh well
var cellDate = t.cellDate;
var cellIsAllDay = t.cellIsAllDay;
@@ -5054,21 +5053,21 @@ function SelectionManager() {
}
-
+
function OverlayManager() {
var t = this;
-
-
+
+
// exports
t.renderOverlay = renderOverlay;
t.clearOverlays = clearOverlays;
-
-
+
+
// locals
var usedOverlays = [];
var unusedOverlays = [];
-
-
+
+
function renderOverlay(rect, parent) {
var e = unusedOverlays.shift();
if (!e) {
@@ -5080,7 +5079,7 @@ function OverlayManager() {
usedOverlays.push(e.css(rect).show());
return e;
}
-
+
function clearOverlays() {
var e;
@@ -5097,15 +5096,15 @@ function CoordinateGrid(buildFunc) {
var t = this;
var rows;
var cols;
-
-
+
+
t.build = function() {
rows = [];
cols = [];
buildFunc(rows, cols);
};
-
-
+
+
t.cell = function(x, y) {
var rowCnt = rows.length;
var colCnt = cols.length;
@@ -5124,8 +5123,8 @@ function CoordinateGrid(buildFunc) {
}
return (r>=0 && c>=0) ? { row:r, col:c } : null;
};
-
-
+
+
t.rect = function(row0, col0, row1, col1, originElement) { // row1,col1 is inclusive
var origin = originElement.offset();
return {
@@ -5146,8 +5145,8 @@ function HoverListener(coordinateGrid) {
var change;
var firstCell;
var cell;
-
-
+
+
t.start = function(_change, ev, _bindType) {
change = _change;
firstCell = cell = null;
@@ -5156,8 +5155,8 @@ function HoverListener(coordinateGrid) {
bindType = _bindType || 'mousemove';
$(document).bind(bindType, mouse);
};
-
-
+
+
function mouse(ev) {
_fixUIEvent(ev); // see below
var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
@@ -5173,14 +5172,14 @@ function HoverListener(coordinateGrid) {
cell = newCell;
}
}
-
-
+
+
t.stop = function() {
$(document).unbind(bindType, mouse);
return cell;
};
-
-
+
+
}
@@ -5202,25 +5201,25 @@ function HorizontalPositionCache(getElement) {
elements = {},
lefts = {},
rights = {};
-
+
function e(i) {
return elements[i] = elements[i] || getElement(i);
}
-
+
t.left = function(i) {
return lefts[i] = lefts[i] === undefined ? e(i).position().left : lefts[i];
};
-
+
t.right = function(i) {
return rights[i] = rights[i] === undefined ? t.left(i) + e(i).width() : rights[i];
};
-
+
t.clear = function() {
elements = {};
lefts = {};
rights = {};
};
-
+
}
})(jQuery);