rgrove/jsmin-php — Issue #11: Fatal error: Uncaught exception 'JSMinException' with message 'Unterminated regular expression literal
Author: DWboutin
Created: 2012-03-08 15:47:18+00:00
State: open

I got this error... Don't know from where when i minify this file below

$(document).ready(function () {
/**
* FullCalendar v1.5.1
* http://arshaw.com/fullcalendar/
*
* Use fullcalendar.css for basic styling.
* For event drag & drop, requires jQuery UI draggable.
* For event resizing, requires jQuery UI resizable.
*
* Copyright (c) 2011 Adam Shaw
* Dual licensed under the MIT and GPL licenses, located in
* MIT-LICENSE.txt and GPL-LICENSE.txt respectively.
*
* Date: Sat Apr 9 14:09:51 2011 -0700
*
*/

(function($, undefined) {

var defaults = {

// display
defaultView: 'month',
aspectRatio: 1.35,
header: {
left: 'title',
center: '',
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',
week: "MMM d[ yyyy]{ '—'[ MMM] d yyyy}",
day: 'dddd, MMM d, yyyy'
},
columnFormat: {
month: 'ddd',
week: 'ddd M/d',
day: 'dddd M/d'
},
timeFormat: { // for event elements
'': 'h(:mm)t' // default
},

// locale
isRTL: false,
firstDay: 0,
monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'],
monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
buttonText: {
prev: ' ◄ ',
next: ' ► ',
prevYear: ' << ',
nextYear: ' >> ',
today: 'today',
month: 'month',
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
var rtlDefaults = {
header: {
left: 'next,prev today',
center: '',
right: 'title'
},
buttonText: {
prev: ' ► ',
next: ' ◄ ',
prevYear: ' >> ',
nextYear: ' << '
},
buttonIcons: {
prev: 'circle-triangle-e',
next: 'circle-triangle-w'
}
};

var fc = $.fullCalendar = { version: "1.5.1" };
var fcViews = fc.views = {};

$.fn.fullCalendar = function(options) {

// method calling
if (typeof options == 'string') {
var args = Array.prototype.slice.call(arguments, 1);
var res;
this.each(function() {
var calendar = $.data(this, 'fullCalendar');
if (calendar && $.isFunction(calendar[options])) {
var r = calendar[options].apply(calendar, args);
if (res === undefined) {
res = r;
}
if (options == 'destroy') {
$.removeData(this, 'fullCalendar');
}
}
});
if (res !== undefined) {
return res;
}
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;
if (options.events) {
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;

};

// function for adding/overriding defaults
function setDefaults(d) {
$.extend(true, defaults, d);
}

function Calendar(element, options, eventSources) {
var t = this;

// exports
t.options = options;
t.render = render;
t.destroy = destroy;
t.refetchEvents = refetchEvents;
t.reportEvents = reportEvents;
t.reportEventChange = reportEventChange;
t.rerenderEvents = rerenderEvents;
t.changeView = changeView;
t.select = select;
t.unselect = unselect;
t.prev = prev;
t.next = next;
t.prevYear = prevYear;
t.nextYear = nextYear;
t.today = today;
t.gotoDate = gotoDate;
t.incrementDate = incrementDate;
t.formatDate = function(format, date) { return formatDate(format, date, options) };
t.formatDates = function(format, date1, date2) { return formatDates(format, date1, date2, options) };
t.getDate = getDate;
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;
var headerElement;
var content;
var tm; // for making theme classes
var currentView;
var viewInstances = {};
var elementOuterWidth;
var suggestedViewHeight;
var absoluteViewElement;
var resizeUID = 0;
var ignoreWindowResize = 0;
var date = new Date();
var events = [];
var _dragElement;

/* Main Rendering
-----------------------------------------------------------------------------*/

setYMD(date, options.year, options.month, options.date);

function render(inc) {
if (!content) {
initialRender();
}else{
calcSize();
markSizesDirty();
markEventsDirty();
renderView(inc);
}
}

function initialRender() {
tm = options.theme ? 'ui' : 'fc';
element.addClass('fc');
if (options.isRTL) {
element.addClass('fc-rtl');
}
if (options.theme) {
element.addClass('ui-widget');
}
content = $("

")
.prependTo(element);
header = new Header(t, options);
headerElement = header.render();
if (headerElement) {
element.prepend(headerElement);
}
changeView(options.defaultView);
$(window).resize(windowResize);
// needed for IE in a 0x0 iframe, b/c when it is resized, never triggers a windowResize
if (!bodyVisible()) {
lateRender();
}
}

// called when we know the calendar couldn't be rendered when it was initialized,
// but we think it's ready now
function lateRender() {
setTimeout(function() { // IE7 needs this so dimensions are calculated correctly
if (!currentView.start && bodyVisible()) { // !currentView.start makes sure this never happens more than once
renderView();
}
},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());
oldView.element.hide();
}else{
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();
}else{
currentView = viewInstances[newViewName] = new fcViews[newViewName](
newViewElement = absoluteViewElement =
$("

")
.appendTo(content),
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)
currentView.render(date, inc || 0); // responsible for clearing events
setSize(true);
forceEventRender = true;
}
else if (currentView.sizeDirty) {
// view must resize (and rerender events)
currentView.clearEvents();
setSize();
forceEventRender = true;
}
else if (currentView.eventsDirty) {
currentView.clearEvents();
forceEventRender = true;
}
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) {
header.disableButton('today');
}else{
header.enableButton('today');
}

ignoreWindowResize--;
currentView.trigger('viewDisplay', _element);
}
}

/* Resizing
-----------------------------------------------------------------------------*/

function updateSize() {
markSizesDirty();
if (elementVisible()) {
calcSize();
setSize();
unselect();
currentView.clearEvents();
currentView.renderEvents(events);
currentView.sizeDirty = false;
}
}

function markSizesDirty() {
$.each(viewInstances, function(i, inst) {
inst.sizeDirty = true;
});
}

function calcSize() {
if (options.contentHeight) {
suggestedViewHeight = options.contentHeight;
}
else if (options.height) {
suggestedViewHeight = options.height - (headerElement ? headerElement.height() : 0) - vsides(content);
}
else {
suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
}
}

function setSize(dateChanged) { // todo: dateChanged?
ignoreWindowResize++;
currentView.setHeight(suggestedViewHeight, dateChanged);
if (absoluteViewElement) {
absoluteViewElement.css('position', 'relative');
absoluteViewElement = null;
}
currentView.setWidth(content.width(), dateChanged);
ignoreWindowResize--;
}

function windowResize() {
if (!ignoreWindowResize) {
if (currentView.start) { // view has already been rendered
var uid = ++resizeUID;
setTimeout(function() { // add a delay
if (uid == resizeUID && !ignoreWindowResize && elementVisible()) {
if (elementOuterWidth != (elementOuterWidth = element.outerWidth())) {
ignoreWindowResize++; // in case the windowResize callback changes the height
updateSize();
currentView.trigger('windowResize', _element);
ignoreWindowResize--;
}
}
}, 200);
}else{
// calendar must have been initialized in a 0x0 iframe that has just been resized
lateRender();
}
}
}

/* 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)) {
refetchEvents();
}
else if (forceRender) {
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();
if (elementVisible()) {
currentView.clearEvents();
currentView.renderEvents(events, modifiedEventID);
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
}else{
setYMD(date, year, month, dateOfMonth);
}
renderView();
}

function incrementDate(years, months, days) {
if (years !== undefined) {
addYears(date, years);
}
if (months !== undefined) {
addMonths(date, months);
}
if (days !== undefined) {
addDays(date, days);
}
renderView();
}

function getDate() {
return cloneDate(date);
}

/* Misc
-----------------------------------------------------------------------------*/

function getView() {
return currentView;
}

function option(name, value) {
if (value === undefined) {
return options[name];
}
if (name == 'height' || name == 'contentHeight' || name == 'aspectRatio') {
options[name] = value;
updateSize();
}
}

function trigger(name, thisObj) {
if (options[name]) {
return options[name].apply(
thisObj || _element,
Array.prototype.slice.call(arguments, 2)
);
}
}

/* External Dragging
------------------------------------------------------------------------*/

if (options.droppable) {
$(document)
.bind('dragstart', function(ev, ui) {
var _e = ev.target;
var e = $(_e);
if (!e.parents('.fc').length) { // not already inside a calendar
var accept = options.dropAccept;
if ($.isFunction(accept) ? accept.call(_e, e) : e.is(accept)) {
_dragElement = _e;
currentView.dragStart(_dragElement, ev, ui);
}
}
})
.bind('dragstop', function(ev, ui) {
if (_dragElement) {
currentView.dragStop(_dragElement, ev, ui);
_dragElement = null;
}
});
}

}

function Header(calendar, options) {
var t = this;

// exports
t.render = render;
t.destroy = destroy;
t.updateTitle = updateTitle;
t.activateButton = activateButton;
t.deactivateButton = deactivateButton;
t.disableButton = disableButton;
t.enableButton = enableButton;

// locals
var element = $([]);
var tm;

function render() {
tm = options.theme ? 'ui' : 'fc';
var sections = options.header;
if (sections) {
element = $("

")
.append(
$("
")
.append(renderSection('left'))
.append(renderSection('center'))
.append(renderSection('right'))
);
return element;
}
}

function destroy() {
element.remove();
}

function renderSection(position) {
var e = $("	");
var buttonStr = options.header[position];
if (buttonStr) {
$.each(buttonStr.split(' '), function(i) {
if (i > 0) {
e.append("");
}
var prevButton;
$.each(this.split(','), function(j, buttonName) {
if (buttonName == 'title') {
e.append("

");
if (prevButton) {
prevButton.addClass(tm + '-corner-right');
}
prevButton = null;
}else{
var buttonClick;
if (calendar[buttonName]) {
buttonClick = calendar[buttonName]; // calendar method
}
else if (fcViews[buttonName]) {
buttonClick = function() {
button.removeClass(tm + '-state-hover'); // forget why
calendar.changeView(buttonName);
};
}
if (buttonClick) {
var icon = options.theme ? smartProperty(options.buttonIcons, buttonName) : null; // why are we using smartProperty here?
var text = smartProperty(options.buttonText, buttonName); // why are we using smartProperty here?
var button = $(
"" +
"" +
"" +
(icon ?
"" +
"" +
"" :
text
) +
"" +
"" +
"" +
""
);
if (button) {
button
.click(function() {
if (!button.hasClass(tm + '-state-disabled')) {
buttonClick();
}
})
.mousedown(function() {
button
.not('.' + tm + '-state-active')
.not('.' + tm + '-state-disabled')
.addClass(tm + '-state-down');
})
.mouseup(function() {
button.removeClass(tm + '-state-down');
})
.hover(
function() {
button
.not('.' + tm + '-state-active')
.not('.' + tm + '-state-disabled')
.addClass(tm + '-state-hover');
},
function() {
button
.removeClass(tm + '-state-hover')
.removeClass(tm + '-state-down');
}
)
.appendTo(e);
if (!prevButton) {
button.addClass(tm + '-corner-left');
}
prevButton = button;
}
}
}
});
if (prevButton) {
prevButton.addClass(tm + '-corner-right');
}
});
}
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');
}

}

fc.sourceNormalizers = [];
fc.sourceFetchers = [];

var ajaxDefaults = {
dataType: 'json',
cache: false
};

var eventGUID = 1;

function EventManager(options, _sources) {
var t = this;

// exports
t.isFetchNeeded = isFetchNeeded;
t.fetchEvents = fetchEvents;
t.addEventSource = addEventSource;
t.removeEventSource = removeEventSource;
t.updateEvent = updateEvent;
t.renderEvent = renderEvent;
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 ];
var rangeStart, rangeEnd;
var currentFetchID = 0;
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;
cache = [];
var fetchID = ++currentFetchID;
var len = sources.length;
pendingSourceCnt = len;
for (var i=0; i)), return null instead
return null;
}

function parseISO8601(s, ignoreTimezone) { // ignoreTimezone defaults to false
// derived from http://delete.me.uk/2005/03/iso8601.html
// TODO: for a know glitch/feature, read tests/issue_206_parseDate_dst.html
var m = s.match(/^([0-9]{4})(-([0-9]{2})(-([0-9]{2})([T ]([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?(Z|(([-+])([0-9]{2})(:?([0-9]{2}))?))?)?)?)?$/);
if (!m) {
return null;
}
var date = new Date(m[1], 0, 1);
if (ignoreTimezone || !m[14]) {
var check = new Date(m[1], 0, 1, 9, 0);
if (m[3]) {
date.setMonth(m[3] - 1);
check.setMonth(m[3] - 1);
}
if (m[5]) {
date.setDate(m[5]);
check.setDate(m[5]);
}
fixDate(date, check);
if (m[7]) {
date.setHours(m[7]);
}
if (m[8]) {
date.setMinutes(m[8]);
}
if (m[10]) {
date.setSeconds(m[10]);
}
if (m[12]) {
date.setMilliseconds(Number("0." + m[12]) * 1000);
}
fixDate(date, check);
}else{
date.setUTCFullYear(
m[1],
m[3] ? m[3] - 1 : 0,
m[5] || 1
);
date.setUTCHours(
m[7] || 0,
m[8] || 0,
m[10] || 0,
m[12] ? Number("0." + m[12]) * 1000 : 0
);
var offset = Number(m[16]) * 60 + (m[18] ? Number(m[18]) : 0);
offset *= m[15] == '-' ? 1 : -1;
date = new Date(+date + (offset * 60 * 1000));
}
return date;
}

function parseTime(s) { // returns minutes since start of day
if (typeof s == 'number') { // an hour
return s * 60;
}
if (typeof s == 'object') { // a Date object
return s.getHours() * 60 + s.getMinutes();
}
var m = s.match(/(\d+)(?::(\d+))?\s*(\w+)?/);
if (m) {
var h = parseInt(m[1], 10);
if (m[3]) {
h %= 12;
if (m[3].toLowerCase().charAt(0) == 'p') {
h += 12;
}
}
return h * 60 + (m[2] ? parseInt(m[2], 10) : 0);
}
}

/* Date Formatting
-----------------------------------------------------------------------------*/
// TODO: use same function formatDate(date, [date2], format, [options])

function formatDate(date, format, options) {
return formatDates(date, null, format, options);
}

function formatDates(date1, date2, format, options) {
options = options || defaults;
var date = date1,
otherDate = date2,
i, len = format.length, c,
i2, formatter,
res = '';
for (i=0; ii; i2--) {
if (formatter = dateFormatters[format.substring(i, i2)]) {
if (date) {
res += formatter(date, options);
}
i = i2 - 1;
break;
}
}
if (i2 == i) {
if (date) {
res += c;
}
}
}
}
return res;
};

var dateFormatters = {
s	: function(d)	{ return d.getSeconds() },
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()) },
d	: function(d)	{ return d.getDate() },
dd	: function(d)	{ return zeroPad(d.getDate()) },
ddd	: function(d,o)	{ return o.dayNamesShort[d.getDay()] },
dddd: function(d,o)	{ return o.dayNames[d.getDay()] },
M	: function(d)	{ return d.getMonth() + 1 },
MM	: function(d)	{ return zeroPad(d.getMonth() + 1) },
MMM	: function(d,o)	{ return o.monthNamesShort[d.getMonth()] },
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' },
u	: function(d)	{ return formatDate(d, "yyyy-MM-dd'T'HH:mm:ss'Z'") },
S	: function(d)	{
var date = d.getDate();
if (date > 10 && date < 20) {
return 'th';
}
return ['st', 'nd', 'rd'][date%10-1] || 'th';
}
};

fc.applyAll = applyAll;

/* Event Date Math
-----------------------------------------------------------------------------*/

function exclEndDay(event) {
if (event.end) {
return _exclEndDay(event.end, event.allDay);
}else{
return addDays(cloneDate(event.start), 1);
}
}

function _exclEndDay(end, allDay) {
end = cloneDate(end);
return allDay || end.getHours() || end.getMinutes() ? addDays(end, 1) : clearTime(end);
}

function segCmp(a, b) {
return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
}

function segsCollide(seg1, seg2) {
return seg1.end > seg2.start && seg1.start < seg2.end;
}

/* Event Sorting
-----------------------------------------------------------------------------*/

// event rendering utilities
function sliceSegs(events, visEventEnds, start, end) {
var segs = [],
i, len=events.length, event,
eventStart, eventEnd,
segStart, segEnd,
isStart, isEnd;
for (i=0; i start && eventStart < end) {
if (eventStart < start) {
segStart = cloneDate(start);
isStart = false;
}else{
segStart = eventStart;
isStart = true;
}
if (eventEnd > end) {
segEnd = cloneDate(end);
isEnd = false;
}else{
segEnd = eventEnd;
isEnd = true;
}
segs.push({
event: event,
start: segStart,
end: segEnd,
isStart: isStart,
isEnd: isEnd,
msLength: segEnd - segStart
});
}
}
return segs.sort(segCmp);
}

// event rendering calculation utilities
function stackSegs(segs) {
var levels = [],
i, len = segs.length, seg,
j, collide, k;
for (i=0; i=0; i--) {
res = obj[parts[i].toLowerCase()];
if (res !== undefined) {
return res;
}
}
return obj[''];
}

function htmlEscape(s) {
return s.replace(/&/g, '&')
.replace(//g, '>')
.replace(/'/g, ''')
.replace(/"/g, '"')
.replace(/\n/g, '
');
}

function cssKey(_element) {
return _element.id + '/' + _element.className + '/' + _element.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/ig, '');
}

function disableTextSelection(element) {
element
.attr('unselectable', 'on')
.css('MozUserSelect', 'none')
.bind('selectstart.ui', function() { return false; });
}

/*
function enableTextSelection(element) {
element
.attr('unselectable', 'off')
.css('MozUserSelect', '')
.unbind('selectstart.ui');
}
*/

function markFirstLast(e) {
e.children()
.removeClass('fc-first fc-last')
.filter(':first-child')
.addClass('fc-first')
.end()
.filter(':last-child')
.addClass('fc-last');
}

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 eventColor = event.color;
var sourceColor = source.color;
var optionColor = opt('eventColor');
var backgroundColor =
event.backgroundColor ||
eventColor ||
source.backgroundColor ||
sourceColor ||
opt('eventBackgroundColor') ||
optionColor;
var borderColor =
event.borderColor ||
eventColor ||
source.borderColor ||
sourceColor ||
opt('eventBorderColor') ||
optionColor;
var textColor =
event.textColor ||
source.textColor ||
opt('eventTextColor');
var statements = [];
if (backgroundColor) {
statements.push('background-color:' + backgroundColor);
}
if (borderColor) {
statements.push('border-color:' + borderColor);
}
if (textColor) {
statements.push('color:' + textColor);
}
return statements.join(';');
}

function applyAll(functions, thisObj, args) {
if ($.isFunction(functions)) {
functions = [ functions ];
}
if (functions) {
var i;
var ret;
for (i=0; i" +
"
";
for (i=0; i"; // need fc- for setDayID
}
s +=
"
" +
"
" +
"
";
for (i=0; i";
for (j=0; j" + // need fc- for setDayID
"

" +
(showNumbers ?
"

" :
''
) +
"

" +
"

" +
"

" +
"

" +
"";
}
s +=
"
";
}
s +=
"
" +
"

";
table = $(s).appendTo(element);

head = table.find('thead');
headCells = head.find('th');
body = table.find('tbody');
bodyRows = body.find('tr');
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 =
$("

")
.appendTo(element);
}

function updateCells(firstTime) {
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 (dowDirty) {
headCells.each(function(i, _cell) {
cell = $(_cell);
date = indexDate(i);
cell.html(formatDate(date, colFormat));
setDayID(cell, date);
});
}

bodyCells.each(function(i, _cell) {
cell = $(_cell);
date = indexDate(i);
if (date.getMonth() == month) {
cell.removeClass('fc-other-month');
}else{
cell.addClass('fc-other-month');
}
if (+date == +today) {
cell.addClass(tm + '-state-highlight fc-today');
}else{
cell.removeClass(tm + '-state-highlight fc-today');
}
cell.find('div.fc-day-number').text(date.getDate());
if (dowDirty) {
setDayID(cell, date);
}
});

bodyRows.each(function(i, _row) {
row = $(_row);
if (i < rowCnt) {
row.show();
if (i == rowCnt-1) {
row.addClass('fc-last');
}else{
row.removeClass('fc-last');
}
}else{
row.hide();
}
});
}

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);
setMinHeight(
cell.find('> div'),
(i==rowCnt-1 ? rowHeightLast : rowHeight) - vsides(cell)
);
}
});

}

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
var date = indexDate(index);
trigger('dayClick', this, date, true, ev);
}
}

/* Semi-transparent Overlay Helpers
------------------------------------------------------*/

function renderDayOverlay(overlayStart, overlayEnd, refreshCoordinateGrid) { // overlayEnd is exclusive
if (refreshCoordinateGrid) {
coordinateGrid.build();
}
var rowStart = cloneDate(t.visStart);
var rowEnd = addDays(cloneDate(rowStart), colCnt);
for (var i=0; i