*', function(ev) {
+ var seg = $(this).data('fc-seg'); // grab segment data. put there by View::renderEvents
+
+ // only call the handlers if there is not a drag/resize in progress
+ if (seg && !_this.isDraggingSeg && !_this.isResizingSeg) {
+ return func.call(this, seg, ev); // `this` will be the event element
+ }
+ });
+ }
+ );
+ },
+
+
+ // Updates internal state and triggers handlers for when an event element is moused over
+ triggerSegMouseover: function(seg, ev) {
+ if (!this.mousedOverSeg) {
+ this.mousedOverSeg = seg;
+ this.view.trigger('eventMouseover', seg.el[0], seg.event, ev);
+ }
+ },
+
+
+ // Updates internal state and triggers handlers for when an event element is moused out.
+ // Can be given no arguments, in which case it will mouseout the segment that was previously moused over.
+ triggerSegMouseout: function(seg, ev) {
+ ev = ev || {}; // if given no args, make a mock mouse event
+
+ if (this.mousedOverSeg) {
+ seg = seg || this.mousedOverSeg; // if given no args, use the currently moused-over segment
+ this.mousedOverSeg = null;
+ this.view.trigger('eventMouseout', seg.el[0], seg.event, ev);
+ }
+ },
+
+
+ /* Event Dragging
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Called when the user does a mousedown on an event, which might lead to dragging.
+ // Generic enough to work with any type of Grid.
+ segDragMousedown: function(seg, ev) {
+ var _this = this;
+ var view = this.view;
+ var calendar = view.calendar;
+ var el = seg.el;
+ var event = seg.event;
+ var dropLocation; // a "span" (start/end possibly with additional properties)
+
+ // A clone of the original element that will move with the mouse
+ var mouseFollower = new MouseFollower(seg.el, {
+ parentEl: view.el,
+ opacity: view.opt('dragOpacity'),
+ revertDuration: view.opt('dragRevertDuration'),
+ zIndex: 2 // one above the .fc-view
+ });
+
+ // Tracks mouse movement over the *view's* coordinate map. Allows dragging and dropping between subcomponents
+ // of the view.
+ var dragListener = new HitDragListener(view, {
+ distance: 5,
+ scroll: view.opt('dragScroll'),
+ subjectEl: el,
+ subjectCenter: true,
+ listenStart: function(ev) {
+ mouseFollower.hide(); // don't show until we know this is a real drag
+ mouseFollower.start(ev);
+ },
+ dragStart: function(ev) {
+ _this.triggerSegMouseout(seg, ev); // ensure a mouseout on the manipulated event has been reported
+ _this.segDragStart(seg, ev);
+ view.hideEvent(event); // hide all event segments. our mouseFollower will take over
+ },
+ hitOver: function(hit, isOrig, origHit) {
+
+ // starting hit could be forced (DayGrid.limit)
+ if (seg.hit) {
+ origHit = seg.hit;
+ }
+
+ // since we are querying the parent view, might not belong to this grid
+ dropLocation = _this.computeEventDrop(
+ origHit.component.getHitSpan(origHit),
+ hit.component.getHitSpan(hit),
+ event
+ );
+
+ if (dropLocation && !calendar.isEventRangeAllowed(dropLocation, event)) {
+ disableCursor();
+ dropLocation = null;
+ }
+
+ // if a valid drop location, have the subclass render a visual indication
+ if (dropLocation && view.renderDrag(dropLocation, seg)) {
+ mouseFollower.hide(); // if the subclass is already using a mock event "helper", hide our own
+ }
+ else {
+ mouseFollower.show(); // otherwise, have the helper follow the mouse (no snapping)
+ }
+
+ if (isOrig) {
+ dropLocation = null; // needs to have moved hits to be a valid drop
+ }
+ },
+ hitOut: function() { // called before mouse moves to a different hit OR moved out of all hits
+ view.unrenderDrag(); // unrender whatever was done in renderDrag
+ mouseFollower.show(); // show in case we are moving out of all hits
+ dropLocation = null;
+ },
+ hitDone: function() { // Called after a hitOut OR before a dragStop
+ enableCursor();
+ },
+ dragStop: function(ev) {
+ // do revert animation if hasn't changed. calls a callback when finished (whether animation or not)
+ mouseFollower.stop(!dropLocation, function() {
+ view.unrenderDrag();
+ view.showEvent(event);
+ _this.segDragStop(seg, ev);
+
+ if (dropLocation) {
+ view.reportEventDrop(event, dropLocation, this.largeUnit, el, ev);
+ }
+ });
+ },
+ listenStop: function() {
+ mouseFollower.stop(); // put in listenStop in case there was a mousedown but the drag never started
+ }
+ });
+
+ dragListener.mousedown(ev); // start listening, which will eventually lead to a dragStart
+ },
+
+
+ // Called before event segment dragging starts
+ segDragStart: function(seg, ev) {
+ this.isDraggingSeg = true;
+ this.view.trigger('eventDragStart', seg.el[0], seg.event, ev, {}); // last argument is jqui dummy
+ },
+
+
+ // Called after event segment dragging stops
+ segDragStop: function(seg, ev) {
+ this.isDraggingSeg = false;
+ this.view.trigger('eventDragStop', seg.el[0], seg.event, ev, {}); // last argument is jqui dummy
+ },
+
+
+ // Given the spans an event drag began, and the span event was dropped, calculates the new start/end/allDay
+ // values for the event. Subclasses may override and set additional properties to be used by renderDrag.
+ // A falsy returned value indicates an invalid drop.
+ computeEventDrop: function(startSpan, endSpan, event) {
+ var calendar = this.view.calendar;
+ var dragStart = startSpan.start;
+ var dragEnd = endSpan.start;
+ var delta;
+ var dropLocation;
+
+ if (dragStart.hasTime() === dragEnd.hasTime()) {
+ delta = this.diffDates(dragEnd, dragStart);
+
+ // if an all-day event was in a timed area and it was dragged to a different time,
+ // guarantee an end and adjust start/end to have times
+ if (event.allDay && durationHasTime(delta)) {
+ dropLocation = {
+ start: event.start.clone(),
+ end: calendar.getEventEnd(event), // will be an ambig day
+ allDay: false // for normalizeEventRangeTimes
+ };
+ calendar.normalizeEventRangeTimes(dropLocation);
+ }
+ // othewise, work off existing values
+ else {
+ dropLocation = {
+ start: event.start.clone(),
+ end: event.end ? event.end.clone() : null,
+ allDay: event.allDay // keep it the same
+ };
+ }
+
+ dropLocation.start.add(delta);
+ if (dropLocation.end) {
+ dropLocation.end.add(delta);
+ }
+ }
+ else {
+ // if switching from day <-> timed, start should be reset to the dropped date, and the end cleared
+ dropLocation = {
+ start: dragEnd.clone(),
+ end: null, // end should be cleared
+ allDay: !dragEnd.hasTime()
+ };
+ }
+
+ return dropLocation;
+ },
+
+
+ // Utility for apply dragOpacity to a jQuery set
+ applyDragOpacity: function(els) {
+ var opacity = this.view.opt('dragOpacity');
+
+ if (opacity != null) {
+ els.each(function(i, node) {
+ // Don't use jQuery (will set an IE filter), do it the old fashioned way.
+ // In IE8, a helper element will disappears if there's a filter.
+ node.style.opacity = opacity;
+ });
+ }
+ },
+
+
+ /* External Element Dragging
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Called when a jQuery UI drag is initiated anywhere in the DOM
+ externalDragStart: function(ev, ui) {
+ var view = this.view;
+ var el;
+ var accept;
+
+ if (view.opt('droppable')) { // only listen if this setting is on
+ el = $((ui ? ui.item : null) || ev.target);
+
+ // Test that the dragged element passes the dropAccept selector or filter function.
+ // FYI, the default is "*" (matches all)
+ accept = view.opt('dropAccept');
+ if ($.isFunction(accept) ? accept.call(el[0], el) : el.is(accept)) {
+ if (!this.isDraggingExternal) { // prevent double-listening if fired twice
+ this.listenToExternalDrag(el, ev, ui);
+ }
+ }
+ }
+ },
+
+
+ // Called when a jQuery UI drag starts and it needs to be monitored for dropping
+ listenToExternalDrag: function(el, ev, ui) {
+ var _this = this;
+ var meta = getDraggedElMeta(el); // extra data about event drop, including possible event to create
+ var dropLocation; // a null value signals an unsuccessful drag
+
+ // listener that tracks mouse movement over date-associated pixel regions
+ var dragListener = new HitDragListener(this, {
+ listenStart: function() {
+ _this.isDraggingExternal = true;
+ },
+ hitOver: function(hit) {
+ dropLocation = _this.computeExternalDrop(
+ hit.component.getHitSpan(hit), // since we are querying the parent view, might not belong to this grid
+ meta
+ );
+ if (dropLocation) {
+ _this.renderDrag(dropLocation); // called without a seg parameter
+ }
+ else { // invalid hit
+ disableCursor();
+ }
+ },
+ hitOut: function() {
+ dropLocation = null; // signal unsuccessful
+ _this.unrenderDrag();
+ enableCursor();
+ },
+ dragStop: function() {
+ _this.unrenderDrag();
+ enableCursor();
+
+ if (dropLocation) { // element was dropped on a valid hit
+ _this.view.reportExternalDrop(meta, dropLocation, el, ev, ui);
+ }
+ },
+ listenStop: function() {
+ _this.isDraggingExternal = false;
+ }
+ });
+
+ dragListener.startDrag(ev); // start listening immediately
+ },
+
+
+ // Given a hit to be dropped upon, and misc data associated with the jqui drag (guaranteed to be a plain object),
+ // returns start/end dates for the event that would result from the hypothetical drop. end might be null.
+ // Returning a null value signals an invalid drop hit.
+ computeExternalDrop: function(span, meta) {
+ var dropLocation = {
+ start: span.start,
+ end: null
+ };
+
+ // if dropped on an all-day span, and element's metadata specified a time, set it
+ if (meta.startTime && !dropLocation.start.hasTime()) {
+ dropLocation.start.time(meta.startTime);
+ }
+
+ if (meta.duration) {
+ dropLocation.end = dropLocation.start.clone().add(meta.duration);
+ }
+
+ if (!this.view.calendar.isExternalDropRangeAllowed(dropLocation, meta.eventProps)) {
+ return null;
+ }
+
+ return dropLocation;
+ },
+
+
+
+ /* Drag Rendering (for both events and an external elements)
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a visual indication of an event or external element being dragged.
+ // `dropLocation` contains hypothetical start/end/allDay values the event would have if dropped. end can be null.
+ // `seg` is the internal segment object that is being dragged. If dragging an external element, `seg` is null.
+ // A truthy returned value indicates this method has rendered a helper element.
+ renderDrag: function(dropLocation, seg) {
+ // subclasses must implement
+ },
+
+
+ // Unrenders a visual indication of an event or external element being dragged
+ unrenderDrag: function() {
+ // subclasses must implement
+ },
+
+
+ /* Resizing
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Called when the user does a mousedown on an event's resizer, which might lead to resizing.
+ // Generic enough to work with any type of Grid.
+ segResizeMousedown: function(seg, ev, isStart) {
+ var _this = this;
+ var view = this.view;
+ var calendar = view.calendar;
+ var el = seg.el;
+ var event = seg.event;
+ var eventEnd = calendar.getEventEnd(event);
+ var resizeLocation; // falsy if invalid resize
+
+ // Tracks mouse movement over the *grid's* coordinate map
+ var dragListener = new HitDragListener(this, {
+ distance: 5,
+ scroll: view.opt('dragScroll'),
+ subjectEl: el,
+ dragStart: function(ev) {
+ _this.triggerSegMouseout(seg, ev); // ensure a mouseout on the manipulated event has been reported
+ _this.segResizeStart(seg, ev);
+ },
+ hitOver: function(hit, isOrig, origHit) {
+ var origHitSpan = _this.getHitSpan(origHit);
+ var hitSpan = _this.getHitSpan(hit);
+
+ resizeLocation = isStart ?
+ _this.computeEventStartResize(origHitSpan, hitSpan, event) :
+ _this.computeEventEndResize(origHitSpan, hitSpan, event);
+
+ if (resizeLocation) {
+ if (!calendar.isEventRangeAllowed(resizeLocation, event)) {
+ disableCursor();
+ resizeLocation = null;
+ }
+ // no change? (TODO: how does this work with timezones?)
+ else if (resizeLocation.start.isSame(event.start) && resizeLocation.end.isSame(eventEnd)) {
+ resizeLocation = null;
+ }
+ }
+
+ if (resizeLocation) {
+ view.hideEvent(event);
+ _this.renderEventResize(resizeLocation, seg);
+ }
+ },
+ hitOut: function() { // called before mouse moves to a different hit OR moved out of all hits
+ resizeLocation = null;
+ },
+ hitDone: function() { // resets the rendering to show the original event
+ _this.unrenderEventResize();
+ view.showEvent(event);
+ enableCursor();
+ },
+ dragStop: function(ev) {
+ _this.segResizeStop(seg, ev);
+
+ if (resizeLocation) { // valid date to resize to?
+ view.reportEventResize(event, resizeLocation, this.largeUnit, el, ev);
+ }
+ }
+ });
+
+ dragListener.mousedown(ev); // start listening, which will eventually lead to a dragStart
+ },
+
+
+ // Called before event segment resizing starts
+ segResizeStart: function(seg, ev) {
+ this.isResizingSeg = true;
+ this.view.trigger('eventResizeStart', seg.el[0], seg.event, ev, {}); // last argument is jqui dummy
+ },
+
+
+ // Called after event segment resizing stops
+ segResizeStop: function(seg, ev) {
+ this.isResizingSeg = false;
+ this.view.trigger('eventResizeStop', seg.el[0], seg.event, ev, {}); // last argument is jqui dummy
+ },
+
+
+ // Returns new date-information for an event segment being resized from its start
+ computeEventStartResize: function(startSpan, endSpan, event) {
+ return this.computeEventResize('start', startSpan, endSpan, event);
+ },
+
+
+ // Returns new date-information for an event segment being resized from its end
+ computeEventEndResize: function(startSpan, endSpan, event) {
+ return this.computeEventResize('end', startSpan, endSpan, event);
+ },
+
+
+ // Returns new date-information for an event segment being resized from its start OR end
+ // `type` is either 'start' or 'end'
+ computeEventResize: function(type, startSpan, endSpan, event) {
+ var calendar = this.view.calendar;
+ var delta = this.diffDates(endSpan[type], startSpan[type]);
+ var range;
+ var defaultDuration;
+
+ // build original values to work from, guaranteeing a start and end
+ range = {
+ start: event.start.clone(),
+ end: calendar.getEventEnd(event),
+ allDay: event.allDay
+ };
+
+ // if an all-day event was in a timed area and was resized to a time, adjust start/end to have times
+ if (range.allDay && durationHasTime(delta)) {
+ range.allDay = false;
+ calendar.normalizeEventRangeTimes(range);
+ }
+
+ range[type].add(delta); // apply delta to start or end
+
+ // if the event was compressed too small, find a new reasonable duration for it
+ if (!range.start.isBefore(range.end)) {
+
+ defaultDuration =
+ this.minResizeDuration || // TODO: hack
+ (event.allDay ?
+ calendar.defaultAllDayEventDuration :
+ calendar.defaultTimedEventDuration);
+
+ if (type == 'start') { // resizing the start?
+ range.start = range.end.clone().subtract(defaultDuration);
+ }
+ else { // resizing the end?
+ range.end = range.start.clone().add(defaultDuration);
+ }
+ }
+
+ return range;
+ },
+
+
+ // Renders a visual indication of an event being resized.
+ // `range` has the updated dates of the event. `seg` is the original segment object involved in the drag.
+ renderEventResize: function(range, seg) {
+ // subclasses must implement
+ },
+
+
+ // Unrenders a visual indication of an event being resized.
+ unrenderEventResize: function() {
+ // subclasses must implement
+ },
+
+
+ /* Rendering Utils
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Compute the text that should be displayed on an event's element.
+ // `range` can be the Event object itself, or something range-like, with at least a `start`.
+ // If event times are disabled, or the event has no time, will return a blank string.
+ // If not specified, formatStr will default to the eventTimeFormat setting,
+ // and displayEnd will default to the displayEventEnd setting.
+ getEventTimeText: function(range, formatStr, displayEnd) {
+
+ if (formatStr == null) {
+ formatStr = this.eventTimeFormat;
+ }
+
+ if (displayEnd == null) {
+ displayEnd = this.displayEventEnd;
+ }
+
+ if (this.displayEventTime && range.start.hasTime()) {
+ if (displayEnd && range.end) {
+ return this.view.formatRange(range, formatStr);
+ }
+ else {
+ return range.start.format(formatStr);
+ }
+ }
+
+ return '';
+ },
+
+
+ // Generic utility for generating the HTML classNames for an event segment's element
+ getSegClasses: function(seg, isDraggable, isResizable) {
+ var event = seg.event;
+ var classes = [
+ 'fc-event',
+ seg.isStart ? 'fc-start' : 'fc-not-start',
+ seg.isEnd ? 'fc-end' : 'fc-not-end'
+ ].concat(
+ event.className,
+ event.source ? event.source.className : []
+ );
+
+ if (isDraggable) {
+ classes.push('fc-draggable');
+ }
+ if (isResizable) {
+ classes.push('fc-resizable');
+ }
+
+ return classes;
+ },
+
+
+ // Utility for generating event skin-related CSS properties
+ getEventSkinCss: function(event) {
+ var view = this.view;
+ var source = event.source || {};
+ var eventColor = event.color;
+ var sourceColor = source.color;
+ var optionColor = view.opt('eventColor');
+
+ return {
+ 'background-color':
+ event.backgroundColor ||
+ eventColor ||
+ source.backgroundColor ||
+ sourceColor ||
+ view.opt('eventBackgroundColor') ||
+ optionColor,
+ 'border-color':
+ event.borderColor ||
+ eventColor ||
+ source.borderColor ||
+ sourceColor ||
+ view.opt('eventBorderColor') ||
+ optionColor,
+ color:
+ event.textColor ||
+ source.textColor ||
+ view.opt('eventTextColor')
+ };
+ },
+
+
+ /* Converting events -> ranges -> segs
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Converts an array of event objects into an array of event segment objects.
+ // A custom `rangeToSegsFunc` may be given for arbitrarily slicing up events.
+ // Doesn't guarantee an order for the resulting array.
+ eventsToSegs: function(events, rangeToSegsFunc) {
+ var eventRanges = this.eventsToRanges(events);
+ var segs = [];
+ var i;
+
+ for (i = 0; i < eventRanges.length; i++) {
+ segs.push.apply(
+ segs,
+ this.eventRangeToSegs(eventRanges[i], rangeToSegsFunc)
+ );
+ }
+
+ return segs;
+ },
+
+
+ // Converts an array of events into an array of "range" objects.
+ // A "range" object is a plain object with start/end properties denoting the time it covers. Also an event property.
+ // For "normal" events, this will be identical to the event's start/end, but for "inverse-background" events,
+ // will create an array of ranges that span the time *not* covered by the given event.
+ // Doesn't guarantee an order for the resulting array.
+ eventsToRanges: function(events) {
+ var _this = this;
+ var eventsById = groupEventsById(events);
+ var ranges = [];
+
+ // group by ID so that related inverse-background events can be rendered together
+ $.each(eventsById, function(id, eventGroup) {
+ if (eventGroup.length) {
+ ranges.push.apply(
+ ranges,
+ isInverseBgEvent(eventGroup[0]) ?
+ _this.eventsToInverseRanges(eventGroup) :
+ _this.eventsToNormalRanges(eventGroup)
+ );
+ }
+ });
+
+ return ranges;
+ },
+
+
+ // Converts an array of "normal" events (not inverted rendering) into a parallel array of ranges
+ eventsToNormalRanges: function(events) {
+ var calendar = this.view.calendar;
+ var ranges = [];
+ var i, event;
+ var eventStart, eventEnd;
+
+ for (i = 0; i < events.length; i++) {
+ event = events[i];
+
+ // make copies and normalize by stripping timezone
+ eventStart = event.start.clone().stripZone();
+ eventEnd = calendar.getEventEnd(event).stripZone();
+
+ ranges.push({
+ event: event,
+ start: eventStart,
+ end: eventEnd,
+ eventStartMS: +eventStart,
+ eventDurationMS: eventEnd - eventStart
+ });
+ }
+
+ return ranges;
+ },
+
+
+ // Converts an array of events, with inverse-background rendering, into an array of range objects.
+ // The range objects will cover all the time NOT covered by the events.
+ eventsToInverseRanges: function(events) {
+ var view = this.view;
+ var viewStart = view.start.clone().stripZone(); // normalize timezone
+ var viewEnd = view.end.clone().stripZone(); // normalize timezone
+ var normalRanges = this.eventsToNormalRanges(events); // will give us normalized dates we can use w/o copies
+ var inverseRanges = [];
+ var event0 = events[0]; // assign this to each range's `.event`
+ var start = viewStart; // the end of the previous range. the start of the new range
+ var i, normalRange;
+
+ // ranges need to be in order. required for our date-walking algorithm
+ normalRanges.sort(compareNormalRanges);
+
+ for (i = 0; i < normalRanges.length; i++) {
+ normalRange = normalRanges[i];
+
+ // add the span of time before the event (if there is any)
+ if (normalRange.start > start) { // compare millisecond time (skip any ambig logic)
+ inverseRanges.push({
+ event: event0,
+ start: start,
+ end: normalRange.start
+ });
+ }
+
+ start = normalRange.end;
+ }
+
+ // add the span of time after the last event (if there is any)
+ if (start < viewEnd) { // compare millisecond time (skip any ambig logic)
+ inverseRanges.push({
+ event: event0,
+ start: start,
+ end: viewEnd
+ });
+ }
+
+ return inverseRanges;
+ },
+
+
+ // Slices the given event range into one or more segment objects.
+ // A `rangeToSegsFunc` custom slicing function can be given.
+ eventRangeToSegs: function(eventRange, rangeToSegsFunc) {
+ var segs;
+ var i, seg;
+
+ eventRange = this.view.calendar.ensureVisibleEventRange(eventRange);
+
+ if (rangeToSegsFunc) {
+ segs = rangeToSegsFunc(eventRange);
+ }
+ else {
+ segs = this.rangeToSegs(eventRange); // defined by the subclass
+ }
+
+ for (i = 0; i < segs.length; i++) {
+ seg = segs[i];
+ seg.event = eventRange.event;
+ seg.eventStartMS = eventRange.eventStartMS;
+ seg.eventDurationMS = eventRange.eventDurationMS;
+ }
+
+ return segs;
+ },
+
+
+ sortSegs: function(segs) {
+ segs.sort(proxy(this, 'compareSegs'));
+ },
+
+
+ // A cmp function for determining which segments should take visual priority
+ // DOES NOT WORK ON INVERTED BACKGROUND EVENTS because they have no eventStartMS/eventDurationMS
+ compareSegs: function(seg1, seg2) {
+ return seg1.eventStartMS - seg2.eventStartMS || // earlier events go first
+ seg2.eventDurationMS - seg1.eventDurationMS || // tie? longer events go first
+ seg2.event.allDay - seg1.event.allDay || // tie? put all-day events first (booleans cast to 0/1)
+ compareByFieldSpecs(seg1.event, seg2.event, this.view.eventOrderSpecs);
+ }
+
+});
+
+
+/* Utilities
+----------------------------------------------------------------------------------------------------------------------*/
+
+
+function isBgEvent(event) { // returns true if background OR inverse-background
+ var rendering = getEventRendering(event);
+ return rendering === 'background' || rendering === 'inverse-background';
+}
+
+
+function isInverseBgEvent(event) {
+ return getEventRendering(event) === 'inverse-background';
+}
+
+
+function getEventRendering(event) {
+ return firstDefined((event.source || {}).rendering, event.rendering);
+}
+
+
+function groupEventsById(events) {
+ var eventsById = {};
+ var i, event;
+
+ for (i = 0; i < events.length; i++) {
+ event = events[i];
+ (eventsById[event._id] || (eventsById[event._id] = [])).push(event);
+ }
+
+ return eventsById;
+}
+
+
+// A cmp function for determining which non-inverted "ranges" (see above) happen earlier
+function compareNormalRanges(range1, range2) {
+ return range1.eventStartMS - range2.eventStartMS; // earlier ranges go first
+}
+
+
+/* External-Dragging-Element Data
+----------------------------------------------------------------------------------------------------------------------*/
+
+// Require all HTML5 data-* attributes used by FullCalendar to have this prefix.
+// A value of '' will query attributes like data-event. A value of 'fc' will query attributes like data-fc-event.
+FC.dataAttrPrefix = '';
+
+// Given a jQuery element that might represent a dragged FullCalendar event, returns an intermediate data structure
+// to be used for Event Object creation.
+// A defined `.eventProps`, even when empty, indicates that an event should be created.
+function getDraggedElMeta(el) {
+ var prefix = FC.dataAttrPrefix;
+ var eventProps; // properties for creating the event, not related to date/time
+ var startTime; // a Duration
+ var duration;
+ var stick;
+
+ if (prefix) { prefix += '-'; }
+ eventProps = el.data(prefix + 'event') || null;
+
+ if (eventProps) {
+ if (typeof eventProps === 'object') {
+ eventProps = $.extend({}, eventProps); // make a copy
+ }
+ else { // something like 1 or true. still signal event creation
+ eventProps = {};
+ }
+
+ // pluck special-cased date/time properties
+ startTime = eventProps.start;
+ if (startTime == null) { startTime = eventProps.time; } // accept 'time' as well
+ duration = eventProps.duration;
+ stick = eventProps.stick;
+ delete eventProps.start;
+ delete eventProps.time;
+ delete eventProps.duration;
+ delete eventProps.stick;
+ }
+
+ // fallback to standalone attribute values for each of the date/time properties
+ if (startTime == null) { startTime = el.data(prefix + 'start'); }
+ if (startTime == null) { startTime = el.data(prefix + 'time'); } // accept 'time' as well
+ if (duration == null) { duration = el.data(prefix + 'duration'); }
+ if (stick == null) { stick = el.data(prefix + 'stick'); }
+
+ // massage into correct data types
+ startTime = startTime != null ? moment.duration(startTime) : null;
+ duration = duration != null ? moment.duration(duration) : null;
+ stick = Boolean(stick);
+
+ return { eventProps: eventProps, startTime: startTime, duration: duration, stick: stick };
+}
+
+
+;;
+
+/*
+A set of rendering and date-related methods for a visual component comprised of one or more rows of day columns.
+Prerequisite: the object being mixed into needs to be a *Grid*
+*/
+var DayTableMixin = FC.DayTableMixin = {
+
+ breakOnWeeks: false, // should create a new row for each week?
+ dayDates: null, // whole-day dates for each column. left to right
+ dayIndices: null, // for each day from start, the offset
+ daysPerRow: null,
+ rowCnt: null,
+ colCnt: null,
+ colHeadFormat: null,
+
+
+ // Populates internal variables used for date calculation and rendering
+ updateDayTable: function() {
+ var view = this.view;
+ var date = this.start.clone();
+ var dayIndex = -1;
+ var dayIndices = [];
+ var dayDates = [];
+ var daysPerRow;
+ var firstDay;
+ var rowCnt;
+
+ while (date.isBefore(this.end)) { // loop each day from start to end
+ if (view.isHiddenDay(date)) {
+ dayIndices.push(dayIndex + 0.5); // mark that it's between indices
+ }
+ else {
+ dayIndex++;
+ dayIndices.push(dayIndex);
+ dayDates.push(date.clone());
+ }
+ date.add(1, 'days');
+ }
+
+ if (this.breakOnWeeks) {
+ // count columns until the day-of-week repeats
+ firstDay = dayDates[0].day();
+ for (daysPerRow = 1; daysPerRow < dayDates.length; daysPerRow++) {
+ if (dayDates[daysPerRow].day() == firstDay) {
+ break;
+ }
+ }
+ rowCnt = Math.ceil(dayDates.length / daysPerRow);
+ }
+ else {
+ rowCnt = 1;
+ daysPerRow = dayDates.length;
+ }
+
+ this.dayDates = dayDates;
+ this.dayIndices = dayIndices;
+ this.daysPerRow = daysPerRow;
+ this.rowCnt = rowCnt;
+
+ this.updateDayTableCols();
+ },
+
+
+ // Computes and assigned the colCnt property and updates any options that may be computed from it
+ updateDayTableCols: function() {
+ this.colCnt = this.computeColCnt();
+ this.colHeadFormat = this.view.opt('columnFormat') || this.computeColHeadFormat();
+ },
+
+
+ // Determines how many columns there should be in the table
+ computeColCnt: function() {
+ return this.daysPerRow;
+ },
+
+
+ // Computes the ambiguously-timed moment for the given cell
+ getCellDate: function(row, col) {
+ return this.dayDates[
+ this.getCellDayIndex(row, col)
+ ].clone();
+ },
+
+
+ // Computes the ambiguously-timed date range for the given cell
+ getCellRange: function(row, col) {
+ var start = this.getCellDate(row, col);
+ var end = start.clone().add(1, 'days');
+
+ return { start: start, end: end };
+ },
+
+
+ // Returns the number of day cells, chronologically, from the first of the grid (0-based)
+ getCellDayIndex: function(row, col) {
+ return row * this.daysPerRow + this.getColDayIndex(col);
+ },
+
+
+ // Returns the numner of day cells, chronologically, from the first cell in *any given row*
+ getColDayIndex: function(col) {
+ if (this.isRTL) {
+ return this.colCnt - 1 - col;
+ }
+ else {
+ return col;
+ }
+ },
+
+
+ // Given a date, returns its chronolocial cell-index from the first cell of the grid.
+ // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
+ // If before the first offset, returns a negative number.
+ // If after the last offset, returns an offset past the last cell offset.
+ // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
+ getDateDayIndex: function(date) {
+ var dayIndices = this.dayIndices;
+ var dayOffset = date.diff(this.start, 'days');
+
+ if (dayOffset < 0) {
+ return dayIndices[0] - 1;
+ }
+ else if (dayOffset >= dayIndices.length) {
+ return dayIndices[dayIndices.length - 1] + 1;
+ }
+ else {
+ return dayIndices[dayOffset];
+ }
+ },
+
+
+ /* Options
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Computes a default column header formatting string if `colFormat` is not explicitly defined
+ computeColHeadFormat: function() {
+ // if more than one week row, or if there are a lot of columns with not much space,
+ // put just the day numbers will be in each cell
+ if (this.rowCnt > 1 || this.colCnt > 10) {
+ return 'ddd'; // "Sat"
+ }
+ // multiple days, so full single date string WON'T be in title text
+ else if (this.colCnt > 1) {
+ return this.view.opt('dayOfMonthFormat'); // "Sat 12/10"
+ }
+ // single day, so full single date string will probably be in title text
+ else {
+ return 'dddd'; // "Saturday"
+ }
+ },
+
+
+ /* Slicing
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Slices up a date range into a segment for every week-row it intersects with
+ sliceRangeByRow: function(range) {
+ var daysPerRow = this.daysPerRow;
+ var normalRange = this.view.computeDayRange(range); // make whole-day range, considering nextDayThreshold
+ var rangeFirst = this.getDateDayIndex(normalRange.start); // inclusive first index
+ var rangeLast = this.getDateDayIndex(normalRange.end.clone().subtract(1, 'days')); // inclusive last index
+ var segs = [];
+ var row;
+ var rowFirst, rowLast; // inclusive day-index range for current row
+ var segFirst, segLast; // inclusive day-index range for segment
+
+ for (row = 0; row < this.rowCnt; row++) {
+ rowFirst = row * daysPerRow;
+ rowLast = rowFirst + daysPerRow - 1;
+
+ // intersect segment's offset range with the row's
+ segFirst = Math.max(rangeFirst, rowFirst);
+ segLast = Math.min(rangeLast, rowLast);
+
+ // deal with in-between indices
+ segFirst = Math.ceil(segFirst); // in-between starts round to next cell
+ segLast = Math.floor(segLast); // in-between ends round to prev cell
+
+ if (segFirst <= segLast) { // was there any intersection with the current row?
+ segs.push({
+ row: row,
+
+ // normalize to start of row
+ firstRowDayIndex: segFirst - rowFirst,
+ lastRowDayIndex: segLast - rowFirst,
+
+ // must be matching integers to be the segment's start/end
+ isStart: segFirst === rangeFirst,
+ isEnd: segLast === rangeLast
+ });
+ }
+ }
+
+ return segs;
+ },
+
+
+ // Slices up a date range into a segment for every day-cell it intersects with.
+ // TODO: make more DRY with sliceRangeByRow somehow.
+ sliceRangeByDay: function(range) {
+ var daysPerRow = this.daysPerRow;
+ var normalRange = this.view.computeDayRange(range); // make whole-day range, considering nextDayThreshold
+ var rangeFirst = this.getDateDayIndex(normalRange.start); // inclusive first index
+ var rangeLast = this.getDateDayIndex(normalRange.end.clone().subtract(1, 'days')); // inclusive last index
+ var segs = [];
+ var row;
+ var rowFirst, rowLast; // inclusive day-index range for current row
+ var i;
+ var segFirst, segLast; // inclusive day-index range for segment
+
+ for (row = 0; row < this.rowCnt; row++) {
+ rowFirst = row * daysPerRow;
+ rowLast = rowFirst + daysPerRow - 1;
+
+ for (i = rowFirst; i <= rowLast; i++) {
+
+ // intersect segment's offset range with the row's
+ segFirst = Math.max(rangeFirst, i);
+ segLast = Math.min(rangeLast, i);
+
+ // deal with in-between indices
+ segFirst = Math.ceil(segFirst); // in-between starts round to next cell
+ segLast = Math.floor(segLast); // in-between ends round to prev cell
+
+ if (segFirst <= segLast) { // was there any intersection with the current row?
+ segs.push({
+ row: row,
+
+ // normalize to start of row
+ firstRowDayIndex: segFirst - rowFirst,
+ lastRowDayIndex: segLast - rowFirst,
+
+ // must be matching integers to be the segment's start/end
+ isStart: segFirst === rangeFirst,
+ isEnd: segLast === rangeLast
+ });
+ }
+ }
+ }
+
+ return segs;
+ },
+
+
+ /* Header Rendering
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ renderHeadHtml: function() {
+ var view = this.view;
+
+ return '' +
+ '';
+ },
+
+
+ renderHeadIntroHtml: function() {
+ return this.renderIntroHtml(); // fall back to generic
+ },
+
+
+ renderHeadTrHtml: function() {
+ return '' +
+ '' +
+ (this.isRTL ? '' : this.renderHeadIntroHtml()) +
+ this.renderHeadDateCellsHtml() +
+ (this.isRTL ? this.renderHeadIntroHtml() : '') +
+ '
';
+ },
+
+
+ renderHeadDateCellsHtml: function() {
+ var htmls = [];
+ var col, date;
+
+ for (col = 0; col < this.colCnt; col++) {
+ date = this.getCellDate(0, col);
+ htmls.push(this.renderHeadDateCellHtml(date));
+ }
+
+ return htmls.join('');
+ },
+
+
+ renderHeadDateCellHtml: function(date, colspan) {
+ var view = this.view;
+
+ return '' +
+ '';
+ },
+
+
+ /* Background Rendering
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ renderBgTrHtml: function(row) {
+ return '' +
+ '' +
+ (this.isRTL ? '' : this.renderBgIntroHtml(row)) +
+ this.renderBgCellsHtml(row) +
+ (this.isRTL ? this.renderBgIntroHtml(row) : '') +
+ '
';
+ },
+
+
+ renderBgIntroHtml: function(row) {
+ return this.renderIntroHtml(); // fall back to generic
+ },
+
+
+ renderBgCellsHtml: function(row) {
+ var htmls = [];
+ var col, date;
+
+ for (col = 0; col < this.colCnt; col++) {
+ date = this.getCellDate(row, col);
+ htmls.push(this.renderBgCellHtml(date));
+ }
+
+ return htmls.join('');
+ },
+
+
+ renderBgCellHtml: function(date) {
+ var view = this.view;
+ var classes = this.getDayClasses(date);
+
+ classes.unshift('fc-day', view.widgetContentClass);
+
+ return ' | ';
+ },
+
+
+ /* Generic
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Generates the default HTML intro for any row. User classes should override
+ renderIntroHtml: function() {
+ },
+
+
+ /* Utils
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Applies the generic "intro" and "outro" HTML to the given cells.
+ // Intro means the leftmost cell when the calendar is LTR and the rightmost cell when RTL. Vice-versa for outro.
+ bookendCells: function(trEl) {
+ var introHtml = this.renderIntroHtml();
+
+ if (introHtml) {
+ if (this.isRTL) {
+ trEl.append(introHtml);
+ }
+ else {
+ trEl.prepend(introHtml);
+ }
+ }
+ }
+
+};
+
+;;
+
+/* A component that renders a grid of whole-days that runs horizontally. There can be multiple rows, one per week.
+----------------------------------------------------------------------------------------------------------------------*/
+
+var DayGrid = FC.DayGrid = Grid.extend(DayTableMixin, {
+
+ numbersVisible: false, // should render a row for day/week numbers? set by outside view. TODO: make internal
+ bottomCoordPadding: 0, // hack for extending the hit area for the last row of the coordinate grid
+
+ rowEls: null, // set of fake row elements
+ cellEls: null, // set of whole-day elements comprising the row's background
+ helperEls: null, // set of cell skeleton elements for rendering the mock event "helper"
+
+ rowCoordCache: null,
+ colCoordCache: null,
+
+
+ // Renders the rows and columns into the component's `this.el`, which should already be assigned.
+ // isRigid determins whether the individual rows should ignore the contents and be a constant height.
+ // Relies on the view's colCnt and rowCnt. In the future, this component should probably be self-sufficient.
+ renderDates: function(isRigid) {
+ var view = this.view;
+ var rowCnt = this.rowCnt;
+ var colCnt = this.colCnt;
+ var html = '';
+ var row;
+ var col;
+
+ for (row = 0; row < rowCnt; row++) {
+ html += this.renderDayRowHtml(row, isRigid);
+ }
+ this.el.html(html);
+
+ this.rowEls = this.el.find('.fc-row');
+ this.cellEls = this.el.find('.fc-day');
+
+ this.rowCoordCache = new CoordCache({
+ els: this.rowEls,
+ isVertical: true
+ });
+ this.colCoordCache = new CoordCache({
+ els: this.cellEls.slice(0, this.colCnt), // only the first row
+ isHorizontal: true
+ });
+
+ // trigger dayRender with each cell's element
+ for (row = 0; row < rowCnt; row++) {
+ for (col = 0; col < colCnt; col++) {
+ view.trigger(
+ 'dayRender',
+ null,
+ this.getCellDate(row, col),
+ this.getCellEl(row, col)
+ );
+ }
+ }
+ },
+
+
+ unrenderDates: function() {
+ this.removeSegPopover();
+ },
+
+
+ renderBusinessHours: function() {
+ var events = this.view.calendar.getBusinessHoursEvents(true); // wholeDay=true
+ var segs = this.eventsToSegs(events);
+
+ this.renderFill('businessHours', segs, 'bgevent');
+ },
+
+
+ // Generates the HTML for a single row, which is a div that wraps a table.
+ // `row` is the row number.
+ renderDayRowHtml: function(row, isRigid) {
+ var view = this.view;
+ var classes = [ 'fc-row', 'fc-week', view.widgetContentClass ];
+
+ if (isRigid) {
+ classes.push('fc-rigid');
+ }
+
+ return '' +
+ '' +
+ '
' +
+ '
' +
+ this.renderBgTrHtml(row) +
+ '
' +
+ '
' +
+ '
' +
+ '
' +
+ (this.numbersVisible ?
+ '' +
+ this.renderNumberTrHtml(row) +
+ '' :
+ ''
+ ) +
+ '
' +
+ '
' +
+ '
';
+ },
+
+
+ /* Grid Number Rendering
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ renderNumberTrHtml: function(row) {
+ return '' +
+ '' +
+ (this.isRTL ? '' : this.renderNumberIntroHtml(row)) +
+ this.renderNumberCellsHtml(row) +
+ (this.isRTL ? this.renderNumberIntroHtml(row) : '') +
+ '
';
+ },
+
+
+ renderNumberIntroHtml: function(row) {
+ return this.renderIntroHtml();
+ },
+
+
+ renderNumberCellsHtml: function(row) {
+ var htmls = [];
+ var col, date;
+
+ for (col = 0; col < this.colCnt; col++) {
+ date = this.getCellDate(row, col);
+ htmls.push(this.renderNumberCellHtml(date));
+ }
+
+ return htmls.join('');
+ },
+
+
+ // Generates the HTML for the s of the "number" row in the DayGrid's content skeleton.
+ // The number row will only exist if either day numbers or week numbers are turned on.
+ renderNumberCellHtml: function(date) {
+ var classes;
+
+ if (!this.view.dayNumbersVisible) { // if there are week numbers but not day numbers
+ return ' | | '; // will create an empty space above events :(
+ }
+
+ classes = this.getDayClasses(date);
+ classes.unshift('fc-day-number');
+
+ return '' +
+ '' +
+ date.date() +
+ ' | ';
+ },
+
+
+ /* Options
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Computes a default event time formatting string if `timeFormat` is not explicitly defined
+ computeEventTimeFormat: function() {
+ return this.view.opt('extraSmallTimeFormat'); // like "6p" or "6:30p"
+ },
+
+
+ // Computes a default `displayEventEnd` value if one is not expliclty defined
+ computeDisplayEventEnd: function() {
+ return this.colCnt == 1; // we'll likely have space if there's only one day
+ },
+
+
+ /* Dates
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ rangeUpdated: function() {
+ this.updateDayTable();
+ },
+
+
+ // Slices up a date range by row into an array of segments
+ rangeToSegs: function(range) {
+ var segs = this.sliceRangeByRow(range);
+ var i, seg;
+
+ for (i = 0; i < segs.length; i++) {
+ seg = segs[i];
+ if (this.isRTL) {
+ seg.leftCol = this.daysPerRow - 1 - seg.lastRowDayIndex;
+ seg.rightCol = this.daysPerRow - 1 - seg.firstRowDayIndex;
+ }
+ else {
+ seg.leftCol = seg.firstRowDayIndex;
+ seg.rightCol = seg.lastRowDayIndex;
+ }
+ }
+
+ return segs;
+ },
+
+
+ /* Hit System
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ prepareHits: function() {
+ this.colCoordCache.build();
+ this.rowCoordCache.build();
+ this.rowCoordCache.bottoms[this.rowCnt - 1] += this.bottomCoordPadding; // hack
+ },
+
+
+ releaseHits: function() {
+ this.colCoordCache.clear();
+ this.rowCoordCache.clear();
+ },
+
+
+ queryHit: function(leftOffset, topOffset) {
+ var col = this.colCoordCache.getHorizontalIndex(leftOffset);
+ var row = this.rowCoordCache.getVerticalIndex(topOffset);
+
+ if (row != null && col != null) {
+ return this.getCellHit(row, col);
+ }
+ },
+
+
+ getHitSpan: function(hit) {
+ return this.getCellRange(hit.row, hit.col);
+ },
+
+
+ getHitEl: function(hit) {
+ return this.getCellEl(hit.row, hit.col);
+ },
+
+
+ /* Cell System
+ ------------------------------------------------------------------------------------------------------------------*/
+ // FYI: the first column is the leftmost column, regardless of date
+
+
+ getCellHit: function(row, col) {
+ return {
+ row: row,
+ col: col,
+ component: this, // needed unfortunately :(
+ left: this.colCoordCache.getLeftOffset(col),
+ right: this.colCoordCache.getRightOffset(col),
+ top: this.rowCoordCache.getTopOffset(row),
+ bottom: this.rowCoordCache.getBottomOffset(row)
+ };
+ },
+
+
+ getCellEl: function(row, col) {
+ return this.cellEls.eq(row * this.colCnt + col);
+ },
+
+
+ /* Event Drag Visualization
+ ------------------------------------------------------------------------------------------------------------------*/
+ // TODO: move to DayGrid.event, similar to what we did with Grid's drag methods
+
+
+ // Renders a visual indication of an event or external element being dragged.
+ // The dropLocation's end can be null. seg can be null. See Grid::renderDrag for more info.
+ renderDrag: function(dropLocation, seg) {
+
+ // always render a highlight underneath
+ this.renderHighlight(this.eventRangeToSegs(dropLocation));
+
+ // if a segment from the same calendar but another component is being dragged, render a helper event
+ if (seg && !seg.el.closest(this.el).length) {
+
+ this.renderRangeHelper(dropLocation, seg);
+ this.applyDragOpacity(this.helperEls);
+
+ return true; // a helper has been rendered
+ }
+ },
+
+
+ // Unrenders any visual indication of a hovering event
+ unrenderDrag: function() {
+ this.unrenderHighlight();
+ this.unrenderHelper();
+ },
+
+
+ /* Event Resize Visualization
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a visual indication of an event being resized
+ renderEventResize: function(range, seg) {
+ this.renderHighlight(this.eventRangeToSegs(range));
+ this.renderRangeHelper(range, seg);
+ },
+
+
+ // Unrenders a visual indication of an event being resized
+ unrenderEventResize: function() {
+ this.unrenderHighlight();
+ this.unrenderHelper();
+ },
+
+
+ /* Event Helper
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a mock "helper" event. `sourceSeg` is the associated internal segment object. It can be null.
+ renderHelper: function(event, sourceSeg) {
+ var helperNodes = [];
+ var segs = this.eventsToSegs([ event ]);
+ var rowStructs;
+
+ segs = this.renderFgSegEls(segs); // assigns each seg's el and returns a subset of segs that were rendered
+ rowStructs = this.renderSegRows(segs);
+
+ // inject each new event skeleton into each associated row
+ this.rowEls.each(function(row, rowNode) {
+ var rowEl = $(rowNode); // the .fc-row
+ var skeletonEl = $(''); // will be absolutely positioned
+ var skeletonTop;
+
+ // If there is an original segment, match the top position. Otherwise, put it at the row's top level
+ if (sourceSeg && sourceSeg.row === row) {
+ skeletonTop = sourceSeg.el.position().top;
+ }
+ else {
+ skeletonTop = rowEl.find('.fc-content-skeleton tbody').position().top;
+ }
+
+ skeletonEl.css('top', skeletonTop)
+ .find('table')
+ .append(rowStructs[row].tbodyEl);
+
+ rowEl.append(skeletonEl);
+ helperNodes.push(skeletonEl[0]);
+ });
+
+ this.helperEls = $(helperNodes); // array -> jQuery set
+ },
+
+
+ // Unrenders any visual indication of a mock helper event
+ unrenderHelper: function() {
+ if (this.helperEls) {
+ this.helperEls.remove();
+ this.helperEls = null;
+ }
+ },
+
+
+ /* Fill System (highlight, background events, business hours)
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ fillSegTag: 'td', // override the default tag name
+
+
+ // Renders a set of rectangles over the given segments of days.
+ // Only returns segments that successfully rendered.
+ renderFill: function(type, segs, className) {
+ var nodes = [];
+ var i, seg;
+ var skeletonEl;
+
+ segs = this.renderFillSegEls(type, segs); // assignes `.el` to each seg. returns successfully rendered segs
+
+ for (i = 0; i < segs.length; i++) {
+ seg = segs[i];
+ skeletonEl = this.renderFillRow(type, seg, className);
+ this.rowEls.eq(seg.row).append(skeletonEl);
+ nodes.push(skeletonEl[0]);
+ }
+
+ this.elsByFill[type] = $(nodes);
+
+ return segs;
+ },
+
+
+ // Generates the HTML needed for one row of a fill. Requires the seg's el to be rendered.
+ renderFillRow: function(type, seg, className) {
+ var colCnt = this.colCnt;
+ var startCol = seg.leftCol;
+ var endCol = seg.rightCol + 1;
+ var skeletonEl;
+ var trEl;
+
+ className = className || type.toLowerCase();
+
+ skeletonEl = $(
+ ''
+ );
+ trEl = skeletonEl.find('tr');
+
+ if (startCol > 0) {
+ trEl.append(' | ');
+ }
+
+ trEl.append(
+ seg.el.attr('colspan', endCol - startCol)
+ );
+
+ if (endCol < colCnt) {
+ trEl.append(' | ');
+ }
+
+ this.bookendCells(trEl);
+
+ return skeletonEl;
+ }
+
+});
+
+;;
+
+/* Event-rendering methods for the DayGrid class
+----------------------------------------------------------------------------------------------------------------------*/
+
+DayGrid.mixin({
+
+ rowStructs: null, // an array of objects, each holding information about a row's foreground event-rendering
+
+
+ // Unrenders all events currently rendered on the grid
+ unrenderEvents: function() {
+ this.removeSegPopover(); // removes the "more.." events popover
+ Grid.prototype.unrenderEvents.apply(this, arguments); // calls the super-method
+ },
+
+
+ // Retrieves all rendered segment objects currently rendered on the grid
+ getEventSegs: function() {
+ return Grid.prototype.getEventSegs.call(this) // get the segments from the super-method
+ .concat(this.popoverSegs || []); // append the segments from the "more..." popover
+ },
+
+
+ // Renders the given background event segments onto the grid
+ renderBgSegs: function(segs) {
+
+ // don't render timed background events
+ var allDaySegs = $.grep(segs, function(seg) {
+ return seg.event.allDay;
+ });
+
+ return Grid.prototype.renderBgSegs.call(this, allDaySegs); // call the super-method
+ },
+
+
+ // Renders the given foreground event segments onto the grid
+ renderFgSegs: function(segs) {
+ var rowStructs;
+
+ // render an `.el` on each seg
+ // returns a subset of the segs. segs that were actually rendered
+ segs = this.renderFgSegEls(segs);
+
+ rowStructs = this.rowStructs = this.renderSegRows(segs);
+
+ // append to each row's content skeleton
+ this.rowEls.each(function(i, rowNode) {
+ $(rowNode).find('.fc-content-skeleton > table').append(
+ rowStructs[i].tbodyEl
+ );
+ });
+
+ return segs; // return only the segs that were actually rendered
+ },
+
+
+ // Unrenders all currently rendered foreground event segments
+ unrenderFgSegs: function() {
+ var rowStructs = this.rowStructs || [];
+ var rowStruct;
+
+ while ((rowStruct = rowStructs.pop())) {
+ rowStruct.tbodyEl.remove();
+ }
+
+ this.rowStructs = null;
+ },
+
+
+ // Uses the given events array to generate elements that should be appended to each row's content skeleton.
+ // Returns an array of rowStruct objects (see the bottom of `renderSegRow`).
+ // PRECONDITION: each segment shoud already have a rendered and assigned `.el`
+ renderSegRows: function(segs) {
+ var rowStructs = [];
+ var segRows;
+ var row;
+
+ segRows = this.groupSegRows(segs); // group into nested arrays
+
+ // iterate each row of segment groupings
+ for (row = 0; row < segRows.length; row++) {
+ rowStructs.push(
+ this.renderSegRow(row, segRows[row])
+ );
+ }
+
+ return rowStructs;
+ },
+
+
+ // Builds the HTML to be used for the default element for an individual segment
+ fgSegHtml: function(seg, disableResizing) {
+ var view = this.view;
+ var event = seg.event;
+ var isDraggable = view.isEventDraggable(event);
+ var isResizableFromStart = !disableResizing && event.allDay &&
+ seg.isStart && view.isEventResizableFromStart(event);
+ var isResizableFromEnd = !disableResizing && event.allDay &&
+ seg.isEnd && view.isEventResizableFromEnd(event);
+ var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd);
+ var skinCss = cssToStr(this.getEventSkinCss(event));
+ var timeHtml = '';
+ var timeText;
+ var titleHtml;
+
+ classes.unshift('fc-day-grid-event', 'fc-h-event');
+
+ // Only display a timed events time if it is the starting segment
+ if (seg.isStart) {
+ timeText = this.getEventTimeText(event);
+ if (timeText) {
+ timeHtml = '' + htmlEscape(timeText) + '';
+ }
+ }
+
+ titleHtml =
+ '' +
+ (htmlEscape(event.title || '') || ' ') + // we always want one line of height
+ '';
+
+ return '' +
+ '' +
+ (this.isRTL ?
+ titleHtml + ' ' + timeHtml : // put a natural space in between
+ timeHtml + ' ' + titleHtml //
+ ) +
+ '
' +
+ (isResizableFromStart ?
+ '' :
+ ''
+ ) +
+ (isResizableFromEnd ?
+ '' :
+ ''
+ ) +
+ '';
+ },
+
+
+ // Given a row # and an array of segments all in the same row, render a element, a skeleton that contains
+ // the segments. Returns object with a bunch of internal data about how the render was calculated.
+ // NOTE: modifies rowSegs
+ renderSegRow: function(row, rowSegs) {
+ var colCnt = this.colCnt;
+ var segLevels = this.buildSegLevels(rowSegs); // group into sub-arrays of levels
+ var levelCnt = Math.max(1, segLevels.length); // ensure at least one level
+ var tbody = $('');
+ var segMatrix = []; // lookup for which segments are rendered into which level+col cells
+ var cellMatrix = []; // lookup for all elements of the level+col matrix
+ var loneCellMatrix = []; // lookup for | elements that only take up a single column
+ var i, levelSegs;
+ var col;
+ var tr;
+ var j, seg;
+ var td;
+
+ // populates empty cells from the current column (`col`) to `endCol`
+ function emptyCellsUntil(endCol) {
+ while (col < endCol) {
+ // try to grab a cell from the level above and extend its rowspan. otherwise, create a fresh cell
+ td = (loneCellMatrix[i - 1] || [])[col];
+ if (td) {
+ td.attr(
+ 'rowspan',
+ parseInt(td.attr('rowspan') || 1, 10) + 1
+ );
+ }
+ else {
+ td = $(' | | ');
+ tr.append(td);
+ }
+ cellMatrix[i][col] = td;
+ loneCellMatrix[i][col] = td;
+ col++;
+ }
+ }
+
+ for (i = 0; i < levelCnt; i++) { // iterate through all levels
+ levelSegs = segLevels[i];
+ col = 0;
+ tr = $('
');
+
+ segMatrix.push([]);
+ cellMatrix.push([]);
+ loneCellMatrix.push([]);
+
+ // levelCnt might be 1 even though there are no actual levels. protect against this.
+ // this single empty row is useful for styling.
+ if (levelSegs) {
+ for (j = 0; j < levelSegs.length; j++) { // iterate through segments in level
+ seg = levelSegs[j];
+
+ emptyCellsUntil(seg.leftCol);
+
+ // create a container that occupies or more columns. append the event element.
+ td = $(' | ').append(seg.el);
+ if (seg.leftCol != seg.rightCol) {
+ td.attr('colspan', seg.rightCol - seg.leftCol + 1);
+ }
+ else { // a single-column segment
+ loneCellMatrix[i][col] = td;
+ }
+
+ while (col <= seg.rightCol) {
+ cellMatrix[i][col] = td;
+ segMatrix[i][col] = seg;
+ col++;
+ }
+
+ tr.append(td);
+ }
+ }
+
+ emptyCellsUntil(colCnt); // finish off the row
+ this.bookendCells(tr);
+ tbody.append(tr);
+ }
+
+ return { // a "rowStruct"
+ row: row, // the row number
+ tbodyEl: tbody,
+ cellMatrix: cellMatrix,
+ segMatrix: segMatrix,
+ segLevels: segLevels,
+ segs: rowSegs
+ };
+ },
+
+
+ // Stacks a flat array of segments, which are all assumed to be in the same row, into subarrays of vertical levels.
+ // NOTE: modifies segs
+ buildSegLevels: function(segs) {
+ var levels = [];
+ var i, seg;
+ var j;
+
+ // Give preference to elements with certain criteria, so they have
+ // a chance to be closer to the top.
+ this.sortSegs(segs);
+
+ for (i = 0; i < segs.length; i++) {
+ seg = segs[i];
+
+ // loop through levels, starting with the topmost, until the segment doesn't collide with other segments
+ for (j = 0; j < levels.length; j++) {
+ if (!isDaySegCollision(seg, levels[j])) {
+ break;
+ }
+ }
+ // `j` now holds the desired subrow index
+ seg.level = j;
+
+ // create new level array if needed and append segment
+ (levels[j] || (levels[j] = [])).push(seg);
+ }
+
+ // order segments left-to-right. very important if calendar is RTL
+ for (j = 0; j < levels.length; j++) {
+ levels[j].sort(compareDaySegCols);
+ }
+
+ return levels;
+ },
+
+
+ // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's row
+ groupSegRows: function(segs) {
+ var segRows = [];
+ var i;
+
+ for (i = 0; i < this.rowCnt; i++) {
+ segRows.push([]);
+ }
+
+ for (i = 0; i < segs.length; i++) {
+ segRows[segs[i].row].push(segs[i]);
+ }
+
+ return segRows;
+ }
+
+});
+
+
+// Computes whether two segments' columns collide. They are assumed to be in the same row.
+function isDaySegCollision(seg, otherSegs) {
+ var i, otherSeg;
+
+ for (i = 0; i < otherSegs.length; i++) {
+ otherSeg = otherSegs[i];
+
+ if (
+ otherSeg.leftCol <= seg.rightCol &&
+ otherSeg.rightCol >= seg.leftCol
+ ) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+// A cmp function for determining the leftmost event
+function compareDaySegCols(a, b) {
+ return a.leftCol - b.leftCol;
+}
+
+;;
+
+/* Methods relate to limiting the number events for a given day on a DayGrid
+----------------------------------------------------------------------------------------------------------------------*/
+// NOTE: all the segs being passed around in here are foreground segs
+
+DayGrid.mixin({
+
+ segPopover: null, // the Popover that holds events that can't fit in a cell. null when not visible
+ popoverSegs: null, // an array of segment objects that the segPopover holds. null when not visible
+
+
+ removeSegPopover: function() {
+ if (this.segPopover) {
+ this.segPopover.hide(); // in handler, will call segPopover's removeElement
+ }
+ },
+
+
+ // Limits the number of "levels" (vertically stacking layers of events) for each row of the grid.
+ // `levelLimit` can be false (don't limit), a number, or true (should be computed).
+ limitRows: function(levelLimit) {
+ var rowStructs = this.rowStructs || [];
+ var row; // row #
+ var rowLevelLimit;
+
+ for (row = 0; row < rowStructs.length; row++) {
+ this.unlimitRow(row);
+
+ if (!levelLimit) {
+ rowLevelLimit = false;
+ }
+ else if (typeof levelLimit === 'number') {
+ rowLevelLimit = levelLimit;
+ }
+ else {
+ rowLevelLimit = this.computeRowLevelLimit(row);
+ }
+
+ if (rowLevelLimit !== false) {
+ this.limitRow(row, rowLevelLimit);
+ }
+ }
+ },
+
+
+ // Computes the number of levels a row will accomodate without going outside its bounds.
+ // Assumes the row is "rigid" (maintains a constant height regardless of what is inside).
+ // `row` is the row number.
+ computeRowLevelLimit: function(row) {
+ var rowEl = this.rowEls.eq(row); // the containing "fake" row div
+ var rowHeight = rowEl.height(); // TODO: cache somehow?
+ var trEls = this.rowStructs[row].tbodyEl.children();
+ var i, trEl;
+ var trHeight;
+
+ function iterInnerHeights(i, childNode) {
+ trHeight = Math.max(trHeight, $(childNode).outerHeight());
+ }
+
+ // Reveal one level at a time and stop when we find one out of bounds
+ for (i = 0; i < trEls.length; i++) {
+ trEl = trEls.eq(i).removeClass('fc-limited'); // reset to original state (reveal)
+
+ // with rowspans>1 and IE8, trEl.outerHeight() would return the height of the largest cell,
+ // so instead, find the tallest inner content element.
+ trHeight = 0;
+ trEl.find('> td > :first-child').each(iterInnerHeights);
+
+ if (trEl.position().top + trHeight > rowHeight) {
+ return i;
+ }
+ }
+
+ return false; // should not limit at all
+ },
+
+
+ // Limits the given grid row to the maximum number of levels and injects "more" links if necessary.
+ // `row` is the row number.
+ // `levelLimit` is a number for the maximum (inclusive) number of levels allowed.
+ limitRow: function(row, levelLimit) {
+ var _this = this;
+ var rowStruct = this.rowStructs[row];
+ var moreNodes = []; // array of "more" links and DOM nodes
+ var col = 0; // col #, left-to-right (not chronologically)
+ var levelSegs; // array of segment objects in the last allowable level, ordered left-to-right
+ var cellMatrix; // a matrix (by level, then column) of all | jQuery elements in the row
+ var limitedNodes; // array of temporarily hidden level |
and segment DOM nodes
+ var i, seg;
+ var segsBelow; // array of segment objects below `seg` in the current `col`
+ var totalSegsBelow; // total number of segments below `seg` in any of the columns `seg` occupies
+ var colSegsBelow; // array of segment arrays, below seg, one for each column (offset from segs's first column)
+ var td, rowspan;
+ var segMoreNodes; // array of "more" | cells that will stand-in for the current seg's cell
+ var j;
+ var moreTd, moreWrap, moreLink;
+
+ // Iterates through empty level cells and places "more" links inside if need be
+ function emptyCellsUntil(endCol) { // goes from current `col` to `endCol`
+ while (col < endCol) {
+ segsBelow = _this.getCellSegs(row, col, levelLimit);
+ if (segsBelow.length) {
+ td = cellMatrix[levelLimit - 1][col];
+ moreLink = _this.renderMoreLink(row, col, segsBelow);
+ moreWrap = $('').append(moreLink);
+ td.append(moreWrap);
+ moreNodes.push(moreWrap[0]);
+ }
+ col++;
+ }
+ }
+
+ if (levelLimit && levelLimit < rowStruct.segLevels.length) { // is it actually over the limit?
+ levelSegs = rowStruct.segLevels[levelLimit - 1];
+ cellMatrix = rowStruct.cellMatrix;
+
+ limitedNodes = rowStruct.tbodyEl.children().slice(levelLimit) // get level |
elements past the limit
+ .addClass('fc-limited').get(); // hide elements and get a simple DOM-nodes array
+
+ // iterate though segments in the last allowable level
+ for (i = 0; i < levelSegs.length; i++) {
+ seg = levelSegs[i];
+ emptyCellsUntil(seg.leftCol); // process empty cells before the segment
+
+ // determine *all* segments below `seg` that occupy the same columns
+ colSegsBelow = [];
+ totalSegsBelow = 0;
+ while (col <= seg.rightCol) {
+ segsBelow = this.getCellSegs(row, col, levelLimit);
+ colSegsBelow.push(segsBelow);
+ totalSegsBelow += segsBelow.length;
+ col++;
+ }
+
+ if (totalSegsBelow) { // do we need to replace this segment with one or many "more" links?
+ td = cellMatrix[levelLimit - 1][seg.leftCol]; // the segment's parent cell
+ rowspan = td.attr('rowspan') || 1;
+ segMoreNodes = [];
+
+ // make a replacement for each column the segment occupies. will be one for each colspan
+ for (j = 0; j < colSegsBelow.length; j++) {
+ moreTd = $(' | | ').attr('rowspan', rowspan);
+ segsBelow = colSegsBelow[j];
+ moreLink = this.renderMoreLink(
+ row,
+ seg.leftCol + j,
+ [ seg ].concat(segsBelow) // count seg as hidden too
+ );
+ moreWrap = $('').append(moreLink);
+ moreTd.append(moreWrap);
+ segMoreNodes.push(moreTd[0]);
+ moreNodes.push(moreTd[0]);
+ }
+
+ td.addClass('fc-limited').after($(segMoreNodes)); // hide original and inject replacements
+ limitedNodes.push(td[0]);
+ }
+ }
+
+ emptyCellsUntil(this.colCnt); // finish off the level
+ rowStruct.moreEls = $(moreNodes); // for easy undoing later
+ rowStruct.limitedEls = $(limitedNodes); // for easy undoing later
+ }
+ },
+
+
+ // Reveals all levels and removes all "more"-related elements for a grid's row.
+ // `row` is a row number.
+ unlimitRow: function(row) {
+ var rowStruct = this.rowStructs[row];
+
+ if (rowStruct.moreEls) {
+ rowStruct.moreEls.remove();
+ rowStruct.moreEls = null;
+ }
+
+ if (rowStruct.limitedEls) {
+ rowStruct.limitedEls.removeClass('fc-limited');
+ rowStruct.limitedEls = null;
+ }
+ },
+
+
+ // Renders an element that represents hidden event element for a cell.
+ // Responsible for attaching click handler as well.
+ renderMoreLink: function(row, col, hiddenSegs) {
+ var _this = this;
+ var view = this.view;
+
+ return $('')
+ .text(
+ this.getMoreLinkText(hiddenSegs.length)
+ )
+ .on('click', function(ev) {
+ var clickOption = view.opt('eventLimitClick');
+ var date = _this.getCellDate(row, col);
+ var moreEl = $(this);
+ var dayEl = _this.getCellEl(row, col);
+ var allSegs = _this.getCellSegs(row, col);
+
+ // rescope the segments to be within the cell's date
+ var reslicedAllSegs = _this.resliceDaySegs(allSegs, date);
+ var reslicedHiddenSegs = _this.resliceDaySegs(hiddenSegs, date);
+
+ if (typeof clickOption === 'function') {
+ // the returned value can be an atomic option
+ clickOption = view.trigger('eventLimitClick', null, {
+ date: date,
+ dayEl: dayEl,
+ moreEl: moreEl,
+ segs: reslicedAllSegs,
+ hiddenSegs: reslicedHiddenSegs
+ }, ev);
+ }
+
+ if (clickOption === 'popover') {
+ _this.showSegPopover(row, col, moreEl, reslicedAllSegs);
+ }
+ else if (typeof clickOption === 'string') { // a view name
+ view.calendar.zoomTo(date, clickOption);
+ }
+ });
+ },
+
+
+ // Reveals the popover that displays all events within a cell
+ showSegPopover: function(row, col, moreLink, segs) {
+ var _this = this;
+ var view = this.view;
+ var moreWrap = moreLink.parent(); // the wrapper around the
+ var topEl; // the element we want to match the top coordinate of
+ var options;
+
+ if (this.rowCnt == 1) {
+ topEl = view.el; // will cause the popover to cover any sort of header
+ }
+ else {
+ topEl = this.rowEls.eq(row); // will align with top of row
+ }
+
+ options = {
+ className: 'fc-more-popover',
+ content: this.renderSegPopoverContent(row, col, segs),
+ parentEl: this.el,
+ top: topEl.offset().top,
+ autoHide: true, // when the user clicks elsewhere, hide the popover
+ viewportConstrain: view.opt('popoverViewportConstrain'),
+ hide: function() {
+ // kill everything when the popover is hidden
+ _this.segPopover.removeElement();
+ _this.segPopover = null;
+ _this.popoverSegs = null;
+ }
+ };
+
+ // Determine horizontal coordinate.
+ // We use the moreWrap instead of the to avoid border confusion.
+ if (this.isRTL) {
+ options.right = moreWrap.offset().left + moreWrap.outerWidth() + 1; // +1 to be over cell border
+ }
+ else {
+ options.left = moreWrap.offset().left - 1; // -1 to be over cell border
+ }
+
+ this.segPopover = new Popover(options);
+ this.segPopover.show();
+ },
+
+
+ // Builds the inner DOM contents of the segment popover
+ renderSegPopoverContent: function(row, col, segs) {
+ var view = this.view;
+ var isTheme = view.opt('theme');
+ var title = this.getCellDate(row, col).format(view.opt('dayPopoverFormat'));
+ var content = $(
+ '' +
+ ''
+ );
+ var segContainer = content.find('.fc-event-container');
+ var i;
+
+ // render each seg's `el` and only return the visible segs
+ segs = this.renderFgSegEls(segs, true); // disableResizing=true
+ this.popoverSegs = segs;
+
+ for (i = 0; i < segs.length; i++) {
+
+ // because segments in the popover are not part of a grid coordinate system, provide a hint to any
+ // grids that want to do drag-n-drop about which cell it came from
+ this.prepareHits();
+ segs[i].hit = this.getCellHit(row, col);
+ this.releaseHits();
+
+ segContainer.append(segs[i].el);
+ }
+
+ return content;
+ },
+
+
+ // Given the events within an array of segment objects, reslice them to be in a single day
+ resliceDaySegs: function(segs, dayDate) {
+
+ // build an array of the original events
+ var events = $.map(segs, function(seg) {
+ return seg.event;
+ });
+
+ var dayStart = dayDate.clone().stripTime();
+ var dayEnd = dayStart.clone().add(1, 'days');
+ var dayRange = { start: dayStart, end: dayEnd };
+
+ // slice the events with a custom slicing function
+ segs = this.eventsToSegs(
+ events,
+ function(range) {
+ var seg = intersectionToSeg(range, dayRange); // undefind if no intersection
+ return seg ? [ seg ] : []; // must return an array of segments
+ }
+ );
+
+ // force an order because eventsToSegs doesn't guarantee one
+ this.sortSegs(segs);
+
+ return segs;
+ },
+
+
+ // Generates the text that should be inside a "more" link, given the number of events it represents
+ getMoreLinkText: function(num) {
+ var opt = this.view.opt('eventLimitText');
+
+ if (typeof opt === 'function') {
+ return opt(num);
+ }
+ else {
+ return '+' + num + ' ' + opt;
+ }
+ },
+
+
+ // Returns segments within a given cell.
+ // If `startLevel` is specified, returns only events including and below that level. Otherwise returns all segs.
+ getCellSegs: function(row, col, startLevel) {
+ var segMatrix = this.rowStructs[row].segMatrix;
+ var level = startLevel || 0;
+ var segs = [];
+ var seg;
+
+ while (level < segMatrix.length) {
+ seg = segMatrix[level][col];
+ if (seg) {
+ segs.push(seg);
+ }
+ level++;
+ }
+
+ return segs;
+ }
+
+});
+
+;;
+
+/* A component that renders one or more columns of vertical time slots
+----------------------------------------------------------------------------------------------------------------------*/
+// We mixin DayTable, even though there is only a single row of days
+
+var TimeGrid = FC.TimeGrid = Grid.extend(DayTableMixin, {
+
+ slotDuration: null, // duration of a "slot", a distinct time segment on given day, visualized by lines
+ snapDuration: null, // granularity of time for dragging and selecting
+ snapsPerSlot: null,
+ minTime: null, // Duration object that denotes the first visible time of any given day
+ maxTime: null, // Duration object that denotes the exclusive visible end time of any given day
+ labelFormat: null, // formatting string for times running along vertical axis
+ labelInterval: null, // duration of how often a label should be displayed for a slot
+
+ colEls: null, // cells elements in the day-row background
+ slatEls: null, // elements running horizontally across all columns
+ helperEl: null, // cell skeleton element for rendering the mock event "helper"
+
+ colCoordCache: null,
+ slatCoordCache: null,
+
+ businessHourSegs: null,
+
+
+ constructor: function() {
+ Grid.apply(this, arguments); // call the super-constructor
+
+ this.processOptions();
+ },
+
+
+ // Renders the time grid into `this.el`, which should already be assigned.
+ // Relies on the view's colCnt. In the future, this component should probably be self-sufficient.
+ renderDates: function() {
+ this.el.html(this.renderHtml());
+ this.colEls = this.el.find('.fc-day');
+ this.slatEls = this.el.find('.fc-slats tr');
+
+ this.colCoordCache = new CoordCache({
+ els: this.colEls,
+ isHorizontal: true
+ });
+ this.slatCoordCache = new CoordCache({
+ els: this.slatEls,
+ isVertical: true
+ });
+ },
+
+
+ renderBusinessHours: function() {
+ var events = this.view.calendar.getBusinessHoursEvents();
+ this.businessHourSegs = this.renderFill('businessHours', this.eventsToSegs(events), 'bgevent');
+ },
+
+
+ // Renders the basic HTML skeleton for the grid
+ renderHtml: function() {
+ return '' +
+ '' +
+ ' ' +
+ this.renderBgTrHtml(0) + // row=0
+ ' ' +
+ ' ' +
+ '' +
+ ' ' +
+ this.renderSlatRowHtml() +
+ ' ' +
+ ' ';
+ },
+
+
+ // Generates the HTML for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
+ renderSlatRowHtml: function() {
+ var view = this.view;
+ var isRTL = this.isRTL;
+ var html = '';
+ var slotTime = moment.duration(+this.minTime); // wish there was .clone() for durations
+ var slotDate; // will be on the view's first day, but we only care about its time
+ var isLabeled;
+ var axisHtml;
+
+ // Calculate the time for each slot
+ while (slotTime < this.maxTime) {
+ slotDate = this.start.clone().time(slotTime); // after .time() will be in UTC. but that's good, avoids DST issues
+ isLabeled = isInt(divideDurationByDuration(slotTime, this.labelInterval));
+
+ axisHtml =
+ ' | ' +
+ (isLabeled ?
+ '' + // for matchCellWidths
+ htmlEscape(slotDate.format(this.labelFormat)) +
+ '' :
+ ''
+ ) +
+ ' | ';
+
+ html +=
+ ' ' +
+ (!isRTL ? axisHtml : '') +
+ ' | ' +
+ (isRTL ? axisHtml : '') +
+ " ";
+
+ slotTime.add(this.slotDuration);
+ }
+
+ return html;
+ },
+
+
+ /* Options
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Parses various options into properties of this object
+ processOptions: function() {
+ var view = this.view;
+ var slotDuration = view.opt('slotDuration');
+ var snapDuration = view.opt('snapDuration');
+ var input;
+
+ slotDuration = moment.duration(slotDuration);
+ snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration;
+
+ this.slotDuration = slotDuration;
+ this.snapDuration = snapDuration;
+ this.snapsPerSlot = slotDuration / snapDuration; // TODO: ensure an integer multiple?
+
+ this.minResizeDuration = snapDuration; // hack
+
+ this.minTime = moment.duration(view.opt('minTime'));
+ this.maxTime = moment.duration(view.opt('maxTime'));
+
+ // might be an array value (for TimelineView).
+ // if so, getting the most granular entry (the last one probably).
+ input = view.opt('slotLabelFormat');
+ if ($.isArray(input)) {
+ input = input[input.length - 1];
+ }
+
+ this.labelFormat =
+ input ||
+ view.opt('axisFormat') || // deprecated
+ view.opt('smallTimeFormat'); // the computed default
+
+ input = view.opt('slotLabelInterval');
+ this.labelInterval = input ?
+ moment.duration(input) :
+ this.computeLabelInterval(slotDuration);
+ },
+
+
+ // Computes an automatic value for slotLabelInterval
+ computeLabelInterval: function(slotDuration) {
+ var i;
+ var labelInterval;
+ var slotsPerLabel;
+
+ // find the smallest stock label interval that results in more than one slots-per-label
+ for (i = AGENDA_STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) {
+ labelInterval = moment.duration(AGENDA_STOCK_SUB_DURATIONS[i]);
+ slotsPerLabel = divideDurationByDuration(labelInterval, slotDuration);
+ if (isInt(slotsPerLabel) && slotsPerLabel > 1) {
+ return labelInterval;
+ }
+ }
+
+ return moment.duration(slotDuration); // fall back. clone
+ },
+
+
+ // Computes a default event time formatting string if `timeFormat` is not explicitly defined
+ computeEventTimeFormat: function() {
+ return this.view.opt('noMeridiemTimeFormat'); // like "6:30" (no AM/PM)
+ },
+
+
+ // Computes a default `displayEventEnd` value if one is not expliclty defined
+ computeDisplayEventEnd: function() {
+ return true;
+ },
+
+
+ /* Hit System
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ prepareHits: function() {
+ this.colCoordCache.build();
+ this.slatCoordCache.build();
+ },
+
+
+ releaseHits: function() {
+ this.colCoordCache.clear();
+ // NOTE: don't clear slatCoordCache because we rely on it for computeTimeTop
+ },
+
+
+ queryHit: function(leftOffset, topOffset) {
+ var snapsPerSlot = this.snapsPerSlot;
+ var colCoordCache = this.colCoordCache;
+ var slatCoordCache = this.slatCoordCache;
+ var colIndex = colCoordCache.getHorizontalIndex(leftOffset);
+ var slatIndex = slatCoordCache.getVerticalIndex(topOffset);
+
+ if (colIndex != null && slatIndex != null) {
+ var slatTop = slatCoordCache.getTopOffset(slatIndex);
+ var slatHeight = slatCoordCache.getHeight(slatIndex);
+ var partial = (topOffset - slatTop) / slatHeight; // floating point number between 0 and 1
+ var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
+ var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
+ var snapTop = slatTop + (localSnapIndex / snapsPerSlot) * slatHeight;
+ var snapBottom = slatTop + ((localSnapIndex + 1) / snapsPerSlot) * slatHeight;
+
+ return {
+ col: colIndex,
+ snap: snapIndex,
+ component: this, // needed unfortunately :(
+ left: colCoordCache.getLeftOffset(colIndex),
+ right: colCoordCache.getRightOffset(colIndex),
+ top: snapTop,
+ bottom: snapBottom
+ };
+ }
+ },
+
+
+ getHitSpan: function(hit) {
+ var date = this.getCellDate(0, hit.col); // row=0
+ var time = this.computeSnapTime(hit.snap); // pass in the snap-index
+ var start = this.view.calendar.rezoneDate(date); // gives it a 00:00 time
+ var end;
+
+ start.time(time);
+ end = start.clone().add(this.snapDuration);
+
+ return { start: start, end: end };
+ },
+
+
+ getHitEl: function(hit) {
+ return this.colEls.eq(hit.col);
+ },
+
+
+ /* Dates
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ rangeUpdated: function() {
+ this.updateDayTable();
+ },
+
+
+ // Given a row number of the grid, representing a "snap", returns a time (Duration) from its start-of-day
+ computeSnapTime: function(snapIndex) {
+ return moment.duration(this.minTime + this.snapDuration * snapIndex);
+ },
+
+
+ // Slices up a date range by column into an array of segments
+ rangeToSegs: function(range) {
+ var segs = this.sliceRangeByTimes(range);
+ var i;
+
+ for (i = 0; i < segs.length; i++) {
+ if (this.isRTL) {
+ segs[i].col = this.daysPerRow - 1 - segs[i].dayIndex;
+ }
+ else {
+ segs[i].col = segs[i].dayIndex;
+ }
+ }
+
+ return segs;
+ },
+
+
+ sliceRangeByTimes: function(range) {
+ var segs = [];
+ var seg;
+ var dayIndex;
+ var dayDate;
+ var dayRange;
+
+ // normalize :(
+ range = {
+ start: range.start.clone().stripZone(),
+ end: range.end.clone().stripZone()
+ };
+
+ for (dayIndex = 0; dayIndex < this.daysPerRow; dayIndex++) {
+ dayDate = this.dayDates[dayIndex].clone(); // TODO: better API for this?
+ dayRange = {
+ start: dayDate.clone().time(this.minTime),
+ end: dayDate.clone().time(this.maxTime)
+ };
+ seg = intersectionToSeg(range, dayRange); // both will be ambig timezone
+ if (seg) {
+ seg.dayIndex = dayIndex;
segs.push(seg);
}
}
+
+ return segs;
+ },
+
+
+ /* Coordinates
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ updateSize: function(isResize) { // NOT a standard Grid method
+ this.slatCoordCache.build();
+
+ if (isResize) {
+ this.updateSegVerticals();
+ }
+ },
+
+
+ // Computes the top coordinate, relative to the bounds of the grid, of the given date.
+ // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
+ computeDateTop: function(date, startOfDayDate) {
+ return this.computeTimeTop(
+ moment.duration(
+ date.clone().stripZone() - startOfDayDate.clone().stripTime()
+ )
+ );
+ },
+
+
+ // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
+ computeTimeTop: function(time) {
+ var len = this.slatEls.length;
+ var slatCoverage = (time - this.minTime) / this.slotDuration; // floating-point value of # of slots covered
+ var slatIndex;
+ var slatRemainder;
+
+ // compute a floating-point number for how many slats should be progressed through.
+ // from 0 to number of slats (inclusive)
+ // constrained because minTime/maxTime might be customized.
+ slatCoverage = Math.max(0, slatCoverage);
+ slatCoverage = Math.min(len, slatCoverage);
+
+ // an integer index of the furthest whole slat
+ // from 0 to number slats (*exclusive*, so len-1)
+ slatIndex = Math.floor(slatCoverage);
+ slatIndex = Math.min(slatIndex, len - 1);
+
+ // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
+ // could be 1.0 if slatCoverage is covering *all* the slots
+ slatRemainder = slatCoverage - slatIndex;
+
+ return this.slatCoordCache.getTopPosition(slatIndex) +
+ this.slatCoordCache.getHeight(slatIndex) * slatRemainder;
+ },
+
+
+
+ /* Event Drag Visualization
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a visual indication of an event being dragged over the specified date(s).
+ // dropLocation's end might be null, as well as `seg`. See Grid::renderDrag for more info.
+ // A returned value of `true` signals that a mock "helper" event has been rendered.
+ renderDrag: function(dropLocation, seg) {
+
+ if (seg) { // if there is event information for this drag, render a helper event
+ this.renderRangeHelper(dropLocation, seg);
+ this.applyDragOpacity(this.helperEl);
+
+ return true; // signal that a helper has been rendered
+ }
+ else {
+ // otherwise, just render a highlight
+ this.renderHighlight(this.eventRangeToSegs(dropLocation));
+ }
+ },
+
+
+ // Unrenders any visual indication of an event being dragged
+ unrenderDrag: function() {
+ this.unrenderHelper();
+ this.unrenderHighlight();
+ },
+
+
+ /* Event Resize Visualization
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a visual indication of an event being resized
+ renderEventResize: function(range, seg) {
+ this.renderRangeHelper(range, seg);
+ },
+
+
+ // Unrenders any visual indication of an event being resized
+ unrenderEventResize: function() {
+ this.unrenderHelper();
+ },
+
+
+ /* Event Helper
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a mock "helper" event. `sourceSeg` is the original segment object and might be null (an external drag)
+ renderHelper: function(event, sourceSeg) {
+ var segs = this.eventsToSegs([ event ]);
+ var tableEl;
+ var i, seg;
+ var sourceEl;
+
+ segs = this.renderFgSegEls(segs); // assigns each seg's el and returns a subset of segs that were rendered
+ tableEl = this.renderSegTable(segs);
+
+ // Try to make the segment that is in the same row as sourceSeg look the same
+ for (i = 0; i < segs.length; i++) {
+ seg = segs[i];
+ if (sourceSeg && sourceSeg.col === seg.col) {
+ sourceEl = sourceSeg.el;
+ seg.el.css({
+ left: sourceEl.css('left'),
+ right: sourceEl.css('right'),
+ 'margin-left': sourceEl.css('margin-left'),
+ 'margin-right': sourceEl.css('margin-right')
+ });
+ }
+ }
+
+ this.helperEl = $(' ')
+ .append(tableEl)
+ .appendTo(this.el);
+ },
+
+
+ // Unrenders any mock helper event
+ unrenderHelper: function() {
+ if (this.helperEl) {
+ this.helperEl.remove();
+ this.helperEl = null;
+ }
+ },
+
+
+ /* Selection
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a visual indication of a selection. Overrides the default, which was to simply render a highlight.
+ renderSelection: function(range) {
+ if (this.view.opt('selectHelper')) { // this setting signals that a mock helper event should be rendered
+ this.renderRangeHelper(range);
+ }
+ else {
+ this.renderHighlight(this.selectionRangeToSegs(range));
+ }
+ },
+
+
+ // Unrenders any visual indication of a selection
+ unrenderSelection: function() {
+ this.unrenderHelper();
+ this.unrenderHighlight();
+ },
+
+
+ /* Fill System (highlight, background events, business hours)
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a set of rectangles over the given time segments.
+ // Only returns segments that successfully rendered.
+ renderFill: function(type, segs, className) {
+ var segCols;
+ var skeletonEl;
+ var trEl;
+ var col, colSegs;
+ var tdEl;
+ var containerEl;
+ var dayDate;
+ var i, seg;
+
+ if (segs.length) {
+
+ segs = this.renderFillSegEls(type, segs); // assignes `.el` to each seg. returns successfully rendered segs
+ segCols = this.groupSegCols(segs); // group into sub-arrays, and assigns 'col' to each seg
+
+ className = className || type.toLowerCase();
+ skeletonEl = $(
+ ' '
+ );
+ trEl = skeletonEl.find('tr');
+
+ for (col = 0; col < segCols.length; col++) {
+ colSegs = segCols[col];
+ tdEl = $(' | ').appendTo(trEl);
+
+ if (colSegs.length) {
+ containerEl = $(' ').appendTo(tdEl);
+ dayDate = this.getCellDate(0, col); // row=0
+
+ for (i = 0; i < colSegs.length; i++) {
+ seg = colSegs[i];
+ containerEl.append(
+ seg.el.css({
+ top: this.computeDateTop(seg.start, dayDate),
+ bottom: -this.computeDateTop(seg.end, dayDate) // the y position of the bottom edge
+ })
+ );
+ }
+ }
+ }
+
+ this.bookendCells(trEl);
+
+ this.el.append(skeletonEl);
+ this.elsByFill[type] = skeletonEl;
+ }
+
return segs;
}
-
-
- function compileSlotSegs(events) {
- var colCnt = getColCnt(),
- minMinute = getMinMinute(),
- maxMinute = getMaxMinute(),
- d = addMinutes(cloneDate(t.visStart), minMinute),
- visEventEnds = $.map(events, slotEventEnd),
- i, col,
- j, level,
- k, seg,
- segs=[];
- for (i=0; i " +
- "" +
- " " +
- htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
- " " +
- " " +
- htmlEscape(event.title) +
- " " +
- " " +
- "";
- if (seg.isEnd && isEventResizable(event)) {
- html +=
- "= ";
- }
- html +=
- "" + (url ? "a" : "div") + ">";
- return html;
- }
-
-
- function bindDaySeg(event, eventElement, seg) {
- if (isEventDraggable(event)) {
- draggableDayEvent(event, eventElement, seg.isStart);
- }
- if (seg.isEnd && isEventResizable(event)) {
- resizableDayEvent(event, eventElement, seg);
- }
- 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)) {
- draggableSlotEvent(event, eventElement, timeElement);
- }
- if (seg.isEnd && isEventResizable(event)) {
- resizableSlotEvent(event, eventElement, timeElement);
- }
- eventElementHandlers(event, eventElement);
- }
-
-
-
- /* Dragging
- -----------------------------------------------------------------------------------*/
-
-
- // when event starts out FULL-DAY
-
- function draggableDayEvent(event, eventElement, isStart) {
- var origWidth;
- var revert;
- var allDay=true;
- var dayDelta;
- var dis = opt('isRTL') ? -1 : 1;
- var hoverListener = getHoverListener();
- var colWidth = getColWidth();
- var snapHeight = getSnapHeight();
- var snapMinutes = getSnapMinutes();
- var minMinute = getMinMinute();
- eventElement.draggable({
- zIndex: 9,
- opacity: opt('dragOpacity', 'month'), // use whatever the month view was using
- revertDuration: opt('dragRevertDuration'),
- start: function(ev, ui) {
- trigger('eventDragStart', eventElement, event, ev, ui);
- hideEvents(event, eventElement);
- origWidth = eventElement.width();
- hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
- clearOverlays();
- if (cell) {
- //setOverflowHidden(true);
- revert = false;
- dayDelta = colDelta * dis;
- if (!cell.row) {
- // on full-days
- renderDayOverlay(
- addDays(cloneDate(event.start), dayDelta),
- addDays(exclEndDay(event), dayDelta)
- );
- resetElement();
- }else{
- // mouse is over bottom slots
- if (isStart) {
- if (allDay) {
- // convert event to temporary slot-event
- eventElement.width(colWidth - 10); // don't use entire width
- setOuterHeight(
- eventElement,
- snapHeight * Math.round(
- (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) /
- snapMinutes
- )
- );
- eventElement.draggable('option', 'grid', [colWidth, 1]);
- allDay = false;
- }
- }else{
- revert = true;
- }
- }
- revert = revert || (allDay && !dayDelta);
- }else{
- resetElement();
- //setOverflowHidden(false);
- revert = true;
- }
- eventElement.draggable('option', 'revert', revert);
- }, ev, 'drag');
- },
- stop: function(ev, ui) {
- hoverListener.stop();
- clearOverlays();
- trigger('eventDragStop', eventElement, event, ev, ui);
- if (revert) {
- // hasn't moved or is out of bounds (draggable has already reverted)
- resetElement();
- eventElement.css('filter', ''); // clear IE opacity side-effects
- showEvents(event, eventElement);
- }else{
- // changed!
- var minuteDelta = 0;
- if (!allDay) {
- minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / snapHeight)
- * snapMinutes
- + minMinute
- - (event.start.getHours() * 60 + event.start.getMinutes());
- }
- eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui);
- }
- //setOverflowHidden(false);
- }
- });
- function resetElement() {
- if (!allDay) {
- eventElement
- .width(origWidth)
- .height('')
- .draggable('option', 'grid', null);
- allDay = true;
- }
- }
- }
-
-
- // when event starts out IN TIMESLOTS
-
- function draggableSlotEvent(event, eventElement, timeElement) {
- var origPosition;
- var allDay=false;
- var dayDelta;
- var minuteDelta;
- var prevMinuteDelta;
- var dis = opt('isRTL') ? -1 : 1;
- var hoverListener = getHoverListener();
- var colCnt = getColCnt();
- var colWidth = getColWidth();
- var snapHeight = getSnapHeight();
- var snapMinutes = getSnapMinutes();
- eventElement.draggable({
- zIndex: 9,
- scroll: false,
- grid: [colWidth, snapHeight],
- axis: colCnt==1 ? 'y' : false,
- opacity: opt('dragOpacity'),
- revertDuration: opt('dragRevertDuration'),
- start: function(ev, ui) {
- trigger('eventDragStart', eventElement, event, ev, ui);
- hideEvents(event, eventElement);
- origPosition = eventElement.position();
- minuteDelta = prevMinuteDelta = 0;
- hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
- eventElement.draggable('option', 'revert', !cell);
- clearOverlays();
- if (cell) {
- dayDelta = colDelta * dis;
- if (opt('allDaySlot') && !cell.row) {
- // over full days
- if (!allDay) {
- // convert to temporary all-day event
- allDay = true;
- timeElement.hide();
- eventElement.draggable('option', 'grid', null);
- }
- renderDayOverlay(
- addDays(cloneDate(event.start), dayDelta),
- addDays(exclEndDay(event), dayDelta)
- );
- }else{
- // on slots
- resetElement();
- }
- }
- }, ev, 'drag');
- },
- drag: function(ev, ui) {
- minuteDelta = Math.round((ui.position.top - origPosition.top) / snapHeight) * snapMinutes;
- if (minuteDelta != prevMinuteDelta) {
- if (!allDay) {
- updateTimeText(minuteDelta);
- }
- prevMinuteDelta = minuteDelta;
- }
- },
- stop: function(ev, ui) {
- var cell = hoverListener.stop();
- clearOverlays();
- trigger('eventDragStop', eventElement, event, ev, ui);
- if (cell && (dayDelta || minuteDelta || allDay)) {
- // changed!
- eventDrop(this, event, dayDelta, allDay ? 0 : minuteDelta, allDay, ev, ui);
- }else{
- // either no change or out-of-bounds (draggable has already reverted)
- resetElement();
- eventElement.css('filter', ''); // clear IE opacity side-effects
- eventElement.css(origPosition); // sometimes fast drags make event revert to wrong position
- updateTimeText(0);
- showEvents(event, eventElement);
- }
- }
- });
- function updateTimeText(minuteDelta) {
- var newStart = addMinutes(cloneDate(event.start), minuteDelta);
- var newEnd;
- if (event.end) {
- newEnd = addMinutes(cloneDate(event.end), minuteDelta);
- }
- timeElement.text(formatDates(newStart, newEnd, opt('timeFormat')));
- }
- function resetElement() {
- // convert back to original slot-event
- if (allDay) {
- timeElement.css('display', ''); // show() was causing display=inline
- eventElement.draggable('option', 'grid', [colWidth, snapHeight]);
- allDay = false;
- }
- }
- }
-
-
-
- /* Resizing
- --------------------------------------------------------------------------------------*/
-
-
- function resizableSlotEvent(event, eventElement, timeElement) {
- var snapDelta, prevSnapDelta;
- var snapHeight = getSnapHeight();
- var snapMinutes = getSnapMinutes();
- eventElement.resizable({
- handles: {
- s: '.ui-resizable-handle'
- },
- grid: snapHeight,
- start: function(ev, ui) {
- snapDelta = prevSnapDelta = 0;
- hideEvents(event, eventElement);
- eventElement.css('z-index', 9);
- trigger('eventResizeStart', this, event, ev, ui);
- },
- resize: function(ev, ui) {
- // don't rely on ui.size.height, doesn't take grid into account
- snapDelta = Math.round((Math.max(snapHeight, eventElement.height()) - ui.originalSize.height) / snapHeight);
- if (snapDelta != prevSnapDelta) {
- timeElement.text(
- formatDates(
- event.start,
- (!snapDelta && !event.end) ? null : // no change, so don't display time range
- addMinutes(eventEnd(event), snapMinutes*snapDelta),
- opt('timeFormat')
- )
- );
- prevSnapDelta = snapDelta;
- }
- },
- stop: function(ev, ui) {
- trigger('eventResizeStop', this, event, ev, ui);
- if (snapDelta) {
- eventResize(this, event, 0, snapMinutes*snapDelta, ev, ui);
- }else{
- eventElement.css('z-index', 8);
- showEvents(event, eventElement);
- // BUG: if event was really short, need to put title back in span
- }
- }
- });
- }
-
-
-}
-
-
-function countForwardSegs(levels) {
- var i, j, k, level, segForward, segBack;
- for (i=levels.length-1; i>0; i--) {
- level = levels[i];
- for (j=0; j')
+ .append(this.renderSegTable(segs))
+ );
+
+ return segs; // return only the segs that were actually rendered
+ },
+
+
+ // Unrenders all currently rendered foreground event segments
+ unrenderFgSegs: function(segs) {
+ if (this.eventSkeletonEl) {
+ this.eventSkeletonEl.remove();
+ this.eventSkeletonEl = null;
}
- return v;
+ },
+
+
+ // Renders and returns the portion of the event-skeleton.
+ // Returns an object with properties 'tbodyEl' and 'segs'.
+ renderSegTable: function(segs) {
+ var tableEl = $('');
+ var trEl = tableEl.find('tr');
+ var segCols;
+ var i, seg;
+ var col, colSegs;
+ var containerEl;
+
+ segCols = this.groupSegCols(segs); // group into sub-arrays, and assigns 'col' to each seg
+
+ this.computeSegVerticals(segs); // compute and assign top/bottom
+
+ for (col = 0; col < segCols.length; col++) { // iterate each column grouping
+ colSegs = segCols[col];
+ this.placeSlotSegs(colSegs); // compute horizontal coordinates, z-index's, and reorder the array
+
+ containerEl = $('');
+
+ // assign positioning CSS and insert into container
+ for (i = 0; i < colSegs.length; i++) {
+ seg = colSegs[i];
+ seg.el.css(this.generateSegPositionCss(seg));
+
+ // if the height is short, add a className for alternate styling
+ if (seg.bottom - seg.top < 30) {
+ seg.el.addClass('fc-short');
+ }
+
+ containerEl.append(seg.el);
+ }
+
+ trEl.append($(' | ').append(containerEl));
+ }
+
+ this.bookendCells(trEl);
+
+ return tableEl;
+ },
+
+
+ // Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
+ // NOTE: Also reorders the given array by date!
+ placeSlotSegs: function(segs) {
+ var levels;
+ var level0;
+ var i;
+
+ this.sortSegs(segs); // order by date
+ levels = buildSlotSegLevels(segs);
+ computeForwardSlotSegs(levels);
+
+ if ((level0 = levels[0])) {
+
+ for (i = 0; i < level0.length; i++) {
+ computeSlotSegPressures(level0[i]);
+ }
+
+ for (i = 0; i < level0.length; i++) {
+ this.computeSlotSegCoords(level0[i], 0, 0);
+ }
+ }
+ },
+
+
+ // Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
+ // from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
+ // seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
+ //
+ // The segment might be part of a "series", which means consecutive segments with the same pressure
+ // who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
+ // segments behind this one in the current series, and `seriesBackwardCoord` is the starting
+ // coordinate of the first segment in the series.
+ computeSlotSegCoords: function(seg, seriesBackwardPressure, seriesBackwardCoord) {
+ var forwardSegs = seg.forwardSegs;
+ var i;
+
+ if (seg.forwardCoord === undefined) { // not already computed
+
+ if (!forwardSegs.length) {
+
+ // if there are no forward segments, this segment should butt up against the edge
+ seg.forwardCoord = 1;
+ }
+ else {
+
+ // sort highest pressure first
+ this.sortForwardSlotSegs(forwardSegs);
+
+ // this segment's forwardCoord will be calculated from the backwardCoord of the
+ // highest-pressure forward segment.
+ this.computeSlotSegCoords(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
+ seg.forwardCoord = forwardSegs[0].backwardCoord;
+ }
+
+ // calculate the backwardCoord from the forwardCoord. consider the series
+ seg.backwardCoord = seg.forwardCoord -
+ (seg.forwardCoord - seriesBackwardCoord) / // available width for series
+ (seriesBackwardPressure + 1); // # of segments in the series
+
+ // use this segment's coordinates to computed the coordinates of the less-pressurized
+ // forward segments
+ for (i=0; i' +
+ '' +
+ (timeText ?
+ ' ' +
+ '' + htmlEscape(timeText) + '' +
+ ' ' :
+ ''
+ ) +
+ (event.title ?
+ ' ' +
+ htmlEscape(event.title) +
+ ' ' :
+ ''
+ ) +
+ ' ' +
+ '' +
+ /* TODO: write CSS for this
+ (isResizableFromStart ?
+ '' :
+ ''
+ ) +
+ */
+ (isResizableFromEnd ?
+ '' :
+ ''
+ ) +
+ '';
+ },
+
+
+ // Generates an object with CSS properties/values that should be applied to an event segment element.
+ // Contains important positioning-related properties that should be applied to any event element, customized or not.
+ generateSegPositionCss: function(seg) {
+ var shouldOverlap = this.view.opt('slotEventOverlap');
+ var backwardCoord = seg.backwardCoord; // the left side if LTR. the right side if RTL. floating-point
+ var forwardCoord = seg.forwardCoord; // the right side if LTR. the left side if RTL. floating-point
+ var props = this.generateSegVerticalCss(seg); // get top/bottom first
+ var left; // amount of space from left edge, a fraction of the total width
+ var right; // amount of space from right edge, a fraction of the total width
+
+ if (shouldOverlap) {
+ // double the width, but don't go beyond the maximum forward coordinate (1.0)
+ forwardCoord = Math.min(1, backwardCoord + (forwardCoord - backwardCoord) * 2);
+ }
+
+ if (this.isRTL) {
+ left = 1 - forwardCoord;
+ right = backwardCoord;
+ }
+ else {
+ left = backwardCoord;
+ right = 1 - forwardCoord;
+ }
+
+ props.zIndex = seg.level + 1; // convert from 0-base to 1-based
+ props.left = left * 100 + '%';
+ props.right = right * 100 + '%';
+
+ if (shouldOverlap && seg.forwardPressure) {
+ // add padding to the edge so that forward stacked events don't cover the resizer's icon
+ props[this.isRTL ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
+ }
+
+ return props;
+ },
+
+
+ // Generates an object with CSS properties for the top/bottom coordinates of a segment element
+ generateSegVerticalCss: function(seg) {
+ return {
+ top: seg.top,
+ bottom: -seg.bottom // flipped because needs to be space beyond bottom edge of event container
+ };
+ },
+
+
+ // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's col
+ groupSegCols: function(segs) {
+ var segCols = [];
+ var i;
+
+ for (i = 0; i < this.colCnt; i++) {
+ segCols.push([]);
+ }
+
+ for (i = 0; i < segs.length; i++) {
+ segCols[segs[i].col].push(segs[i]);
+ }
+
+ return segCols;
+ },
+
+
+ sortForwardSlotSegs: function(forwardSegs) {
+ forwardSegs.sort(proxy(this, 'compareForwardSlotSegs'));
+ },
+
+
+ // A cmp function for determining which forward segment to rely on more when computing coordinates.
+ compareForwardSlotSegs: function(seg1, seg2) {
+ // put higher-pressure first
+ return seg2.forwardPressure - seg1.forwardPressure ||
+ // put segments that are closer to initial edge first (and favor ones with no coords yet)
+ (seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) ||
+ // do normal sorting...
+ this.compareSegs(seg1, seg2);
}
-
- function trigger(name, thisObj) {
+});
+
+
+// Builds an array of segments "levels". The first level will be the leftmost tier of segments if the calendar is
+// left-to-right, or the rightmost if the calendar is right-to-left. Assumes the segments are already ordered by date.
+function buildSlotSegLevels(segs) {
+ var levels = [];
+ var i, seg;
+ var j;
+
+ for (i=0; i seg2.top && seg1.top < seg2.bottom;
+}
+
+;;
+
+/* An abstract class from which other views inherit from
+----------------------------------------------------------------------------------------------------------------------*/
+
+var View = FC.View = Class.extend({
+
+ type: null, // subclass' view name (string)
+ name: null, // deprecated. use `type` instead
+ title: null, // the text that will be displayed in the header's title
+
+ calendar: null, // owner Calendar object
+ options: null, // hash containing all options. already merged with view-specific-options
+ el: null, // the view's containing element. set by Calendar
+
+ displaying: null, // a promise representing the state of rendering. null if no render requested
+ isSkeletonRendered: false,
+ isEventsRendered: false,
+
+ // range the view is actually displaying (moments)
+ start: null,
+ end: null, // exclusive
+
+ // range the view is formally responsible for (moments)
+ // may be different from start/end. for example, a month view might have 1st-31st, excluding padded dates
+ intervalStart: null,
+ intervalEnd: null, // exclusive
+ intervalDuration: null,
+ intervalUnit: null, // name of largest unit being displayed, like "month" or "week"
+
+ isRTL: false,
+ isSelected: false, // boolean whether a range of time is user-selected or not
+
+ eventOrderSpecs: null, // criteria for ordering events when they have same date/time
+
+ // subclasses can optionally use a scroll container
+ scrollerEl: null, // the element that will most likely scroll when content is too tall
+ scrollTop: null, // cached vertical scroll value
+
+ // classNames styled by jqui themes
+ widgetHeaderClass: null,
+ widgetContentClass: null,
+ highlightStateClass: null,
+
+ // for date utils, computed from options
+ nextDayThreshold: null,
+ isHiddenDayHash: null,
+
+ // document handlers, bound to `this` object
+ documentMousedownProxy: null, // TODO: doesn't work with touch
+
+
+ constructor: function(calendar, type, options, intervalDuration) {
+
+ this.calendar = calendar;
+ this.type = this.name = type; // .name is deprecated
+ this.options = options;
+ this.intervalDuration = intervalDuration || moment.duration(1, 'day');
+
+ this.nextDayThreshold = moment.duration(this.opt('nextDayThreshold'));
+ this.initThemingProps();
+ this.initHiddenDays();
+ this.isRTL = this.opt('isRTL');
+
+ this.eventOrderSpecs = parseFieldSpecs(this.opt('eventOrder'));
+
+ this.documentMousedownProxy = proxy(this, 'documentMousedown');
+
+ this.initialize();
+ },
+
+
+ // A good place for subclasses to initialize member variables
+ initialize: function() {
+ // subclasses can implement
+ },
+
+
+ // Retrieves an option with the given name
+ opt: function(name) {
+ return this.options[name];
+ },
+
+
+ // Triggers handlers that are view-related. Modifies args before passing to calendar.
+ trigger: function(name, thisObj) { // arguments beyond thisObj are passed along
+ var calendar = this.calendar;
+
return calendar.trigger.apply(
calendar,
- [name, thisObj || t].concat(Array.prototype.slice.call(arguments, 2), [t])
+ [name, thisObj || this].concat(
+ Array.prototype.slice.call(arguments, 2), // arguments beyond thisObj
+ [ this ] // always make the last argument a reference to the view. TODO: deprecate
+ )
);
- }
-
-
- /*
- 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 = {};
- var i, len=events.length, event;
- for (i=0; i 1) {
+ return 'll'; // multi-day range. shorter, like "Sep 9 - 10 2014"
+ }
+ else {
+ return 'LL'; // one day. longer, like "September 9 2014"
+ }
+ },
+
+
+ // Utility for formatting a range. Accepts a range object, formatting string, and optional separator.
+ // Displays all-day ranges naturally, with an inclusive end. Takes the current isRTL into account.
+ formatRange: function(range, formatStr, separator) {
+ var end = range.end;
+
+ if (!end.hasTime()) { // all-day?
+ end = end.clone().subtract(1); // convert to inclusive. last ms of previous day
+ }
+
+ return formatRange(range.start, end, formatStr, separator, this.opt('isRTL'));
+ },
+
+
+ /* Rendering
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Sets the container element that the view should render inside of.
+ // Does other DOM-related initializations.
+ setElement: function(el) {
+ this.el = el;
+ this.bindGlobalHandlers();
+ },
+
+
+ // Removes the view's container element from the DOM, clearing any content beforehand.
+ // Undoes any other DOM-related attachments.
+ removeElement: function() {
+ this.clear(); // clears all content
+
+ // clean up the skeleton
+ if (this.isSkeletonRendered) {
+ this.unrenderSkeleton();
+ this.isSkeletonRendered = false;
+ }
+
+ this.unbindGlobalHandlers();
+
+ this.el.remove();
+
+ // NOTE: don't null-out this.el in case the View was destroyed within an API callback.
+ // We don't null-out the View's other jQuery element references upon destroy,
+ // so we shouldn't kill this.el either.
+ },
+
+
+ // Does everything necessary to display the view centered around the given date.
+ // Does every type of rendering EXCEPT rendering events.
+ // Is asychronous and returns a promise.
+ display: function(date) {
+ var _this = this;
+ var scrollState = null;
+
+ if (this.displaying) {
+ scrollState = this.queryScroll();
+ }
+
+ return this.clear().then(function() { // clear the content first (async)
+ return (
+ _this.displaying =
+ $.when(_this.displayView(date)) // displayView might return a promise
+ .then(function() {
+ _this.forceScroll(_this.computeInitialScroll(scrollState));
+ _this.triggerRender();
+ })
+ );
+ });
+ },
+
+
+ // Does everything necessary to clear the content of the view.
+ // Clears dates and events. Does not clear the skeleton.
+ // Is asychronous and returns a promise.
+ clear: function() {
+ var _this = this;
+ var displaying = this.displaying;
+
+ if (displaying) { // previously displayed, or in the process of being displayed?
+ return displaying.then(function() { // wait for the display to finish
+ _this.displaying = null;
+ _this.clearEvents();
+ return _this.clearView(); // might return a promise. chain it
+ });
+ }
+ else {
+ return $.when(); // an immediately-resolved promise
+ }
+ },
+
+
+ // Displays the view's non-event content, such as date-related content or anything required by events.
+ // Renders the view's non-content skeleton if necessary.
+ // Can be asynchronous and return a promise.
+ displayView: function(date) {
+ if (!this.isSkeletonRendered) {
+ this.renderSkeleton();
+ this.isSkeletonRendered = true;
+ }
+ this.setDate(date);
+ if (this.render) {
+ this.render(); // TODO: deprecate
+ }
+ this.renderDates();
+ this.updateSize();
+ this.renderBusinessHours(); // might need coordinates, so should go after updateSize()
+ },
+
+
+ // Unrenders the view content that was rendered in displayView.
+ // Can be asynchronous and return a promise.
+ clearView: function() {
+ this.unselect();
+ this.triggerUnrender();
+ this.unrenderBusinessHours();
+ this.unrenderDates();
+ if (this.destroy) {
+ this.destroy(); // TODO: deprecate
+ }
+ },
+
+
+ // Renders the basic structure of the view before any content is rendered
+ renderSkeleton: function() {
+ // subclasses should implement
+ },
+
+
+ // Unrenders the basic structure of the view
+ unrenderSkeleton: function() {
+ // subclasses should implement
+ },
+
+
+ // Renders the view's date-related content.
+ // Assumes setRange has already been called and the skeleton has already been rendered.
+ renderDates: function() {
+ // subclasses should implement
+ },
+
+
+ // Unrenders the view's date-related content
+ unrenderDates: function() {
+ // subclasses should override
+ },
+
+
+ // Renders business-hours onto the view. Assumes updateSize has already been called.
+ renderBusinessHours: function() {
+ // subclasses should implement
+ },
+
+
+ // Unrenders previously-rendered business-hours
+ unrenderBusinessHours: function() {
+ // subclasses should implement
+ },
+
+
+ // Signals that the view's content has been rendered
+ triggerRender: function() {
+ this.trigger('viewRender', this, this, this.el);
+ },
+
+
+ // Signals that the view's content is about to be unrendered
+ triggerUnrender: function() {
+ this.trigger('viewDestroy', this, this, this.el);
+ },
+
+
+ // Binds DOM handlers to elements that reside outside the view container, such as the document
+ bindGlobalHandlers: function() {
+ $(document).on('mousedown', this.documentMousedownProxy);
+ },
+
+
+ // Unbinds DOM handlers from elements that reside outside the view container
+ unbindGlobalHandlers: function() {
+ $(document).off('mousedown', this.documentMousedownProxy);
+ },
+
+
+ // Initializes internal variables related to theming
+ initThemingProps: function() {
+ var tm = this.opt('theme') ? 'ui' : 'fc';
+
+ this.widgetHeaderClass = tm + '-widget-header';
+ this.widgetContentClass = tm + '-widget-content';
+ this.highlightStateClass = tm + '-state-highlight';
+ },
+
+
+ /* Dimensions
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Refreshes anything dependant upon sizing of the container element of the grid
+ updateSize: function(isResize) {
+ var scrollState;
+
+ if (isResize) {
+ scrollState = this.queryScroll();
+ }
+
+ this.updateHeight(isResize);
+ this.updateWidth(isResize);
+
+ if (isResize) {
+ this.setScroll(scrollState);
+ }
+ },
+
+
+ // Refreshes the horizontal dimensions of the calendar
+ updateWidth: function(isResize) {
+ // subclasses should implement
+ },
+
+
+ // Refreshes the vertical dimensions of the calendar
+ updateHeight: function(isResize) {
+ var calendar = this.calendar; // we poll the calendar for height information
+
+ this.setHeight(
+ calendar.getSuggestedViewHeight(),
+ calendar.isHeightAuto()
+ );
+ },
+
+
+ // Updates the vertical dimensions of the calendar to the specified height.
+ // if `isAuto` is set to true, height becomes merely a suggestion and the view should use its "natural" height.
+ setHeight: function(height, isAuto) {
+ // subclasses should implement
+ },
+
+
+ /* Scroller
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Given the total height of the view, return the number of pixels that should be used for the scroller.
+ // Utility for subclasses.
+ computeScrollerHeight: function(totalHeight) {
+ var scrollerEl = this.scrollerEl;
+ var both;
+ var otherHeight; // cumulative height of everything that is not the scrollerEl in the view (header+borders)
+
+ both = this.el.add(scrollerEl);
+
+ // fuckin IE8/9/10/11 sometimes returns 0 for dimensions. this weird hack was the only thing that worked
+ both.css({
+ position: 'relative', // cause a reflow, which will force fresh dimension recalculation
+ left: -1 // ensure reflow in case the el was already relative. negative is less likely to cause new scroll
+ });
+ otherHeight = this.el.outerHeight() - scrollerEl.height(); // grab the dimensions
+ both.css({ position: '', left: '' }); // undo hack
+
+ return totalHeight - otherHeight;
+ },
+
+
+ // Computes the initial pre-configured scroll state prior to allowing the user to change it.
+ // Given the scroll state from the previous rendering. If first time rendering, given null.
+ computeInitialScroll: function(previousScrollState) {
+ return 0;
+ },
+
+
+ // Retrieves the view's current natural scroll state. Can return an arbitrary format.
+ queryScroll: function() {
+ if (this.scrollerEl) {
+ return this.scrollerEl.scrollTop(); // operates on scrollerEl by default
+ }
+ },
+
+
+ // Sets the view's scroll state. Will accept the same format computeInitialScroll and queryScroll produce.
+ setScroll: function(scrollState) {
+ if (this.scrollerEl) {
+ return this.scrollerEl.scrollTop(scrollState); // operates on scrollerEl by default
+ }
+ },
+
+
+ // Sets the scroll state, making sure to overcome any predefined scroll value the browser has in mind
+ forceScroll: function(scrollState) {
+ var _this = this;
+
+ this.setScroll(scrollState);
+ setTimeout(function() {
+ _this.setScroll(scrollState);
+ }, 0);
+ },
+
+
+ /* Event Elements / Segments
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Does everything necessary to display the given events onto the current view
+ displayEvents: function(events) {
+ var scrollState = this.queryScroll();
+
+ this.clearEvents();
+ this.renderEvents(events);
+ this.isEventsRendered = true;
+ this.setScroll(scrollState);
+ this.triggerEventRender();
+ },
+
+
+ // Does everything necessary to clear the view's currently-rendered events
+ clearEvents: function() {
+ if (this.isEventsRendered) {
+ this.triggerEventUnrender();
+ if (this.destroyEvents) {
+ this.destroyEvents(); // TODO: deprecate
+ }
+ this.unrenderEvents();
+ this.isEventsRendered = false;
+ }
+ },
+
+
+ // Renders the events onto the view.
+ renderEvents: function(events) {
+ // subclasses should implement
+ },
+
+
+ // Removes event elements from the view.
+ unrenderEvents: function() {
+ // subclasses should implement
+ },
+
+
+ // Signals that all events have been rendered
+ triggerEventRender: function() {
+ this.renderedEventSegEach(function(seg) {
+ this.trigger('eventAfterRender', seg.event, seg.event, seg.el);
+ });
+ this.trigger('eventAfterAllRender');
+ },
+
+
+ // Signals that all event elements are about to be removed
+ triggerEventUnrender: function() {
+ this.renderedEventSegEach(function(seg) {
+ this.trigger('eventDestroy', seg.event, seg.event, seg.el);
+ });
+ },
+
+
+ // Given an event and the default element used for rendering, returns the element that should actually be used.
+ // Basically runs events and elements through the eventRender hook.
+ resolveEventEl: function(event, el) {
+ var custom = this.trigger('eventRender', event, event, el);
+
+ if (custom === false) { // means don't render at all
+ el = null;
+ }
+ else if (custom && custom !== true) {
+ el = $(custom);
+ }
+
+ return el;
+ },
+
+
+ // Hides all rendered event segments linked to the given event
+ showEvent: function(event) {
+ this.renderedEventSegEach(function(seg) {
+ seg.el.css('visibility', '');
+ }, event);
+ },
+
+
+ // Shows all rendered event segments linked to the given event
+ hideEvent: function(event) {
+ this.renderedEventSegEach(function(seg) {
+ seg.el.css('visibility', 'hidden');
+ }, event);
+ },
+
+
+ // Iterates through event segments that have been rendered (have an el). Goes through all by default.
+ // If the optional `event` argument is specified, only iterates through segments linked to that event.
+ // The `this` value of the callback function will be the view.
+ renderedEventSegEach: function(func, event) {
+ var segs = this.getEventSegs();
+ var i;
+
+ for (i = 0; i < segs.length; i++) {
+ if (!event || segs[i].event._id === event._id) {
+ if (segs[i].el) {
+ func.call(this, segs[i]);
+ }
+ }
+ }
+ },
+
+
+ // Retrieves all the rendered segment objects for the view
+ getEventSegs: function() {
+ // subclasses must implement
+ return [];
+ },
+
+
+ /* Event Drag-n-Drop
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Computes if the given event is allowed to be dragged by the user
+ isEventDraggable: function(event) {
+ var source = event.source || {};
+
+ return firstDefined(
+ event.startEditable,
+ source.startEditable,
+ this.opt('eventStartEditable'),
+ event.editable,
+ source.editable,
+ this.opt('editable')
+ );
+ },
+
+
+ // Must be called when an event in the view is dropped onto new location.
+ // `dropLocation` is an object that contains the new start/end/allDay values for the event.
+ reportEventDrop: function(event, dropLocation, largeUnit, el, ev) {
+ var calendar = this.calendar;
+ var mutateResult = calendar.mutateEvent(event, dropLocation, largeUnit);
+ var undoFunc = function() {
+ mutateResult.undo();
+ calendar.reportEventChange();
+ };
+
+ this.triggerEventDrop(event, mutateResult.dateDelta, undoFunc, el, ev);
+ calendar.reportEventChange(); // will rerender events
+ },
+
+
+ // Triggers event-drop handlers that have subscribed via the API
+ triggerEventDrop: function(event, dateDelta, undoFunc, el, ev) {
+ this.trigger('eventDrop', el[0], event, dateDelta, undoFunc, ev, {}); // {} = jqui dummy
+ },
+
+
+ /* External Element Drag-n-Drop
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Must be called when an external element, via jQuery UI, has been dropped onto the calendar.
+ // `meta` is the parsed data that has been embedded into the dragging event.
+ // `dropLocation` is an object that contains the new start/end/allDay values for the event.
+ reportExternalDrop: function(meta, dropLocation, el, ev, ui) {
+ var eventProps = meta.eventProps;
+ var eventInput;
+ var event;
+
+ // Try to build an event object and render it. TODO: decouple the two
+ if (eventProps) {
+ eventInput = $.extend({}, eventProps, dropLocation);
+ event = this.calendar.renderEvent(eventInput, meta.stick)[0]; // renderEvent returns an array
+ }
+
+ this.triggerExternalDrop(event, dropLocation, el, ev, ui);
+ },
+
+
+ // Triggers external-drop handlers that have subscribed via the API
+ triggerExternalDrop: function(event, dropLocation, el, ev, ui) {
+
+ // trigger 'drop' regardless of whether element represents an event
+ this.trigger('drop', el[0], dropLocation.start, ev, ui);
+
+ if (event) {
+ this.trigger('eventReceive', null, event); // signal an external event landed
+ }
+ },
+
+
+ /* Drag-n-Drop Rendering (for both events and external elements)
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a visual indication of a event or external-element drag over the given drop zone.
+ // If an external-element, seg will be `null`
+ renderDrag: function(dropLocation, seg) {
+ // subclasses must implement
+ },
+
+
+ // Unrenders a visual indication of an event or external-element being dragged.
+ unrenderDrag: function() {
+ // subclasses must implement
+ },
+
+
+ /* Event Resizing
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Computes if the given event is allowed to be resized from its starting edge
+ isEventResizableFromStart: function(event) {
+ return this.opt('eventResizableFromStart') && this.isEventResizable(event);
+ },
+
+
+ // Computes if the given event is allowed to be resized from its ending edge
+ isEventResizableFromEnd: function(event) {
+ return this.isEventResizable(event);
+ },
+
+
+ // Computes if the given event is allowed to be resized by the user at all
+ isEventResizable: function(event) {
+ var source = event.source || {};
+
+ return firstDefined(
+ event.durationEditable,
+ source.durationEditable,
+ this.opt('eventDurationEditable'),
+ event.editable,
+ source.editable,
+ this.opt('editable')
+ );
+ },
+
+
+ // Must be called when an event in the view has been resized to a new length
+ reportEventResize: function(event, resizeLocation, largeUnit, el, ev) {
+ var calendar = this.calendar;
+ var mutateResult = calendar.mutateEvent(event, resizeLocation, largeUnit);
+ var undoFunc = function() {
+ mutateResult.undo();
+ calendar.reportEventChange();
+ };
+
+ this.triggerEventResize(event, mutateResult.durationDelta, undoFunc, el, ev);
+ calendar.reportEventChange(); // will rerender events
+ },
+
+
+ // Triggers event-resize handlers that have subscribed via the API
+ triggerEventResize: function(event, durationDelta, undoFunc, el, ev) {
+ this.trigger('eventResize', el[0], event, durationDelta, undoFunc, ev, {}); // {} = jqui dummy
+ },
+
+
+ /* Selection
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Selects a date range on the view. `start` and `end` are both Moments.
+ // `ev` is the native mouse event that begin the interaction.
+ select: function(range, ev) {
+ this.unselect(ev);
+ this.renderSelection(range);
+ this.reportSelection(range, ev);
+ },
+
+
+ // Renders a visual indication of the selection
+ renderSelection: function(range) {
+ // subclasses should implement
+ },
+
+
+ // Called when a new selection is made. Updates internal state and triggers handlers.
+ reportSelection: function(range, ev) {
+ this.isSelected = true;
+ this.triggerSelect(range, ev);
+ },
+
+
+ // Triggers handlers to 'select'
+ triggerSelect: function(range, ev) {
+ this.trigger('select', null, range.start, range.end, ev);
+ },
+
+
+ // Undoes a selection. updates in the internal state and triggers handlers.
+ // `ev` is the native mouse event that began the interaction.
+ unselect: function(ev) {
+ if (this.isSelected) {
+ this.isSelected = false;
+ if (this.destroySelection) {
+ this.destroySelection(); // TODO: deprecate
+ }
+ this.unrenderSelection();
+ this.trigger('unselect', null, ev);
+ }
+ },
+
+
+ // Unrenders a visual indication of selection
+ unrenderSelection: function() {
+ // subclasses should implement
+ },
+
+
+ // Handler for unselecting when the user clicks something and the 'unselectAuto' setting is on
+ documentMousedown: function(ev) {
+ var ignore;
+
+ // is there a selection, and has the user made a proper left click?
+ if (this.isSelected && this.opt('unselectAuto') && isPrimaryMouseButton(ev)) {
+
+ // only unselect if the clicked element is not identical to or inside of an 'unselectCancel' element
+ ignore = this.opt('unselectCancel');
+ if (!ignore || !$(ev.target).closest(ignore).length) {
+ this.unselect(ev);
+ }
+ }
+ },
+
+
+ /* Day Click
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Triggers handlers to 'dayClick'
+ triggerDayClick: function(date, dayEl, ev) {
+ this.trigger('dayClick', dayEl, date, ev);
+ },
+
+
+ /* Date Utils
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Initializes internal variables related to calculating hidden days-of-week
+ initHiddenDays: function() {
+ var hiddenDays = this.opt('hiddenDays') || []; // array of day-of-week indices that are hidden
+ var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
+ var dayCnt = 0;
+ var i;
+
+ if (this.opt('weekends') === false) {
+ hiddenDays.push(0, 6); // 0=sunday, 6=saturday
+ }
+
+ for (i = 0; i < 7; i++) {
+ if (
+ !(isHiddenDayHash[i] = $.inArray(i, hiddenDays) !== -1)
+ ) {
+ dayCnt++;
+ }
+ }
+
+ if (!dayCnt) {
+ throw 'invalid hiddenDays'; // all days were hidden? bad.
+ }
+
+ this.isHiddenDayHash = isHiddenDayHash;
+ },
+
+
+ // Is the current day hidden?
+ // `day` is a day-of-week index (0-6), or a Moment
+ isHiddenDay: function(day) {
+ if (moment.isMoment(day)) {
+ day = day.day();
+ }
+ return this.isHiddenDayHash[day];
+ },
+
+
+ // Incrementing the current day until it is no longer a hidden day, returning a copy.
+ // If the initial value of `date` is not a hidden day, don't do anything.
+ // Pass `isExclusive` as `true` if you are dealing with an end date.
+ // `inc` defaults to `1` (increment one day forward each time)
+ skipHiddenDays: function(date, inc, isExclusive) {
+ var out = date.clone();
+ inc = inc || 1;
+ while (
+ this.isHiddenDayHash[(out.day() + (isExclusive ? inc : 0) + 7) % 7]
+ ) {
+ out.add(inc, 'days');
+ }
+ return out;
+ },
+
+
+ // Returns the date range of the full days the given range visually appears to occupy.
+ // Returns a new range object.
+ computeDayRange: function(range) {
+ var startDay = range.start.clone().stripTime(); // the beginning of the day the range starts
+ var end = range.end;
+ var endDay = null;
+ var endTimeMS;
+
+ if (end) {
+ endDay = end.clone().stripTime(); // the beginning of the day the range exclusively ends
+ endTimeMS = +end.time(); // # of milliseconds into `endDay`
+
+ // If the end time is actually inclusively part of the next day and is equal to or
+ // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
+ // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
+ if (endTimeMS && endTimeMS >= this.nextDayThreshold) {
+ endDay.add(1, 'days');
+ }
+ }
+
+ // If no end was specified, or if it is within `startDay` but not past nextDayThreshold,
+ // assign the default duration of one day.
+ if (!end || endDay <= startDay) {
+ endDay = startDay.clone().add(1, 'days');
+ }
+
+ return { start: startDay, end: endDay };
+ },
+
+
+ // Does the given event visually appear to occupy more than one day?
+ isMultiDayEvent: function(event) {
+ var range = this.computeDayRange(event); // event is range-ish
+
+ return range.end.diff(range.start, 'days') > 1;
+ }
+
+});
;;
-function DayEventRenderer() {
+var Calendar = FC.Calendar = Class.extend({
+
+ dirDefaults: null, // option defaults related to LTR or RTL
+ langDefaults: null, // option defaults related to current locale
+ overrides: null, // option overrides given to the fullCalendar constructor
+ options: null, // all defaults combined with overrides
+ viewSpecCache: null, // cache of view definitions
+ view: null, // current View object
+ header: null,
+ loadingLevel: 0, // number of simultaneous loading tasks
+
+
+ // a lot of this class' OOP logic is scoped within this constructor function,
+ // but in the future, write individual methods on the prototype.
+ constructor: Calendar_constructor,
+
+
+ // Subclasses can override this for initialization logic after the constructor has been called
+ initialize: function() {
+ },
+
+
+ // Initializes `this.options` and other important options-related objects
+ initOptions: function(overrides) {
+ var lang, langDefaults;
+ var isRTL, dirDefaults;
+
+ // converts legacy options into non-legacy ones.
+ // in the future, when this is removed, don't use `overrides` reference. make a copy.
+ overrides = massageOverrides(overrides);
+
+ lang = overrides.lang;
+ langDefaults = langOptionHash[lang];
+ if (!langDefaults) {
+ lang = Calendar.defaults.lang;
+ langDefaults = langOptionHash[lang] || {};
+ }
+
+ isRTL = firstDefined(
+ overrides.isRTL,
+ langDefaults.isRTL,
+ Calendar.defaults.isRTL
+ );
+ dirDefaults = isRTL ? Calendar.rtlDefaults : {};
+
+ this.dirDefaults = dirDefaults;
+ this.langDefaults = langDefaults;
+ this.overrides = overrides;
+ this.options = mergeOptions([ // merge defaults and overrides. lowest to highest precedence
+ Calendar.defaults, // global defaults
+ dirDefaults,
+ langDefaults,
+ overrides
+ ]);
+ populateInstanceComputableOptions(this.options);
+
+ this.viewSpecCache = {}; // somewhat unrelated
+ },
+
+
+ // Gets information about how to create a view. Will use a cache.
+ getViewSpec: function(viewType) {
+ var cache = this.viewSpecCache;
+
+ return cache[viewType] || (cache[viewType] = this.buildViewSpec(viewType));
+ },
+
+
+ // Given a duration singular unit, like "week" or "day", finds a matching view spec.
+ // Preference is given to views that have corresponding buttons.
+ getUnitViewSpec: function(unit) {
+ var viewTypes;
+ var i;
+ var spec;
+
+ if ($.inArray(unit, intervalUnits) != -1) {
+
+ // put views that have buttons first. there will be duplicates, but oh well
+ viewTypes = this.header.getViewsWithButtons();
+ $.each(FC.views, function(viewType) { // all views
+ viewTypes.push(viewType);
+ });
+
+ for (i = 0; i < viewTypes.length; i++) {
+ spec = this.getViewSpec(viewTypes[i]);
+ if (spec) {
+ if (spec.singleUnit == unit) {
+ return spec;
+ }
+ }
+ }
+ }
+ },
+
+
+ // Builds an object with information on how to create a given view
+ buildViewSpec: function(requestedViewType) {
+ var viewOverrides = this.overrides.views || {};
+ var specChain = []; // for the view. lowest to highest priority
+ var defaultsChain = []; // for the view. lowest to highest priority
+ var overridesChain = []; // for the view. lowest to highest priority
+ var viewType = requestedViewType;
+ var spec; // for the view
+ var overrides; // for the view
+ var duration;
+ var unit;
+
+ // iterate from the specific view definition to a more general one until we hit an actual View class
+ while (viewType) {
+ spec = fcViews[viewType];
+ overrides = viewOverrides[viewType];
+ viewType = null; // clear. might repopulate for another iteration
+
+ if (typeof spec === 'function') { // TODO: deprecate
+ spec = { 'class': spec };
+ }
+
+ if (spec) {
+ specChain.unshift(spec);
+ defaultsChain.unshift(spec.defaults || {});
+ duration = duration || spec.duration;
+ viewType = viewType || spec.type;
+ }
+
+ if (overrides) {
+ overridesChain.unshift(overrides); // view-specific option hashes have options at zero-level
+ duration = duration || overrides.duration;
+ viewType = viewType || overrides.type;
+ }
+ }
+
+ spec = mergeProps(specChain);
+ spec.type = requestedViewType;
+ if (!spec['class']) {
+ return false;
+ }
+
+ if (duration) {
+ duration = moment.duration(duration);
+ if (duration.valueOf()) { // valid?
+ spec.duration = duration;
+ unit = computeIntervalUnit(duration);
+
+ // view is a single-unit duration, like "week" or "day"
+ // incorporate options for this. lowest priority
+ if (duration.as(unit) === 1) {
+ spec.singleUnit = unit;
+ overridesChain.unshift(viewOverrides[unit] || {});
+ }
+ }
+ }
+
+ spec.defaults = mergeOptions(defaultsChain);
+ spec.overrides = mergeOptions(overridesChain);
+
+ this.buildViewSpecOptions(spec);
+ this.buildViewSpecButtonText(spec, requestedViewType);
+
+ return spec;
+ },
+
+
+ // Builds and assigns a view spec's options object from its already-assigned defaults and overrides
+ buildViewSpecOptions: function(spec) {
+ spec.options = mergeOptions([ // lowest to highest priority
+ Calendar.defaults, // global defaults
+ spec.defaults, // view's defaults (from ViewSubclass.defaults)
+ this.dirDefaults,
+ this.langDefaults, // locale and dir take precedence over view's defaults!
+ this.overrides, // calendar's overrides (options given to constructor)
+ spec.overrides // view's overrides (view-specific options)
+ ]);
+ populateInstanceComputableOptions(spec.options);
+ },
+
+
+ // Computes and assigns a view spec's buttonText-related options
+ buildViewSpecButtonText: function(spec, requestedViewType) {
+
+ // given an options object with a possible `buttonText` hash, lookup the buttonText for the
+ // requested view, falling back to a generic unit entry like "week" or "day"
+ function queryButtonText(options) {
+ var buttonText = options.buttonText || {};
+ return buttonText[requestedViewType] ||
+ (spec.singleUnit ? buttonText[spec.singleUnit] : null);
+ }
+
+ // highest to lowest priority
+ spec.buttonTextOverride =
+ queryButtonText(this.overrides) || // constructor-specified buttonText lookup hash takes precedence
+ spec.overrides.buttonText; // `buttonText` for view-specific options is a string
+
+ // highest to lowest priority. mirrors buildViewSpecOptions
+ spec.buttonTextDefault =
+ queryButtonText(this.langDefaults) ||
+ queryButtonText(this.dirDefaults) ||
+ spec.defaults.buttonText || // a single string. from ViewSubclass.defaults
+ queryButtonText(Calendar.defaults) ||
+ (spec.duration ? this.humanizeDuration(spec.duration) : null) || // like "3 days"
+ requestedViewType; // fall back to given view name
+ },
+
+
+ // Given a view name for a custom view or a standard view, creates a ready-to-go View object
+ instantiateView: function(viewType) {
+ var spec = this.getViewSpec(viewType);
+
+ return new spec['class'](this, viewType, spec.options, spec.duration);
+ },
+
+
+ // Returns a boolean about whether the view is okay to instantiate at some point
+ isValidViewType: function(viewType) {
+ return Boolean(this.getViewSpec(viewType));
+ },
+
+
+ // Should be called when any type of async data fetching begins
+ pushLoading: function() {
+ if (!(this.loadingLevel++)) {
+ this.trigger('loading', null, true, this.view);
+ }
+ },
+
+
+ // Should be called when any type of async data fetching completes
+ popLoading: function() {
+ if (!(--this.loadingLevel)) {
+ this.trigger('loading', null, false, this.view);
+ }
+ },
+
+
+ // Given arguments to the select method in the API, returns a range
+ buildSelectRange: function(start, end) {
+
+ start = this.moment(start);
+ if (end) {
+ end = this.moment(end);
+ }
+ else if (start.hasTime()) {
+ end = start.clone().add(this.defaultTimedEventDuration);
+ }
+ else {
+ end = start.clone().add(this.defaultAllDayEventDuration);
+ }
+
+ return { start: start, end: end };
+ }
+
+});
+
+
+Calendar.mixin(Emitter);
+
+
+function Calendar_constructor(element, overrides) {
var t = this;
+
+ t.initOptions(overrides || {});
+ var options = this.options;
+
- // exports
- t.renderDaySegs = renderDaySegs;
- t.resizableDayEvent = resizableDayEvent;
+ // Exports
+ // -----------------------------------------------------------------------------------
+
+ t.render = render;
+ t.destroy = destroy;
+ t.refetchEvents = refetchEvents;
+ t.reportEvents = reportEvents;
+ t.reportEventChange = reportEventChange;
+ t.rerenderEvents = renderEvents; // `renderEvents` serves as a rerender. an API method
+ t.changeView = renderView; // `renderView` will switch to another view
+ 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.zoomTo = zoomTo;
+ t.getDate = getDate;
+ t.getCalendar = getCalendar;
+ t.getView = getView;
+ t.option = option;
+ t.trigger = trigger;
+
+
+
+ // Language-data Internals
+ // -----------------------------------------------------------------------------------
+ // Apply overrides to the current language's data
+
+
+ var localeData = createObject( // make a cheap copy
+ getMomentLocaleData(options.lang) // will fall back to en
+ );
+
+ if (options.monthNames) {
+ localeData._months = options.monthNames;
+ }
+ if (options.monthNamesShort) {
+ localeData._monthsShort = options.monthNamesShort;
+ }
+ if (options.dayNames) {
+ localeData._weekdays = options.dayNames;
+ }
+ if (options.dayNamesShort) {
+ localeData._weekdaysShort = options.dayNamesShort;
+ }
+ if (options.firstDay != null) {
+ var _week = createObject(localeData._week); // _week: { dow: # }
+ _week.dow = options.firstDay;
+ localeData._week = _week;
+ }
+
+ // assign a normalized value, to be used by our .week() moment extension
+ localeData._fullCalendar_weekCalc = (function(weekCalc) {
+ if (typeof weekCalc === 'function') {
+ return weekCalc;
+ }
+ else if (weekCalc === 'local') {
+ return weekCalc;
+ }
+ else if (weekCalc === 'iso' || weekCalc === 'ISO') {
+ return 'ISO';
+ }
+ })(options.weekNumberCalculation);
+
+
+
+ // Calendar-specific Date Utilities
+ // -----------------------------------------------------------------------------------
+
+
+ t.defaultAllDayEventDuration = moment.duration(options.defaultAllDayEventDuration);
+ t.defaultTimedEventDuration = moment.duration(options.defaultTimedEventDuration);
+
+
+ // Builds a moment using the settings of the current calendar: timezone and language.
+ // Accepts anything the vanilla moment() constructor accepts.
+ t.moment = function() {
+ var mom;
+
+ if (options.timezone === 'local') {
+ mom = FC.moment.apply(null, arguments);
+
+ // Force the moment to be local, because FC.moment doesn't guarantee it.
+ if (mom.hasTime()) { // don't give ambiguously-timed moments a local zone
+ mom.local();
+ }
+ }
+ else if (options.timezone === 'UTC') {
+ mom = FC.moment.utc.apply(null, arguments); // process as UTC
+ }
+ else {
+ mom = FC.moment.parseZone.apply(null, arguments); // let the input decide the zone
+ }
+
+ if ('_locale' in mom) { // moment 2.8 and above
+ mom._locale = localeData;
+ }
+ else { // pre-moment-2.8
+ mom._lang = localeData;
+ }
+
+ return mom;
+ };
+
+
+ // Returns a boolean about whether or not the calendar knows how to calculate
+ // the timezone offset of arbitrary dates in the current timezone.
+ t.getIsAmbigTimezone = function() {
+ return options.timezone !== 'local' && options.timezone !== 'UTC';
+ };
+
+
+ // Returns a copy of the given date in the current timezone of it is ambiguously zoned.
+ // This will also give the date an unambiguous time.
+ t.rezoneDate = function(date) {
+ return t.moment(date.toArray());
+ };
+
+
+ // Returns a moment for the current date, as defined by the client's computer,
+ // or overridden by the `now` option.
+ t.getNow = function() {
+ var now = options.now;
+ if (typeof now === 'function') {
+ now = now();
+ }
+ return t.moment(now);
+ };
+
+
+ // Get an event's normalized end date. If not present, calculate it from the defaults.
+ t.getEventEnd = function(event) {
+ if (event.end) {
+ return event.end.clone();
+ }
+ else {
+ return t.getDefaultEventEnd(event.allDay, event.start);
+ }
+ };
+
+
+ // Given an event's allDay status and start date, return swhat its fallback end date should be.
+ t.getDefaultEventEnd = function(allDay, start) { // TODO: rename to computeDefaultEventEnd
+ var end = start.clone();
+
+ if (allDay) {
+ end.stripTime().add(t.defaultAllDayEventDuration);
+ }
+ else {
+ end.add(t.defaultTimedEventDuration);
+ }
+
+ if (t.getIsAmbigTimezone()) {
+ end.stripZone(); // we don't know what the tzo should be
+ }
+
+ return end;
+ };
+
+
+ // Produces a human-readable string for the given duration.
+ // Side-effect: changes the locale of the given duration.
+ t.humanizeDuration = function(duration) {
+ return (duration.locale || duration.lang).call(duration, options.lang) // works moment-pre-2.8
+ .humanize();
+ };
+
+
-
- // imports
- var opt = t.opt;
- var trigger = t.trigger;
- var isEventDraggable = t.isEventDraggable;
- var isEventResizable = t.isEventResizable;
- var eventEnd = t.eventEnd;
- var reportEventElement = t.reportEventElement;
- var showEvents = t.showEvents;
- var hideEvents = t.hideEvents;
- var eventResize = t.eventResize;
- var getRowCnt = t.getRowCnt;
- var getColCnt = t.getColCnt;
- var getColWidth = t.getColWidth;
- var allDayRow = t.allDayRow;
- var allDayBounds = t.allDayBounds;
- var colContentLeft = t.colContentLeft;
- var colContentRight = t.colContentRight;
- var dayOfWeekCol = t.dayOfWeekCol;
- var dateCell = t.dateCell;
- var compileDaySegs = t.compileDaySegs;
- var getDaySegmentContainer = t.getDaySegmentContainer;
- var bindDaySeg = t.bindDaySeg; //TODO: streamline this
- var formatDates = t.calendar.formatDates;
- var renderDayOverlay = t.renderDayOverlay;
- var clearOverlays = t.clearOverlays;
- var clearSelection = t.clearSelection;
+ // Imports
+ // -----------------------------------------------------------------------------------
+
+
+ EventManager.call(t, options);
+ 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; // NOTE: keep this in sync with this.view
+ var viewsByType = {}; // holds all instantiated view instances, current or not
+ var suggestedViewHeight;
+ var windowResizeProxy; // wraps the windowResize function
+ var ignoreWindowResize = 0;
+ var date;
+ var events = [];
- /* Rendering
+ // Main Rendering
+ // -----------------------------------------------------------------------------------
+
+
+ if (options.defaultDate != null) {
+ date = t.moment(options.defaultDate);
+ }
+ else {
+ date = t.getNow();
+ }
+
+
+ function render() {
+ if (!content) {
+ initialRender();
+ }
+ else if (elementVisible()) {
+ // mainly for the public API
+ calcSize();
+ renderView();
+ }
+ }
+
+
+ function initialRender() {
+ tm = options.theme ? 'ui' : 'fc';
+ element.addClass('fc');
+
+ if (options.isRTL) {
+ element.addClass('fc-rtl');
+ }
+ else {
+ element.addClass('fc-ltr');
+ }
+
+ if (options.theme) {
+ element.addClass('ui-widget');
+ }
+ else {
+ element.addClass('fc-unthemed');
+ }
+
+ content = $("").prependTo(element);
+
+ header = t.header = new Header(t, options);
+ headerElement = header.render();
+ if (headerElement) {
+ element.prepend(headerElement);
+ }
+
+ renderView(options.defaultView);
+
+ if (options.handleWindowResize) {
+ windowResizeProxy = debounce(windowResize, options.windowResizeDelay); // prevents rapid calls
+ $(window).resize(windowResizeProxy);
+ }
+ }
+
+
+ function destroy() {
+
+ if (currentView) {
+ currentView.removeElement();
+
+ // NOTE: don't null-out currentView/t.view in case API methods are called after destroy.
+ // It is still the "current" view, just not rendered.
+ }
+
+ header.removeElement();
+ content.remove();
+ element.removeClass('fc fc-ltr fc-rtl fc-unthemed ui-widget');
+
+ if (windowResizeProxy) {
+ $(window).unbind('resize', windowResizeProxy);
+ }
+ }
+
+
+ function elementVisible() {
+ return element.is(':visible');
+ }
+
+
+
+ // View Rendering
+ // -----------------------------------------------------------------------------------
+
+
+ // Renders a view because of a date change, view-type change, or for the first time.
+ // If not given a viewType, keep the current view but render different dates.
+ function renderView(viewType) {
+ ignoreWindowResize++;
+
+ // if viewType is changing, remove the old view's rendering
+ if (currentView && viewType && currentView.type !== viewType) {
+ header.deactivateButton(currentView.type);
+ freezeContentHeight(); // prevent a scroll jump when view element is removed
+ currentView.removeElement();
+ currentView = t.view = null;
+ }
+
+ // if viewType changed, or the view was never created, create a fresh view
+ if (!currentView && viewType) {
+ currentView = t.view =
+ viewsByType[viewType] ||
+ (viewsByType[viewType] = t.instantiateView(viewType));
+
+ currentView.setElement(
+ $("").appendTo(content)
+ );
+ header.activateButton(viewType);
+ }
+
+ if (currentView) {
+
+ // in case the view should render a period of time that is completely hidden
+ date = currentView.massageCurrentDate(date);
+
+ // render or rerender the view
+ if (
+ !currentView.displaying ||
+ !date.isWithin(currentView.intervalStart, currentView.intervalEnd) // implicit date window change
+ ) {
+ if (elementVisible()) {
+
+ freezeContentHeight();
+ currentView.display(date);
+ unfreezeContentHeight(); // immediately unfreeze regardless of whether display is async
+
+ // need to do this after View::render, so dates are calculated
+ updateHeaderTitle();
+ updateTodayButton();
+
+ getAndRenderEvents();
+ }
+ }
+ }
+
+ unfreezeContentHeight(); // undo any lone freezeContentHeight calls
+ ignoreWindowResize--;
+ }
+
+
+
+ // Resizing
+ // -----------------------------------------------------------------------------------
+
+
+ t.getSuggestedViewHeight = function() {
+ if (suggestedViewHeight === undefined) {
+ calcSize();
+ }
+ return suggestedViewHeight;
+ };
+
+
+ t.isHeightAuto = function() {
+ return options.contentHeight === 'auto' || options.height === 'auto';
+ };
+
+
+ function updateSize(shouldRecalc) {
+ if (elementVisible()) {
+
+ if (shouldRecalc) {
+ _calcSize();
+ }
+
+ ignoreWindowResize++;
+ currentView.updateSize(true); // isResize=true. will poll getSuggestedViewHeight() and isHeightAuto()
+ ignoreWindowResize--;
+
+ return true; // signal success
+ }
+ }
+
+
+ function calcSize() {
+ if (elementVisible()) {
+ _calcSize();
+ }
+ }
+
+
+ function _calcSize() { // assumes elementVisible
+ if (typeof options.contentHeight === 'number') { // exists and not 'auto'
+ suggestedViewHeight = options.contentHeight;
+ }
+ else if (typeof options.height === 'number') { // exists and not 'auto'
+ suggestedViewHeight = options.height - (headerElement ? headerElement.outerHeight(true) : 0);
+ }
+ else {
+ suggestedViewHeight = Math.round(content.width() / Math.max(options.aspectRatio, .5));
+ }
+ }
+
+
+ function windowResize(ev) {
+ if (
+ !ignoreWindowResize &&
+ ev.target === window && // so we don't process jqui "resize" events that have bubbled up
+ currentView.start // view has already been rendered
+ ) {
+ if (updateSize(true)) {
+ currentView.trigger('windowResize', _element);
+ }
+ }
+ }
+
+
+
+ /* Event Fetching/Rendering
+ -----------------------------------------------------------------------------*/
+ // TODO: going forward, most of this stuff should be directly handled by the view
+
+
+ function refetchEvents() { // can be called as an API method
+ destroyEvents(); // so that events are cleared before user starts waiting for AJAX
+ fetchAndRenderEvents();
+ }
+
+
+ function renderEvents() { // destroys old events if previously rendered
+ if (elementVisible()) {
+ freezeContentHeight();
+ currentView.displayEvents(events);
+ unfreezeContentHeight();
+ }
+ }
+
+
+ function destroyEvents() {
+ freezeContentHeight();
+ currentView.clearEvents();
+ unfreezeContentHeight();
+ }
+
+
+ function getAndRenderEvents() {
+ if (!options.lazyFetching || isFetchNeeded(currentView.start, currentView.end)) {
+ fetchAndRenderEvents();
+ }
+ else {
+ renderEvents();
+ }
+ }
+
+
+ function fetchAndRenderEvents() {
+ fetchEvents(currentView.start, currentView.end);
+ // ... will call reportEvents
+ // ... which will call renderEvents
+ }
+
+
+ // called when event data arrives
+ function reportEvents(_events) {
+ events = _events;
+ renderEvents();
+ }
+
+
+ // called when a single event's data has been changed
+ function reportEventChange() {
+ renderEvents();
+ }
+
+
+
+ /* Header Updating
+ -----------------------------------------------------------------------------*/
+
+
+ function updateHeaderTitle() {
+ header.updateTitle(currentView.title);
+ }
+
+
+ function updateTodayButton() {
+ var now = t.getNow();
+ if (now.isWithin(currentView.intervalStart, currentView.intervalEnd)) {
+ header.disableButton('today');
+ }
+ else {
+ header.enableButton('today');
+ }
+ }
+
+
+
+ /* Selection
+ -----------------------------------------------------------------------------*/
+
+
+ function select(start, end) {
+ currentView.select(
+ t.buildSelectRange.apply(t, arguments)
+ );
+ }
+
+
+ function unselect() { // safe to be called before renderView
+ if (currentView) {
+ currentView.unselect();
+ }
+ }
+
+
+
+ /* Date
-----------------------------------------------------------------------------*/
- function renderDaySegs(segs, modifiedEventId) {
- var segmentContainer = getDaySegmentContainer();
- var rowDivs;
- var rowCnt = getRowCnt();
- var colCnt = getColCnt();
- var i = 0;
- var rowI;
- var levelI;
- var colHeights;
- var j;
- var segCnt = segs.length;
- var seg;
- var top;
- var k;
- segmentContainer[0].innerHTML = daySegHTML(segs); // faster than .html()
- daySegElementResolve(segs, segmentContainer.children());
- daySegElementReport(segs);
- daySegHandlers(segs, segmentContainer, modifiedEventId);
- daySegCalcHSides(segs);
- daySegSetWidths(segs);
- daySegCalcHeights(segs);
- rowDivs = getRowDivs();
- // set row heights, calculate event tops (in relation to row top)
- for (rowI=0; rowI");
- var elements;
- var segmentContainer = getDaySegmentContainer();
- var i;
- var segCnt = segs.length;
- var element;
- tempContainer[0].innerHTML = daySegHTML(segs); // faster than .html()
- elements = tempContainer.children();
- segmentContainer.append(elements);
- daySegElementResolve(segs, elements);
- daySegCalcHSides(segs);
- daySegSetWidths(segs);
- daySegCalcHeights(segs);
- daySegSetTops(segs, getRowTops(getRowDivs()));
- elements = [];
- for (i=0; i" +
- "";
- if (!event.allDay && seg.isStart) {
- html +=
- "" +
- htmlEscape(formatDates(event.start, event.end, opt('timeFormat'))) +
- "";
- }
- html +=
- "" + htmlEscape(event.title) + "" +
- " ";
- if (seg.isEnd && isEventResizable(event)) {
- html +=
- "" +
- " " + // makes hit area a lot better for IE6/7
- " ";
- }
- html +=
- "" + (url ? "a" : "div" ) + ">";
- seg.left = left;
- seg.outerWidth = right - left;
- seg.startCol = leftCol;
- seg.endCol = rightCol + 1; // needs to be exclusive
- }
- return html;
+ function prevYear() {
+ date.add(-1, 'years');
+ renderView();
}
- function daySegElementResolve(segs, elements) { // sets seg.element
- var i;
- var segCnt = segs.length;
- var seg;
- var event;
- var element;
- var triggerRes;
- for (i=0; i div'); // optimal selector?
- }
- return rowDivs;
- }
-
-
- function getRowTops(rowDivs) {
- var i;
- var rowCnt = rowDivs.length;
- var tops = [];
- for (i=0; i selection for IE
- element
- .mousedown(function(ev) { // prevent native selection for others
- ev.preventDefault();
- })
- .click(function(ev) {
- if (isResizing) {
- ev.preventDefault(); // prevent link from being visited (only method that worked in IE6)
- ev.stopImmediatePropagation(); // prevent fullcalendar eventClick handler from being called
- // (eventElementHandlers needs to be bound after resizableDayEvent)
- }
- });
-
- handle.mousedown(function(ev) {
- if (ev.which != 1) {
- return; // needs to be left mouse button
- }
- isResizing = true;
- var hoverListener = t.getHoverListener();
- var rowCnt = getRowCnt();
- var colCnt = getColCnt();
- var dis = rtl ? -1 : 1;
- var dit = rtl ? colCnt-1 : 0;
- var elementTop = element.css('top');
- var dayDelta;
- var helpers;
- var eventCopy = $.extend({}, event);
- var minCell = dateCell(event.start);
- clearSelection();
- $('body')
- .css('cursor', direction + '-resize')
- .one('mouseup', mouseup);
- trigger('eventResizeStart', this, event, ev);
- hoverListener.start(function(cell, origCell) {
- if (cell) {
- var r = Math.max(minCell.row, cell.row);
- var c = cell.col;
- if (rowCnt == 1) {
- r = 0; // hack for all-day area in agenda views
- }
- if (r == minCell.row) {
- if (rtl) {
- c = Math.min(minCell.col, c);
- }else{
- c = Math.max(minCell.col, c);
- }
- }
- dayDelta = (r*7 + c*dis+dit) - (origCell.row*7 + origCell.col*dis+dit);
- var newEnd = addDays(eventEnd(event), dayDelta, true);
- if (dayDelta) {
- eventCopy.end = newEnd;
- var oldHelpers = helpers;
- helpers = renderTempDaySegs(compileDaySegs([eventCopy]), seg.row, elementTop);
- helpers.find('*').css('cursor', direction + '-resize');
- if (oldHelpers) {
- oldHelpers.remove();
- }
- hideEvents(event);
- }else{
- if (helpers) {
- showEvents(event);
- helpers.remove();
- helpers = null;
- }
- }
- clearOverlays();
- 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', '');
- hoverListener.stop();
- clearOverlays();
- if (dayDelta) {
- eventResize(this, event, dayDelta, 0, ev);
- // 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);
- }
-
+
+
+ function unfreezeContentHeight() {
+ content.css({
+ width: '',
+ height: '',
+ overflow: ''
});
}
+
+
+ /* Misc
+ -----------------------------------------------------------------------------*/
+
+
+ function getCalendar() {
+ return t;
+ }
+
+
+ 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(true); // true = allow recalculation of height
+ }
+ }
+
+
+ function trigger(name, thisObj) { // overrides the Emitter's trigger method :(
+ var args = Array.prototype.slice.call(arguments, 2);
+
+ thisObj = thisObj || _element;
+ this.triggerWith(name, thisObj, args); // Emitter's method
+
+ if (options[name]) {
+ return options[name].apply(thisObj, args);
+ }
+ }
+
+ t.initialize();
+}
+
+;;
+
+Calendar.defaults = {
+
+ titleRangeSeparator: ' \u2014 ', // emphasized dash
+ monthYearFormat: 'MMMM YYYY', // required for en. other languages rely on datepicker computable option
+
+ defaultTimedEventDuration: '02:00:00',
+ defaultAllDayEventDuration: { days: 1 },
+ forceEventDuration: false,
+ nextDayThreshold: '09:00:00', // 9am
+
+ // display
+ defaultView: 'month',
+ aspectRatio: 1.35,
+ header: {
+ left: 'title',
+ center: '',
+ right: 'today prev,next'
+ },
+ weekends: true,
+ weekNumbers: false,
+
+ weekNumberTitle: 'W',
+ weekNumberCalculation: 'local',
+
+ //editable: false,
+
+ scrollTime: '06:00:00',
+
+ // event ajax
+ lazyFetching: true,
+ startParam: 'start',
+ endParam: 'end',
+ timezoneParam: 'timezone',
+
+ timezone: false,
+
+ //allDayDefault: undefined,
+
+ // locale
+ isRTL: false,
+ buttonText: {
+ prev: "prev",
+ next: "next",
+ prevYear: "prev year",
+ nextYear: "next year",
+ year: 'year', // TODO: locale files need to specify this
+ today: 'today',
+ month: 'month',
+ week: 'week',
+ day: 'day'
+ },
+
+ buttonIcons: {
+ prev: 'left-single-arrow',
+ next: 'right-single-arrow',
+ prevYear: 'left-double-arrow',
+ nextYear: 'right-double-arrow'
+ },
+
+ // jquery-ui theming
+ theme: false,
+ themeButtonIcons: {
+ prev: 'circle-triangle-w',
+ next: 'circle-triangle-e',
+ prevYear: 'seek-prev',
+ nextYear: 'seek-next'
+ },
+
+ //eventResizableFromStart: false,
+ dragOpacity: .75,
+ dragRevertDuration: 500,
+ dragScroll: true,
+
+ //selectable: false,
+ unselectAuto: true,
+
+ dropAccept: '*',
+
+ eventOrder: 'title',
+
+ eventLimit: false,
+ eventLimitText: 'more',
+ eventLimitClick: 'popover',
+ dayPopoverFormat: 'LL',
+
+ handleWindowResize: true,
+ windowResizeDelay: 200 // milliseconds before an updateSize happens
+
+};
+
+
+Calendar.englishDefaults = { // used by lang.js
+ dayPopoverFormat: 'dddd, MMMM D'
+};
+
+
+Calendar.rtlDefaults = { // right-to-left defaults
+ header: { // TODO: smarter solution (first/center/last ?)
+ left: 'next,prev today',
+ center: '',
+ right: 'title'
+ },
+ buttonIcons: {
+ prev: 'right-single-arrow',
+ next: 'left-single-arrow',
+ prevYear: 'right-double-arrow',
+ nextYear: 'left-double-arrow'
+ },
+ themeButtonIcons: {
+ prev: 'circle-triangle-e',
+ next: 'circle-triangle-w',
+ nextYear: 'seek-prev',
+ prevYear: 'seek-next'
+ }
+};
+
+;;
+
+var langOptionHash = FC.langs = {}; // initialize and expose
+
+
+// TODO: document the structure and ordering of a FullCalendar lang file
+// TODO: rename everything "lang" to "locale", like what the moment project did
+
+
+// Initialize jQuery UI datepicker translations while using some of the translations
+// Will set this as the default language for datepicker.
+FC.datepickerLang = function(langCode, dpLangCode, dpOptions) {
+
+ // get the FullCalendar internal option hash for this language. create if necessary
+ var fcOptions = langOptionHash[langCode] || (langOptionHash[langCode] = {});
+
+ // transfer some simple options from datepicker to fc
+ fcOptions.isRTL = dpOptions.isRTL;
+ fcOptions.weekNumberTitle = dpOptions.weekHeader;
+
+ // compute some more complex options from datepicker
+ $.each(dpComputableOptions, function(name, func) {
+ fcOptions[name] = func(dpOptions);
+ });
+
+ // is jQuery UI Datepicker is on the page?
+ if ($.datepicker) {
+
+ // Register the language data.
+ // FullCalendar and MomentJS use language codes like "pt-br" but Datepicker
+ // does it like "pt-BR" or if it doesn't have the language, maybe just "pt".
+ // Make an alias so the language can be referenced either way.
+ $.datepicker.regional[dpLangCode] =
+ $.datepicker.regional[langCode] = // alias
+ dpOptions;
+
+ // Alias 'en' to the default language data. Do this every time.
+ $.datepicker.regional.en = $.datepicker.regional[''];
+
+ // Set as Datepicker's global defaults.
+ $.datepicker.setDefaults(dpOptions);
+ }
+};
+
+
+// Sets FullCalendar-specific translations. Will set the language as the global default.
+FC.lang = function(langCode, newFcOptions) {
+ var fcOptions;
+ var momOptions;
+
+ // get the FullCalendar internal option hash for this language. create if necessary
+ fcOptions = langOptionHash[langCode] || (langOptionHash[langCode] = {});
+
+ // provided new options for this language? merge them in
+ if (newFcOptions) {
+ fcOptions = langOptionHash[langCode] = mergeOptions([ fcOptions, newFcOptions ]);
+ }
+
+ // compute language options that weren't defined.
+ // always do this. newFcOptions can be undefined when initializing from i18n file,
+ // so no way to tell if this is an initialization or a default-setting.
+ momOptions = getMomentLocaleData(langCode); // will fall back to en
+ $.each(momComputableOptions, function(name, func) {
+ if (fcOptions[name] == null) {
+ fcOptions[name] = func(momOptions, fcOptions);
+ }
+ });
+
+ // set it as the default language for FullCalendar
+ Calendar.defaults.lang = langCode;
+};
+
+
+// NOTE: can't guarantee any of these computations will run because not every language has datepicker
+// configs, so make sure there are English fallbacks for these in the defaults file.
+var dpComputableOptions = {
+
+ buttonText: function(dpOptions) {
+ return {
+ // the translations sometimes wrongly contain HTML entities
+ prev: stripHtmlEntities(dpOptions.prevText),
+ next: stripHtmlEntities(dpOptions.nextText),
+ today: stripHtmlEntities(dpOptions.currentText)
+ };
+ },
+
+ // Produces format strings like "MMMM YYYY" -> "September 2014"
+ monthYearFormat: function(dpOptions) {
+ return dpOptions.showMonthAfterYear ?
+ 'YYYY[' + dpOptions.yearSuffix + '] MMMM' :
+ 'MMMM YYYY[' + dpOptions.yearSuffix + ']';
+ }
+
+};
+
+var momComputableOptions = {
+
+ // Produces format strings like "ddd M/D" -> "Fri 9/15"
+ dayOfMonthFormat: function(momOptions, fcOptions) {
+ var format = momOptions.longDateFormat('l'); // for the format like "M/D/YYYY"
+
+ // strip the year off the edge, as well as other misc non-whitespace chars
+ format = format.replace(/^Y+[^\w\s]*|[^\w\s]*Y+$/g, '');
+
+ if (fcOptions.isRTL) {
+ format += ' ddd'; // for RTL, add day-of-week to end
+ }
+ else {
+ format = 'ddd ' + format; // for LTR, add day-of-week to beginning
+ }
+ return format;
+ },
+
+ // Produces format strings like "h:mma" -> "6:00pm"
+ mediumTimeFormat: function(momOptions) { // can't be called `timeFormat` because collides with option
+ return momOptions.longDateFormat('LT')
+ .replace(/\s*a$/i, 'a'); // convert AM/PM/am/pm to lowercase. remove any spaces beforehand
+ },
+
+ // Produces format strings like "h(:mm)a" -> "6pm" / "6:30pm"
+ smallTimeFormat: function(momOptions) {
+ return momOptions.longDateFormat('LT')
+ .replace(':mm', '(:mm)')
+ .replace(/(\Wmm)$/, '($1)') // like above, but for foreign langs
+ .replace(/\s*a$/i, 'a'); // convert AM/PM/am/pm to lowercase. remove any spaces beforehand
+ },
+
+ // Produces format strings like "h(:mm)t" -> "6p" / "6:30p"
+ extraSmallTimeFormat: function(momOptions) {
+ return momOptions.longDateFormat('LT')
+ .replace(':mm', '(:mm)')
+ .replace(/(\Wmm)$/, '($1)') // like above, but for foreign langs
+ .replace(/\s*a$/i, 't'); // convert to AM/PM/am/pm to lowercase one-letter. remove any spaces beforehand
+ },
+
+ // Produces format strings like "ha" / "H" -> "6pm" / "18"
+ hourFormat: function(momOptions) {
+ return momOptions.longDateFormat('LT')
+ .replace(':mm', '')
+ .replace(/(\Wmm)$/, '') // like above, but for foreign langs
+ .replace(/\s*a$/i, 'a'); // convert AM/PM/am/pm to lowercase. remove any spaces beforehand
+ },
+
+ // Produces format strings like "h:mm" -> "6:30" (with no AM/PM)
+ noMeridiemTimeFormat: function(momOptions) {
+ return momOptions.longDateFormat('LT')
+ .replace(/\s*a$/i, ''); // remove trailing AM/PM
+ }
+
+};
+
+
+// options that should be computed off live calendar options (considers override options)
+// TODO: best place for this? related to lang?
+// TODO: flipping text based on isRTL is a bad idea because the CSS `direction` might want to handle it
+var instanceComputableOptions = {
+
+ // Produces format strings for results like "Mo 16"
+ smallDayDateFormat: function(options) {
+ return options.isRTL ?
+ 'D dd' :
+ 'dd D';
+ },
+
+ // Produces format strings for results like "Wk 5"
+ weekFormat: function(options) {
+ return options.isRTL ?
+ 'w[ ' + options.weekNumberTitle + ']' :
+ '[' + options.weekNumberTitle + ' ]w';
+ },
+
+ // Produces format strings for results like "Wk5"
+ smallWeekFormat: function(options) {
+ return options.isRTL ?
+ 'w[' + options.weekNumberTitle + ']' :
+ '[' + options.weekNumberTitle + ']w';
+ }
+
+};
+
+function populateInstanceComputableOptions(options) {
+ $.each(instanceComputableOptions, function(name, func) {
+ if (options[name] == null) {
+ options[name] = func(options);
+ }
+ });
+}
+
+
+// Returns moment's internal locale data. If doesn't exist, returns English.
+// Works with moment-pre-2.8
+function getMomentLocaleData(langCode) {
+ var func = moment.localeData || moment.langData;
+ return func.call(moment, langCode) ||
+ func.call(moment, 'en'); // the newer localData could return null, so fall back to en
+}
+
+
+// Initialize English by forcing computation of moment-derived options.
+// Also, sets it as the default.
+FC.lang('en', Calendar.englishDefaults);
+
+;;
+
+/* Top toolbar area with buttons and title
+----------------------------------------------------------------------------------------------------------------------*/
+// TODO: rename all header-related things to "toolbar"
+
+function Header(calendar, options) {
+ var t = this;
+
+ // exports
+ t.render = render;
+ t.removeElement = removeElement;
+ t.updateTitle = updateTitle;
+ t.activateButton = activateButton;
+ t.deactivateButton = deactivateButton;
+ t.disableButton = disableButton;
+ t.enableButton = enableButton;
+ t.getViewsWithButtons = getViewsWithButtons;
+
+ // locals
+ var el = $();
+ var viewsWithButtons = [];
+ var tm;
+
+
+ function render() {
+ var sections = options.header;
+
+ tm = options.theme ? 'ui' : 'fc';
+
+ if (sections) {
+ el = $("")
+ .append(renderSection('left'))
+ .append(renderSection('right'))
+ .append(renderSection('center'))
+ .append('');
+
+ return el;
+ }
+ }
+
+
+ function removeElement() {
+ el.remove();
+ el = $();
+ }
+
+
+ function renderSection(position) {
+ var sectionEl = $('');
+ var buttonStr = options.header[position];
+
+ if (buttonStr) {
+ $.each(buttonStr.split(' '), function(i) {
+ var groupChildren = $();
+ var isOnlyButtons = true;
+ var groupEl;
+
+ $.each(this.split(','), function(j, buttonName) {
+ var customButtonProps;
+ var viewSpec;
+ var buttonClick;
+ var overrideText; // text explicitly set by calendar's constructor options. overcomes icons
+ var defaultText;
+ var themeIcon;
+ var normalIcon;
+ var innerHtml;
+ var classes;
+ var button; // the element
+
+ if (buttonName == 'title') {
+ groupChildren = groupChildren.add($(' ')); // we always want it to take up height
+ isOnlyButtons = false;
+ }
+ else {
+ if ((customButtonProps = (calendar.options.customButtons || {})[buttonName])) {
+ buttonClick = function(ev) {
+ if (customButtonProps.click) {
+ customButtonProps.click.call(button[0], ev);
+ }
+ };
+ overrideText = ''; // icons will override text
+ defaultText = customButtonProps.text;
+ }
+ else if ((viewSpec = calendar.getViewSpec(buttonName))) {
+ buttonClick = function() {
+ calendar.changeView(buttonName);
+ };
+ viewsWithButtons.push(buttonName);
+ overrideText = viewSpec.buttonTextOverride;
+ defaultText = viewSpec.buttonTextDefault;
+ }
+ else if (calendar[buttonName]) { // a calendar method
+ buttonClick = function() {
+ calendar[buttonName]();
+ };
+ overrideText = (calendar.overrides.buttonText || {})[buttonName];
+ defaultText = options.buttonText[buttonName]; // everything else is considered default
+ }
+
+ if (buttonClick) {
+
+ themeIcon =
+ customButtonProps ?
+ customButtonProps.themeIcon :
+ options.themeButtonIcons[buttonName];
+
+ normalIcon =
+ customButtonProps ?
+ customButtonProps.icon :
+ options.buttonIcons[buttonName];
+
+ if (overrideText) {
+ innerHtml = htmlEscape(overrideText);
+ }
+ else if (themeIcon && options.theme) {
+ innerHtml = "";
+ }
+ else if (normalIcon && !options.theme) {
+ innerHtml = "";
+ }
+ else {
+ innerHtml = htmlEscape(defaultText);
+ }
+
+ classes = [
+ 'fc-' + buttonName + '-button',
+ tm + '-button',
+ tm + '-state-default'
+ ];
+
+ button = $( // type="button" so that it doesn't submit a form
+ ''
+ )
+ .click(function(ev) {
+ // don't process clicks for disabled buttons
+ if (!button.hasClass(tm + '-state-disabled')) {
+
+ buttonClick(ev);
+
+ // after the click action, if the button becomes the "active" tab, or disabled,
+ // it should never have a hover class, so remove it now.
+ if (
+ button.hasClass(tm + '-state-active') ||
+ button.hasClass(tm + '-state-disabled')
+ ) {
+ button.removeClass(tm + '-state-hover');
+ }
+ }
+ })
+ .mousedown(function() {
+ // the *down* effect (mouse pressed in).
+ // only on buttons that are not the "active" tab, or disabled
+ button
+ .not('.' + tm + '-state-active')
+ .not('.' + tm + '-state-disabled')
+ .addClass(tm + '-state-down');
+ })
+ .mouseup(function() {
+ // undo the *down* effect
+ button.removeClass(tm + '-state-down');
+ })
+ .hover(
+ function() {
+ // the *hover* effect.
+ // only on buttons that are not the "active" tab, or disabled
+ button
+ .not('.' + tm + '-state-active')
+ .not('.' + tm + '-state-disabled')
+ .addClass(tm + '-state-hover');
+ },
+ function() {
+ // undo the *hover* effect
+ button
+ .removeClass(tm + '-state-hover')
+ .removeClass(tm + '-state-down'); // if mouseleave happens before mouseup
+ }
+ );
+
+ groupChildren = groupChildren.add(button);
+ }
+ }
+ });
+
+ if (isOnlyButtons) {
+ groupChildren
+ .first().addClass(tm + '-corner-left').end()
+ .last().addClass(tm + '-corner-right').end();
+ }
+
+ if (groupChildren.length > 1) {
+ groupEl = $('');
+ if (isOnlyButtons) {
+ groupEl.addClass('fc-button-group');
+ }
+ groupEl.append(groupChildren);
+ sectionEl.append(groupEl);
+ }
+ else {
+ sectionEl.append(groupChildren); // 1 or 0 children
+ }
+ });
+ }
+
+ return sectionEl;
+ }
+
+
+ function updateTitle(text) {
+ el.find('h2').text(text);
+ }
+
+
+ function activateButton(buttonName) {
+ el.find('.fc-' + buttonName + '-button')
+ .addClass(tm + '-state-active');
+ }
+
+
+ function deactivateButton(buttonName) {
+ el.find('.fc-' + buttonName + '-button')
+ .removeClass(tm + '-state-active');
+ }
+
+
+ function disableButton(buttonName) {
+ el.find('.fc-' + buttonName + '-button')
+ .attr('disabled', 'disabled')
+ .addClass(tm + '-state-disabled');
+ }
+
+
+ function enableButton(buttonName) {
+ el.find('.fc-' + buttonName + '-button')
+ .removeAttr('disabled')
+ .removeClass(tm + '-state-disabled');
+ }
+
+
+ function getViewsWithButtons() {
+ return viewsWithButtons;
+ }
}
;;
-//BUG: unselect needs to be triggered when events are dragged+dropped
+FC.sourceNormalizers = [];
+FC.sourceFetchers = [];
-function SelectionManager() {
+var ajaxDefaults = {
+ dataType: 'json',
+ cache: false
+};
+
+var eventGUID = 1;
+
+
+function EventManager(options) { // assumed to be a calendar
var t = this;
// exports
- t.select = select;
- t.unselect = unselect;
- t.reportSelection = reportSelection;
- t.daySelectionMousedown = daySelectionMousedown;
+ 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.mutateEvent = mutateEvent;
+ t.normalizeEventRange = normalizeEventRange;
+ t.normalizeEventRangeTimes = normalizeEventRangeTimes;
+ t.ensureVisibleEventRange = ensureVisibleEventRange;
// imports
- var opt = t.opt;
- var trigger = t.trigger;
- var defaultSelectionEnd = t.defaultSelectionEnd;
- var renderSelection = t.renderSelection;
- var clearSelection = t.clearSelection;
+ var reportEvents = t.reportEvents;
// locals
- var selected = false;
+ var stickySource = { events: [] };
+ var sources = [ stickySource ];
+ var rangeStart, rangeEnd;
+ var currentFetchID = 0;
+ var pendingSourceCnt = 0;
+ var cache = []; // holds events that have already been expanded
+ $.each(
+ (options.events ? [ options.events ] : []).concat(options.eventSources || []),
+ function(i, sourceInput) {
+ var source = buildEventSource(sourceInput);
+ if (source) {
+ sources.push(source);
+ }
+ }
+ );
+
+
+
+ /* Fetching
+ -----------------------------------------------------------------------------*/
+
+
+ function isFetchNeeded(start, end) {
+ return !rangeStart || // nothing has been fetched yet?
+ // or, a part of the new range is outside of the old range? (after normalizing)
+ start.clone().stripZone() < rangeStart.clone().stripZone() ||
+ end.clone().stripZone() > rangeEnd.clone().stripZone();
+ }
+
+
+ function fetchEvents(start, end) {
+ rangeStart = start;
+ rangeEnd = end;
+ cache = [];
+ var fetchID = ++currentFetchID;
+ var len = sources.length;
+ pendingSourceCnt = len;
+ for (var i=0; i");
- }
- if (e[0].parentNode != parent[0]) {
- e.appendTo(parent);
- }
- usedOverlays.push(e.css(rect).show());
- return e;
+ return cache; // else, return all
}
+
+
+ /* Event Normalization
+ -----------------------------------------------------------------------------*/
- function clearOverlays() {
- var e;
- while (e = usedOverlays.shift()) {
- unusedOverlays.push(e.hide().unbind());
+
+ // Given a raw object with key/value properties, returns an "abstract" Event object.
+ // An "abstract" event is an event that, if recurring, will not have been expanded yet.
+ // Will return `false` when input is invalid.
+ // `source` is optional
+ function buildEventFromInput(input, source) {
+ var out = {};
+ var start, end;
+ var allDay;
+
+ if (options.eventDataTransform) {
+ input = options.eventDataTransform(input);
+ }
+ if (source && source.eventDataTransform) {
+ input = source.eventDataTransform(input);
}
- }
+ // Copy all properties over to the resulting object.
+ // The special-case properties will be copied over afterwards.
+ $.extend(out, input);
-}
+ if (source) {
+ out.source = source;
+ }
-;;
+ out._id = input._id || (input.id === undefined ? '_fc' + eventGUID++ : input.id + '');
-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;
- var i, r=-1, c=-1;
- for (i=0; i= rows[i][0] && y < rows[i][1]) {
- r = i;
- break;
+ if (input.className) {
+ if (typeof input.className == 'string') {
+ out.className = input.className.split(/\s+/);
+ }
+ else { // assumed to be an array
+ out.className = input.className;
}
}
- for (i=0; i= cols[i][0] && x < cols[i][1]) {
- c = i;
- break;
- }
+ else {
+ out.className = [];
}
- 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 {
- top: rows[row0][0] - origin.top,
- left: cols[col0][0] - origin.left,
- width: cols[col1][1] - cols[col0][0],
- height: rows[row1][1] - rows[row0][0]
- };
- };
-}
+ start = input.start || input.date; // "date" is an alias for "start"
+ end = input.end;
-;;
+ // parse as a time (Duration) if applicable
+ if (isTimeString(start)) {
+ start = moment.duration(start);
+ }
+ if (isTimeString(end)) {
+ end = moment.duration(end);
+ }
-function HoverListener(coordinateGrid) {
+ if (input.dow || moment.isDuration(start) || moment.isDuration(end)) {
+ // the event is "abstract" (recurring) so don't calculate exact start/end dates just yet
+ out.start = start ? moment.duration(start) : null; // will be a Duration or null
+ out.end = end ? moment.duration(end) : null; // will be a Duration or null
+ out._recurring = true; // our internal marker
+ }
+ else {
- var t = this;
- var bindType;
- var change;
- var firstCell;
- var cell;
-
-
- t.start = function(_change, ev, _bindType) {
- change = _change;
- firstCell = cell = null;
- coordinateGrid.build();
- mouse(ev);
- bindType = _bindType || 'mousemove';
- $(document).bind(bindType, mouse);
- };
-
-
- function mouse(ev) {
- _fixUIEvent(ev); // see below
- var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
- if (!newCell != !cell || newCell && (newCell.row != cell.row || newCell.col != cell.col)) {
- if (newCell) {
- if (!firstCell) {
- firstCell = newCell;
+ if (start) {
+ start = t.moment(start);
+ if (!start.isValid()) {
+ return false;
}
- change(newCell, firstCell, newCell.row-firstCell.row, newCell.col-firstCell.col);
- }else{
- change(newCell, firstCell);
}
- cell = newCell;
+
+ if (end) {
+ end = t.moment(end);
+ if (!end.isValid()) {
+ end = null; // let defaults take over
+ }
+ }
+
+ allDay = input.allDay;
+ if (allDay === undefined) { // still undefined? fallback to default
+ allDay = firstDefined(
+ source ? source.allDayDefault : undefined,
+ options.allDayDefault
+ );
+ // still undefined? normalizeEventRange will calculate it
+ }
+
+ assignDatesToEvent(start, end, allDay, out);
+ }
+
+ return out;
+ }
+
+
+ // Normalizes and assigns the given dates to the given partially-formed event object.
+ // NOTE: mutates the given start/end moments. does not make a copy.
+ function assignDatesToEvent(start, end, allDay, event) {
+ event.start = start;
+ event.end = end;
+ event.allDay = allDay;
+ normalizeEventRange(event);
+ backupEventDates(event);
+ }
+
+
+ // Ensures proper values for allDay/start/end. Accepts an Event object, or a plain object with event-ish properties.
+ // NOTE: Will modify the given object.
+ function normalizeEventRange(props) {
+
+ normalizeEventRangeTimes(props);
+
+ if (props.end && !props.end.isAfter(props.start)) {
+ props.end = null;
+ }
+
+ if (!props.end) {
+ if (options.forceEventDuration) {
+ props.end = t.getDefaultEventEnd(props.allDay, props.start);
+ }
+ else {
+ props.end = null;
+ }
}
}
-
-
- t.stop = function() {
- $(document).unbind(bindType, mouse);
- return cell;
+
+
+ // Ensures the allDay property exists and the timeliness of the start/end dates are consistent
+ function normalizeEventRangeTimes(range) {
+ if (range.allDay == null) {
+ range.allDay = !(range.start.hasTime() || (range.end && range.end.hasTime()));
+ }
+
+ if (range.allDay) {
+ range.start.stripTime();
+ if (range.end) {
+ // TODO: consider nextDayThreshold here? If so, will require a lot of testing and adjustment
+ range.end.stripTime();
+ }
+ }
+ else {
+ if (!range.start.hasTime()) {
+ range.start = t.rezoneDate(range.start); // will assign a 00:00 time
+ }
+ if (range.end && !range.end.hasTime()) {
+ range.end = t.rezoneDate(range.end); // will assign a 00:00 time
+ }
+ }
+ }
+
+
+ // If `range` is a proper range with a start and end, returns the original object.
+ // If missing an end, computes a new range with an end, computing it as if it were an event.
+ // TODO: make this a part of the event -> eventRange system
+ function ensureVisibleEventRange(range) {
+ var allDay;
+
+ if (!range.end) {
+
+ allDay = range.allDay; // range might be more event-ish than we think
+ if (allDay == null) {
+ allDay = !range.start.hasTime();
+ }
+
+ range = $.extend({}, range); // make a copy, copying over other misc properties
+ range.end = t.getDefaultEventEnd(allDay, range.start);
+ }
+ return range;
+ }
+
+
+ // If the given event is a recurring event, break it down into an array of individual instances.
+ // If not a recurring event, return an array with the single original event.
+ // If given a falsy input (probably because of a failed buildEventFromInput call), returns an empty array.
+ // HACK: can override the recurring window by providing custom rangeStart/rangeEnd (for businessHours).
+ function expandEvent(abstractEvent, _rangeStart, _rangeEnd) {
+ var events = [];
+ var dowHash;
+ var dow;
+ var i;
+ var date;
+ var startTime, endTime;
+ var start, end;
+ var event;
+
+ _rangeStart = _rangeStart || rangeStart;
+ _rangeEnd = _rangeEnd || rangeEnd;
+
+ if (abstractEvent) {
+ if (abstractEvent._recurring) {
+
+ // make a boolean hash as to whether the event occurs on each day-of-week
+ if ((dow = abstractEvent.dow)) {
+ dowHash = {};
+ for (i = 0; i < dow.length; i++) {
+ dowHash[dow[i]] = true;
+ }
+ }
+
+ // iterate through every day in the current range
+ date = _rangeStart.clone().stripTime(); // holds the date of the current day
+ while (date.isBefore(_rangeEnd)) {
+
+ if (!dowHash || dowHash[date.day()]) { // if everyday, or this particular day-of-week
+
+ startTime = abstractEvent.start; // the stored start and end properties are times (Durations)
+ endTime = abstractEvent.end; // "
+ start = date.clone();
+ end = null;
+
+ if (startTime) {
+ start = start.time(startTime);
+ }
+ if (endTime) {
+ end = date.clone().time(endTime);
+ }
+
+ event = $.extend({}, abstractEvent); // make a copy of the original
+ assignDatesToEvent(
+ start, end,
+ !startTime && !endTime, // allDay?
+ event
+ );
+ events.push(event);
+ }
+
+ date.add(1, 'days');
+ }
+ }
+ else {
+ events.push(abstractEvent); // return the original event. will be a one-item array
+ }
+ }
+
+ return events;
+ }
+
+
+
+ /* Event Modification Math
+ -----------------------------------------------------------------------------------------*/
+
+
+ // Modifies an event and all related events by applying the given properties.
+ // Special date-diffing logic is used for manipulation of dates.
+ // If `props` does not contain start/end dates, the updated values are assumed to be the event's current start/end.
+ // All date comparisons are done against the event's pristine _start and _end dates.
+ // Returns an object with delta information and a function to undo all operations.
+ // For making computations in a granularity greater than day/time, specify largeUnit.
+ // NOTE: The given `newProps` might be mutated for normalization purposes.
+ function mutateEvent(event, newProps, largeUnit) {
+ var miscProps = {};
+ var oldProps;
+ var clearEnd;
+ var startDelta;
+ var endDelta;
+ var durationDelta;
+ var undoFunc;
+
+ // diffs the dates in the appropriate way, returning a duration
+ function diffDates(date1, date0) { // date1 - date0
+ if (largeUnit) {
+ return diffByUnit(date1, date0, largeUnit);
+ }
+ else if (newProps.allDay) {
+ return diffDay(date1, date0);
+ }
+ else {
+ return diffDayTime(date1, date0);
+ }
+ }
+
+ newProps = newProps || {};
+
+ // normalize new date-related properties
+ if (!newProps.start) {
+ newProps.start = event.start.clone();
+ }
+ if (newProps.end === undefined) {
+ newProps.end = event.end ? event.end.clone() : null;
+ }
+ if (newProps.allDay == null) { // is null or undefined?
+ newProps.allDay = event.allDay;
+ }
+ normalizeEventRange(newProps);
+
+ // create normalized versions of the original props to compare against
+ // need a real end value, for diffing
+ oldProps = {
+ start: event._start.clone(),
+ end: event._end ? event._end.clone() : t.getDefaultEventEnd(event._allDay, event._start),
+ allDay: newProps.allDay // normalize the dates in the same regard as the new properties
+ };
+ normalizeEventRange(oldProps);
+
+ // need to clear the end date if explicitly changed to null
+ clearEnd = event._end !== null && newProps.end === null;
+
+ // compute the delta for moving the start date
+ startDelta = diffDates(newProps.start, oldProps.start);
+
+ // compute the delta for moving the end date
+ if (newProps.end) {
+ endDelta = diffDates(newProps.end, oldProps.end);
+ durationDelta = endDelta.subtract(startDelta);
+ }
+ else {
+ durationDelta = null;
+ }
+
+ // gather all non-date-related properties
+ $.each(newProps, function(name, val) {
+ if (isMiscEventPropName(name)) {
+ if (val !== undefined) {
+ miscProps[name] = val;
+ }
+ }
+ });
+
+ // apply the operations to the event and all related events
+ undoFunc = mutateEvents(
+ clientEvents(event._id), // get events with this ID
+ clearEnd,
+ newProps.allDay,
+ startDelta,
+ durationDelta,
+ miscProps
+ );
+
+ return {
+ dateDelta: startDelta,
+ durationDelta: durationDelta,
+ undo: undoFunc
+ };
+ }
+
+
+ // Modifies an array of events in the following ways (operations are in order):
+ // - clear the event's `end`
+ // - convert the event to allDay
+ // - add `dateDelta` to the start and end
+ // - add `durationDelta` to the event's duration
+ // - assign `miscProps` to the event
+ //
+ // Returns a function that can be called to undo all the operations.
+ //
+ // TODO: don't use so many closures. possible memory issues when lots of events with same ID.
+ //
+ function mutateEvents(events, clearEnd, allDay, dateDelta, durationDelta, miscProps) {
+ var isAmbigTimezone = t.getIsAmbigTimezone();
+ var undoFunctions = [];
+
+ // normalize zero-length deltas to be null
+ if (dateDelta && !dateDelta.valueOf()) { dateDelta = null; }
+ if (durationDelta && !durationDelta.valueOf()) { durationDelta = null; }
+
+ $.each(events, function(i, event) {
+ var oldProps;
+ var newProps;
+
+ // build an object holding all the old values, both date-related and misc.
+ // for the undo function.
+ oldProps = {
+ start: event.start.clone(),
+ end: event.end ? event.end.clone() : null,
+ allDay: event.allDay
+ };
+ $.each(miscProps, function(name) {
+ oldProps[name] = event[name];
+ });
+
+ // new date-related properties. work off the original date snapshot.
+ // ok to use references because they will be thrown away when backupEventDates is called.
+ newProps = {
+ start: event._start,
+ end: event._end,
+ allDay: allDay // normalize the dates in the same regard as the new properties
+ };
+ normalizeEventRange(newProps); // massages start/end/allDay
+
+ // strip or ensure the end date
+ if (clearEnd) {
+ newProps.end = null;
+ }
+ else if (durationDelta && !newProps.end) { // the duration translation requires an end date
+ newProps.end = t.getDefaultEventEnd(newProps.allDay, newProps.start);
+ }
+
+ if (dateDelta) {
+ newProps.start.add(dateDelta);
+ if (newProps.end) {
+ newProps.end.add(dateDelta);
+ }
+ }
+
+ if (durationDelta) {
+ newProps.end.add(durationDelta); // end already ensured above
+ }
+
+ // if the dates have changed, and we know it is impossible to recompute the
+ // timezone offsets, strip the zone.
+ if (
+ isAmbigTimezone &&
+ !newProps.allDay &&
+ (dateDelta || durationDelta)
+ ) {
+ newProps.start.stripZone();
+ if (newProps.end) {
+ newProps.end.stripZone();
+ }
+ }
+
+ $.extend(event, miscProps, newProps); // copy over misc props, then date-related props
+ backupEventDates(event); // regenerate internal _start/_end/_allDay
+
+ undoFunctions.push(function() {
+ $.extend(event, oldProps);
+ backupEventDates(event); // regenerate internal _start/_end/_allDay
+ });
+ });
+
+ return function() {
+ for (var i = 0; i < undoFunctions.length; i++) {
+ undoFunctions[i]();
+ }
+ };
+ }
+
+
+ /* Business Hours
+ -----------------------------------------------------------------------------------------*/
+
+ t.getBusinessHoursEvents = getBusinessHoursEvents;
+
+
+ // Returns an array of events as to when the business hours occur in the given view.
+ // Abuse of our event system :(
+ function getBusinessHoursEvents(wholeDay) {
+ var optionVal = options.businessHours;
+ var defaultVal = {
+ className: 'fc-nonbusiness',
+ start: '09:00',
+ end: '17:00',
+ dow: [ 1, 2, 3, 4, 5 ], // monday - friday
+ rendering: 'inverse-background'
+ };
+ var view = t.getView();
+ var eventInput;
+
+ if (optionVal) { // `true` (which means "use the defaults") or an override object
+ eventInput = $.extend(
+ {}, // copy to a new object in either case
+ defaultVal,
+ typeof optionVal === 'object' ? optionVal : {} // override the defaults
+ );
+ }
+
+ if (eventInput) {
+
+ // if a whole-day series is requested, clear the start/end times
+ if (wholeDay) {
+ eventInput.start = null;
+ eventInput.end = null;
+ }
+
+ return expandEvent(
+ buildEventFromInput(eventInput),
+ view.start,
+ view.end
+ );
+ }
+
+ return [];
+ }
+
+
+ /* Overlapping / Constraining
+ -----------------------------------------------------------------------------------------*/
+
+ t.isEventRangeAllowed = isEventRangeAllowed;
+ t.isSelectionRangeAllowed = isSelectionRangeAllowed;
+ t.isExternalDropRangeAllowed = isExternalDropRangeAllowed;
+
+
+ function isEventRangeAllowed(range, event) {
+ var source = event.source || {};
+ var constraint = firstDefined(
+ event.constraint,
+ source.constraint,
+ options.eventConstraint
+ );
+ var overlap = firstDefined(
+ event.overlap,
+ source.overlap,
+ options.eventOverlap
+ );
+
+ range = ensureVisibleEventRange(range); // ensure a proper range with an end for isRangeAllowed
+
+ return isRangeAllowed(range, constraint, overlap, event);
+ }
+
+
+ function isSelectionRangeAllowed(range) {
+ return isRangeAllowed(range, options.selectConstraint, options.selectOverlap);
+ }
+
+
+ // when `eventProps` is defined, consider this an event.
+ // `eventProps` can contain misc non-date-related info about the event.
+ function isExternalDropRangeAllowed(range, eventProps) {
+ var eventInput;
+ var event;
+
+ // note: very similar logic is in View's reportExternalDrop
+ if (eventProps) {
+ eventInput = $.extend({}, eventProps, range);
+ event = expandEvent(buildEventFromInput(eventInput))[0];
+ }
+
+ if (event) {
+ return isEventRangeAllowed(range, event);
+ }
+ else { // treat it as a selection
+
+ range = ensureVisibleEventRange(range); // ensure a proper range with an end for isSelectionRangeAllowed
+
+ return isSelectionRangeAllowed(range);
+ }
+ }
+
+
+ // Returns true if the given range (caused by an event drop/resize or a selection) is allowed to exist
+ // according to the constraint/overlap settings.
+ // `event` is not required if checking a selection.
+ function isRangeAllowed(range, constraint, overlap, event) {
+ var constraintEvents;
+ var anyContainment;
+ var peerEvents;
+ var i, peerEvent;
+ var peerOverlap;
+
+ // normalize. fyi, we're normalizing in too many places :(
+ range = $.extend({}, range); // copy all properties in case there are misc non-date properties
+ range.start = range.start.clone().stripZone();
+ range.end = range.end.clone().stripZone();
+
+ // the range must be fully contained by at least one of produced constraint events
+ if (constraint != null) {
+
+ // not treated as an event! intermediate data structure
+ // TODO: use ranges in the future
+ constraintEvents = constraintToEvents(constraint);
+
+ anyContainment = false;
+ for (i = 0; i < constraintEvents.length; i++) {
+ if (eventContainsRange(constraintEvents[i], range)) {
+ anyContainment = true;
+ break;
+ }
+ }
+
+ if (!anyContainment) {
+ return false;
+ }
+ }
+
+ peerEvents = t.getPeerEvents(event, range);
+
+ for (i = 0; i < peerEvents.length; i++) {
+ peerEvent = peerEvents[i];
+
+ // there needs to be an actual intersection before disallowing anything
+ if (eventIntersectsRange(peerEvent, range)) {
+
+ // evaluate overlap for the given range and short-circuit if necessary
+ if (overlap === false) {
+ return false;
+ }
+ // if the event's overlap is a test function, pass the peer event in question as the first param
+ else if (typeof overlap === 'function' && !overlap(peerEvent, event)) {
+ return false;
+ }
+
+ // if we are computing if the given range is allowable for an event, consider the other event's
+ // EventObject-specific or Source-specific `overlap` property
+ if (event) {
+ peerOverlap = firstDefined(
+ peerEvent.overlap,
+ (peerEvent.source || {}).overlap
+ // we already considered the global `eventOverlap`
+ );
+ if (peerOverlap === false) {
+ return false;
+ }
+ // if the peer event's overlap is a test function, pass the subject event as the first param
+ if (typeof peerOverlap === 'function' && !peerOverlap(event, peerEvent)) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+
+ // Given an event input from the API, produces an array of event objects. Possible event inputs:
+ // 'businessHours'
+ // An event ID (number or string)
+ // An object with specific start/end dates or a recurring event (like what businessHours accepts)
+ function constraintToEvents(constraintInput) {
+
+ if (constraintInput === 'businessHours') {
+ return getBusinessHoursEvents();
+ }
+
+ if (typeof constraintInput === 'object') {
+ return expandEvent(buildEventFromInput(constraintInput));
+ }
+
+ return clientEvents(constraintInput); // probably an ID
+ }
+
+
+ // Does the event's date range fully contain the given range?
+ // start/end already assumed to have stripped zones :(
+ function eventContainsRange(event, range) {
+ var eventStart = event.start.clone().stripZone();
+ var eventEnd = t.getEventEnd(event).stripZone();
+
+ return range.start >= eventStart && range.end <= eventEnd;
+ }
+
+
+ // Does the event's date range intersect with the given range?
+ // start/end already assumed to have stripped zones :(
+ function eventIntersectsRange(event, range) {
+ var eventStart = event.start.clone().stripZone();
+ var eventEnd = t.getEventEnd(event).stripZone();
+
+ return range.start < eventEnd && range.end > eventStart;
+ }
+
+
+ t.getEventCache = function() {
+ return cache;
};
-
-
+
}
+// Returns a list of events that the given event should be compared against when being considered for a move to
+// the specified range. Attached to the Calendar's prototype because EventManager is a mixin for a Calendar.
+Calendar.prototype.getPeerEvents = function(event, range) {
+ var cache = this.getEventCache();
+ var peerEvents = [];
+ var i, otherEvent;
-// this fix was only necessary for jQuery UI 1.8.16 (and jQuery 1.7 or 1.7.1)
-// upgrading to jQuery UI 1.8.17 (and using either jQuery 1.7 or 1.7.1) fixed the problem
-// but keep this in here for 1.8.16 users
-// and maybe remove it down the line
-
-function _fixUIEvent(event) { // for issue 1168
- if (event.pageX === undefined) {
- event.pageX = event.originalEvent.pageX;
- event.pageY = event.originalEvent.pageY;
+ for (i = 0; i < cache.length; i++) {
+ otherEvent = cache[i];
+ if (
+ !event ||
+ event._id !== otherEvent._id // don't compare the event to itself or other related [repeating] events
+ ) {
+ peerEvents.push(otherEvent);
+ }
}
-}
-;;
-function HorizontalPositionCache(getElement) {
+ return peerEvents;
+};
- var t = this,
- 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 = {};
- };
-
+
+// updates the "backup" properties, which are preserved in order to compute diffs later on.
+function backupEventDates(event) {
+ event._allDay = event.allDay;
+ event._start = event.start.clone();
+ event._end = event.end ? event.end.clone() : null;
}
;;
-})(jQuery);
\ No newline at end of file
+/* An abstract class for the "basic" views, as well as month view. Renders one or more rows of day cells.
+----------------------------------------------------------------------------------------------------------------------*/
+// It is a manager for a DayGrid subcomponent, which does most of the heavy lifting.
+// It is responsible for managing width/height.
+
+var BasicView = FC.BasicView = View.extend({
+
+ dayGridClass: DayGrid, // class the dayGrid will be instantiated from (overridable by subclasses)
+ dayGrid: null, // the main subcomponent that does most of the heavy lifting
+
+ dayNumbersVisible: false, // display day numbers on each day cell?
+ weekNumbersVisible: false, // display week numbers along the side?
+
+ weekNumberWidth: null, // width of all the week-number cells running down the side
+
+ headContainerEl: null, // div that hold's the dayGrid's rendered date header
+ headRowEl: null, // the fake row element of the day-of-week header
+
+
+ initialize: function() {
+ this.dayGrid = this.instantiateDayGrid();
+ },
+
+
+ // Generates the DayGrid object this view needs. Draws from this.dayGridClass
+ instantiateDayGrid: function() {
+ // generate a subclass on the fly with BasicView-specific behavior
+ // TODO: cache this subclass
+ var subclass = this.dayGridClass.extend(basicDayGridMethods);
+
+ return new subclass(this);
+ },
+
+
+ // Sets the display range and computes all necessary dates
+ setRange: function(range) {
+ View.prototype.setRange.call(this, range); // call the super-method
+
+ this.dayGrid.breakOnWeeks = /year|month|week/.test(this.intervalUnit); // do before setRange
+ this.dayGrid.setRange(range);
+ },
+
+
+ // Compute the value to feed into setRange. Overrides superclass.
+ computeRange: function(date) {
+ var range = View.prototype.computeRange.call(this, date); // get value from the super-method
+
+ // year and month views should be aligned with weeks. this is already done for week
+ if (/year|month/.test(range.intervalUnit)) {
+ range.start.startOf('week');
+ range.start = this.skipHiddenDays(range.start);
+
+ // make end-of-week if not already
+ if (range.end.weekday()) {
+ range.end.add(1, 'week').startOf('week');
+ range.end = this.skipHiddenDays(range.end, -1, true); // exclusively move backwards
+ }
+ }
+
+ return range;
+ },
+
+
+ // Renders the view into `this.el`, which should already be assigned
+ renderDates: function() {
+
+ this.dayNumbersVisible = this.dayGrid.rowCnt > 1; // TODO: make grid responsible
+ this.weekNumbersVisible = this.opt('weekNumbers');
+ this.dayGrid.numbersVisible = this.dayNumbersVisible || this.weekNumbersVisible;
+
+ this.el.addClass('fc-basic-view').html(this.renderSkeletonHtml());
+ this.renderHead();
+
+ this.scrollerEl = this.el.find('.fc-day-grid-container');
+
+ this.dayGrid.setElement(this.el.find('.fc-day-grid'));
+ this.dayGrid.renderDates(this.hasRigidRows());
+ },
+
+
+ // render the day-of-week headers
+ renderHead: function() {
+ this.headContainerEl =
+ this.el.find('.fc-head-container')
+ .html(this.dayGrid.renderHeadHtml());
+ this.headRowEl = this.headContainerEl.find('.fc-row');
+ },
+
+
+ // Unrenders the content of the view. Since we haven't separated skeleton rendering from date rendering,
+ // always completely kill the dayGrid's rendering.
+ unrenderDates: function() {
+ this.dayGrid.unrenderDates();
+ this.dayGrid.removeElement();
+ },
+
+
+ renderBusinessHours: function() {
+ this.dayGrid.renderBusinessHours();
+ },
+
+
+ // Builds the HTML skeleton for the view.
+ // The day-grid component will render inside of a container defined by this HTML.
+ renderSkeletonHtml: function() {
+ return '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' ' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' | ' +
+ ' ' +
+ '' +
+ ' ';
+ },
+
+
+ // Generates an HTML attribute string for setting the width of the week number column, if it is known
+ weekNumberStyleAttr: function() {
+ if (this.weekNumberWidth !== null) {
+ return 'style="width:' + this.weekNumberWidth + 'px"';
+ }
+ return '';
+ },
+
+
+ // Determines whether each row should have a constant height
+ hasRigidRows: function() {
+ var eventLimit = this.opt('eventLimit');
+ return eventLimit && typeof eventLimit !== 'number';
+ },
+
+
+ /* Dimensions
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Refreshes the horizontal dimensions of the view
+ updateWidth: function() {
+ if (this.weekNumbersVisible) {
+ // Make sure all week number cells running down the side have the same width.
+ // Record the width for cells created later.
+ this.weekNumberWidth = matchCellWidths(
+ this.el.find('.fc-week-number')
+ );
+ }
+ },
+
+
+ // Adjusts the vertical dimensions of the view to the specified values
+ setHeight: function(totalHeight, isAuto) {
+ var eventLimit = this.opt('eventLimit');
+ var scrollerHeight;
+
+ // reset all heights to be natural
+ unsetScroller(this.scrollerEl);
+ uncompensateScroll(this.headRowEl);
+
+ this.dayGrid.removeSegPopover(); // kill the "more" popover if displayed
+
+ // is the event limit a constant level number?
+ if (eventLimit && typeof eventLimit === 'number') {
+ this.dayGrid.limitRows(eventLimit); // limit the levels first so the height can redistribute after
+ }
+
+ scrollerHeight = this.computeScrollerHeight(totalHeight);
+ this.setGridHeight(scrollerHeight, isAuto);
+
+ // is the event limit dynamically calculated?
+ if (eventLimit && typeof eventLimit !== 'number') {
+ this.dayGrid.limitRows(eventLimit); // limit the levels after the grid's row heights have been set
+ }
+
+ if (!isAuto && setPotentialScroller(this.scrollerEl, scrollerHeight)) { // using scrollbars?
+
+ compensateScroll(this.headRowEl, getScrollbarWidths(this.scrollerEl));
+
+ // doing the scrollbar compensation might have created text overflow which created more height. redo
+ scrollerHeight = this.computeScrollerHeight(totalHeight);
+ this.scrollerEl.height(scrollerHeight);
+ }
+ },
+
+
+ // Sets the height of just the DayGrid component in this view
+ setGridHeight: function(height, isAuto) {
+ if (isAuto) {
+ undistributeHeight(this.dayGrid.rowEls); // let the rows be their natural height with no expanding
+ }
+ else {
+ distributeHeight(this.dayGrid.rowEls, height, true); // true = compensate for height-hogging rows
+ }
+ },
+
+
+ /* Hit Areas
+ ------------------------------------------------------------------------------------------------------------------*/
+ // forward all hit-related method calls to dayGrid
+
+
+ prepareHits: function() {
+ this.dayGrid.prepareHits();
+ },
+
+
+ releaseHits: function() {
+ this.dayGrid.releaseHits();
+ },
+
+
+ queryHit: function(left, top) {
+ return this.dayGrid.queryHit(left, top);
+ },
+
+
+ getHitSpan: function(hit) {
+ return this.dayGrid.getHitSpan(hit);
+ },
+
+
+ getHitEl: function(hit) {
+ return this.dayGrid.getHitEl(hit);
+ },
+
+
+ /* Events
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders the given events onto the view and populates the segments array
+ renderEvents: function(events) {
+ this.dayGrid.renderEvents(events);
+
+ this.updateHeight(); // must compensate for events that overflow the row
+ },
+
+
+ // Retrieves all segment objects that are rendered in the view
+ getEventSegs: function() {
+ return this.dayGrid.getEventSegs();
+ },
+
+
+ // Unrenders all event elements and clears internal segment data
+ unrenderEvents: function() {
+ this.dayGrid.unrenderEvents();
+
+ // we DON'T need to call updateHeight() because:
+ // A) a renderEvents() call always happens after this, which will eventually call updateHeight()
+ // B) in IE8, this causes a flash whenever events are rerendered
+ },
+
+
+ /* Dragging (for both events and external elements)
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // A returned value of `true` signals that a mock "helper" event has been rendered.
+ renderDrag: function(dropLocation, seg) {
+ return this.dayGrid.renderDrag(dropLocation, seg);
+ },
+
+
+ unrenderDrag: function() {
+ this.dayGrid.unrenderDrag();
+ },
+
+
+ /* Selection
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a visual indication of a selection
+ renderSelection: function(range) {
+ this.dayGrid.renderSelection(range);
+ },
+
+
+ // Unrenders a visual indications of a selection
+ unrenderSelection: function() {
+ this.dayGrid.unrenderSelection();
+ }
+
+});
+
+
+// Methods that will customize the rendering behavior of the BasicView's dayGrid
+var basicDayGridMethods = {
+
+
+ // Generates the HTML that will go before the day-of week header cells
+ renderHeadIntroHtml: function() {
+ var view = this.view;
+
+ if (view.weekNumbersVisible) {
+ return '' +
+ '';
+ }
+
+ return '';
+ },
+
+
+ // Generates the HTML that will go before content-skeleton cells that display the day/week numbers
+ renderNumberIntroHtml: function(row) {
+ var view = this.view;
+
+ if (view.weekNumbersVisible) {
+ return '' +
+ '' +
+ '' + // needed for matchCellWidths
+ this.getCellDate(row, 0).format('w') +
+ '' +
+ ' | ';
+ }
+
+ return '';
+ },
+
+
+ // Generates the HTML that goes before the day bg cells for each day-row
+ renderBgIntroHtml: function() {
+ var view = this.view;
+
+ if (view.weekNumbersVisible) {
+ return ' | ';
+ }
+
+ return '';
+ },
+
+
+ // Generates the HTML that goes before every other type of row generated by DayGrid.
+ // Affects helper-skeleton and highlight-skeleton rows.
+ renderIntroHtml: function() {
+ var view = this.view;
+
+ if (view.weekNumbersVisible) {
+ return ' | ';
+ }
+
+ return '';
+ }
+
+};
+
+;;
+
+/* A month view with day cells running in rows (one-per-week) and columns
+----------------------------------------------------------------------------------------------------------------------*/
+
+var MonthView = FC.MonthView = BasicView.extend({
+
+ // Produces information about what range to display
+ computeRange: function(date) {
+ var range = BasicView.prototype.computeRange.call(this, date); // get value from super-method
+ var rowCnt;
+
+ // ensure 6 weeks
+ if (this.isFixedWeeks()) {
+ rowCnt = Math.ceil(range.end.diff(range.start, 'weeks', true)); // could be partial weeks due to hiddenDays
+ range.end.add(6 - rowCnt, 'weeks');
+ }
+
+ return range;
+ },
+
+
+ // Overrides the default BasicView behavior to have special multi-week auto-height logic
+ setGridHeight: function(height, isAuto) {
+
+ isAuto = isAuto || this.opt('weekMode') === 'variable'; // LEGACY: weekMode is deprecated
+
+ // if auto, make the height of each row the height that it would be if there were 6 weeks
+ if (isAuto) {
+ height *= this.rowCnt / 6;
+ }
+
+ distributeHeight(this.dayGrid.rowEls, height, !isAuto); // if auto, don't compensate for height-hogging rows
+ },
+
+
+ isFixedWeeks: function() {
+ var weekMode = this.opt('weekMode'); // LEGACY: weekMode is deprecated
+ if (weekMode) {
+ return weekMode === 'fixed'; // if any other type of weekMode, assume NOT fixed
+ }
+
+ return this.opt('fixedWeekCount');
+ }
+
+});
+
+;;
+
+fcViews.basic = {
+ 'class': BasicView
+};
+
+fcViews.basicDay = {
+ type: 'basic',
+ duration: { days: 1 }
+};
+
+fcViews.basicWeek = {
+ type: 'basic',
+ duration: { weeks: 1 }
+};
+
+fcViews.month = {
+ 'class': MonthView,
+ duration: { months: 1 }, // important for prev/next
+ defaults: {
+ fixedWeekCount: true
+ }
+};
+;;
+
+/* An abstract class for all agenda-related views. Displays one more columns with time slots running vertically.
+----------------------------------------------------------------------------------------------------------------------*/
+// Is a manager for the TimeGrid subcomponent and possibly the DayGrid subcomponent (if allDaySlot is on).
+// Responsible for managing width/height.
+
+var AgendaView = FC.AgendaView = View.extend({
+
+ timeGridClass: TimeGrid, // class used to instantiate the timeGrid. subclasses can override
+ timeGrid: null, // the main time-grid subcomponent of this view
+
+ dayGridClass: DayGrid, // class used to instantiate the dayGrid. subclasses can override
+ dayGrid: null, // the "all-day" subcomponent. if all-day is turned off, this will be null
+
+ axisWidth: null, // the width of the time axis running down the side
+
+ headContainerEl: null, // div that hold's the timeGrid's rendered date header
+ noScrollRowEls: null, // set of fake row elements that must compensate when scrollerEl has scrollbars
+
+ // when the time-grid isn't tall enough to occupy the given height, we render an underneath
+ bottomRuleEl: null,
+ bottomRuleHeight: null,
+
+
+ initialize: function() {
+ this.timeGrid = this.instantiateTimeGrid();
+
+ if (this.opt('allDaySlot')) { // should we display the "all-day" area?
+ this.dayGrid = this.instantiateDayGrid(); // the all-day subcomponent of this view
+ }
+ },
+
+
+ // Instantiates the TimeGrid object this view needs. Draws from this.timeGridClass
+ instantiateTimeGrid: function() {
+ var subclass = this.timeGridClass.extend(agendaTimeGridMethods);
+
+ return new subclass(this);
+ },
+
+
+ // Instantiates the DayGrid object this view might need. Draws from this.dayGridClass
+ instantiateDayGrid: function() {
+ var subclass = this.dayGridClass.extend(agendaDayGridMethods);
+
+ return new subclass(this);
+ },
+
+
+ /* Rendering
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Sets the display range and computes all necessary dates
+ setRange: function(range) {
+ View.prototype.setRange.call(this, range); // call the super-method
+
+ this.timeGrid.setRange(range);
+ if (this.dayGrid) {
+ this.dayGrid.setRange(range);
+ }
+ },
+
+
+ // Renders the view into `this.el`, which has already been assigned
+ renderDates: function() {
+
+ this.el.addClass('fc-agenda-view').html(this.renderSkeletonHtml());
+ this.renderHead();
+
+ // the element that wraps the time-grid that will probably scroll
+ this.scrollerEl = this.el.find('.fc-time-grid-container');
+
+ this.timeGrid.setElement(this.el.find('.fc-time-grid'));
+ this.timeGrid.renderDates();
+
+ // the that sometimes displays under the time-grid
+ this.bottomRuleEl = $('')
+ .appendTo(this.timeGrid.el); // inject it into the time-grid
+
+ if (this.dayGrid) {
+ this.dayGrid.setElement(this.el.find('.fc-day-grid'));
+ this.dayGrid.renderDates();
+
+ // have the day-grid extend it's coordinate area over the dividing the two grids
+ this.dayGrid.bottomCoordPadding = this.dayGrid.el.next('hr').outerHeight();
+ }
+
+ this.noScrollRowEls = this.el.find('.fc-row:not(.fc-scroller *)'); // fake rows not within the scroller
+ },
+
+
+ // render the day-of-week headers
+ renderHead: function() {
+ this.headContainerEl =
+ this.el.find('.fc-head-container')
+ .html(this.timeGrid.renderHeadHtml());
+ },
+
+
+ // Unrenders the content of the view. Since we haven't separated skeleton rendering from date rendering,
+ // always completely kill each grid's rendering.
+ unrenderDates: function() {
+ this.timeGrid.unrenderDates();
+ this.timeGrid.removeElement();
+
+ if (this.dayGrid) {
+ this.dayGrid.unrenderDates();
+ this.dayGrid.removeElement();
+ }
+ },
+
+
+ renderBusinessHours: function() {
+ this.timeGrid.renderBusinessHours();
+
+ if (this.dayGrid) {
+ this.dayGrid.renderBusinessHours();
+ }
+ },
+
+
+ // Builds the HTML skeleton for the view.
+ // The day-grid and time-grid components will render inside containers defined by this HTML.
+ renderSkeletonHtml: function() {
+ return '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ ' ' +
+ '' +
+ '' +
+ '' +
+ '' +
+ (this.dayGrid ?
+ '' +
+ '' :
+ ''
+ ) +
+ '' +
+ ' | ' +
+ ' ' +
+ '' +
+ ' ';
+ },
+
+
+ // Generates an HTML attribute string for setting the width of the axis, if it is known
+ axisStyleAttr: function() {
+ if (this.axisWidth !== null) {
+ return 'style="width:' + this.axisWidth + 'px"';
+ }
+ return '';
+ },
+
+
+ /* Dimensions
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ updateSize: function(isResize) {
+ this.timeGrid.updateSize(isResize);
+
+ View.prototype.updateSize.call(this, isResize); // call the super-method
+ },
+
+
+ // Refreshes the horizontal dimensions of the view
+ updateWidth: function() {
+ // make all axis cells line up, and record the width so newly created axis cells will have it
+ this.axisWidth = matchCellWidths(this.el.find('.fc-axis'));
+ },
+
+
+ // Adjusts the vertical dimensions of the view to the specified values
+ setHeight: function(totalHeight, isAuto) {
+ var eventLimit;
+ var scrollerHeight;
+
+ if (this.bottomRuleHeight === null) {
+ // calculate the height of the rule the very first time
+ this.bottomRuleHeight = this.bottomRuleEl.outerHeight();
+ }
+ this.bottomRuleEl.hide(); // .show() will be called later if this is necessary
+
+ // reset all dimensions back to the original state
+ this.scrollerEl.css('overflow', '');
+ unsetScroller(this.scrollerEl);
+ uncompensateScroll(this.noScrollRowEls);
+
+ // limit number of events in the all-day area
+ if (this.dayGrid) {
+ this.dayGrid.removeSegPopover(); // kill the "more" popover if displayed
+
+ eventLimit = this.opt('eventLimit');
+ if (eventLimit && typeof eventLimit !== 'number') {
+ eventLimit = AGENDA_ALL_DAY_EVENT_LIMIT; // make sure "auto" goes to a real number
+ }
+ if (eventLimit) {
+ this.dayGrid.limitRows(eventLimit);
+ }
+ }
+
+ if (!isAuto) { // should we force dimensions of the scroll container, or let the contents be natural height?
+
+ scrollerHeight = this.computeScrollerHeight(totalHeight);
+ if (setPotentialScroller(this.scrollerEl, scrollerHeight)) { // using scrollbars?
+
+ // make the all-day and header rows lines up
+ compensateScroll(this.noScrollRowEls, getScrollbarWidths(this.scrollerEl));
+
+ // the scrollbar compensation might have changed text flow, which might affect height, so recalculate
+ // and reapply the desired height to the scroller.
+ scrollerHeight = this.computeScrollerHeight(totalHeight);
+ this.scrollerEl.height(scrollerHeight);
+ }
+ else { // no scrollbars
+ // still, force a height and display the bottom rule (marks the end of day)
+ this.scrollerEl.height(scrollerHeight).css('overflow', 'hidden'); // in case goes outside
+ this.bottomRuleEl.show();
+ }
+ }
+ },
+
+
+ // Computes the initial pre-configured scroll state prior to allowing the user to change it
+ computeInitialScroll: function() {
+ var scrollTime = moment.duration(this.opt('scrollTime'));
+ var top = this.timeGrid.computeTimeTop(scrollTime);
+
+ // zoom can give weird floating-point values. rather scroll a little bit further
+ top = Math.ceil(top);
+
+ if (top) {
+ top++; // to overcome top border that slots beyond the first have. looks better
+ }
+
+ return top;
+ },
+
+
+ /* Hit Areas
+ ------------------------------------------------------------------------------------------------------------------*/
+ // forward all hit-related method calls to the grids (dayGrid might not be defined)
+
+
+ prepareHits: function() {
+ this.timeGrid.prepareHits();
+ if (this.dayGrid) {
+ this.dayGrid.prepareHits();
+ }
+ },
+
+
+ releaseHits: function() {
+ this.timeGrid.releaseHits();
+ if (this.dayGrid) {
+ this.dayGrid.releaseHits();
+ }
+ },
+
+
+ queryHit: function(left, top) {
+ var hit = this.timeGrid.queryHit(left, top);
+
+ if (!hit && this.dayGrid) {
+ hit = this.dayGrid.queryHit(left, top);
+ }
+
+ return hit;
+ },
+
+
+ getHitSpan: function(hit) {
+ // TODO: hit.component is set as a hack to identify where the hit came from
+ return hit.component.getHitSpan(hit);
+ },
+
+
+ getHitEl: function(hit) {
+ // TODO: hit.component is set as a hack to identify where the hit came from
+ return hit.component.getHitEl(hit);
+ },
+
+
+ /* Events
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders events onto the view and populates the View's segment array
+ renderEvents: function(events) {
+ var dayEvents = [];
+ var timedEvents = [];
+ var daySegs = [];
+ var timedSegs;
+ var i;
+
+ // separate the events into all-day and timed
+ for (i = 0; i < events.length; i++) {
+ if (events[i].allDay) {
+ dayEvents.push(events[i]);
+ }
+ else {
+ timedEvents.push(events[i]);
+ }
+ }
+
+ // render the events in the subcomponents
+ timedSegs = this.timeGrid.renderEvents(timedEvents);
+ if (this.dayGrid) {
+ daySegs = this.dayGrid.renderEvents(dayEvents);
+ }
+
+ // the all-day area is flexible and might have a lot of events, so shift the height
+ this.updateHeight();
+ },
+
+
+ // Retrieves all segment objects that are rendered in the view
+ getEventSegs: function() {
+ return this.timeGrid.getEventSegs().concat(
+ this.dayGrid ? this.dayGrid.getEventSegs() : []
+ );
+ },
+
+
+ // Unrenders all event elements and clears internal segment data
+ unrenderEvents: function() {
+
+ // unrender the events in the subcomponents
+ this.timeGrid.unrenderEvents();
+ if (this.dayGrid) {
+ this.dayGrid.unrenderEvents();
+ }
+
+ // we DON'T need to call updateHeight() because:
+ // A) a renderEvents() call always happens after this, which will eventually call updateHeight()
+ // B) in IE8, this causes a flash whenever events are rerendered
+ },
+
+
+ /* Dragging (for events and external elements)
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // A returned value of `true` signals that a mock "helper" event has been rendered.
+ renderDrag: function(dropLocation, seg) {
+ if (dropLocation.start.hasTime()) {
+ return this.timeGrid.renderDrag(dropLocation, seg);
+ }
+ else if (this.dayGrid) {
+ return this.dayGrid.renderDrag(dropLocation, seg);
+ }
+ },
+
+
+ unrenderDrag: function() {
+ this.timeGrid.unrenderDrag();
+ if (this.dayGrid) {
+ this.dayGrid.unrenderDrag();
+ }
+ },
+
+
+ /* Selection
+ ------------------------------------------------------------------------------------------------------------------*/
+
+
+ // Renders a visual indication of a selection
+ renderSelection: function(range) {
+ if (range.start.hasTime() || range.end.hasTime()) {
+ this.timeGrid.renderSelection(range);
+ }
+ else if (this.dayGrid) {
+ this.dayGrid.renderSelection(range);
+ }
+ },
+
+
+ // Unrenders a visual indications of a selection
+ unrenderSelection: function() {
+ this.timeGrid.unrenderSelection();
+ if (this.dayGrid) {
+ this.dayGrid.unrenderSelection();
+ }
+ }
+
+});
+
+
+// Methods that will customize the rendering behavior of the AgendaView's timeGrid
+var agendaTimeGridMethods = {
+
+
+ // Generates the HTML that will go before the day-of week header cells
+ renderHeadIntroHtml: function() {
+ var view = this.view;
+ var weekText;
+
+ if (view.opt('weekNumbers')) {
+ weekText = this.start.format(view.opt('smallWeekFormat'));
+
+ return '' +
+ '';
+ }
+ else {
+ return '';
+ }
+ },
+
+
+ // Generates the HTML that goes before the bg of the TimeGrid slot area. Long vertical column.
+ renderBgIntroHtml: function() {
+ var view = this.view;
+
+ return ' | ';
+ },
+
+
+ // Generates the HTML that goes before all other types of cells.
+ // Affects content-skeleton, helper-skeleton, highlight-skeleton for both the time-grid and day-grid.
+ renderIntroHtml: function() {
+ var view = this.view;
+
+ return ' | ';
+ }
+
+};
+
+
+// Methods that will customize the rendering behavior of the AgendaView's dayGrid
+var agendaDayGridMethods = {
+
+
+ // Generates the HTML that goes before the all-day cells
+ renderBgIntroHtml: function() {
+ var view = this.view;
+
+ return '' +
+ '' +
+ '' + // needed for matchCellWidths
+ (view.opt('allDayHtml') || htmlEscape(view.opt('allDayText'))) +
+ '' +
+ ' | ';
+ },
+
+
+ // Generates the HTML that goes before all other types of cells.
+ // Affects content-skeleton, helper-skeleton, highlight-skeleton for both the time-grid and day-grid.
+ renderIntroHtml: function() {
+ var view = this.view;
+
+ return ' | ';
+ }
+
+};
+
+;;
+
+var AGENDA_ALL_DAY_EVENT_LIMIT = 5;
+
+// potential nice values for the slot-duration and interval-duration
+// from largest to smallest
+var AGENDA_STOCK_SUB_DURATIONS = [
+ { hours: 1 },
+ { minutes: 30 },
+ { minutes: 15 },
+ { seconds: 30 },
+ { seconds: 15 }
+];
+
+fcViews.agenda = {
+ 'class': AgendaView,
+ defaults: {
+ allDaySlot: true,
+ allDayText: 'all-day',
+ slotDuration: '00:30:00',
+ minTime: '00:00:00',
+ maxTime: '24:00:00',
+ slotEventOverlap: true // a bad name. confused with overlap/constraint system
+ }
+};
+
+fcViews.agendaDay = {
+ type: 'agenda',
+ duration: { days: 1 }
+};
+
+fcViews.agendaWeek = {
+ type: 'agenda',
+ duration: { weeks: 1 }
+};
+;;
+
+return FC; // export for Node/CommonJS
+});
\ No newline at end of file
diff --git a/library/fullcalendar/fullcalendar.min.css b/library/fullcalendar/fullcalendar.min.css
new file mode 100644
index 000000000..f9c93ef7c
--- /dev/null
+++ b/library/fullcalendar/fullcalendar.min.css
@@ -0,0 +1,5 @@
+/*!
+ * FullCalendar v2.5.0-beta Stylesheet
+ * Docs & License: http://fullcalendar.io/
+ * (c) 2015 Adam Shaw
+ */.fc{direction:ltr;text-align:left}.fc-rtl{text-align:right}body .fc{font-size:1em}.fc-unthemed .fc-divider,.fc-unthemed .fc-popover,.fc-unthemed .fc-row,.fc-unthemed tbody,.fc-unthemed td,.fc-unthemed th,.fc-unthemed thead{border-color:#ddd}.fc-unthemed .fc-popover{background-color:#fff}.fc-unthemed .fc-divider,.fc-unthemed .fc-popover .fc-header{background:#eee}.fc-unthemed .fc-popover .fc-header .fc-close{color:#666}.fc-unthemed .fc-today{background:#fcf8e3}.fc-highlight{background:#bce8f1;opacity:.3;filter:alpha(opacity=30)}.fc-bgevent{background:#8fdf82;opacity:.3;filter:alpha(opacity=30)}.fc-nonbusiness{background:#d7d7d7}.fc-icon{display:inline-block;width:1em;height:1em;line-height:1em;font-size:1em;text-align:center;overflow:hidden;font-family:"Courier New",Courier,monospace;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.fc-icon:after{position:relative;margin:0 -1em}.fc-icon-left-single-arrow:after{content:"\02039";font-weight:700;font-size:200%;top:-7%;left:3%}.fc-icon-right-single-arrow:after{content:"\0203A";font-weight:700;font-size:200%;top:-7%;left:-3%}.fc-icon-left-double-arrow:after{content:"\000AB";font-size:160%;top:-7%}.fc-icon-right-double-arrow:after{content:"\000BB";font-size:160%;top:-7%}.fc-icon-left-triangle:after{content:"\25C4";font-size:125%;top:3%;left:-2%}.fc-icon-right-triangle:after{content:"\25BA";font-size:125%;top:3%;left:2%}.fc-icon-down-triangle:after{content:"\25BC";font-size:125%;top:2%}.fc-icon-x:after{content:"\000D7";font-size:200%;top:6%}.fc button{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0;height:2.1em;padding:0 .6em;font-size:1em;white-space:nowrap;cursor:pointer}.fc button::-moz-focus-inner{margin:0;padding:0}.fc-state-default{border:1px solid}.fc-state-default.fc-corner-left{border-top-left-radius:4px;border-bottom-left-radius:4px}.fc-state-default.fc-corner-right{border-top-right-radius:4px;border-bottom-right-radius:4px}.fc button .fc-icon{position:relative;top:-.05em;margin:0 .2em;vertical-align:middle}.fc-state-default{background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.fc-state-active,.fc-state-disabled,.fc-state-down,.fc-state-hover{color:#333;background-color:#e6e6e6}.fc-state-hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.fc-state-active,.fc-state-down{background-color:#ccc;background-image:none;box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.fc-state-disabled{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);box-shadow:none}.fc-button-group{display:inline-block}.fc .fc-button-group>*{float:left;margin:0 0 0 -1px}.fc .fc-button-group>:first-child{margin-left:0}.fc-popover{position:absolute;box-shadow:0 2px 6px rgba(0,0,0,.15)}.fc-popover .fc-header{padding:2px 4px}.fc-popover .fc-header .fc-title{margin:0 2px}.fc-popover .fc-header .fc-close{cursor:pointer}.fc-ltr .fc-popover .fc-header .fc-title,.fc-rtl .fc-popover .fc-header .fc-close{float:left}.fc-ltr .fc-popover .fc-header .fc-close,.fc-rtl .fc-popover .fc-header .fc-title{float:right}.fc-unthemed .fc-popover{border-width:1px;border-style:solid}.fc-unthemed .fc-popover .fc-header .fc-close{font-size:.9em;margin-top:2px}.fc-popover>.ui-widget-header+.ui-widget-content{border-top:0}.fc-divider{border-style:solid;border-width:1px}hr.fc-divider{height:0;margin:0;padding:0 0 2px;border-width:1px 0}.fc-clear{clear:both}.fc-bg,.fc-bgevent-skeleton,.fc-helper-skeleton,.fc-highlight-skeleton{position:absolute;top:0;left:0;right:0}.fc-bg{bottom:0}.fc-bg table{height:100%}.fc table{width:100%;table-layout:fixed;border-collapse:collapse;border-spacing:0;font-size:1em}.fc th{text-align:center}.fc td,.fc th{border-style:solid;border-width:1px;padding:0;vertical-align:top}.fc td.fc-today{border-style:double}.fc .fc-row{border-style:solid;border-width:0}.fc-row table{border-left:0 hidden transparent;border-right:0 hidden transparent;border-bottom:0 hidden transparent}.fc-row:first-child table{border-top:0 hidden transparent}.fc-row{position:relative}.fc-row .fc-bg{z-index:1}.fc-row .fc-bgevent-skeleton,.fc-row .fc-highlight-skeleton{bottom:0}.fc-row .fc-bgevent-skeleton table,.fc-row .fc-highlight-skeleton table{height:100%}.fc-row .fc-bgevent-skeleton td,.fc-row .fc-highlight-skeleton td{border-color:transparent}.fc-row .fc-bgevent-skeleton{z-index:2}.fc-row .fc-highlight-skeleton{z-index:3}.fc-row .fc-content-skeleton{position:relative;z-index:4;padding-bottom:2px}.fc-row .fc-helper-skeleton{z-index:5}.fc-row .fc-content-skeleton td,.fc-row .fc-helper-skeleton td{background:0 0;border-color:transparent;border-bottom:0}.fc-row .fc-content-skeleton tbody td,.fc-row .fc-helper-skeleton tbody td{border-top:0}.fc-scroller{overflow-y:scroll;overflow-x:hidden}.fc-scroller>*{position:relative;width:100%;overflow:hidden}.fc-event{position:relative;display:block;font-size:.85em;line-height:1.3;border-radius:3px;border:1px solid #3a87ad;background-color:#3a87ad;font-weight:400}.fc-event,.fc-event:hover,.ui-widget .fc-event{color:#fff;text-decoration:none}.fc-event.fc-draggable,.fc-event[href]{cursor:pointer}.fc-not-allowed,.fc-not-allowed .fc-event{cursor:not-allowed}.fc-event .fc-bg{z-index:1;background:#fff;opacity:.25;filter:alpha(opacity=25)}.fc-event .fc-content{position:relative;z-index:2}.fc-event .fc-resizer{position:absolute;z-index:3}.fc-ltr .fc-h-event.fc-not-start,.fc-rtl .fc-h-event.fc-not-end{margin-left:0;border-left-width:0;padding-left:1px;border-top-left-radius:0;border-bottom-left-radius:0}.fc-ltr .fc-h-event.fc-not-end,.fc-rtl .fc-h-event.fc-not-start{margin-right:0;border-right-width:0;padding-right:1px;border-top-right-radius:0;border-bottom-right-radius:0}.fc-h-event .fc-resizer{top:-1px;bottom:-1px;left:-1px;right:-1px;width:5px}.fc-ltr .fc-h-event .fc-start-resizer,.fc-ltr .fc-h-event .fc-start-resizer:after,.fc-ltr .fc-h-event .fc-start-resizer:before,.fc-rtl .fc-h-event .fc-end-resizer,.fc-rtl .fc-h-event .fc-end-resizer:after,.fc-rtl .fc-h-event .fc-end-resizer:before{right:auto;cursor:w-resize}.fc-ltr .fc-h-event .fc-end-resizer,.fc-ltr .fc-h-event .fc-end-resizer:after,.fc-ltr .fc-h-event .fc-end-resizer:before,.fc-rtl .fc-h-event .fc-start-resizer,.fc-rtl .fc-h-event .fc-start-resizer:after,.fc-rtl .fc-h-event .fc-start-resizer:before{left:auto;cursor:e-resize}.fc-day-grid-event{margin:1px 2px 0;padding:0 1px}.fc-day-grid-event .fc-content{white-space:nowrap;overflow:hidden}.fc-day-grid-event .fc-time{font-weight:700}.fc-day-grid-event .fc-resizer{left:-3px;right:-3px;width:7px}a.fc-more{margin:1px 3px;font-size:.85em;cursor:pointer;text-decoration:none}a.fc-more:hover{text-decoration:underline}.fc-limited{display:none}.fc-day-grid .fc-row{z-index:1}.fc-more-popover{z-index:2;width:220px}.fc-more-popover .fc-event-container{padding:10px}.fc-toolbar{text-align:center;margin-bottom:1em}.fc-toolbar .fc-left{float:left}.fc-toolbar .fc-right{float:right}.fc-toolbar .fc-center{display:inline-block}.fc .fc-toolbar>*>*{float:left;margin-left:.75em}.fc .fc-toolbar>*>:first-child{margin-left:0}.fc-toolbar h2{margin:0}.fc-toolbar button{position:relative}.fc-toolbar .fc-state-hover,.fc-toolbar .ui-state-hover{z-index:2}.fc-toolbar .fc-state-down{z-index:3}.fc-toolbar .fc-state-active,.fc-toolbar .ui-state-active{z-index:4}.fc-toolbar button:focus{z-index:5}.fc-view-container *,.fc-view-container :after,.fc-view-container :before{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.fc-view,.fc-view>table{position:relative;z-index:1}.fc-basicDay-view .fc-content-skeleton,.fc-basicWeek-view .fc-content-skeleton{padding-top:1px;padding-bottom:1em}.fc-basic-view .fc-body .fc-row{min-height:4em}.fc-row.fc-rigid{overflow:hidden}.fc-row.fc-rigid .fc-content-skeleton{position:absolute;top:0;left:0;right:0}.fc-basic-view .fc-day-number,.fc-basic-view .fc-week-number{padding:0 2px}.fc-basic-view td.fc-day-number,.fc-basic-view td.fc-week-number span{padding-top:2px;padding-bottom:2px}.fc-basic-view .fc-week-number{text-align:center}.fc-basic-view .fc-week-number span{display:inline-block;min-width:1.25em}.fc-ltr .fc-basic-view .fc-day-number{text-align:right}.fc-rtl .fc-basic-view .fc-day-number{text-align:left}.fc-day-number.fc-other-month{opacity:.3;filter:alpha(opacity=30)}.fc-agenda-view .fc-day-grid{position:relative;z-index:2}.fc-agenda-view .fc-day-grid .fc-row{min-height:3em}.fc-agenda-view .fc-day-grid .fc-row .fc-content-skeleton{padding-top:1px;padding-bottom:1em}.fc .fc-axis{vertical-align:middle;padding:0 4px;white-space:nowrap}.fc-ltr .fc-axis{text-align:right}.fc-rtl .fc-axis{text-align:left}.ui-widget td.fc-axis{font-weight:400}.fc-time-grid,.fc-time-grid-container{position:relative;z-index:1}.fc-time-grid{min-height:100%}.fc-time-grid table{border:0 hidden transparent}.fc-time-grid>.fc-bg{z-index:1}.fc-time-grid .fc-slats,.fc-time-grid>hr{position:relative;z-index:2}.fc-time-grid .fc-bgevent-skeleton,.fc-time-grid .fc-content-skeleton{position:absolute;top:0;left:0;right:0}.fc-time-grid .fc-bgevent-skeleton{z-index:3}.fc-time-grid .fc-highlight-skeleton{z-index:4}.fc-time-grid .fc-content-skeleton{z-index:5}.fc-time-grid .fc-helper-skeleton{z-index:6}.fc-time-grid .fc-slats td{height:1.5em;border-bottom:0}.fc-time-grid .fc-slats .fc-minor td{border-top-style:dotted}.fc-time-grid .fc-slats .ui-widget-content{background:0 0}.fc-time-grid .fc-highlight-container{position:relative}.fc-time-grid .fc-highlight{position:absolute;left:0;right:0}.fc-time-grid .fc-bgevent-container,.fc-time-grid .fc-event-container{position:relative}.fc-ltr .fc-time-grid .fc-event-container{margin:0 2.5% 0 2px}.fc-rtl .fc-time-grid .fc-event-container{margin:0 2px 0 2.5%}.fc-time-grid .fc-bgevent,.fc-time-grid .fc-event{position:absolute;z-index:1}.fc-time-grid .fc-bgevent{left:0;right:0}.fc-v-event.fc-not-start{border-top-width:0;padding-top:1px;border-top-left-radius:0;border-top-right-radius:0}.fc-v-event.fc-not-end{border-bottom-width:0;padding-bottom:1px;border-bottom-left-radius:0;border-bottom-right-radius:0}.fc-time-grid-event{overflow:hidden}.fc-time-grid-event .fc-time,.fc-time-grid-event .fc-title{padding:0 1px}.fc-time-grid-event .fc-time{font-size:.85em;white-space:nowrap}.fc-time-grid-event.fc-short .fc-content{white-space:nowrap}.fc-time-grid-event.fc-short .fc-time,.fc-time-grid-event.fc-short .fc-title{display:inline-block;vertical-align:top}.fc-time-grid-event.fc-short .fc-time span{display:none}.fc-time-grid-event.fc-short .fc-time:before{content:attr(data-start)}.fc-time-grid-event.fc-short .fc-time:after{content:"\000A0-\000A0"}.fc-time-grid-event.fc-short .fc-title{font-size:.85em;padding:0}.fc-time-grid-event .fc-resizer{left:0;right:0;bottom:0;height:8px;overflow:hidden;line-height:8px;font-size:11px;font-family:monospace;text-align:center;cursor:s-resize}.fc-time-grid-event .fc-resizer:after{content:"="}
\ No newline at end of file
diff --git a/library/fullcalendar/fullcalendar.min.js b/library/fullcalendar/fullcalendar.min.js
index 2f07418e3..b152237bd 100644
--- a/library/fullcalendar/fullcalendar.min.js
+++ b/library/fullcalendar/fullcalendar.min.js
@@ -1,7 +1,9 @@
/*!
- * FullCalendar v1.6.0
- * Docs & License: http://arshaw.com/fullcalendar/
- * (c) 2013 Adam Shaw
+ * FullCalendar v2.5.0-beta
+ * Docs & License: http://fullcalendar.io/
+ * (c) 2015 Adam Shaw
*/
-(function(t,e){function n(e){t.extend(!0,ye,e)}function r(n,r,l){function u(t){G?(S(),C(),R(),b(t)):f()}function f(){K=r.theme?"ui":"fc",n.addClass("fc"),r.isRTL?n.addClass("fc-rtl"):n.addClass("fc-ltr"),r.theme&&n.addClass("ui-widget"),G=t("").prependTo(n),$=new a(Z,r),Q=$.render(),Q&&n.prepend(Q),y(r.defaultView),t(window).resize(x),m()||v()}function v(){setTimeout(function(){!te.start&&m()&&b()},0)}function h(){t(window).unbind("resize",x),$.destroy(),G.remove(),n.removeClass("fc fc-rtl ui-widget")}function g(){return 0!==se.offsetWidth}function m(){return 0!==t("body")[0].offsetWidth}function y(e){if(!te||e!=te.name){ue++,W();var n,r=te;r?((r.beforeHide||I)(),q(G,G.height()),r.element.hide()):q(G,1),G.css("overflow","hidden"),te=ce[e],te?te.element.show():te=ce[e]=new De[e](n=re=t("").appendTo(G),Z),r&&$.deactivateButton(r.name),$.activateButton(e),b(),G.css("overflow",""),r&&q(G,1),n||(te.afterShow||I)(),ue--}}function b(t){if(g()){ue++,W(),ne===e&&S();var r=!1;!te.start||t||te.start>fe||fe>=te.end?(te.render(fe,t||0),E(!0),r=!0):te.sizeDirty?(te.clearEvents(),E(),r=!0):te.eventsDirty&&(te.clearEvents(),r=!0),te.sizeDirty=!1,te.eventsDirty=!1,T(r),ee=n.outerWidth(),$.updateTitle(te.title);var a=new Date;a>=te.start&&te.end>a?$.disableButton("today"):$.enableButton("today"),ue--,te.trigger("viewDisplay",se)}}function M(){C(),g()&&(S(),E(),W(),te.clearEvents(),te.renderEvents(de),te.sizeDirty=!1)}function C(){t.each(ce,function(t,e){e.sizeDirty=!0})}function S(){ne=r.contentHeight?r.contentHeight:r.height?r.height-(Q?Q.height():0)-L(G):Math.round(G.width()/Math.max(r.aspectRatio,.5))}function E(t){ue++,te.setHeight(ne,t),re&&(re.css("position","relative"),re=null),te.setWidth(G.width(),t),ue--}function x(){if(!ue)if(te.start){var t=++le;setTimeout(function(){t==le&&!ue&&g()&&ee!=(ee=n.outerWidth())&&(ue++,M(),te.trigger("windowResize",se),ue--)},200)}else v()}function T(t){!r.lazyFetching||oe(te.visStart,te.visEnd)?k():t&&F()}function k(){ie(te.visStart,te.visEnd)}function H(t){de=t,F()}function z(t){F(t)}function F(t){R(),g()&&(te.clearEvents(),te.renderEvents(de,t),te.eventsDirty=!1)}function R(){t.each(ce,function(t,e){e.eventsDirty=!0})}function N(t,n,r){te.select(t,n,r===e?!0:r)}function W(){te&&te.unselect()}function A(){b(-1)}function _(){b(1)}function O(){i(fe,-1),b()}function B(){i(fe,1),b()}function Y(){fe=new Date,b()}function j(t,e,n){t instanceof Date?fe=d(t):p(fe,t,e,n),b()}function P(t,n,r){t!==e&&i(fe,t),n!==e&&s(fe,n),r!==e&&c(fe,r),b()}function J(){return d(fe)}function V(){return te}function X(t,n){return n===e?r[t]:(("height"==t||"contentHeight"==t||"aspectRatio"==t)&&(r[t]=n,M()),e)}function U(t,n){return r[t]?r[t].apply(n||se,Array.prototype.slice.call(arguments,2)):e}var Z=this;Z.options=r,Z.render=u,Z.destroy=h,Z.refetchEvents=k,Z.reportEvents=H,Z.reportEventChange=z,Z.rerenderEvents=F,Z.changeView=y,Z.select=N,Z.unselect=W,Z.prev=A,Z.next=_,Z.prevYear=O,Z.nextYear=B,Z.today=Y,Z.gotoDate=j,Z.incrementDate=P,Z.formatDate=function(t,e){return w(t,e,r)},Z.formatDates=function(t,e,n){return D(t,e,n,r)},Z.getDate=J,Z.getView=V,Z.option=X,Z.trigger=U,o.call(Z,r,l);var $,Q,G,K,te,ee,ne,re,ae,oe=Z.isFetchNeeded,ie=Z.fetchEvents,se=n[0],ce={},le=0,ue=0,fe=new Date,de=[];p(fe,r.year,r.month,r.date),r.droppable&&t(document).bind("dragstart",function(e,n){var a=e.target,o=t(a);if(!o.parents(".fc").length){var i=r.dropAccept;(t.isFunction(i)?i.call(a,o):o.is(i))&&(ae=a,te.dragStart(ae,e,n))}}).bind("dragstop",function(t,e){ae&&(te.dragStop(ae,t,e),ae=null)})}function a(n,r){function a(){v=r.theme?"ui":"fc";var n=r.header;return n?h=t("").append(t(" ").append(i("left")).append(i("center")).append(i("right"))):e}function o(){h.remove()}function i(e){var a=t(""),o=r.header[e];return o&&t.each(o.split(" "),function(e){e>0&&a.append("");var o;t.each(this.split(","),function(e,i){if("title"==i)a.append(""),o&&o.addClass(v+"-corner-right"),o=null;else{var s;if(n[i]?s=n[i]:De[i]&&(s=function(){u.removeClass(v+"-state-hover"),n.changeView(i)}),s){var c=r.theme?J(r.buttonIcons,i):null,l=J(r.buttonText,i),u=t(""+(c?""+"":l)+"").click(function(){u.hasClass(v+"-state-disabled")||s()}).mousedown(function(){u.not("."+v+"-state-active").not("."+v+"-state-disabled").addClass(v+"-state-down")}).mouseup(function(){u.removeClass(v+"-state-down")}).hover(function(){u.not("."+v+"-state-active").not("."+v+"-state-disabled").addClass(v+"-state-hover")},function(){u.removeClass(v+"-state-hover").removeClass(v+"-state-down")}).appendTo(a);U(u),o||u.addClass(v+"-corner-left"),o=u}}}),o&&o.addClass(v+"-corner-right")}),a}function s(t){h.find("h2").html(t)}function c(t){h.find("span.fc-button-"+t).addClass(v+"-state-active")}function l(t){h.find("span.fc-button-"+t).removeClass(v+"-state-active")}function u(t){h.find("span.fc-button-"+t).addClass(v+"-state-disabled")}function f(t){h.find("span.fc-button-"+t).removeClass(v+"-state-disabled")}var d=this;d.render=a,d.destroy=o,d.updateTitle=s,d.activateButton=c,d.deactivateButton=l,d.disableButton=u,d.enableButton=f;var v,h=t([])}function o(n,r){function a(t,e){return!S||S>t||e>E}function o(t,e){S=t,E=e,W=[];var n=++F,r=z.length;R=r;for(var a=0;r>a;a++)i(z[a],n)}function i(e,r){s(e,function(a){if(r==F){if(a){n.eventDataTransform&&(a=t.map(a,n.eventDataTransform)),e.eventDataTransform&&(a=t.map(a,e.eventDataTransform));for(var o=0;a.length>o;o++)a[o].source=e,b(a[o]);W=W.concat(a)}R--,R||k(W)}})}function s(r,a){var o,i,c=we.sourceFetchers;for(o=0;c.length>o;o++){if(i=c[o](r,S,E,a),i===!0)return;if("object"==typeof i)return s(i,a),e}var l=r.events;if(l)t.isFunction(l)?(p(),l(d(S),d(E),function(t){a(t),y()})):t.isArray(l)?a(l):a();else{var u=r.url;if(u){var f=r.success,v=r.error,h=r.complete,g=t.extend({},r.data||{}),m=K(r.startParam,n.startParam),b=K(r.endParam,n.endParam);m&&(g[m]=Math.round(+S/1e3)),b&&(g[b]=Math.round(+E/1e3)),p(),t.ajax(t.extend({},Me,r,{data:g,success:function(e){e=e||[];var n=G(f,this,arguments);t.isArray(n)&&(e=n),a(e)},error:function(){G(v,this,arguments),a()},complete:function(){G(h,this,arguments),y()}}))}else a()}}function c(t){t=l(t),t&&(R++,i(t,F))}function l(n){return t.isFunction(n)||t.isArray(n)?n={events:n}:"string"==typeof n&&(n={url:n}),"object"==typeof n?(w(n),z.push(n),n):e}function u(e){z=t.grep(z,function(t){return!D(t,e)}),W=t.grep(W,function(t){return!D(t.source,e)}),k(W)}function f(t){var e,n,r=W.length,a=T().defaultEventEnd,o=t.start-t._start,i=t.end?t.end-(t._end||a(t)):0;for(e=0;r>e;e++)n=W[e],n._id==t._id&&n!=t&&(n.start=new Date(+n.start+o),n.end=t.end?n.end?new Date(+n.end+i):new Date(+a(n)+i):null,n.title=t.title,n.url=t.url,n.allDay=t.allDay,n.className=t.className,n.editable=t.editable,n.color=t.color,n.backgroudColor=t.backgroudColor,n.borderColor=t.borderColor,n.textColor=t.textColor,b(n));b(t),k(W)}function v(t,e){b(t),t.source||(e&&(H.events.push(t),t.source=H),W.push(t)),k(W)}function h(e){if(e){if(!t.isFunction(e)){var n=e+"";e=function(t){return t._id==n}}W=t.grep(W,e,!0);for(var r=0;z.length>r;r++)t.isArray(z[r].events)&&(z[r].events=t.grep(z[r].events,e,!0))}else{W=[];for(var r=0;z.length>r;r++)t.isArray(z[r].events)&&(z[r].events=[])}k(W)}function g(e){return t.isFunction(e)?t.grep(W,e):e?(e+="",t.grep(W,function(t){return t._id==e})):W}function p(){N++||x("loading",null,!0)}function y(){--N||x("loading",null,!1)}function b(t){var r=t.source||{},a=K(r.ignoreTimezone,n.ignoreTimezone);t._id=t._id||(t.id===e?"_fc"+Ce++:t.id+""),t.date&&(t.start||(t.start=t.date),delete t.date),t._start=d(t.start=m(t.start,a)),t.end=m(t.end,a),t.end&&t.end<=t.start&&(t.end=null),t._end=t.end?d(t.end):null,t.allDay===e&&(t.allDay=K(r.allDayDefault,n.allDayDefault)),t.className?"string"==typeof t.className&&(t.className=t.className.split(/\s+/)):t.className=[]}function w(t){t.className?"string"==typeof t.className&&(t.className=t.className.split(/\s+/)):t.className=[];for(var e=we.sourceNormalizers,n=0;e.length>n;n++)e[n](t)}function D(t,e){return t&&e&&M(t)==M(e)}function M(t){return("object"==typeof t?t.events||t.url:"")||t}var C=this;C.isFetchNeeded=a,C.fetchEvents=o,C.addEventSource=c,C.removeEventSource=u,C.updateEvent=f,C.renderEvent=v,C.removeEvents=h,C.clientEvents=g,C.normalizeEvent=b;for(var S,E,x=C.trigger,T=C.getView,k=C.reportEvents,H={events:[]},z=[H],F=0,R=0,N=0,W=[],A=0;r.length>A;A++)l(r[A])}function i(t,e,n){return t.setFullYear(t.getFullYear()+e),n||f(t),t}function s(t,e,n){if(+t){var r=t.getMonth()+e,a=d(t);for(a.setDate(1),a.setMonth(r),t.setMonth(r),n||f(t);t.getMonth()!=a.getMonth();)t.setDate(t.getDate()+(a>t?1:-1))}return t}function c(t,e,n){if(+t){var r=t.getDate()+e,a=d(t);a.setHours(9),a.setDate(r),t.setDate(r),n||f(t),l(t,a)}return t}function l(t,e){if(+t)for(;t.getDate()!=e.getDate();)t.setTime(+t+(e>t?1:-1)*xe)}function u(t,e){return t.setMinutes(t.getMinutes()+e),t}function f(t){return t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),t}function d(t,e){return e?f(new Date(+t)):new Date(+t)}function v(){var t,e=0;do t=new Date(1970,e++,1);while(t.getHours());return t}function h(t,e,n){for(e=e||1;!t.getDay()||n&&1==t.getDay()||!n&&6==t.getDay();)c(t,e);return t}function g(t,e){return Math.round((d(t,!0)-d(e,!0))/Ee)}function p(t,n,r,a){n!==e&&n!=t.getFullYear()&&(t.setDate(1),t.setMonth(0),t.setFullYear(n)),r!==e&&r!=t.getMonth()&&(t.setDate(1),t.setMonth(r)),a!==e&&t.setDate(a)}function m(t,n){return"object"==typeof t?t:"number"==typeof t?new Date(1e3*t):"string"==typeof t?t.match(/^\d+(\.\d+)?$/)?new Date(1e3*parseFloat(t)):(n===e&&(n=!0),y(t,n)||(t?new Date(t):null)):null}function y(t,e){var n=t.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(!n)return null;var r=new Date(n[1],0,1);if(e||!n[13]){var a=new Date(n[1],0,1,9,0);n[3]&&(r.setMonth(n[3]-1),a.setMonth(n[3]-1)),n[5]&&(r.setDate(n[5]),a.setDate(n[5])),l(r,a),n[7]&&r.setHours(n[7]),n[8]&&r.setMinutes(n[8]),n[10]&&r.setSeconds(n[10]),n[12]&&r.setMilliseconds(1e3*Number("0."+n[12])),l(r,a)}else if(r.setUTCFullYear(n[1],n[3]?n[3]-1:0,n[5]||1),r.setUTCHours(n[7]||0,n[8]||0,n[10]||0,n[12]?1e3*Number("0."+n[12]):0),n[14]){var o=60*Number(n[16])+(n[18]?Number(n[18]):0);o*="-"==n[15]?1:-1,r=new Date(+r+1e3*60*o)}return r}function b(t){if("number"==typeof t)return 60*t;if("object"==typeof t)return 60*t.getHours()+t.getMinutes();var e=t.match(/(\d+)(?::(\d+))?\s*(\w+)?/);if(e){var n=parseInt(e[1],10);return e[3]&&(n%=12,"p"==e[3].toLowerCase().charAt(0)&&(n+=12)),60*n+(e[2]?parseInt(e[2],10):0)}}function w(t,e,n){return D(t,null,e,n)}function D(t,e,n,r){r=r||ye;var a,o,i,s,c=t,l=e,u=n.length,f="";for(a=0;u>a;a++)if(o=n.charAt(a),"'"==o){for(i=a+1;u>i;i++)if("'"==n.charAt(i)){c&&(f+=i==a+1?"'":n.substring(a+1,i),a=i);break}}else if("("==o){for(i=a+1;u>i;i++)if(")"==n.charAt(i)){var d=w(c,n.substring(a+1,i),r);parseInt(d.replace(/\D/,""),10)&&(f+=d),a=i;break}}else if("["==o){for(i=a+1;u>i;i++)if("]"==n.charAt(i)){var v=n.substring(a+1,i),d=w(c,v,r);d!=w(l,v,r)&&(f+=d),a=i;break}}else if("{"==o)c=e,l=t;else if("}"==o)c=t,l=e;else{for(i=u;i>a;i--)if(s=ke[n.substring(a,i)]){c&&(f+=s(c,r)),a=i-1;break}i==a&&c&&(f+=o)}return f}function M(t){var e,n=new Date(t.getTime());return n.setDate(n.getDate()+4-(n.getDay()||7)),e=n.getTime(),n.setMonth(0),n.setDate(1),Math.floor(Math.round((e-n)/864e5)/7)+1}function C(t){return t.end?S(t.end,t.allDay):c(d(t.start),1)}function S(t,e){return t=d(t),e||t.getHours()||t.getMinutes()?c(t,1):f(t)}function E(t,e){return 100*(e.msLength-t.msLength)+(t.event.start-e.event.start)}function x(t,e){return t.end>e.start&&t.starta;a++)o=t[a],i=o.start,s=e[a],s>n&&r>i&&(n>i?(c=d(n),u=!1):(c=i,u=!0),s>r?(l=d(r),f=!1):(l=s,f=!0),v.push({event:o,start:c,end:l,isStart:u,isEnd:f,msLength:l-c}));return v.sort(E)}function k(t){var e,n,r,a,o,i=[],s=t.length;for(e=0;s>e;e++){for(n=t[e],r=0;;){if(a=!1,i[r])for(o=0;i[r].length>o;o++)if(x(i[r][o],n)){a=!0;break}if(!a)break;r++}i[r]?i[r].push(n):i[r]=[n]}return i}function H(n,r,a){n.unbind("mouseover").mouseover(function(n){for(var o,i,s,c=n.target;c!=this;)o=c,c=c.parentNode;(i=o._fci)!==e&&(o._fci=e,s=r[i],a(s.event,s.element,s),t(n.target).trigger(n)),n.stopPropagation()})}function z(e,n,r){for(var a,o=0;e.length>o;o++)a=t(e[o]),a.width(Math.max(0,n-R(a,r)))}function F(e,n,r){for(var a,o=0;e.length>o;o++)a=t(e[o]),a.height(Math.max(0,n-L(a,r)))}function R(t,e){return N(t)+A(t)+(e?W(t):0)}function N(e){return(parseFloat(t.css(e[0],"paddingLeft",!0))||0)+(parseFloat(t.css(e[0],"paddingRight",!0))||0)}function W(e){return(parseFloat(t.css(e[0],"marginLeft",!0))||0)+(parseFloat(t.css(e[0],"marginRight",!0))||0)}function A(e){return(parseFloat(t.css(e[0],"borderLeftWidth",!0))||0)+(parseFloat(t.css(e[0],"borderRightWidth",!0))||0)}function L(t,e){return _(t)+B(t)+(e?O(t):0)}function _(e){return(parseFloat(t.css(e[0],"paddingTop",!0))||0)+(parseFloat(t.css(e[0],"paddingBottom",!0))||0)}function O(e){return(parseFloat(t.css(e[0],"marginTop",!0))||0)+(parseFloat(t.css(e[0],"marginBottom",!0))||0)}function B(e){return(parseFloat(t.css(e[0],"borderTopWidth",!0))||0)+(parseFloat(t.css(e[0],"borderBottomWidth",!0))||0)}function q(t,e){e="number"==typeof e?e+"px":e,t.each(function(t,n){n.style.cssText+=";min-height:"+e+";_height:"+e})}function I(){}function Y(t,e){return t-e}function j(t){return Math.max.apply(Math,t)}function P(t){return(10>t?"0":"")+t}function J(t,n){if(t[n]!==e)return t[n];for(var r,a=n.split(/(?=[A-Z])/),o=a.length-1;o>=0;o--)if(r=t[a[o].toLowerCase()],r!==e)return r;return t[""]}function V(t){return t.replace(/&/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""").replace(/\n/g," ")}function X(t){return t.id+"/"+t.className+"/"+t.style.cssText.replace(/(^|;)\s*(top|left|width|height)\s*:[^;]*/gi,"")}function U(t){t.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return!1})}function Z(t){t.children().removeClass("fc-first fc-last").filter(":first-child").addClass("fc-first").end().filter(":last-child").addClass("fc-last")}function $(t,e){t.each(function(t,n){n.className=n.className.replace(/^fc-\w*/,"fc-"+Se[e.getDay()])})}function Q(t,e){var n=t.source||{},r=t.color,a=n.color,o=e("eventColor"),i=t.backgroundColor||r||n.backgroundColor||a||e("eventBackgroundColor")||o,s=t.borderColor||r||n.borderColor||a||e("eventBorderColor")||o,c=t.textColor||n.textColor||e("eventTextColor"),l=[];return i&&l.push("background-color:"+i),s&&l.push("border-color:"+s),c&&l.push("color:"+c),l.join(";")}function G(e,n,r){if(t.isFunction(e)&&(e=[e]),e){var a,o;for(a=0;e.length>a;a++)o=e[a].apply(n,r)||o;return o}}function K(){for(var t=0;arguments.length>t;t++)if(arguments[t]!==e)return arguments[t]}function te(t,e){function n(t,e){e&&(s(t,e),t.setDate(1));var n=d(t,!0);n.setDate(1);var l=s(d(n),1),u=d(n),f=d(l),v=a("firstDay"),g=a("weekends")?0:1;g&&(h(u),h(f,-1,!0)),c(u,-((u.getDay()-Math.max(v,g)+7)%7)),c(f,(7-f.getDay()+Math.max(v,g))%7);var p=Math.round((f-u)/(7*Ee));"fixed"==a("weekMode")&&(c(f,7*(6-p)),p=6),r.title=i(n,a("titleFormat")),r.start=n,r.end=l,r.visStart=u,r.visEnd=f,o(p,g?5:7,!0)}var r=this;r.render=n,re.call(r,t,e,"month");var a=r.opt,o=r.renderBasic,i=e.formatDate}function ee(t,e){function n(t,e){e&&c(t,7*e);var n=c(d(t),-((t.getDay()-a("firstDay")+7)%7)),s=c(d(n),7),l=d(n),u=d(s),f=a("weekends");f||(h(l),h(u,-1,!0)),r.title=i(l,c(d(u),-1),a("titleFormat")),r.start=n,r.end=s,r.visStart=l,r.visEnd=u,o(1,f?7:5,!1)}var r=this;r.render=n,re.call(r,t,e,"basicWeek");var a=r.opt,o=r.renderBasic,i=e.formatDates}function ne(t,e){function n(t,e){e&&(c(t,e),a("weekends")||h(t,0>e?-1:1)),r.title=i(t,a("titleFormat")),r.start=r.visStart=d(t,!0),r.end=r.visEnd=c(d(r.start),1),o(1,1,!1)}var r=this;r.render=n,re.call(r,t,e,"basicDay");var a=r.opt,o=r.renderBasic,i=e.formatDate}function re(e,n,r){function a(t,e,n){ne=t,re=e,o();var r=!P;r?i():Te(),s(n)}function o(){ce=Ee("isRTL"),ce?(le=-1,fe=re-1):(le=1,fe=0),pe=Ee("firstDay"),ye=Ee("weekends")?0:1,be=Ee("theme")?"ui":"fc",we=Ee("columnFormat"),De=Ee("weekNumbers"),Me=Ee("weekNumberTitle"),Ce="iso"!=Ee("weekNumberCalculation")?"w":"W"}function i(){Q=t("").appendTo(e)}function s(n){var r,a,o,i,s="",c=be+"-widget-header",l=be+"-widget-content",u=B.start.getMonth(),d=f(new Date);for(s+="",De&&(s+=" | "),r=0;re>r;r++)s+="";for(s+=" ",r=0;ne>r;r++){for(s+="",De&&(s+=""+""+" | "),a=0;re>a;a++)o=F(r,a),i=["fc-day","fc-"+Se[o.getDay()],l],o.getMonth()!=u&&i.push("fc-other-month"),+o==+d&&(i.push("fc-today"),i.push(be+"-state-highlight")),s+=""+"",n&&(s+=" "+o.getDate()+" "),s+=" | ";s+=" "}s+=" ",_(),I&&I.remove(),I=t(s).appendTo(e),Y=I.find("thead"),j=Y.find(".fc-day-header"),P=I.find("tbody"),J=P.find("tr"),V=P.find(".fc-day"),X=J.find("td:first-child"),$=J.eq(0).find(".fc-day-content > div"),Z(Y.add(Y.find("tr"))),Z(J),J.eq(0).addClass("fc-first"),J.filter(":last").addClass("fc-last"),De&&Y.find(".fc-week-number").text(Me),j.each(function(e,n){var r=R(e);t(n).text(Fe(r,we))}),De&&P.find(".fc-week-number > div").each(function(e,n){var r=F(e,0);t(n).text(Fe(r,Ce))}),V.each(function(e,n){var r=R(e);xe("dayRender",B,r,t(n))}),v(V)}function l(e){K=e;var n,r,a,o=K-Y.height();"variable"==Ee("weekMode")?n=r=Math.floor(o/(1==ne?2:6)):(n=Math.floor(o/ne),r=o-n*(ne-1)),X.each(function(e,o){ne>e&&(a=t(o),q(a.find("> div"),(e==ne-1?r:n)-L(a)))}),O()}function u(t){G=t,se.clear(),ee=0,De&&(ee=Y.find("th.fc-week-number").outerWidth()),te=Math.floor((G-ee)/re),z(j.slice(0,-1),te)}function v(t){t.click(h).mousedown(ze)}function h(e){if(!Ee("selectable")){var n=y(t(this).data("date"));xe("dayClick",this,n,!0,e)}}function p(t,e,n){n&&oe.build();for(var r=d(B.visStart),a=c(d(r),re),o=0;ne>o;o++){var i=new Date(Math.max(r,t)),s=new Date(Math.min(a,e));if(s>i){var l,u;ce?(l=g(s,r)*le+fe+1,u=g(i,r)*le+fe+1):(l=g(i,r),u=g(s,r)),v(m(o,l,o,u-1))}c(r,7),c(a,7)}}function m(t,n,r,a){var o=oe.rect(t,n,r,a,e);return ke(o,e)}function b(t){return d(t)}function w(t,e){p(t,c(d(e),1),!0)}function D(){He()}function M(t,e,n){var r=k(t),a=V[r.row*re+r.col];xe("dayClick",a,t,e,n)}function C(t,e){ie.start(function(t){He(),t&&m(t.row,t.col,t.row,t.col)},e)}function S(t,e,n){var r=ie.stop();if(He(),r){var a=H(r);xe("drop",t,a,!0,e,n)}}function E(t){return d(t.start)}function x(t){return se.left(t)}function T(t){return se.right(t)}function k(t){return{row:Math.floor(g(t,B.visStart)/7),col:N(t.getDay())}}function H(t){return F(t.row,t.col)}function F(t,e){return c(d(B.visStart),7*t+e*le+fe)}function R(t){return F(Math.floor(t/re),t%re)}function N(t){return(t-Math.max(pe,ye)+re)%re*le+fe}function W(t){return J.eq(t)}function A(){var t=0;return De&&(t+=ee),{left:t,right:G}}function _(){q(e,e.height())}function O(){q(e,1)}var B=this;B.renderBasic=a,B.setHeight=l,B.setWidth=u,B.renderDayOverlay=p,B.defaultSelectionEnd=b,B.renderSelection=w,B.clearSelection=D,B.reportDayClick=M,B.dragStart=C,B.dragStop=S,B.defaultEventEnd=E,B.getHoverListener=function(){return ie},B.colContentLeft=x,B.colContentRight=T,B.dayOfWeekCol=N,B.dateCell=k,B.cellDate=H,B.cellIsAllDay=function(){return!0},B.allDayRow=W,B.allDayBounds=A,B.getRowCnt=function(){return ne},B.getColCnt=function(){return re},B.getColWidth=function(){return te},B.getDaySegmentContainer=function(){return Q},ue.call(B,e,n,r),ve.call(B),de.call(B),ae.call(B);var I,Y,j,P,J,V,X,$,Q,G,K,te,ee,ne,re,oe,ie,se,ce,le,fe,pe,ye,be,we,De,Me,Ce,Ee=B.opt,xe=B.trigger,Te=B.clearEvents,ke=B.renderOverlay,He=B.clearOverlays,ze=B.daySelectionMousedown,Fe=n.formatDate;U(e.addClass("fc-grid")),oe=new he(function(e,n){var r,a,o;j.each(function(e,i){r=t(i),a=r.offset().left,e&&(o[1]=a),o=[a],n[e]=o}),o[1]=a+r.outerWidth(),J.each(function(n,i){ne>n&&(r=t(i),a=r.offset().top,n&&(o[1]=a),o=[a],e[n]=o)}),o[1]=a+r.outerHeight()}),ie=new ge(oe),se=new me(function(t){return $.eq(t)})}function ae(){function e(t,e){v(t),x(r(t),e),l("eventAfterAllRender")}function n(){h(),b().empty()}function r(e){var n,r,a,o,s,l,u=S(),f=E(),v=d(i.visStart),h=c(d(v),f),g=t.map(e,C),p=[];for(n=0;u>n;n++){for(r=k(T(e,g,v,h)),a=0;r.length>a;a++)for(o=r[a],s=0;o.length>s;s++)l=o[s],l.row=n,l.level=a,p.push(l);c(v,7),c(h,7)}return p}function a(t,e,n){u(t)&&o(t,e),n.isEnd&&f(t)&&H(t,e,n),g(t,e)}function o(t,e){var n,r=w();e.draggable({zIndex:9,delay:50,opacity:s("dragOpacity"),revertDuration:s("dragRevertDuration"),start:function(a,o){l("eventDragStart",e,t,a,o),m(t,e),r.start(function(r,a,o,i){e.draggable("option","revert",!r||!o&&!i),M(),r?(n=7*o+i*(s("isRTL")?-1:1),D(c(d(t.start),n),c(C(t),n))):n=0},a,"drag")},stop:function(a,o){r.stop(),M(),l("eventDragStop",e,t,a,o),n?y(this,t,n,0,t.allDay,a,o):(e.css("filter",""),p(t,e))}})}var i=this;i.renderEvents=e,i.compileDaySegs=r,i.clearEvents=n,i.bindDaySeg=a,fe.call(i);var s=i.opt,l=i.trigger,u=i.isEventDraggable,f=i.isEventResizable,v=i.reportEvents,h=i.reportEventClear,g=i.eventElementHandlers,p=i.showEvents,m=i.hideEvents,y=i.eventDrop,b=i.getDaySegmentContainer,w=i.getHoverListener,D=i.renderDayOverlay,M=i.clearOverlays,S=i.getRowCnt,E=i.getColCnt,x=i.renderDaySegs,H=i.resizableDayEvent}function oe(t,e){function n(t,e){e&&c(t,7*e);var n=c(d(t),-((t.getDay()-a("firstDay")+7)%7)),s=c(d(n),7),l=d(n),u=d(s),f=a("weekends");f||(h(l),h(u,-1,!0)),r.title=i(l,c(d(u),-1),a("titleFormat")),r.start=n,r.end=s,r.visStart=l,r.visEnd=u,o(f?7:5)}var r=this;r.render=n,se.call(r,t,e,"agendaWeek");var a=r.opt,o=r.renderAgenda,i=e.formatDates}function ie(t,e){function n(t,e){e&&(c(t,e),a("weekends")||h(t,0>e?-1:1));var n=d(t,!0),s=c(d(n),1);r.title=i(t,a("titleFormat")),r.start=r.visStart=n,r.end=r.visEnd=s,o(1)}var r=this;r.render=n,se.call(r,t,e,"agendaDay");var a=r.opt,o=r.renderAgenda,i=e.formatDate}function se(n,r,a){function o(t){Le=t,i(),te?nn():s(),l()}function i(){Ye=tn("theme")?"ui":"fc",Pe=tn("weekends")?0:1,je=tn("firstDay"),(Je=tn("isRTL"))?(Ve=-1,Xe=Le-1):(Ve=1,Xe=0),Ue=b(tn("minTime")),Ze=b(tn("maxTime")),$e=tn("columnFormat"),Qe=tn("weekNumbers"),Ge=tn("weekNumberTitle"),Ke="iso"!=tn("weekNumberCalculation")?"w":"W",Ne=tn("snapMinutes")||tn("slotMinutes")}function s(){var e,r,a,o,i,s=Ye+"-widget-header",c=Ye+"-widget-content",l=0==tn("slotMinutes")%15;for(e="",e+=Qe?" | ":" | ",r=0;Le>r;r++)e+=" | ";for(e+=" | "+" "+""+""+""+" | ",r=0;Le>r;r++)e+=""+""+" | ";for(e+=" | "+" "+""+" ",te=t(e).appendTo(n),ee=te.find("thead"),ne=ee.find("th").slice(1,-1),re=te.find("tbody"),ae=re.find("td").slice(0,-1),oe=ae.find("div.fc-day-content div"),ie=ae.eq(0),se=ie.find("> div"),Z(ee.add(ee.find("tr"))),Z(re.add(re.find("tr"))),Se=ee.find("th:first"),Ee=te.find(".fc-agenda-gutter"),le=t("").appendTo(n),tn("allDaySlot")?(fe=t("").appendTo(le),e=""+tn("allDayText")+" | "+""+""+" | "+" | "+" "+" ",pe=t(e).appendTo(le),ye=pe.find("tr"),D(ye.find("td")),Se=Se.add(pe.find("th:first")),Ee=Ee.add(pe.find("th.fc-agenda-gutter")),le.append("")):fe=t([]),be=t("").appendTo(le),we=t("").appendTo(be),De=t("").appendTo(we),e="",a=v(),o=u(d(a),Ze),u(a,Ue),_e=0,r=0;o>a;r++)i=a.getMinutes(),e+=""+""+(l&&i?" ":un(a,tn("axisFormat")))+" | "+""+" "+" | "+" ",u(a,tn("slotMinutes")),_e++;e+=" ",Me=t(e).appendTo(we),Ce=Me.find("div:first"),M(Me.find("td")),Se=Se.add(Me.find("th:first"))}function l(){var t,e,n,r,a=f(new Date);if(Qe){var o=un(N(0),Ke);Je?o+=Ge:o=Ge+o,ee.find(".fc-week-number").text(o)}for(t=0;Le>t;t++)r=N(t),e=ne.eq(t),e.html(un(r,$e)),n=ae.eq(t),+r==+a?n.addClass(Ye+"-state-highlight fc-today"):n.removeClass(Ye+"-state-highlight fc-today"),$(e.add(n),r)}function h(t,n){t===e&&(t=ke),ke=t,fn={};var r=re.position().top,a=be.position().top,o=Math.min(t-r,Me.height()+a+1);se.height(o-L(ie)),le.css("top",r),be.height(o-a-1),Re=Ce.height()+1,We=tn("slotMinutes")/Ne,Ae=Re/We,n&&m()}function p(e){Te=e,qe.clear(),He=0,z(Se.width("").each(function(e,n){He=Math.max(He,t(n).outerWidth())}),He);var n=be[0].clientWidth;Fe=be.width()-n,Fe?(z(Ee,Fe),Ee.show().prev().removeClass("fc-last")):Ee.hide().prev().addClass("fc-last"),ze=Math.floor((n-He)/Le),z(ne.slice(0,-1),ze)}function m(){function t(){be.scrollTop(r)}var e=v(),n=d(e);n.setHours(tn("firstHour"));var r=_(e,n)+1;t(),setTimeout(t,0)}function y(){Ie=be.scrollTop()}function w(){be.scrollTop(Ie)}function D(t){t.click(C).mousedown(cn)}function M(t){t.click(C).mousedown(V)}function C(t){if(!tn("selectable")){var e=Math.min(Le-1,Math.floor((t.pageX-te.offset().left-He)/ze)),n=N(e),r=this.parentNode.className.match(/fc-slot(\d+)/);if(r){var a=parseInt(r[1])*tn("slotMinutes"),o=Math.floor(a/60);n.setHours(o),n.setMinutes(a%60+Ue),en("dayClick",ae[e],n,!1,t)}else en("dayClick",ae[e],n,!0,t)}}function S(t,e,n){n&&Oe.build();var r,a,o=d(K.visStart);Je?(r=g(e,o)*Ve+Xe+1,a=g(t,o)*Ve+Xe+1):(r=g(t,o),a=g(e,o)),r=Math.max(0,r),a=Math.min(Le,a),a>r&&D(E(0,r,0,a-1))}function E(t,e,n,r){var a=Oe.rect(t,e,n,r,le);return rn(a,le)}function x(t,e){for(var n=d(K.visStart),r=c(d(n),1),a=0;Le>a;a++){var o=new Date(Math.max(n,t)),i=new Date(Math.min(r,e));if(i>o){var s=a*Ve+Xe,l=Oe.rect(0,s,0,s,we),u=_(n,o),f=_(n,i);l.top=u,l.height=f-u,M(rn(l,we))}c(n,1),c(r,1)}}function T(t){return qe.left(t)}function k(t){return qe.right(t)}function H(t){return{row:Math.floor(g(t,K.visStart)/7),col:A(t.getDay())}}function R(t){var e=N(t.col),n=t.row;return tn("allDaySlot")&&n--,n>=0&&u(e,Ue+n*Ne),e}function N(t){return c(d(K.visStart),t*Ve+Xe)}function W(t){return tn("allDaySlot")&&!t.row}function A(t){return(t-Math.max(je,Pe)+Le)%Le*Ve+Xe}function _(t,n){if(t=d(t,!0),u(d(t),Ue)>n)return 0;if(n>=u(d(t),Ze))return Me.height();var r=tn("slotMinutes"),a=60*n.getHours()+n.getMinutes()-Ue,o=Math.floor(a/r),i=fn[o];return i===e&&(i=fn[o]=Me.find("tr:eq("+o+") td div")[0].offsetTop),Math.max(0,Math.round(i-1+Re*(a%r/r)))}function O(){return{left:He,right:Te-Fe}}function B(){return ye}function q(t){var e=d(t.start);return t.allDay?e:u(e,tn("defaultEventMinutes"))}function I(t,e){return e?d(t):u(d(t),tn("slotMinutes"))}function j(t,e,n){n?tn("allDaySlot")&&S(t,c(d(e),1),!0):P(t,e)}function P(e,n){var r=tn("selectHelper");if(Oe.build(),r){var a=g(e,K.visStart)*Ve+Xe;if(a>=0&&Le>a){var o=Oe.rect(0,a,0,a,we),i=_(e,e),s=_(e,n);if(s>i){if(o.top=i,o.height=s-i,o.left+=2,o.width-=5,t.isFunction(r)){var c=r(e,n);c&&(o.position="absolute",o.zIndex=8,xe=t(c).css(o).appendTo(we))}else o.isStart=!0,o.isEnd=!0,xe=t(ln({title:"",start:e,end:n,className:["fc-select-helper"],editable:!1},o)),xe.css("opacity",tn("dragOpacity"));xe&&(M(xe),we.append(xe),z(xe,o.width,!0),F(xe,o.height,!0))}}}else x(e,n)}function J(){an(),xe&&(xe.remove(),xe=null)}function V(e){if(1==e.which&&tn("selectable")){sn(e);var n;Be.start(function(t,e){if(J(),t&&t.col==e.col&&!W(t)){var r=R(e),a=R(t);n=[r,u(d(r),Ne),a,u(d(a),Ne)].sort(Y),P(n[0],n[3])}else n=null},e),t(document).one("mouseup",function(t){Be.stop(),n&&(+n[0]==+n[1]&&X(n[0],!1,t),on(n[0],n[3],!1,t))})}}function X(t,e,n){en("dayClick",ae[A(t.getDay())],t,e,n)}function Q(t,e){Be.start(function(t){if(an(),t)if(W(t))E(t.row,t.col,t.row,t.col);else{var e=R(t),n=u(d(e),tn("defaultEventMinutes"));x(e,n)}},e)}function G(t,e,n){var r=Be.stop();an(),r&&en("drop",t,R(r),W(r),e,n)}var K=this;K.renderAgenda=o,K.setWidth=p,K.setHeight=h,K.beforeHide=y,K.afterShow=w,K.defaultEventEnd=q,K.timePosition=_,K.dayOfWeekCol=A,K.dateCell=H,K.cellDate=R,K.cellIsAllDay=W,K.allDayRow=B,K.allDayBounds=O,K.getHoverListener=function(){return Be},K.colContentLeft=T,K.colContentRight=k,K.getDaySegmentContainer=function(){return fe},K.getSlotSegmentContainer=function(){return De},K.getMinMinute=function(){return Ue},K.getMaxMinute=function(){return Ze},K.getBodyContent=function(){return we},K.getRowCnt=function(){return 1},K.getColCnt=function(){return Le},K.getColWidth=function(){return ze},K.getSnapHeight=function(){return Ae},K.getSnapMinutes=function(){return Ne},K.defaultSelectionEnd=I,K.renderDayOverlay=S,K.renderSelection=j,K.clearSelection=J,K.reportDayClick=X,K.dragStart=Q,K.dragStop=G,ue.call(K,n,r,a),ve.call(K),de.call(K),ce.call(K);var te,ee,ne,re,ae,oe,ie,se,le,fe,pe,ye,be,we,De,Me,Ce,Se,Ee,xe,Te,ke,He,ze,Fe,Re,Ne,We,Ae,Le,_e,Oe,Be,qe,Ie,Ye,je,Pe,Je,Ve,Xe,Ue,Ze,$e,Qe,Ge,Ke,tn=K.opt,en=K.trigger,nn=K.clearEvents,rn=K.renderOverlay,an=K.clearOverlays,on=K.reportSelection,sn=K.unselect,cn=K.daySelectionMousedown,ln=K.slotSegHtml,un=r.formatDate,fn={};U(n.addClass("fc-agenda")),Oe=new he(function(e,n){function r(t){return Math.max(c,Math.min(l,t))}var a,o,i;ne.each(function(e,r){a=t(r),o=a.offset().left,e&&(i[1]=o),i=[o],n[e]=i}),i[1]=o+a.outerWidth(),tn("allDaySlot")&&(a=ye,o=a.offset().top,e[0]=[o,o+a.outerHeight()]);for(var s=we.offset().top,c=be.offset().top,l=c+be.outerHeight(),u=0;_e*We>u;u++)e.push([r(s+Ae*u),r(s+Ae*(u+1))])}),Be=new ge(Oe),qe=new me(function(t){return oe.eq(t)})}function ce(){function n(t,e){S(t);var n,r=t.length,i=[],c=[];for(n=0;r>n;n++)t[n].allDay?i.push(t[n]):c.push(t[n]);y("allDaySlot")&&(Y(a(i),e),z()),s(o(c),e),b("eventAfterAllRender")}function r(){E(),N().empty(),W().empty()}function a(e){var n,r,a,o,i=k(T(e,t.map(e,C),m.visStart,m.visEnd)),s=i.length,c=[];for(n=0;s>n;n++)for(r=i[n],a=0;r.length>a;a++)o=r[a],o.row=0,o.level=n,c.push(o);return c}function o(e){var n,r,a,o,s,l,f=P(),v=O(),h=_(),g=u(d(m.visStart),v),p=t.map(e,i),y=[];for(n=0;f>n;n++){for(r=k(T(e,p,g,u(d(g),h-v))),le(r),a=0;r.length>a;a++)for(o=r[a],s=0;o.length>s;s++)l=o[s],l.col=n,l.level=a,y.push(l);c(g,1,!0)}return y}function i(t){return t.end?d(t.end):u(d(t.start),y("defaultEventMinutes"))}function s(n,r){var a,o,i,s,c,u,f,d,h,g,p,m,w,D,M,C,S,E,x,T,k,z,F=n.length,N="",A={},_={},O=W(),Y=P();for((T=y("isRTL"))?(k=-1,z=Y-1):(k=1,z=0),a=0;F>a;a++)o=n[a],i=o.event,s=B(o.start,o.start),c=B(o.start,o.end),u=o.col,f=o.level,d=o.forward||0,h=q(u*k+z),g=I(u*k+z)-h,g=Math.min(g-6,.95*g),p=f?g/(f+d+1):d?2*(g/(d+1)-6):g,m=h+g/(f+d+1)*f*k+(T?g-p:0),o.top=s,o.left=m,o.outerWidth=p,o.outerHeight=c-s,N+=l(i,o);
-for(O[0].innerHTML=N,w=O.children(),a=0;F>a;a++)o=n[a],i=o.event,D=t(w[a]),M=b("eventRender",i,i,D),M===!1?D.remove():(M&&M!==!0&&(D.remove(),D=t(M).css({position:"absolute",top:o.top,left:o.left}).appendTo(O)),o.element=D,i._id===r?v(i,D,o):D[0]._fci=a,G(i,D));for(H(O,n,v),a=0;F>a;a++)o=n[a],(D=o.element)&&(S=A[C=o.key=X(D[0])],o.vsides=S===e?A[C]=L(D,!0):S,S=_[C],o.hsides=S===e?_[C]=R(D,!0):S,E=D.find(".fc-event-title"),E.length&&(o.contentTop=E[0].offsetTop));for(a=0;F>a;a++)o=n[a],(D=o.element)&&(D[0].style.width=Math.max(0,o.outerWidth-o.hsides)+"px",x=Math.max(0,o.outerHeight-o.vsides),D[0].style.height=x+"px",i=o.event,o.contentTop!==e&&10>x-o.contentTop&&(D.find("div.fc-event-time").text(ie(i.start,y("timeFormat"))+" - "+i.title),D.find("div.fc-event-title").remove()),b("eventAfterRender",i,i,D))}function l(t,e){var n="<",r=t.url,a=Q(t,y),o=["fc-event","fc-event-vert"];return w(t)&&o.push("fc-event-draggable"),e.isStart&&o.push("fc-event-start"),e.isEnd&&o.push("fc-event-end"),o=o.concat(t.className),t.source&&(o=o.concat(t.source.className||[])),n+=r?"a href='"+V(t.url)+"'":"div",n+=" class='"+o.join(" ")+"'"+" style='position:absolute;z-index:8;top:"+e.top+"px;left:"+e.left+"px;"+a+"'"+">"+""+" "+V(se(t.start,t.end,y("timeFormat")))+" "+" "+V(t.title)+" "+" "+"",e.isEnd&&D(t)&&(n+="= "),n+=""+(r?"a":"div")+">"}function f(t,e,n){w(t)&&h(t,e,n.isStart),n.isEnd&&D(t)&&j(t,e,n),x(t,e)}function v(t,e,n){var r=e.find("div.fc-event-time");w(t)&&g(t,e,r),n.isEnd&&D(t)&&p(t,e,r),x(t,e)}function h(t,e,n){function r(){s||(e.width(a).height("").draggable("option","grid",null),s=!0)}var a,o,i,s=!0,l=y("isRTL")?-1:1,u=A(),f=J(),v=U(),h=Z(),g=O();e.draggable({zIndex:9,opacity:y("dragOpacity","month"),revertDuration:y("dragRevertDuration"),start:function(g,p){b("eventDragStart",e,t,g,p),te(t,e),a=e.width(),u.start(function(a,u,g,p){ae(),a?(o=!1,i=p*l,a.row?n?s&&(e.width(f-10),F(e,v*Math.round((t.end?(t.end-t.start)/Te:y("defaultEventMinutes"))/h)),e.draggable("option","grid",[f,1]),s=!1):o=!0:(re(c(d(t.start),i),c(C(t),i)),r()),o=o||s&&!i):(r(),o=!0),e.draggable("option","revert",o)},g,"drag")},stop:function(n,a){if(u.stop(),ae(),b("eventDragStop",e,t,n,a),o)r(),e.css("filter",""),K(t,e);else{var c=0;s||(c=Math.round((e.offset().top-$().offset().top)/v)*h+g-(60*t.start.getHours()+t.start.getMinutes())),ee(this,t,i,c,s,n,a)}}})}function g(t,e,n){function r(e){var r,a=u(d(t.start),e);t.end&&(r=u(d(t.end),e)),n.text(se(a,r,y("timeFormat")))}function a(){f&&(n.css("display",""),e.draggable("option","grid",[p,m]),f=!1)}var o,i,s,l,f=!1,v=y("isRTL")?-1:1,h=A(),g=P(),p=J(),m=U(),w=Z();e.draggable({zIndex:9,scroll:!1,grid:[p,m],axis:1==g?"y":!1,opacity:y("dragOpacity"),revertDuration:y("dragRevertDuration"),start:function(r,u){b("eventDragStart",e,t,r,u),te(t,e),o=e.position(),s=l=0,h.start(function(r,o,s,l){e.draggable("option","revert",!r),ae(),r&&(i=l*v,y("allDaySlot")&&!r.row?(f||(f=!0,n.hide(),e.draggable("option","grid",null)),re(c(d(t.start),i),c(C(t),i))):a())},r,"drag")},drag:function(t,e){s=Math.round((e.position.top-o.top)/m)*w,s!=l&&(f||r(s),l=s)},stop:function(n,c){var l=h.stop();ae(),b("eventDragStop",e,t,n,c),l&&(i||s||f)?ee(this,t,i,f?0:s,f,n,c):(a(),e.css("filter",""),e.css(o),r(0),K(t,e))}})}function p(t,e,n){var r,a,o=U(),i=Z();e.resizable({handles:{s:".ui-resizable-handle"},grid:o,start:function(n,o){r=a=0,te(t,e),e.css("z-index",9),b("eventResizeStart",this,t,n,o)},resize:function(s,c){r=Math.round((Math.max(o,e.height())-c.originalSize.height)/o),r!=a&&(n.text(se(t.start,r||t.end?u(M(t),i*r):null,y("timeFormat"))),a=r)},stop:function(n,a){b("eventResizeStop",this,t,n,a),r?ne(this,t,0,i*r,n,a):(e.css("z-index",8),K(t,e))}})}var m=this;m.renderEvents=n,m.compileDaySegs=a,m.clearEvents=r,m.slotSegHtml=l,m.bindDaySeg=f,fe.call(m);var y=m.opt,b=m.trigger,w=m.isEventDraggable,D=m.isEventResizable,M=m.eventEnd,S=m.reportEvents,E=m.reportEventClear,x=m.eventElementHandlers,z=m.setHeight,N=m.getDaySegmentContainer,W=m.getSlotSegmentContainer,A=m.getHoverListener,_=m.getMaxMinute,O=m.getMinMinute,B=m.timePosition,q=m.colContentLeft,I=m.colContentRight,Y=m.renderDaySegs,j=m.resizableDayEvent,P=m.getColCnt,J=m.getColWidth,U=m.getSnapHeight,Z=m.getSnapMinutes,$=m.getBodyContent,G=m.reportEventElement,K=m.showEvents,te=m.hideEvents,ee=m.eventDrop,ne=m.eventResize,re=m.renderDayOverlay,ae=m.clearOverlays,oe=m.calendar,ie=oe.formatDate,se=oe.formatDates}function le(t){var e,n,r,a,o,i;for(e=t.length-1;e>0;e--)for(a=t[e],n=0;a.length>n;n++)for(o=a[n],r=0;t[e-1].length>r;r++)i=t[e-1][r],x(o,i)&&(i.forward=Math.max(i.forward||0,(o.forward||0)+1))}function ue(t,n,r){function a(t,e){var n=F[t];return"object"==typeof n?J(n,e||r):n}function o(t,e){return n.trigger.apply(n,[t,e||S].concat(Array.prototype.slice.call(arguments,2),[S]))}function i(t){return l(t)&&!a("disableDragging")}function s(t){return l(t)&&!a("disableResizing")}function l(t){return K(t.editable,(t.source||{}).editable,a("editable"))}function f(t){k={};var e,n,r=t.length;for(e=0;r>e;e++)n=t[e],k[n._id]?k[n._id].push(n):k[n._id]=[n]}function v(t){return t.end?d(t.end):E(t)}function h(t,e){H.push(e),z[t._id]?z[t._id].push(e):z[t._id]=[e]}function g(){H=[],z={}}function p(t,n){n.click(function(r){return n.hasClass("ui-draggable-dragging")||n.hasClass("ui-resizable-resizing")?e:o("eventClick",this,t,r)}).hover(function(e){o("eventMouseover",this,t,e)},function(e){o("eventMouseout",this,t,e)})}function m(t,e){b(t,e,"show")}function y(t,e){b(t,e,"hide")}function b(t,e,n){var r,a=z[t._id],o=a.length;for(r=0;o>r;r++)e&&a[r][0]==e[0]||a[r][n]()}function w(t,e,n,r,a,i,s){var c=e.allDay,l=e._id;M(k[l],n,r,a),o("eventDrop",t,e,n,r,a,function(){M(k[l],-n,-r,c),T(l)},i,s),T(l)}function D(t,e,n,r,a,i){var s=e._id;C(k[s],n,r),o("eventResize",t,e,n,r,function(){C(k[s],-n,-r),T(s)},a,i),T(s)}function M(t,n,r,a){r=r||0;for(var o,i=t.length,s=0;i>s;s++)o=t[s],a!==e&&(o.allDay=a),u(c(o.start,n,!0),r),o.end&&(o.end=u(c(o.end,n,!0),r)),x(o,F)}function C(t,e,n){n=n||0;for(var r,a=t.length,o=0;a>o;o++)r=t[o],r.end=u(c(v(r),e,!0),n),x(r,F)}var S=this;S.element=t,S.calendar=n,S.name=r,S.opt=a,S.trigger=o,S.isEventDraggable=i,S.isEventResizable=s,S.reportEvents=f,S.eventEnd=v,S.reportEventElement=h,S.reportEventClear=g,S.eventElementHandlers=p,S.showEvents=m,S.hideEvents=y,S.eventDrop=w,S.eventResize=D;var E=S.defaultEventEnd,x=n.normalizeEvent,T=n.reportEventChange,k={},H=[],z={},F=n.options}function fe(){function n(t,e){var n,r,c,d,p,m,y,b,w=B(),D=T(),M=k(),C=0,S=t.length;for(w[0].innerHTML=a(t),o(t,w.children()),i(t),s(t,w,e),l(t),u(t),f(t),n=v(),r=0;D>r;r++){for(c=0,d=[],p=0;M>p;p++)d[p]=0;for(;S>C&&(m=t[C]).row==r;){for(y=j(d.slice(m.startCol,m.endCol)),m.top=y,y+=m.outerHeight,b=m.startCol;m.endCol>b;b++)d[b]=y;C++}n[r].height(j(d))}g(t,h(n))}function r(e,n,r){var i,s,c,d=t(""),p=B(),m=e.length;for(d[0].innerHTML=a(e),i=d.children(),p.append(i),o(e,i),l(e),u(e),f(e),g(e,h(v())),i=[],s=0;m>s;s++)c=e[s].element,c&&(e[s].row===n&&c.css("top",r),i.push(c[0]));return t(i)}function a(t){var e,n,r,a,o,i,s,c,l,u,f=y("isRTL"),d=t.length,v=F(),h=v.left,g=v.right,p="";for(e=0;d>e;e++)n=t[e],r=n.event,o=["fc-event","fc-event-hori"],w(r)&&o.push("fc-event-draggable"),n.isStart&&o.push("fc-event-start"),n.isEnd&&o.push("fc-event-end"),f?(i=A(n.end.getDay()-1),s=A(n.start.getDay()),c=n.isEnd?N(i):h,l=n.isStart?W(s):g):(i=A(n.start.getDay()),s=A(n.end.getDay()-1),c=n.isStart?N(i):h,l=n.isEnd?W(s):g),o=o.concat(r.className),r.source&&(o=o.concat(r.source.className||[])),a=r.url,u=Q(r,y),p+=a?""+"",!r.allDay&&n.isStart&&(p+=""+V(I(r.start,r.end,y("timeFormat")))+""),p+=""+V(r.title)+""+" ",n.isEnd&&D(r)&&(p+=""+" "+" "),p+=""+(a?"a":"div")+">",n.left=c,n.outerWidth=l-c,n.startCol=i,n.endCol=s+1;return p}function o(e,n){var r,a,o,i,s,c=e.length;for(r=0;c>r;r++)a=e[r],o=a.event,i=t(n[r]),s=b("eventRender",o,o,i),s===!1?i.remove():(s&&s!==!0&&(s=t(s).css({position:"absolute",left:a.left}),i.replaceWith(s),i=s),a.element=i)}function i(t){var e,n,r,a=t.length;for(e=0;a>e;e++)n=t[e],r=n.element,r&&C(n.event,r)}function s(t,e,n){var r,a,o,i,s=t.length;for(r=0;s>r;r++)a=t[r],o=a.element,o&&(i=a.event,i._id===n?q(i,o,a):o[0]._fci=r);H(e,t,q)}function l(t){var n,r,a,o,i,s=t.length,c={};for(n=0;s>n;n++)r=t[n],a=r.element,a&&(o=r.key=X(a[0]),i=c[o],i===e&&(i=c[o]=R(a,!0)),r.hsides=i)}function u(t){var e,n,r,a=t.length;for(e=0;a>e;e++)n=t[e],r=n.element,r&&(r[0].style.width=Math.max(0,n.outerWidth-n.hsides)+"px")}function f(t){var n,r,a,o,i,s=t.length,c={};for(n=0;s>n;n++)r=t[n],a=r.element,a&&(o=r.key,i=c[o],i===e&&(i=c[o]=O(a)),r.outerHeight=a[0].offsetHeight+i)}function v(){var t,e=T(),n=[];for(t=0;e>t;t++)n[t]=z(t).find("div.fc-day-content > div");return n}function h(t){var e,n=t.length,r=[];for(e=0;n>e;e++)r[e]=t[e][0].offsetTop;return r}function g(t,e){var n,r,a,o,i=t.length;for(n=0;i>n;n++)r=t[n],a=r.element,a&&(a[0].style.top=e[r.row]+(r.top||0)+"px",o=r.event,b("eventAfterRender",o,o,a))}function p(e,n,a){var o=y("isRTL"),i=o?"w":"e",s=n.find(".ui-resizable-"+i),l=!1;U(n),n.mousedown(function(t){t.preventDefault()}).click(function(t){l&&(t.preventDefault(),t.stopImmediatePropagation())}),s.mousedown(function(s){function u(n){b("eventResizeStop",this,e,n),t("body").css("cursor",""),h.stop(),P(),f&&x(this,e,f,0,n),setTimeout(function(){l=!1},0)}if(1==s.which){l=!0;var f,v,h=m.getHoverListener(),g=T(),p=k(),y=o?-1:1,w=o?p-1:0,D=n.css("top"),C=t.extend({},e),H=L(e.start);J(),t("body").css("cursor",i+"-resize").one("mouseup",u),b("eventResizeStart",this,e,s),h.start(function(t,n){if(t){var s=Math.max(H.row,t.row),l=t.col;1==g&&(s=0),s==H.row&&(l=o?Math.min(H.col,l):Math.max(H.col,l)),f=7*s+l*y+w-(7*n.row+n.col*y+w);var u=c(M(e),f,!0);if(f){C.end=u;var h=v;v=r(_([C]),a.row,D),v.find("*").css("cursor",i+"-resize"),h&&h.remove(),E(e)}else v&&(S(e),v.remove(),v=null);P(),Y(e.start,c(d(u),1))}},s)}})}var m=this;m.renderDaySegs=n,m.resizableDayEvent=p;var y=m.opt,b=m.trigger,w=m.isEventDraggable,D=m.isEventResizable,M=m.eventEnd,C=m.reportEventElement,S=m.showEvents,E=m.hideEvents,x=m.eventResize,T=m.getRowCnt,k=m.getColCnt;m.getColWidth;var z=m.allDayRow,F=m.allDayBounds,N=m.colContentLeft,W=m.colContentRight,A=m.dayOfWeekCol,L=m.dateCell,_=m.compileDaySegs,B=m.getDaySegmentContainer,q=m.bindDaySeg,I=m.calendar.formatDates,Y=m.renderDayOverlay,P=m.clearOverlays,J=m.clearSelection}function de(){function e(t,e,a){n(),e||(e=c(t,a)),l(t,e,a),r(t,e,a)}function n(t){f&&(f=!1,u(),s("unselect",null,t))}function r(t,e,n,r){f=!0,s("select",null,t,e,n,r)}function a(e){var a=o.cellDate,s=o.cellIsAllDay,c=o.getHoverListener(),f=o.reportDayClick;if(1==e.which&&i("selectable")){n(e);var d;c.start(function(t,e){u(),t&&s(t)?(d=[a(e),a(t)].sort(Y),l(d[0],d[1],!0)):d=null},e),t(document).one("mouseup",function(t){c.stop(),d&&(+d[0]==+d[1]&&f(d[0],!0,t),r(d[0],d[1],!0,t))})}}var o=this;o.select=e,o.unselect=n,o.reportSelection=r,o.daySelectionMousedown=a;var i=o.opt,s=o.trigger,c=o.defaultSelectionEnd,l=o.renderSelection,u=o.clearSelection,f=!1;i("selectable")&&i("unselectAuto")&&t(document).mousedown(function(e){var r=i("unselectCancel");r&&t(e.target).parents(r).length||n(e)})}function ve(){function e(e,n){var r=o.shift();return r||(r=t("")),r[0].parentNode!=n[0]&&r.appendTo(n),a.push(r.css(e).show()),r}function n(){for(var t;t=a.shift();)o.push(t.hide().unbind())}var r=this;r.renderOverlay=e,r.clearOverlays=n;var a=[],o=[]}function he(t){var e,n,r=this;r.build=function(){e=[],n=[],t(e,n)},r.cell=function(t,r){var a,o=e.length,i=n.length,s=-1,c=-1;for(a=0;o>a;a++)if(r>=e[a][0]&&e[a][1]>r){s=a;break}for(a=0;i>a;a++)if(t>=n[a][0]&&n[a][1]>t){c=a;break}return s>=0&&c>=0?{row:s,col:c}:null},r.rect=function(t,r,a,o,i){var s=i.offset();return{top:e[t][0]-s.top,left:n[r][0]-s.left,width:n[o][1]-n[r][0],height:e[a][1]-e[t][0]}}}function ge(e){function n(t){pe(t);var n=e.cell(t.pageX,t.pageY);(!n!=!i||n&&(n.row!=i.row||n.col!=i.col))&&(n?(o||(o=n),a(n,o,n.row-o.row,n.col-o.col)):a(n,o),i=n)}var r,a,o,i,s=this;s.start=function(s,c,l){a=s,o=i=null,e.build(),n(c),r=l||"mousemove",t(document).bind(r,n)},s.stop=function(){return t(document).unbind(r,n),i}}function pe(t){t.pageX===e&&(t.pageX=t.originalEvent.pageX,t.pageY=t.originalEvent.pageY)}function me(t){function n(e){return a[e]=a[e]||t(e)}var r=this,a={},o={},i={};r.left=function(t){return o[t]=o[t]===e?n(t).position().left:o[t]},r.right=function(t){return i[t]=i[t]===e?r.left(t)+n(t).width():i[t]},r.clear=function(){a={},o={},i={}}}var ye={defaultView:"month",aspectRatio:1.35,header:{left:"title",center:"",right:"today prev,next"},weekends:!0,weekNumbers:!1,weekNumberCalculation:"iso",weekNumberTitle:"W",allDayDefault:!0,ignoreTimezone:!0,lazyFetching:!0,startParam:"start",endParam:"end",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:{"":"h(:mm)t"},isRTL:!1,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"},theme:!1,buttonIcons:{prev:"circle-triangle-w",next:"circle-triangle-e"},unselectAuto:!0,dropAccept:"*"},be={header:{left:"next,prev today",center:"",right:"title"},buttonText:{prev:"›",next:"‹",prevYear:"»",nextYear:"«"},buttonIcons:{prev:"circle-triangle-e",next:"circle-triangle-w"}},we=t.fullCalendar={version:"1.6.0"},De=we.views={};t.fn.fullCalendar=function(n){if("string"==typeof n){var a,o=Array.prototype.slice.call(arguments,1);return this.each(function(){var r=t.data(this,"fullCalendar");if(r&&t.isFunction(r[n])){var i=r[n].apply(r,o);a===e&&(a=i),"destroy"==n&&t.removeData(this,"fullCalendar")}}),a!==e?a:this}var i=n.eventSources||[];return delete n.eventSources,n.events&&(i.push(n.events),delete n.events),n=t.extend(!0,{},ye,n.isRTL||n.isRTL===e&&ye.isRTL?be:{},n),this.each(function(e,a){var o=t(a),s=new r(o,n,i);o.data("fullCalendar",s),s.render()}),this},we.sourceNormalizers=[],we.sourceFetchers=[];var Me={dataType:"json",cache:!1},Ce=1;we.addDays=c,we.cloneDate=d,we.parseDate=m,we.parseISO8601=y,we.parseTime=b,we.formatDate=w,we.formatDates=D;var Se=["sun","mon","tue","wed","thu","fri","sat"],Ee=864e5,xe=36e5,Te=6e4,ke={s:function(t){return t.getSeconds()},ss:function(t){return P(t.getSeconds())},m:function(t){return t.getMinutes()},mm:function(t){return P(t.getMinutes())},h:function(t){return t.getHours()%12||12},hh:function(t){return P(t.getHours()%12||12)},H:function(t){return t.getHours()},HH:function(t){return P(t.getHours())},d:function(t){return t.getDate()},dd:function(t){return P(t.getDate())},ddd:function(t,e){return e.dayNamesShort[t.getDay()]},dddd:function(t,e){return e.dayNames[t.getDay()]},M:function(t){return t.getMonth()+1},MM:function(t){return P(t.getMonth()+1)},MMM:function(t,e){return e.monthNamesShort[t.getMonth()]},MMMM:function(t,e){return e.monthNames[t.getMonth()]},yy:function(t){return(t.getFullYear()+"").substring(2)},yyyy:function(t){return t.getFullYear()},t:function(t){return 12>t.getHours()?"a":"p"},tt:function(t){return 12>t.getHours()?"am":"pm"},T:function(t){return 12>t.getHours()?"A":"P"},TT:function(t){return 12>t.getHours()?"AM":"PM"},u:function(t){return w(t,"yyyy-MM-dd'T'HH:mm:ss'Z'")},S:function(t){var e=t.getDate();return e>10&&20>e?"th":["st","nd","rd"][e%10-1]||"th"},w:function(t,e){return e.weekNumberCalculation(t)},W:function(t){return M(t)}};we.dateFormatters=ke,we.applyAll=G,De.month=te,De.basicWeek=ee,De.basicDay=ne,n({weekMode:"fixed"}),De.agendaWeek=oe,De.agendaDay=ie,n({allDaySlot:!0,allDayText:"all-day",firstHour:6,slotMinutes:30,defaultEventMinutes:120,axisFormat:"h(:mm)tt",timeFormat:{agenda:"h:mm{ - h:mm}"},dragOpacity:{agenda:.5},minTime:0,maxTime:24})})(jQuery);
\ No newline at end of file
+!function(a){"function"==typeof define&&define.amd?define(["jquery","moment"],a):"object"==typeof exports?module.exports=a(require("jquery"),require("moment")):a(jQuery,moment)}(function(a,b){function c(a){return Q(a,Ra)}function d(b){var c,d={views:b.views||{}};return a.each(b,function(b,e){"views"!=b&&(a.isPlainObject(e)&&!/(time|duration|interval)$/i.test(b)&&-1==a.inArray(b,Ra)?(c=null,a.each(e,function(a,e){/^(month|week|day|default|basic(Week|Day)?|agenda(Week|Day)?)$/.test(a)?(d.views[a]||(d.views[a]={}),d.views[a][b]=e):(c||(c={}),c[a]=e)}),c&&(d[b]=c)):d[b]=e)}),d}function e(a,b){b.left&&a.css({"border-left-width":1,"margin-left":b.left-1}),b.right&&a.css({"border-right-width":1,"margin-right":b.right-1})}function f(a){a.css({"margin-left":"","margin-right":"","border-left-width":"","border-right-width":""})}function g(){a("body").addClass("fc-not-allowed")}function h(){a("body").removeClass("fc-not-allowed")}function i(b,c,d){var e=Math.floor(c/b.length),f=Math.floor(c-e*(b.length-1)),g=[],h=[],i=[],k=0;j(b),b.each(function(c,d){var j=c===b.length-1?f:e,l=a(d).outerHeight(!0);j>l?(g.push(d),h.push(l),i.push(a(d).height())):k+=l}),d&&(c-=k,e=Math.floor(c/g.length),f=Math.floor(c-e*(g.length-1))),a(g).each(function(b,c){var d=b===g.length-1?f:e,j=h[b],k=i[b],l=d-(j-k);d>j&&a(c).height(l)})}function j(a){a.height("")}function k(b){var c=0;return b.find("> *").each(function(b,d){var e=a(d).outerWidth();e>c&&(c=e)}),c++,b.width(c),c}function l(a,b){return a.height(b).addClass("fc-scroller"),a[0].scrollHeight-1>a[0].clientHeight?!0:(m(a),!1)}function m(a){a.height("").removeClass("fc-scroller")}function n(b){var c=b.css("position"),d=b.parents().filter(function(){var b=a(this);return/(auto|scroll)/.test(b.css("overflow")+b.css("overflow-y")+b.css("overflow-x"))}).eq(0);return"fixed"!==c&&d.length?d:a(b[0].ownerDocument||document)}function o(a){var b=a.offset();return{left:b.left,right:b.left+a.outerWidth(),top:b.top,bottom:b.top+a.outerHeight()}}function p(a){var b=a.offset(),c=r(a),d=b.left+u(a,"border-left-width")+c.left,e=b.top+u(a,"border-top-width")+c.top;return{left:d,right:d+a[0].clientWidth,top:e,bottom:e+a[0].clientHeight}}function q(a){var b=a.offset(),c=b.left+u(a,"border-left-width")+u(a,"padding-left"),d=b.top+u(a,"border-top-width")+u(a,"padding-top");return{left:c,right:c+a.width(),top:d,bottom:d+a.height()}}function r(a){var b=a.innerWidth()-a[0].clientWidth,c={left:0,right:0,top:0,bottom:a.innerHeight()-a[0].clientHeight};return s()&&"rtl"==a.css("direction")?c.left=b:c.right=b,c}function s(){return null===Sa&&(Sa=t()),Sa}function t(){var b=a("").css({position:"absolute",top:-1e3,left:0,border:0,padding:0,overflow:"scroll",direction:"rtl"}).appendTo("body"),c=b.children(),d=c.offset().left>b.offset().left;return b.remove(),d}function u(a,b){return parseFloat(a.css(b))||0}function v(a){return 1==a.which&&!a.ctrlKey}function w(a,b){var c={left:Math.max(a.left,b.left),right:Math.min(a.right,b.right),top:Math.max(a.top,b.top),bottom:Math.min(a.bottom,b.bottom)};return c.lefti&&j>g?(g>=i?(c=g.clone(),e=!0):(c=i.clone(),e=!1),j>=h?(d=h.clone(),f=!0):(d=j.clone(),f=!1),{start:c,end:d,isStart:e,isEnd:f}):void 0}function F(a,c){return b.duration({days:a.clone().stripTime().diff(c.clone().stripTime(),"days"),ms:a.time()-c.time()})}function G(a,c){return b.duration({days:a.clone().stripTime().diff(c.clone().stripTime(),"days")})}function H(a,c,d){return b.duration(Math.round(a.diff(c,d,!0)),d)}function I(a,b){var c,d,e;for(c=0;c=1&&ba(e)));c++);return d}function J(a,c,d){return null!=d?d.diff(c,a,!0):b.isDuration(c)?c.as(a):c.end.diff(c.start,a,!0)}function K(a,b,c){var d;return N(c)?(b-a)/c:(d=c.asMonths(),Math.abs(d)>=1&&ba(d)?b.diff(a,"months",!0)/d:b.diff(a,"days",!0)/c.asDays())}function L(a,b){var c,d;return N(a)||N(b)?a/b:(c=a.asMonths(),d=b.asMonths(),Math.abs(c)>=1&&ba(c)&&Math.abs(d)>=1&&ba(d)?c/d:a.asDays()/b.asDays())}function M(a,c){var d;return N(a)?b.duration(a*c):(d=a.asMonths(),Math.abs(d)>=1&&ba(d)?b.duration({months:d*c}):b.duration({days:a.asDays()*c}))}function N(a){return Boolean(a.hours()||a.minutes()||a.seconds()||a.milliseconds())}function O(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function P(a){return/^\d+\:\d+(?:\:\d+\.?(?:\d{3})?)?$/.test(a)}function Q(a,b){var c,d,e,f,g,h,i={};if(b)for(c=0;c=0;f--)if(g=a[f][d],"object"==typeof g)e.unshift(g);else if(void 0!==g){i[d]=g;break}e.length&&(i[d]=Q(e))}for(c=a.length-1;c>=0;c--){h=a[c];for(d in h)d in i||(i[d]=h[d])}return i}function R(a){var b=function(){};return b.prototype=a,new b}function S(a,b){for(var c in a)U(a,c)&&(b[c]=a[c])}function T(a,b){var c,d,e=["constructor","toString","valueOf"];for(c=0;c/g,">").replace(/'/g,"'").replace(/"/g,""").replace(/\n/g," ")}function Z(a){return a.replace(/&.*?;/g,"")}function $(b){var c=[];return a.each(b,function(a,b){null!=b&&c.push(a+":"+b)}),c.join(";")}function _(a){return a.charAt(0).toUpperCase()+a.slice(1)}function aa(a,b){return a-b}function ba(a){return a%1===0}function ca(a,b){var c=a[b];return function(){return c.apply(a,arguments)}}function da(a,b){var c,d,e,f,g=function(){var h=+new Date-f;b>h&&h>0?c=setTimeout(g,b-h):(c=null,a.apply(e,d),c||(e=d=null))};return function(){e=this,d=arguments,f=+new Date,c||(c=setTimeout(g,b))}}function ea(c,d,e){var f,g,h,i,j=c[0],k=1==c.length&&"string"==typeof j;return b.isMoment(j)?(i=b.apply(null,c),ga(j,i)):O(j)||void 0===j?i=b.apply(null,c):(f=!1,g=!1,k?Za.test(j)?(j+="-01",c=[j],f=!0,g=!0):(h=$a.exec(j))&&(f=!h[5],g=!0):a.isArray(j)&&(g=!0),i=d||f?b.utc.apply(b,c):b.apply(null,c),f?(i._ambigTime=!0,i._ambigZone=!0):e&&(g?i._ambigZone=!0:k&&(i.utcOffset?i.utcOffset(j):i.zone(j)))),i._fullCalendar=!0,i}function fa(a,c){var d,e,f=!1,g=!1,h=a.length,i=[];for(d=0;h>d;d++)e=a[d],b.isMoment(e)||(e=Pa.moment.parseZone(e)),f=f||e._ambigTime,g=g||e._ambigZone,i.push(e);for(d=0;h>d;d++)e=i[d],c||!f||e._ambigTime?g&&!e._ambigZone&&(i[d]=e.clone().stripZone()):i[d]=e.clone().stripTime();return i}function ga(a,b){a._ambigTime?b._ambigTime=!0:b._ambigTime&&(b._ambigTime=!1),a._ambigZone?b._ambigZone=!0:b._ambigZone&&(b._ambigZone=!1)}function ha(a,b){a.year(b[0]||0).month(b[1]||0).date(b[2]||0).hours(b[3]||0).minutes(b[4]||0).seconds(b[5]||0).milliseconds(b[6]||0)}function ia(a,b){return ab.format.call(a,b)}function ja(a,b){return ka(a,pa(b))}function ka(a,b){var c,d="";for(c=0;cg&&(f=oa(a,b,c[h]),f!==!1);h--)k=f+k;for(i=g;h>=i;i++)l+=la(a,c[i]),m+=la(b,c[i]);return(l||m)&&(n=e?m+d+l:l+d+m),j+n+k}function oa(a,b,c){var d,e;return"string"==typeof c?c:(d=c.token)&&(e=cb[d.charAt(0)],e&&a.isSame(b,e))?ia(a,d):!1}function pa(a){return a in db?db[a]:db[a]=qa(a)}function qa(a){for(var b,c=[],d=/\[([^\]]*)\]|\(([^\)]*)\)|(LTS|LT|(\w)\4*o?)|([^\w\[\(]+)/g;b=d.exec(a);)b[1]?c.push(b[1]):b[2]?c.push({maybe:qa(b[2])}):b[3]?c.push({token:b[3]}):b[5]&&c.push(b[5]);return c}function ra(){}function sa(a,b){var c;return U(b,"constructor")&&(c=b.constructor),"function"!=typeof c&&(c=b.constructor=function(){a.apply(this,arguments)}),c.prototype=R(a.prototype),S(b,c.prototype),T(b,c.prototype),S(a,c),c}function ta(a,b){S(b.prototype||b,a.prototype)}function ua(a,b){return a||b?a&&b?a.component===b.component&&va(a,b)&&va(b,a):!1:!0}function va(a,b){for(var c in a)if(!/^(component|left|right|top|bottom)$/.test(c)&&a[c]!==b[c])return!1;return!0}function wa(a){var b=ya(a);return"background"===b||"inverse-background"===b}function xa(a){return"inverse-background"===ya(a)}function ya(a){return X((a.source||{}).rendering,a.rendering)}function za(a){var b,c,d={};for(b=0;b=a.leftCol)return!0;return!1}function Da(a,b){return a.leftCol-b.leftCol}function Ea(a){var b,c,d,e=[];for(b=0;bb.top&&a.top").prependTo(c),S=N.header=new Ma(N,O),T=S.render(),T&&c.prepend(T),i(O.defaultView),O.handleWindowResize&&(Y=da(m,O.windowResizeDelay),a(window).resize(Y))}function g(){W&&W.removeElement(),S.removeElement(),U.remove(),c.removeClass("fc fc-ltr fc-rtl fc-unthemed ui-widget"),Y&&a(window).unbind("resize",Y)}function h(){return c.is(":visible")}function i(b){ca++,W&&b&&W.type!==b&&(S.deactivateButton(W.type),H(),W.removeElement(),W=N.view=null),!W&&b&&(W=N.view=ba[b]||(ba[b]=N.instantiateView(b)),W.setElement(a("").appendTo(U)),S.activateButton(b)),W&&(Z=W.massageCurrentDate(Z),W.displaying&&Z.isWithin(W.intervalStart,W.intervalEnd)||h()&&(H(),W.display(Z),I(),u(),v(),q())),I(),ca--}function j(a){return h()?(a&&l(),ca++,W.updateSize(!0),ca--,!0):void 0}function k(){h()&&l()}function l(){X="number"==typeof O.contentHeight?O.contentHeight:"number"==typeof O.height?O.height-(T?T.outerHeight(!0):0):Math.round(U.width()/Math.max(O.aspectRatio,.5))}function m(a){!ca&&a.target===window&&W.start&&j(!0)&&W.trigger("windowResize",aa)}function n(){p(),r()}function o(){h()&&(H(),W.displayEvents(ea),I())}function p(){H(),W.clearEvents(),I()}function q(){!O.lazyFetching||$(W.start,W.end)?r():o()}function r(){_(W.start,W.end)}function s(a){ea=a,o()}function t(){o()}function u(){S.updateTitle(W.title)}function v(){var a=N.getNow();a.isWithin(W.intervalStart,W.intervalEnd)?S.disableButton("today"):S.enableButton("today")}function w(a,b){W.select(N.buildSelectRange.apply(N,arguments))}function x(){W&&W.unselect()}function y(){Z=W.computePrevDate(Z),i()}function z(){Z=W.computeNextDate(Z),i()}function A(){Z.add(-1,"years"),i()}function B(){Z.add(1,"years"),i()}function C(){Z=N.getNow(),i()}function D(a){Z=N.moment(a),i()}function E(a){Z.add(b.duration(a)),i()}function F(a,b){var c;b=b||"day",c=N.getViewSpec(b)||N.getUnitViewSpec(b),Z=a,i(c?c.type:null)}function G(){return Z.clone()}function H(){U.css({width:"100%",height:U.height(),overflow:"hidden"})}function I(){U.css({width:"",height:"",overflow:""})}function J(){return N}function K(){return W}function L(a,b){return void 0===b?O[a]:void(("height"==a||"contentHeight"==a||"aspectRatio"==a)&&(O[a]=b,j(!0)))}function M(a,b){var c=Array.prototype.slice.call(arguments,2);return b=b||aa,this.triggerWith(a,b,c),O[a]?O[a].apply(b,c):void 0}var N=this;N.initOptions(d||{});var O=this.options;N.render=e,N.destroy=g,N.refetchEvents=n,N.reportEvents=s,N.reportEventChange=t,N.rerenderEvents=o,N.changeView=i,N.select=w,N.unselect=x,N.prev=y,N.next=z,N.prevYear=A,N.nextYear=B,N.today=C,N.gotoDate=D,N.incrementDate=E,N.zoomTo=F,N.getDate=G,N.getCalendar=J,N.getView=K,N.option=L,N.trigger=M;var P=R(La(O.lang));if(O.monthNames&&(P._months=O.monthNames),O.monthNamesShort&&(P._monthsShort=O.monthNamesShort),O.dayNames&&(P._weekdays=O.dayNames),O.dayNamesShort&&(P._weekdaysShort=O.dayNamesShort),null!=O.firstDay){var Q=R(P._week);Q.dow=O.firstDay,P._week=Q}P._fullCalendar_weekCalc=function(a){return"function"==typeof a?a:"local"===a?a:"iso"===a||"ISO"===a?"ISO":void 0}(O.weekNumberCalculation),N.defaultAllDayEventDuration=b.duration(O.defaultAllDayEventDuration),N.defaultTimedEventDuration=b.duration(O.defaultTimedEventDuration),N.moment=function(){var a;return"local"===O.timezone?(a=Pa.moment.apply(null,arguments),a.hasTime()&&a.local()):a="UTC"===O.timezone?Pa.moment.utc.apply(null,arguments):Pa.moment.parseZone.apply(null,arguments),"_locale"in a?a._locale=P:a._lang=P,a},N.getIsAmbigTimezone=function(){return"local"!==O.timezone&&"UTC"!==O.timezone},N.rezoneDate=function(a){return N.moment(a.toArray())},N.getNow=function(){var a=O.now;return"function"==typeof a&&(a=a()),N.moment(a)},N.getEventEnd=function(a){return a.end?a.end.clone():N.getDefaultEventEnd(a.allDay,a.start)},N.getDefaultEventEnd=function(a,b){var c=b.clone();return a?c.stripTime().add(N.defaultAllDayEventDuration):c.add(N.defaultTimedEventDuration),N.getIsAmbigTimezone()&&c.stripZone(),c},N.humanizeDuration=function(a){return(a.locale||a.lang).call(a,O.lang).humanize()},Na.call(N,O);var S,T,U,V,W,X,Y,Z,$=N.isFetchNeeded,_=N.fetchEvents,aa=c[0],ba={},ca=0,ea=[];Z=null!=O.defaultDate?N.moment(O.defaultDate):N.getNow(),N.getSuggestedViewHeight=function(){return void 0===X&&k(),X},N.isHeightAuto=function(){return"auto"===O.contentHeight||"auto"===O.height},N.initialize()}function Ka(b){a.each(tb,function(a,c){null==b[a]&&(b[a]=c(b))})}function La(a){var c=b.localeData||b.langData;return c.call(b,a)||c.call(b,"en")}function Ma(b,c){function d(){var b=c.header;return n=c.theme?"ui":"fc",b?o=a("").append(f("left")).append(f("right")).append(f("center")).append(''):void 0}function e(){o.remove(),o=a()}function f(d){var e=a(''),f=c.header[d];return f&&a.each(f.split(" "),function(d){var f,g=a(),h=!0;a.each(this.split(","),function(d,e){var f,i,j,k,l,m,o,q,r,s;"title"==e?(g=g.add(a(" ")),h=!1):((f=(b.options.customButtons||{})[e])?(j=function(a){f.click&&f.click.call(s[0],a)},k="",l=f.text):(i=b.getViewSpec(e))?(j=function(){b.changeView(e)},p.push(e),k=i.buttonTextOverride,l=i.buttonTextDefault):b[e]&&(j=function(){b[e]()},k=(b.overrides.buttonText||{})[e],l=c.buttonText[e]),j&&(m=f?f.themeIcon:c.themeButtonIcons[e],o=f?f.icon:c.buttonIcons[e],q=k?Y(k):m&&c.theme?"":o&&!c.theme?"":Y(l),r=["fc-"+e+"-button",n+"-button",n+"-state-default"],s=a('").click(function(a){s.hasClass(n+"-state-disabled")||(j(a),(s.hasClass(n+"-state-active")||s.hasClass(n+"-state-disabled"))&&s.removeClass(n+"-state-hover"))}).mousedown(function(){s.not("."+n+"-state-active").not("."+n+"-state-disabled").addClass(n+"-state-down")}).mouseup(function(){s.removeClass(n+"-state-down")}).hover(function(){s.not("."+n+"-state-active").not("."+n+"-state-disabled").addClass(n+"-state-hover")},function(){s.removeClass(n+"-state-hover").removeClass(n+"-state-down")}),g=g.add(s)))}),h&&g.first().addClass(n+"-corner-left").end().last().addClass(n+"-corner-right").end(),g.length>1?(f=a(""),h&&f.addClass("fc-button-group"),f.append(g),e.append(f)):e.append(g)}),e}function g(a){o.find("h2").text(a)}function h(a){o.find(".fc-"+a+"-button").addClass(n+"-state-active")}function i(a){o.find(".fc-"+a+"-button").removeClass(n+"-state-active")}function j(a){o.find(".fc-"+a+"-button").attr("disabled","disabled").addClass(n+"-state-disabled")}function k(a){o.find(".fc-"+a+"-button").removeAttr("disabled").removeClass(n+"-state-disabled")}function l(){return p}var m=this;m.render=d,m.removeElement=e,m.updateTitle=g,m.activateButton=h,m.deactivateButton=i,m.disableButton=j,m.enableButton=k,m.getViewsWithButtons=l;var n,o=a(),p=[]}function Na(c){function d(a,b){return!M||a.clone().stripZone()N.clone().stripZone()}function e(a,b){M=a,N=b,U=[];var c=++S,d=R.length;T=d;for(var e=0;d>e;e++)f(R[e],c)}function f(b,c){g(b,function(d){var e,f,g,h=a.isArray(b.events);if(c==S){if(d)for(e=0;e=c&&b.end<=d}function K(a,b){var c=a.start.clone().stripZone(),d=L.getEventEnd(a).stripZone();return b.startc}var L=this;L.isFetchNeeded=d,L.fetchEvents=e,L.addEventSource=h,L.removeEventSource=j,L.updateEvent=m,L.renderEvent=p,L.removeEvents=q,L.clientEvents=r,L.mutateEvent=y,L.normalizeEventRange=u,L.normalizeEventRangeTimes=v,L.ensureVisibleEventRange=w;var M,N,O=L.reportEvents,Q={events:[]},R=[Q],S=0,T=0,U=[];a.each((c.events?[c.events]:[]).concat(c.eventSources||[]),function(a,b){var c=i(b);c&&R.push(c)}),L.getBusinessHoursEvents=A,L.isEventRangeAllowed=B,L.isSelectionRangeAllowed=C,L.isExternalDropRangeAllowed=D,L.getEventCache=function(){return U}}function Oa(a){a._allDay=a.allDay,a._start=a.start.clone(),a._end=a.end?a.end.clone():null}var Pa=a.fullCalendar={version:"2.5.0-beta"},Qa=Pa.views={};a.fn.fullCalendar=function(b){var c=Array.prototype.slice.call(arguments,1),d=this;return this.each(function(e,f){var g,h=a(f),i=h.data("fullCalendar");"string"==typeof b?i&&a.isFunction(i[b])&&(g=i[b].apply(i,c),e||(d=g),"destroy"===b&&h.removeData("fullCalendar")):i||(i=new pb(h,b),h.data("fullCalendar",i),i.render())}),d};var Ra=["header","buttonText","buttonIcons","themeButtonIcons"];Pa.intersectionToSeg=E,Pa.applyAll=W,Pa.debounce=da,Pa.isInt=ba,Pa.htmlEscape=Y,Pa.cssToStr=$,Pa.proxy=ca,Pa.capitaliseFirstLetter=_,Pa.getOuterRect=o,Pa.getClientRect=p,Pa.getContentRect=q,Pa.getScrollbarWidths=r;var Sa=null;Pa.intersectRects=w,Pa.parseFieldSpecs=A,Pa.compareByFieldSpecs=B,Pa.compareByFieldSpec=C,Pa.flexibleCompare=D,Pa.computeIntervalUnit=I,Pa.divideRangeByDuration=K,Pa.divideDurationByDuration=L,Pa.multiplyDuration=M,Pa.durationHasTime=N;var Ta=["sun","mon","tue","wed","thu","fri","sat"],Ua=["year","month","week","day","hour","minute","second","millisecond"];Pa.log=function(){var a=window.console;return a&&a.log?a.log.apply(a,arguments):void 0},Pa.warn=function(){var a=window.console;return a&&a.warn?a.warn.apply(a,arguments):Pa.log.apply(Pa,arguments)};var Va,Wa,Xa,Ya={}.hasOwnProperty,Za=/^\s*\d{4}-\d\d$/,$a=/^\s*\d{4}-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?)?$/,_a=b.fn,ab=a.extend({},_a);Pa.moment=function(){return ea(arguments)},Pa.moment.utc=function(){var a=ea(arguments,!0);return a.hasTime()&&a.utc(),a},Pa.moment.parseZone=function(){return ea(arguments,!0,!0)},_a.clone=function(){var a=ab.clone.apply(this,arguments);return ga(this,a),this._fullCalendar&&(a._fullCalendar=!0),a},_a.week=_a.weeks=function(a){var b=(this._locale||this._lang)._fullCalendar_weekCalc;return null==a&&"function"==typeof b?b(this):"ISO"===b?ab.isoWeek.apply(this,arguments):ab.week.apply(this,arguments)},_a.time=function(a){if(!this._fullCalendar)return ab.time.apply(this,arguments);if(null==a)return b.duration({hours:this.hours(),minutes:this.minutes(),seconds:this.seconds(),milliseconds:this.milliseconds()});this._ambigTime=!1,b.isDuration(a)||b.isMoment(a)||(a=b.duration(a));var c=0;return b.isDuration(a)&&(c=24*Math.floor(a.asDays())),this.hours(c+a.hours()).minutes(a.minutes()).seconds(a.seconds()).milliseconds(a.milliseconds())},_a.stripTime=function(){var a;return this._ambigTime||(a=this.toArray(),this.utc(),Wa(this,a.slice(0,3)),this._ambigTime=!0,this._ambigZone=!0),this},_a.hasTime=function(){return!this._ambigTime},_a.stripZone=function(){var a,b;return this._ambigZone||(a=this.toArray(),b=this._ambigTime,this.utc(),Wa(this,a),this._ambigTime=b||!1,this._ambigZone=!0),this},_a.hasZone=function(){return!this._ambigZone},_a.local=function(){var a=this.toArray(),b=this._ambigZone;return ab.local.apply(this,arguments),this._ambigTime=!1,this._ambigZone=!1,b&&Xa(this,a),this},_a.utc=function(){return ab.utc.apply(this,arguments),this._ambigTime=!1,this._ambigZone=!1,this},a.each(["zone","utcOffset"],function(a,b){ab[b]&&(_a[b]=function(a){return null!=a&&(this._ambigTime=!1,this._ambigZone=!1),ab[b].apply(this,arguments)})}),_a.format=function(){return this._fullCalendar&&arguments[0]?ja(this,arguments[0]):this._ambigTime?ia(this,"YYYY-MM-DD"):this._ambigZone?ia(this,"YYYY-MM-DD[T]HH:mm:ss"):ab.format.apply(this,arguments)},_a.toISOString=function(){return this._ambigTime?ia(this,"YYYY-MM-DD"):this._ambigZone?ia(this,"YYYY-MM-DD[T]HH:mm:ss"):ab.toISOString.apply(this,arguments)},_a.isWithin=function(a,b){var c=fa([this,a,b]);return c[0]>=c[1]&&c[0]a;a++)b=arguments[a],c-1>a&&ta(this,b);return sa(this,b||{})},ra.mixin=function(a){ta(this,a)};var eb=Pa.Emitter=ra.extend({callbackHash:null,on:function(a,b){return this.getCallbacks(a).add(b),this},off:function(a,b){return this.getCallbacks(a).remove(b),this},trigger:function(a){var b=Array.prototype.slice.call(arguments,1);return this.triggerWith(a,this,b),this},triggerWith:function(a,b,c){var d=this.getCallbacks(a);return d.fireWith(b,c),this},getCallbacks:function(b){var c;return this.callbackHash||(this.callbackHash={}),c=this.callbackHash[b],c||(c=this.callbackHash[b]=a.Callbacks()),c}}),fb=ra.extend({isHidden:!0,options:null,el:null,documentMousedownProxy:null,margin:10,constructor:function(a){this.options=a||{}},show:function(){this.isHidden&&(this.el||this.render(),this.el.show(),this.position(),this.isHidden=!1,this.trigger("show"))},hide:function(){this.isHidden||(this.el.hide(),this.isHidden=!0,this.trigger("hide"))},render:function(){var b=this,c=this.options;this.el=a('').addClass(c.className||"").css({top:0,left:0}).append(c.content).appendTo(c.parentEl),this.el.on("click",".fc-close",function(){b.hide()}),c.autoHide&&a(document).on("mousedown",this.documentMousedownProxy=ca(this,"documentMousedown"))},documentMousedown:function(b){this.el&&!a(b.target).closest(this.el).length&&this.hide()},removeElement:function(){this.hide(),this.el&&(this.el.remove(),this.el=null),a(document).off("mousedown",this.documentMousedownProxy)},position:function(){var b,c,d,e,f,g=this.options,h=this.el.offsetParent().offset(),i=this.el.outerWidth(),j=this.el.outerHeight(),k=a(window),l=n(this.el);e=g.top||0,f=void 0!==g.left?g.left:void 0!==g.right?g.right-i:0,l.is(window)||l.is(document)?(l=k,b=0,c=0):(d=l.offset(),b=d.top,c=d.left),b+=k.scrollTop(),c+=k.scrollLeft(),g.viewportConstrain!==!1&&(e=Math.min(e,b+l.outerHeight()-j-this.margin),
+e=Math.max(e,b+this.margin),f=Math.min(f,c+l.outerWidth()-i-this.margin),f=Math.max(f,c+this.margin)),this.el.css({top:e-h.top,left:f-h.left})},trigger:function(a){this.options[a]&&this.options[a].apply(this,Array.prototype.slice.call(arguments,1))}}),gb=Pa.CoordCache=ra.extend({els:null,origin:null,boundingRect:null,isHorizontal:!1,isVertical:!1,lefts:null,rights:null,tops:null,bottoms:null,constructor:function(b){this.els=a(b.els),this.isHorizontal=b.isHorizontal,this.isVertical=b.isVertical},build:function(){this.origin=this.els.eq(0).offsetParent().offset(),this.boundingRect=this.queryBoundingRect(),this.isHorizontal&&this.buildElHorizontals(),this.isVertical&&this.buildElVerticals()},clear:function(){this.origin=null,this.boundingRect=null,this.lefts=null,this.rights=null,this.tops=null,this.bottoms=null},queryBoundingRect:function(){var a=n(this.els.eq(0));return a.is(document)?void 0:p(a)},buildElHorizontals:function(){var b=[],c=[];this.els.each(function(d,e){var f=a(e),g=f.offset().left,h=f.outerWidth();b.push(g),c.push(g+h)}),this.lefts=b,this.rights=c},buildElVerticals:function(){var b=[],c=[];this.els.each(function(d,e){var f=a(e),g=f.offset().top,h=f.outerHeight();b.push(g),c.push(g+h)}),this.tops=b,this.bottoms=c},getHorizontalIndex:function(a){var b,c=this.boundingRect,d=this.lefts,e=this.rights,f=d.length;if(!c||a>=c.left&&ab;b++)if(a>=d[b]&&a=c.top&&ab;b++)if(a>=d[b]&&a=b*b&&this.startDrag(a)),this.isDragging&&this.drag(d,e,a)},startDrag:function(a){this.isListening||this.startListening(),this.isDragging||(this.isDragging=!0,this.dragStart(a))},dragStart:function(a){var b=this.subjectEl;this.trigger("dragStart",a),(this.subjectHref=b?b.attr("href"):null)&&b.removeAttr("href")},drag:function(a,b,c){this.trigger("drag",a,b,c),this.updateScroll(c)},mouseup:function(a){this.stopListening(a)},stopDrag:function(a){this.isDragging&&(this.stopScrolling(),this.dragStop(a),this.isDragging=!1)},dragStop:function(a){var b=this;this.trigger("dragStop",a),setTimeout(function(){b.subjectHref&&b.subjectEl.attr("href",b.subjectHref)},0)},stopListening:function(b){this.stopDrag(b),this.isListening&&(this.scrollEl&&(this.scrollEl.off("scroll",this.scrollHandlerProxy),this.scrollHandlerProxy=null),a(document).off("mousemove",this.mousemoveProxy).off("mouseup",this.mouseupProxy).off("selectstart",this.preventDefault),this.mousemoveProxy=null,this.mouseupProxy=null,this.isListening=!1,this.listenStop(b))},listenStop:function(a){this.trigger("listenStop",a)},trigger:function(a){this.options[a]&&this.options[a].apply(this,Array.prototype.slice.call(arguments,1))},preventDefault:function(a){a.preventDefault()},computeScrollBounds:function(){var a=this.scrollEl;this.scrollBounds=a?o(a):null},updateScroll:function(a){var b,c,d,e,f=this.scrollSensitivity,g=this.scrollBounds,h=0,i=0;g&&(b=(f-(a.pageY-g.top))/f,c=(f-(g.bottom-a.pageY))/f,d=(f-(a.pageX-g.left))/f,e=(f-(g.right-a.pageX))/f,b>=0&&1>=b?h=b*this.scrollSpeed*-1:c>=0&&1>=c&&(h=c*this.scrollSpeed),d>=0&&1>=d?i=d*this.scrollSpeed*-1:e>=0&&1>=e&&(i=e*this.scrollSpeed)),this.setScrollVel(h,i)},setScrollVel:function(a,b){this.scrollTopVel=a,this.scrollLeftVel=b,this.constrainScrollVel(),!this.scrollTopVel&&!this.scrollLeftVel||this.scrollIntervalId||(this.scrollIntervalId=setInterval(ca(this,"scrollIntervalFunc"),this.scrollIntervalMs))},constrainScrollVel:function(){var a=this.scrollEl;this.scrollTopVel<0?a.scrollTop()<=0&&(this.scrollTopVel=0):this.scrollTopVel>0&&a.scrollTop()+a[0].clientHeight>=a[0].scrollHeight&&(this.scrollTopVel=0),this.scrollLeftVel<0?a.scrollLeft()<=0&&(this.scrollLeftVel=0):this.scrollLeftVel>0&&a.scrollLeft()+a[0].clientWidth>=a[0].scrollWidth&&(this.scrollLeftVel=0)},scrollIntervalFunc:function(){var a=this.scrollEl,b=this.scrollIntervalMs/1e3;this.scrollTopVel&&a.scrollTop(a.scrollTop()+this.scrollTopVel*b),this.scrollLeftVel&&a.scrollLeft(a.scrollLeft()+this.scrollLeftVel*b),this.constrainScrollVel(),this.scrollTopVel||this.scrollLeftVel||this.stopScrolling()},stopScrolling:function(){this.scrollIntervalId&&(clearInterval(this.scrollIntervalId),this.scrollIntervalId=null,this.scrollStop())},scrollHandler:function(){this.scrollIntervalId||this.scrollStop()},scrollStop:function(){}}),ib=hb.extend({component:null,origHit:null,hit:null,coordAdjust:null,constructor:function(a,b){hb.call(this,b),this.component=a},listenStart:function(a){var b,c,d,e=this.subjectEl;hb.prototype.listenStart.apply(this,arguments),this.computeCoords(),a?(c={left:a.pageX,top:a.pageY},d=c,e&&(b=o(e),d=x(d,b)),this.origHit=this.queryHit(d.left,d.top),e&&this.options.subjectCenter&&(this.origHit&&(b=w(this.origHit,b)||b),d=y(b)),this.coordAdjust=z(d,c)):(this.origHit=null,this.coordAdjust=null)},computeCoords:function(){this.component.prepareHits(),this.computeScrollBounds()},dragStart:function(a){var b;hb.prototype.dragStart.apply(this,arguments),b=this.queryHit(a.pageX,a.pageY),b&&this.hitOver(b)},drag:function(a,b,c){var d;hb.prototype.drag.apply(this,arguments),d=this.queryHit(c.pageX,c.pageY),ua(d,this.hit)||(this.hit&&this.hitOut(),d&&this.hitOver(d))},dragStop:function(){this.hitDone(),hb.prototype.dragStop.apply(this,arguments)},hitOver:function(a){var b=ua(a,this.origHit);this.hit=a,this.trigger("hitOver",this.hit,b,this.origHit)},hitOut:function(){this.hit&&(this.trigger("hitOut",this.hit),this.hitDone(),this.hit=null)},hitDone:function(){this.hit&&this.trigger("hitDone",this.hit)},listenStop:function(){hb.prototype.listenStop.apply(this,arguments),this.origHit=null,this.hit=null,this.component.releaseHits()},scrollStop:function(){hb.prototype.scrollStop.apply(this,arguments),this.computeCoords()},queryHit:function(a,b){return this.coordAdjust&&(a+=this.coordAdjust.left,b+=this.coordAdjust.top),this.component.queryHit(a,b)}}),jb=ra.extend({options:null,sourceEl:null,el:null,parentEl:null,top0:null,left0:null,mouseY0:null,mouseX0:null,topDelta:null,leftDelta:null,mousemoveProxy:null,isFollowing:!1,isHidden:!1,isAnimating:!1,constructor:function(b,c){this.options=c=c||{},this.sourceEl=b,this.parentEl=c.parentEl?a(c.parentEl):b.parent()},start:function(b){this.isFollowing||(this.isFollowing=!0,this.mouseY0=b.pageY,this.mouseX0=b.pageX,this.topDelta=0,this.leftDelta=0,this.isHidden||this.updatePosition(),a(document).on("mousemove",this.mousemoveProxy=ca(this,"mousemove")))},stop:function(b,c){function d(){this.isAnimating=!1,e.removeElement(),this.top0=this.left0=null,c&&c()}var e=this,f=this.options.revertDuration;this.isFollowing&&!this.isAnimating&&(this.isFollowing=!1,a(document).off("mousemove",this.mousemoveProxy),b&&f&&!this.isHidden?(this.isAnimating=!0,this.el.animate({top:this.top0,left:this.left0},{duration:f,complete:d})):d())},getEl:function(){var a=this.el;return a||(this.sourceEl.width(),a=this.el=this.sourceEl.clone().css({position:"absolute",visibility:"",display:this.isHidden?"none":"",margin:0,right:"auto",bottom:"auto",width:this.sourceEl.width(),height:this.sourceEl.height(),opacity:this.options.opacity||"",zIndex:this.options.zIndex}).appendTo(this.parentEl)),a},removeElement:function(){this.el&&(this.el.remove(),this.el=null)},updatePosition:function(){var a,b;this.getEl(),null===this.top0&&(this.sourceEl.width(),a=this.sourceEl.offset(),b=this.el.offsetParent().offset(),this.top0=a.top-b.top,this.left0=a.left-b.left),this.el.css({top:this.top0+this.topDelta,left:this.left0+this.leftDelta})},mousemove:function(a){this.topDelta=a.pageY-this.mouseY0,this.leftDelta=a.pageX-this.mouseX0,this.isHidden||this.updatePosition()},hide:function(){this.isHidden||(this.isHidden=!0,this.el&&this.el.hide())},show:function(){this.isHidden&&(this.isHidden=!1,this.updatePosition(),this.getEl().show())}}),kb=Pa.Grid=ra.extend({view:null,isRTL:null,start:null,end:null,el:null,elsByFill:null,externalDragStartProxy:null,eventTimeFormat:null,displayEventTime:null,displayEventEnd:null,minResizeDuration:null,largeUnit:null,constructor:function(a){this.view=a,this.isRTL=a.opt("isRTL"),this.elsByFill={},this.externalDragStartProxy=ca(this,"externalDragStart")},computeEventTimeFormat:function(){return this.view.opt("smallTimeFormat")},computeDisplayEventTime:function(){return!0},computeDisplayEventEnd:function(){return!0},setRange:function(a){this.start=a.start.clone(),this.end=a.end.clone(),this.rangeUpdated(),this.processRangeOptions()},rangeUpdated:function(){},processRangeOptions:function(){var a,b,c=this.view;this.eventTimeFormat=c.opt("eventTimeFormat")||c.opt("timeFormat")||this.computeEventTimeFormat(),a=c.opt("displayEventTime"),null==a&&(a=this.computeDisplayEventTime()),b=c.opt("displayEventEnd"),null==b&&(b=this.computeDisplayEventEnd()),this.displayEventTime=a,this.displayEventEnd=b},rangeToSegs:function(a){},diffDates:function(a,b){return this.largeUnit?H(a,b,this.largeUnit):F(a,b)},prepareHits:function(){},releaseHits:function(){},queryHit:function(a,b){},getHitSpan:function(a){},getHitEl:function(a){},setElement:function(b){var c=this;this.el=b,b.on("mousedown",function(b){a(b.target).is(".fc-event-container *, .fc-more")||a(b.target).closest(".fc-popover").length||c.dayMousedown(b)}),this.bindSegHandlers(),this.bindGlobalHandlers()},removeElement:function(){this.unbindGlobalHandlers(),this.el.remove()},renderSkeleton:function(){},renderDates:function(){},unrenderDates:function(){},bindGlobalHandlers:function(){a(document).on("dragstart sortstart",this.externalDragStartProxy)},unbindGlobalHandlers:function(){a(document).off("dragstart sortstart",this.externalDragStartProxy)},dayMousedown:function(a){var b,c,d=this,e=this.view,f=e.opt("selectable"),i=new ib(this,{scroll:e.opt("dragScroll"),dragStart:function(){e.unselect()},hitOver:function(a,e,h){h&&(b=e?a:null,f&&(c=d.computeSelection(d.getHitSpan(h),d.getHitSpan(a)),c?d.renderSelection(c):c===!1&&g()))},hitOut:function(){b=null,c=null,d.unrenderSelection(),h()},listenStop:function(a){b&&e.triggerDayClick(d.getHitSpan(b).start,d.getHitEl(b),a),c&&e.reportSelection(c,a),h()}});i.mousedown(a)},renderRangeHelper:function(a,b){var c=this.fabricateHelperEvent(a,b);this.renderHelper(c,b)},fabricateHelperEvent:function(a,b){var c=b?R(b.event):{};return c.start=a.start.clone(),c.end=a.end?a.end.clone():null,c.allDay=null,this.view.calendar.normalizeEventRange(c),c.className=(c.className||[]).concat("fc-helper"),b||(c.editable=!1),c},renderHelper:function(a,b){},unrenderHelper:function(){},renderSelection:function(a){this.renderHighlight(this.selectionRangeToSegs(a))},unrenderSelection:function(){this.unrenderHighlight()},computeSelection:function(a,b){var c,d=[a.start,a.end,b.start,b.end];return d.sort(aa),c={start:d[0].clone(),end:d[3].clone()},this.view.calendar.isSelectionRangeAllowed(c)?c:!1},selectionRangeToSegs:function(a){return this.rangeToSegs(a)},renderHighlight:function(a){this.renderFill("highlight",a)},unrenderHighlight:function(){this.unrenderFill("highlight")},highlightSegClasses:function(){return["fc-highlight"]},renderFill:function(a,b){},unrenderFill:function(a){var b=this.elsByFill[a];b&&(b.remove(),delete this.elsByFill[a])},renderFillSegEls:function(b,c){var d,e=this,f=this[b+"SegEl"],g="",h=[];if(c.length){for(d=0;d"},getDayClasses:function(a){var b=this.view,c=b.calendar.getNow().stripTime(),d=["fc-"+Ta[a.day()]];return 1==b.intervalDuration.as("months")&&a.month()!=b.intervalStart.month()&&d.push("fc-other-month"),a.isSame(c,"day")?d.push("fc-today",b.highlightStateClass):c>a?d.push("fc-past"):d.push("fc-future"),d}});kb.mixin({mousedOverSeg:null,isDraggingSeg:!1,isResizingSeg:!1,isDraggingExternal:!1,segs:null,renderEvents:function(a){var b,c,d=this.eventsToSegs(a),e=[],f=[];for(b=0;b *",function(c){var e=a(this).data("fc-seg");return!e||b.isDraggingSeg||b.isResizingSeg?void 0:d.call(this,e,c)})})},triggerSegMouseover:function(a,b){this.mousedOverSeg||(this.mousedOverSeg=a,this.view.trigger("eventMouseover",a.el[0],a.event,b))},triggerSegMouseout:function(a,b){b=b||{},this.mousedOverSeg&&(a=a||this.mousedOverSeg,this.mousedOverSeg=null,this.view.trigger("eventMouseout",a.el[0],a.event,b))},segDragMousedown:function(a,b){var c,d=this,e=this.view,f=e.calendar,i=a.el,j=a.event,k=new jb(a.el,{parentEl:e.el,opacity:e.opt("dragOpacity"),revertDuration:e.opt("dragRevertDuration"),zIndex:2}),l=new ib(e,{distance:5,scroll:e.opt("dragScroll"),subjectEl:i,subjectCenter:!0,listenStart:function(a){k.hide(),k.start(a)},dragStart:function(b){d.triggerSegMouseout(a,b),d.segDragStart(a,b),e.hideEvent(j)},hitOver:function(b,h,i){a.hit&&(i=a.hit),c=d.computeEventDrop(i.component.getHitSpan(i),b.component.getHitSpan(b),j),c&&!f.isEventRangeAllowed(c,j)&&(g(),c=null),c&&e.renderDrag(c,a)?k.hide():k.show(),h&&(c=null)},hitOut:function(){e.unrenderDrag(),k.show(),c=null},hitDone:function(){h()},dragStop:function(b){k.stop(!c,function(){e.unrenderDrag(),e.showEvent(j),d.segDragStop(a,b),c&&e.reportEventDrop(j,c,this.largeUnit,i,b)})},listenStop:function(){k.stop()}});l.mousedown(b)},segDragStart:function(a,b){this.isDraggingSeg=!0,this.view.trigger("eventDragStart",a.el[0],a.event,b,{})},segDragStop:function(a,b){this.isDraggingSeg=!1,this.view.trigger("eventDragStop",a.el[0],a.event,b,{})},computeEventDrop:function(a,b,c){var d,e,f=this.view.calendar,g=a.start,h=b.start;return g.hasTime()===h.hasTime()?(d=this.diffDates(h,g),c.allDay&&N(d)?(e={start:c.start.clone(),end:f.getEventEnd(c),allDay:!1},f.normalizeEventRangeTimes(e)):e={start:c.start.clone(),end:c.end?c.end.clone():null,allDay:c.allDay},e.start.add(d),e.end&&e.end.add(d)):e={start:h.clone(),end:null,allDay:!h.hasTime()},e},applyDragOpacity:function(a){var b=this.view.opt("dragOpacity");null!=b&&a.each(function(a,c){c.style.opacity=b})},externalDragStart:function(b,c){var d,e,f=this.view;f.opt("droppable")&&(d=a((c?c.item:null)||b.target),e=f.opt("dropAccept"),(a.isFunction(e)?e.call(d[0],d):d.is(e))&&(this.isDraggingExternal||this.listenToExternalDrag(d,b,c)))},listenToExternalDrag:function(a,b,c){var d,e=this,f=Ba(a),i=new ib(this,{listenStart:function(){e.isDraggingExternal=!0},hitOver:function(a){d=e.computeExternalDrop(a.component.getHitSpan(a),f),d?e.renderDrag(d):g()},hitOut:function(){d=null,e.unrenderDrag(),h()},dragStop:function(){e.unrenderDrag(),h(),d&&e.view.reportExternalDrop(f,d,a,b,c)},listenStop:function(){e.isDraggingExternal=!1}});i.startDrag(b)},computeExternalDrop:function(a,b){var c={start:a.start,end:null};return b.startTime&&!c.start.hasTime()&&c.start.time(b.startTime),b.duration&&(c.end=c.start.clone().add(b.duration)),this.view.calendar.isExternalDropRangeAllowed(c,b.eventProps)?c:null},renderDrag:function(a,b){},unrenderDrag:function(){},segResizeMousedown:function(a,b,c){var d,e=this,f=this.view,i=f.calendar,j=a.el,k=a.event,l=i.getEventEnd(k),m=new ib(this,{distance:5,scroll:f.opt("dragScroll"),subjectEl:j,dragStart:function(b){e.triggerSegMouseout(a,b),e.segResizeStart(a,b)},hitOver:function(b,h,j){var m=e.getHitSpan(j),n=e.getHitSpan(b);d=c?e.computeEventStartResize(m,n,k):e.computeEventEndResize(m,n,k),d&&(i.isEventRangeAllowed(d,k)?d.start.isSame(k.start)&&d.end.isSame(l)&&(d=null):(g(),d=null)),d&&(f.hideEvent(k),e.renderEventResize(d,a))},hitOut:function(){d=null},hitDone:function(){e.unrenderEventResize(),f.showEvent(k),h()},dragStop:function(b){e.segResizeStop(a,b),d&&f.reportEventResize(k,d,this.largeUnit,j,b)}});m.mousedown(b)},segResizeStart:function(a,b){this.isResizingSeg=!0,this.view.trigger("eventResizeStart",a.el[0],a.event,b,{})},segResizeStop:function(a,b){this.isResizingSeg=!1,this.view.trigger("eventResizeStop",a.el[0],a.event,b,{})},computeEventStartResize:function(a,b,c){return this.computeEventResize("start",a,b,c)},computeEventEndResize:function(a,b,c){return this.computeEventResize("end",a,b,c)},computeEventResize:function(a,b,c,d){var e,f,g=this.view.calendar,h=this.diffDates(c[a],b[a]);return e={start:d.start.clone(),end:g.getEventEnd(d),allDay:d.allDay},e.allDay&&N(h)&&(e.allDay=!1,g.normalizeEventRangeTimes(e)),e[a].add(h),e.start.isBefore(e.end)||(f=this.minResizeDuration||(d.allDay?g.defaultAllDayEventDuration:g.defaultTimedEventDuration),"start"==a?e.start=e.end.clone().subtract(f):e.end=e.start.clone().add(f)),e},renderEventResize:function(a,b){},unrenderEventResize:function(){},getEventTimeText:function(a,b,c){return null==b&&(b=this.eventTimeFormat),null==c&&(c=this.displayEventEnd),this.displayEventTime&&a.start.hasTime()?c&&a.end?this.view.formatRange(a,b):a.start.format(b):""},getSegClasses:function(a,b,c){var d=a.event,e=["fc-event",a.isStart?"fc-start":"fc-not-start",a.isEnd?"fc-end":"fc-not-end"].concat(d.className,d.source?d.source.className:[]);return b&&e.push("fc-draggable"),c&&e.push("fc-resizable"),e},getEventSkinCss:function(a){var b=this.view,c=a.source||{},d=a.color,e=c.color,f=b.opt("eventColor");return{"background-color":a.backgroundColor||d||c.backgroundColor||e||b.opt("eventBackgroundColor")||f,"border-color":a.borderColor||d||c.borderColor||e||b.opt("eventBorderColor")||f,color:a.textColor||c.textColor||b.opt("eventTextColor")}},eventsToSegs:function(a,b){var c,d=this.eventsToRanges(a),e=[];for(c=0;cj&&h.push({event:i,start:j,end:c.start}),j=c.end;return f>j&&h.push({event:i,start:j,end:f}),h},eventRangeToSegs:function(a,b){var c,d,e;for(a=this.view.calendar.ensureVisibleEventRange(a),c=b?b(a):this.rangeToSegs(a),d=0;dc?b[0]-1:c>=b.length?b[b.length-1]+1:b[c]},computeColHeadFormat:function(){return this.rowCnt>1||this.colCnt>10?"ddd":this.colCnt>1?this.view.opt("dayOfMonthFormat"):"dddd"},sliceRangeByRow:function(a){var b,c,d,e,f,g=this.daysPerRow,h=this.view.computeDayRange(a),i=this.getDateDayIndex(h.start),j=this.getDateDayIndex(h.end.clone().subtract(1,"days")),k=[];for(b=0;b=e&&k.push({row:b,firstRowDayIndex:e-c,lastRowDayIndex:f-c,isStart:e===i,isEnd:f===j});return k},sliceRangeByDay:function(a){var b,c,d,e,f,g,h=this.daysPerRow,i=this.view.computeDayRange(a),j=this.getDateDayIndex(i.start),k=this.getDateDayIndex(i.end.clone().subtract(1,"days")),l=[];for(b=0;b=e;e++)f=Math.max(j,e),g=Math.min(k,e),f=Math.ceil(f),g=Math.floor(g),g>=f&&l.push({row:b,firstRowDayIndex:f-c,lastRowDayIndex:g-c,isStart:f===j,isEnd:g===k});return l},renderHeadHtml:function(){var a=this.view;return'"},renderHeadIntroHtml:function(){return this.renderIntroHtml()},renderHeadTrHtml:function(){return""+(this.isRTL?"":this.renderHeadIntroHtml())+this.renderHeadDateCellsHtml()+(this.isRTL?this.renderHeadIntroHtml():"")+" "},renderHeadDateCellsHtml:function(){var a,b,c=[];for(a=0;a"},generateSegPositionCss:function(a){var b,c,d=this.view.opt("slotEventOverlap"),e=a.backwardCoord,f=a.forwardCoord,g=this.generateSegVerticalCss(a);return d&&(f=Math.min(1,e+2*(f-e))),this.isRTL?(b=1-f,c=e):(b=e,c=1-f),g.zIndex=a.level+1,g.left=100*b+"%",g.right=100*c+"%",d&&a.forwardPressure&&(g[this.isRTL?"marginLeft":"marginRight"]=20),g},generateSegVerticalCss:function(a){return{top:a.top,bottom:-a.bottom}},groupSegCols:function(a){var b,c=[];for(b=0;b1?"ll":"LL"},formatRange:function(a,b,c){var d=a.end;return d.hasTime()||(d=d.clone().subtract(1)),ma(a.start,d,b,c,this.opt("isRTL"))},setElement:function(a){this.el=a,this.bindGlobalHandlers()},removeElement:function(){this.clear(),this.isSkeletonRendered&&(this.unrenderSkeleton(),this.isSkeletonRendered=!1),this.unbindGlobalHandlers(),this.el.remove()},display:function(b){var c=this,d=null;return this.displaying&&(d=this.queryScroll()),this.clear().then(function(){return c.displaying=a.when(c.displayView(b)).then(function(){c.forceScroll(c.computeInitialScroll(d)),c.triggerRender()})})},clear:function(){var b=this,c=this.displaying;return c?c.then(function(){return b.displaying=null,b.clearEvents(),b.clearView()}):a.when()},displayView:function(a){this.isSkeletonRendered||(this.renderSkeleton(),this.isSkeletonRendered=!0),this.setDate(a),this.render&&this.render(),this.renderDates(),this.updateSize(),this.renderBusinessHours()},clearView:function(){this.unselect(),this.triggerUnrender(),this.unrenderBusinessHours(),this.unrenderDates(),this.destroy&&this.destroy()},renderSkeleton:function(){},unrenderSkeleton:function(){},renderDates:function(){},unrenderDates:function(){},renderBusinessHours:function(){},unrenderBusinessHours:function(){},triggerRender:function(){this.trigger("viewRender",this,this,this.el)},triggerUnrender:function(){this.trigger("viewDestroy",this,this,this.el)},bindGlobalHandlers:function(){a(document).on("mousedown",this.documentMousedownProxy)},unbindGlobalHandlers:function(){a(document).off("mousedown",this.documentMousedownProxy)},initThemingProps:function(){var a=this.opt("theme")?"ui":"fc";this.widgetHeaderClass=a+"-widget-header",this.widgetContentClass=a+"-widget-content",this.highlightStateClass=a+"-state-highlight"},updateSize:function(a){var b;a&&(b=this.queryScroll()),this.updateHeight(a),this.updateWidth(a),a&&this.setScroll(b)},updateWidth:function(a){},updateHeight:function(a){var b=this.calendar;this.setHeight(b.getSuggestedViewHeight(),b.isHeightAuto())},setHeight:function(a,b){},computeScrollerHeight:function(a){var b,c,d=this.scrollerEl;return b=this.el.add(d),b.css({position:"relative",left:-1}),c=this.el.outerHeight()-d.height(),b.css({position:"",left:""}),a-c},computeInitialScroll:function(a){return 0},queryScroll:function(){return this.scrollerEl?this.scrollerEl.scrollTop():void 0},setScroll:function(a){return this.scrollerEl?this.scrollerEl.scrollTop(a):void 0},forceScroll:function(a){var b=this;this.setScroll(a),setTimeout(function(){b.setScroll(a)},0)},displayEvents:function(a){var b=this.queryScroll();this.clearEvents(),this.renderEvents(a),this.isEventsRendered=!0,this.setScroll(b),this.triggerEventRender()},clearEvents:function(){this.isEventsRendered&&(this.triggerEventUnrender(),this.destroyEvents&&this.destroyEvents(),this.unrenderEvents(),this.isEventsRendered=!1)},renderEvents:function(a){},unrenderEvents:function(){},triggerEventRender:function(){this.renderedEventSegEach(function(a){this.trigger("eventAfterRender",a.event,a.event,a.el)}),this.trigger("eventAfterAllRender")},triggerEventUnrender:function(){this.renderedEventSegEach(function(a){this.trigger("eventDestroy",a.event,a.event,a.el)})},resolveEventEl:function(b,c){var d=this.trigger("eventRender",b,b,c);return d===!1?c=null:d&&d!==!0&&(c=a(d)),c},showEvent:function(a){this.renderedEventSegEach(function(a){a.el.css("visibility","")},a)},hideEvent:function(a){this.renderedEventSegEach(function(a){a.el.css("visibility","hidden")},a)},renderedEventSegEach:function(a,b){var c,d=this.getEventSegs();for(c=0;cb;b++)(d[b]=-1!==a.inArray(b,c))||e++;if(!e)throw"invalid hiddenDays";this.isHiddenDayHash=d},isHiddenDay:function(a){return b.isMoment(a)&&(a=a.day()),this.isHiddenDayHash[a]},skipHiddenDays:function(a,b,c){var d=a.clone();for(b=b||1;this.isHiddenDayHash[(d.day()+(c?b:0)+7)%7];)d.add(b,"days");return d},computeDayRange:function(a){var b,c=a.start.clone().stripTime(),d=a.end,e=null;return d&&(e=d.clone().stripTime(),b=+d.time(),b&&b>=this.nextDayThreshold&&e.add(1,"days")),(!d||c>=e)&&(e=c.clone().add(1,"days")),{start:c,end:e}},isMultiDayEvent:function(a){var b=this.computeDayRange(a);return b.end.diff(b.start,"days")>1}}),pb=Pa.Calendar=ra.extend({dirDefaults:null,langDefaults:null,overrides:null,options:null,viewSpecCache:null,view:null,header:null,loadingLevel:0,constructor:Ja,initialize:function(){},initOptions:function(a){var b,e,f,g;a=d(a),b=a.lang,e=qb[b],e||(b=pb.defaults.lang,e=qb[b]||{}),f=X(a.isRTL,e.isRTL,pb.defaults.isRTL),g=f?pb.rtlDefaults:{},this.dirDefaults=g,this.langDefaults=e,this.overrides=a,this.options=c([pb.defaults,g,e,a]),Ka(this.options),this.viewSpecCache={}},getViewSpec:function(a){var b=this.viewSpecCache;return b[a]||(b[a]=this.buildViewSpec(a))},getUnitViewSpec:function(b){var c,d,e;if(-1!=a.inArray(b,Ua))for(c=this.header.getViewsWithButtons(),a.each(Pa.views,function(a){c.push(a)}),d=0;d1,this.weekNumbersVisible=this.opt("weekNumbers"),this.dayGrid.numbersVisible=this.dayNumbersVisible||this.weekNumbersVisible,this.el.addClass("fc-basic-view").html(this.renderSkeletonHtml()),this.renderHead(),this.scrollerEl=this.el.find(".fc-day-grid-container"),this.dayGrid.setElement(this.el.find(".fc-day-grid")),this.dayGrid.renderDates(this.hasRigidRows())},renderHead:function(){this.headContainerEl=this.el.find(".fc-head-container").html(this.dayGrid.renderHeadHtml()),this.headRowEl=this.headContainerEl.find(".fc-row")},unrenderDates:function(){this.dayGrid.unrenderDates(),this.dayGrid.removeElement()},renderBusinessHours:function(){this.dayGrid.renderBusinessHours()},renderSkeletonHtml:function(){return''},weekNumberStyleAttr:function(){return null!==this.weekNumberWidth?'style="width:'+this.weekNumberWidth+'px"':""},hasRigidRows:function(){var a=this.opt("eventLimit");return a&&"number"!=typeof a},updateWidth:function(){this.weekNumbersVisible&&(this.weekNumberWidth=k(this.el.find(".fc-week-number")))},setHeight:function(a,b){var c,d=this.opt("eventLimit");m(this.scrollerEl),f(this.headRowEl),this.dayGrid.removeSegPopover(),d&&"number"==typeof d&&this.dayGrid.limitRows(d),c=this.computeScrollerHeight(a),this.setGridHeight(c,b),d&&"number"!=typeof d&&this.dayGrid.limitRows(d),!b&&l(this.scrollerEl,c)&&(e(this.headRowEl,r(this.scrollerEl)),c=this.computeScrollerHeight(a),this.scrollerEl.height(c))},setGridHeight:function(a,b){b?j(this.dayGrid.rowEls):i(this.dayGrid.rowEls,a,!0)},prepareHits:function(){this.dayGrid.prepareHits()},releaseHits:function(){this.dayGrid.releaseHits()},queryHit:function(a,b){return this.dayGrid.queryHit(a,b)},getHitSpan:function(a){return this.dayGrid.getHitSpan(a)},getHitEl:function(a){return this.dayGrid.getHitEl(a)},renderEvents:function(a){this.dayGrid.renderEvents(a),this.updateHeight()},getEventSegs:function(){return this.dayGrid.getEventSegs()},unrenderEvents:function(){this.dayGrid.unrenderEvents()},renderDrag:function(a,b){return this.dayGrid.renderDrag(a,b)},unrenderDrag:function(){this.dayGrid.unrenderDrag()},renderSelection:function(a){this.dayGrid.renderSelection(a)},unrenderSelection:function(){this.dayGrid.unrenderSelection()}}),xb={renderHeadIntroHtml:function(){var a=this.view;return a.weekNumbersVisible?'":""},renderNumberIntroHtml:function(a){var b=this.view;return b.weekNumbersVisible?'"+this.getCellDate(a,0).format("w")+" | ":""},renderBgIntroHtml:function(){var a=this.view;return a.weekNumbersVisible?' | ":""},renderIntroHtml:function(){var a=this.view;return a.weekNumbersVisible?' | ":"";
+}},yb=Pa.MonthView=wb.extend({computeRange:function(a){var b,c=wb.prototype.computeRange.call(this,a);return this.isFixedWeeks()&&(b=Math.ceil(c.end.diff(c.start,"weeks",!0)),c.end.add(6-b,"weeks")),c},setGridHeight:function(a,b){b=b||"variable"===this.opt("weekMode"),b&&(a*=this.rowCnt/6),i(this.dayGrid.rowEls,a,!b)},isFixedWeeks:function(){var a=this.opt("weekMode");return a?"fixed"===a:this.opt("fixedWeekCount")}});Qa.basic={"class":wb},Qa.basicDay={type:"basic",duration:{days:1}},Qa.basicWeek={type:"basic",duration:{weeks:1}},Qa.month={"class":yb,duration:{months:1},defaults:{fixedWeekCount:!0}};var zb=Pa.AgendaView=ob.extend({timeGridClass:nb,timeGrid:null,dayGridClass:mb,dayGrid:null,axisWidth:null,headContainerEl:null,noScrollRowEls:null,bottomRuleEl:null,bottomRuleHeight:null,initialize:function(){this.timeGrid=this.instantiateTimeGrid(),this.opt("allDaySlot")&&(this.dayGrid=this.instantiateDayGrid())},instantiateTimeGrid:function(){var a=this.timeGridClass.extend(Ab);return new a(this)},instantiateDayGrid:function(){var a=this.dayGridClass.extend(Bb);return new a(this)},setRange:function(a){ob.prototype.setRange.call(this,a),this.timeGrid.setRange(a),this.dayGrid&&this.dayGrid.setRange(a)},renderDates:function(){this.el.addClass("fc-agenda-view").html(this.renderSkeletonHtml()),this.renderHead(),this.scrollerEl=this.el.find(".fc-time-grid-container"),this.timeGrid.setElement(this.el.find(".fc-time-grid")),this.timeGrid.renderDates(),this.bottomRuleEl=a('').appendTo(this.timeGrid.el),this.dayGrid&&(this.dayGrid.setElement(this.el.find(".fc-day-grid")),this.dayGrid.renderDates(),this.dayGrid.bottomCoordPadding=this.dayGrid.el.next("hr").outerHeight()),this.noScrollRowEls=this.el.find(".fc-row:not(.fc-scroller *)")},renderHead:function(){this.headContainerEl=this.el.find(".fc-head-container").html(this.timeGrid.renderHeadHtml())},unrenderDates:function(){this.timeGrid.unrenderDates(),this.timeGrid.removeElement(),this.dayGrid&&(this.dayGrid.unrenderDates(),this.dayGrid.removeElement())},renderBusinessHours:function(){this.timeGrid.renderBusinessHours(),this.dayGrid&&this.dayGrid.renderBusinessHours()},renderSkeletonHtml:function(){return''},axisStyleAttr:function(){return null!==this.axisWidth?'style="width:'+this.axisWidth+'px"':""},updateSize:function(a){this.timeGrid.updateSize(a),ob.prototype.updateSize.call(this,a)},updateWidth:function(){this.axisWidth=k(this.el.find(".fc-axis"))},setHeight:function(a,b){var c,d;null===this.bottomRuleHeight&&(this.bottomRuleHeight=this.bottomRuleEl.outerHeight()),this.bottomRuleEl.hide(),this.scrollerEl.css("overflow",""),m(this.scrollerEl),f(this.noScrollRowEls),this.dayGrid&&(this.dayGrid.removeSegPopover(),c=this.opt("eventLimit"),c&&"number"!=typeof c&&(c=Cb),c&&this.dayGrid.limitRows(c)),b||(d=this.computeScrollerHeight(a),l(this.scrollerEl,d)?(e(this.noScrollRowEls,r(this.scrollerEl)),d=this.computeScrollerHeight(a),this.scrollerEl.height(d)):(this.scrollerEl.height(d).css("overflow","hidden"),this.bottomRuleEl.show()))},computeInitialScroll:function(){var a=b.duration(this.opt("scrollTime")),c=this.timeGrid.computeTimeTop(a);return c=Math.ceil(c),c&&c++,c},prepareHits:function(){this.timeGrid.prepareHits(),this.dayGrid&&this.dayGrid.prepareHits()},releaseHits:function(){this.timeGrid.releaseHits(),this.dayGrid&&this.dayGrid.releaseHits()},queryHit:function(a,b){var c=this.timeGrid.queryHit(a,b);return!c&&this.dayGrid&&(c=this.dayGrid.queryHit(a,b)),c},getHitSpan:function(a){return a.component.getHitSpan(a)},getHitEl:function(a){return a.component.getHitEl(a)},renderEvents:function(a){var b,c,d=[],e=[],f=[];for(c=0;c |