tags, normalized to work cross-browser)
---------------------------------------------------------------------------------------------------*/
-
-.fc button {
- /* force height to include the border and padding */
- -moz-box-sizing: border-box;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
-
- /* dimensions */
- margin: 0;
- height: 2.1em;
- padding: 0 .6em;
-
- /* text & cursor */
- font-size: 1em; /* normalize */
- white-space: nowrap;
- cursor: pointer;
-}
-
-/* Firefox has an annoying inner border */
-.fc button::-moz-focus-inner { margin: 0; padding: 0; }
-
-.fc-state-default { /* non-theme */
- border: 1px solid;
-}
-
-.fc-state-default.fc-corner-left { /* non-theme */
- border-top-left-radius: 4px;
- border-bottom-left-radius: 4px;
-}
-
-.fc-state-default.fc-corner-right { /* non-theme */
- border-top-right-radius: 4px;
- border-bottom-right-radius: 4px;
-}
-
-/* icons in buttons */
-
-.fc button .fc-icon { /* non-theme */
- position: relative;
- top: -0.05em; /* seems to be a good adjustment across browsers */
- margin: 0 .2em;
- vertical-align: middle;
-}
-
-/*
- button states
- borrowed from twitter bootstrap (http://twitter.github.com/bootstrap/)
-*/
-
-.fc-state-default {
- background-color: #f5f5f5;
- background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
- background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
- background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
- background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
- background-repeat: repeat-x;
- border-color: #e6e6e6 #e6e6e6 #bfbfbf;
- border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
- color: #333;
- text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
- box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.fc-state-hover,
-.fc-state-down,
-.fc-state-active,
-.fc-state-disabled {
- color: #333333;
- background-color: #e6e6e6;
-}
-
-.fc-state-hover {
- color: #333333;
- text-decoration: none;
- background-position: 0 -15px;
- -webkit-transition: background-position 0.1s linear;
- -moz-transition: background-position 0.1s linear;
- -o-transition: background-position 0.1s linear;
- transition: background-position 0.1s linear;
-}
-
-.fc-state-down,
-.fc-state-active {
- background-color: #cccccc;
- background-image: none;
- box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
-}
-
-.fc-state-disabled {
- cursor: default;
- background-image: none;
- opacity: 0.65;
- box-shadow: none;
-}
-
-
-/* Buttons Groups
---------------------------------------------------------------------------------------------------*/
-
-.fc-button-group {
- display: inline-block;
-}
-
-/*
-every button that is not first in a button group should scootch over one pixel and cover the
-previous button's border...
-*/
-
-.fc .fc-button-group > * { /* extra precedence b/c buttons have margin set to zero */
- float: left;
- margin: 0 0 0 -1px;
-}
-
-.fc .fc-button-group > :first-child { /* same */
- margin-left: 0;
-}
-
-
-/* Popover
---------------------------------------------------------------------------------------------------*/
-
-.fc-popover {
- position: absolute;
- box-shadow: 0 2px 6px rgba(0,0,0,.15);
-}
-
-.fc-popover .fc-header { /* TODO: be more consistent with fc-head/fc-body */
- 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-rtl .fc-popover .fc-header .fc-title,
-.fc-ltr .fc-popover .fc-header .fc-close {
- float: right;
-}
-
-/* unthemed */
-
-.fc-unthemed .fc-popover {
- border-width: 1px;
- border-style: solid;
-}
-
-.fc-unthemed .fc-popover .fc-header .fc-close {
- font-size: .9em;
- margin-top: 2px;
-}
-
-/* jqui themed */
-
-.fc-popover > .ui-widget-header + .ui-widget-content {
- border-top: 0; /* where they meet, let the header have the border */
-}
-
-
-/* Misc Reusable Components
---------------------------------------------------------------------------------------------------*/
-
-.fc-divider {
- border-style: solid;
- border-width: 1px;
-}
-
-hr.fc-divider {
- height: 0;
- margin: 0;
- padding: 0 0 2px; /* height is unreliable across browsers, so use padding */
- border-width: 1px 0;
-}
-
-.fc-clear {
- clear: both;
-}
-
-.fc-bg,
-.fc-bgevent-skeleton,
-.fc-highlight-skeleton,
-.fc-helper-skeleton {
- /* these element should always cling to top-left/right corners */
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
-}
-
-.fc-bg {
- bottom: 0; /* strech bg to bottom edge */
-}
-
-.fc-bg table {
- height: 100%; /* strech bg to bottom edge */
-}
-
-
-/* Tables
---------------------------------------------------------------------------------------------------*/
-
-.fc table {
- width: 100%;
- box-sizing: border-box; /* fix scrollbar issue in firefox */
- table-layout: fixed;
- border-collapse: collapse;
- border-spacing: 0;
- font-size: 1em; /* normalize cross-browser */
-}
-
-.fc th {
- text-align: center;
-}
-
-.fc th,
-.fc td {
- border-style: solid;
- border-width: 1px;
- padding: 0;
- vertical-align: top;
-}
-
-.fc td.fc-today {
- border-style: double; /* overcome neighboring borders */
-}
-
-
-/* Internal Nav Links
---------------------------------------------------------------------------------------------------*/
-
-a[data-goto] {
- cursor: pointer;
-}
-
-a[data-goto]:hover {
- text-decoration: underline;
-}
-
-
-/* Fake Table Rows
---------------------------------------------------------------------------------------------------*/
-
-.fc .fc-row { /* extra precedence to overcome themes w/ .ui-widget-content forcing a 1px border */
- /* no visible border by default. but make available if need be (scrollbar width compensation) */
- border-style: solid;
- border-width: 0;
-}
-
-.fc-row table {
- /* don't put left/right border on anything within a fake row.
- the outer tbody will worry about this */
- border-left: 0 hidden transparent;
- border-right: 0 hidden transparent;
-
- /* no bottom borders on rows */
- border-bottom: 0 hidden transparent;
-}
-
-.fc-row:first-child table {
- border-top: 0 hidden transparent; /* no top border on first row */
-}
-
-
-/* Day Row (used within the header and the DayGrid)
---------------------------------------------------------------------------------------------------*/
-
-.fc-row {
- position: relative;
-}
-
-.fc-row .fc-bg {
- z-index: 1;
-}
-
-/* highlighting cells & background event skeleton */
-
-.fc-row .fc-bgevent-skeleton,
-.fc-row .fc-highlight-skeleton {
- bottom: 0; /* stretch skeleton to bottom of row */
-}
-
-.fc-row .fc-bgevent-skeleton table,
-.fc-row .fc-highlight-skeleton table {
- height: 100%; /* stretch skeleton to bottom of row */
-}
-
-.fc-row .fc-highlight-skeleton td,
-.fc-row .fc-bgevent-skeleton td {
- border-color: transparent;
-}
-
-.fc-row .fc-bgevent-skeleton {
- z-index: 2;
-
-}
-
-.fc-row .fc-highlight-skeleton {
- z-index: 3;
-}
-
-/*
-row content (which contains day/week numbers and events) as well as "helper" (which contains
-temporary rendered events).
-*/
-
-.fc-row .fc-content-skeleton {
- position: relative;
- z-index: 4;
- padding-bottom: 2px; /* matches the space above the events */
-}
-
-.fc-row .fc-helper-skeleton {
- z-index: 5;
-}
-
-.fc-row .fc-content-skeleton td,
-.fc-row .fc-helper-skeleton td {
- /* see-through to the background below */
- background: none; /* in case s are globally styled */
- border-color: transparent;
-
- /* don't put a border between events and/or the day number */
- border-bottom: 0;
-}
-
-.fc-row .fc-content-skeleton tbody td, /* cells with events inside (so NOT the day number cell) */
-.fc-row .fc-helper-skeleton tbody td {
- /* don't put a border between event cells */
- border-top: 0;
-}
-
-
-/* Scrolling Container
---------------------------------------------------------------------------------------------------*/
-
-.fc-scroller {
- -webkit-overflow-scrolling: touch;
-}
-
-/* TODO: move to agenda/basic */
-.fc-scroller > .fc-day-grid,
-.fc-scroller > .fc-time-grid {
- position: relative; /* re-scope all positions */
- width: 100%; /* hack to force re-sizing this inner element when scrollbars appear/disappear */
-}
-
-
-/* Global Event Styles
---------------------------------------------------------------------------------------------------*/
-
-.fc-event {
- position: relative; /* for resize handle and other inner positioning */
- display: block; /* make the tag block */
- font-size: .85em;
- line-height: 1.3;
- border-radius: 3px;
- border: 1px solid #3a87ad; /* default BORDER color */
- font-weight: normal; /* undo jqui's ui-widget-header bold */
-}
-
-.fc-event,
-.fc-event-dot {
- background-color: #3a87ad; /* default BACKGROUND color */
-}
-
-/* overpower some of bootstrap's and jqui's styles on tags */
-.fc-event,
-.fc-event:hover,
-.ui-widget .fc-event {
- color: #fff; /* default TEXT color */
- text-decoration: none; /* if has an href */
-}
-
-.fc-event[href],
-.fc-event.fc-draggable {
- cursor: pointer; /* give events with links and draggable events a hand mouse pointer */
-}
-
-.fc-not-allowed, /* causes a "warning" cursor. applied on body */
-.fc-not-allowed .fc-event { /* to override an event's custom cursor */
- cursor: not-allowed;
-}
-
-.fc-event .fc-bg { /* the generic .fc-bg already does position */
- z-index: 1;
- background: #fff;
- opacity: .25;
-}
-
-.fc-event .fc-content {
- position: relative;
- z-index: 2;
-}
-
-/* resizer (cursor AND touch devices) */
-
-.fc-event .fc-resizer {
- position: absolute;
- z-index: 4;
-}
-
-/* resizer (touch devices) */
-
-.fc-event .fc-resizer {
- display: none;
-}
-
-.fc-event.fc-allow-mouse-resize .fc-resizer,
-.fc-event.fc-selected .fc-resizer {
- /* only show when hovering or selected (with touch) */
- display: block;
-}
-
-/* hit area */
-
-.fc-event.fc-selected .fc-resizer:before {
- /* 40x40 touch area */
- content: "";
- position: absolute;
- z-index: 9999; /* user of this util can scope within a lower z-index */
- top: 50%;
- left: 50%;
- width: 40px;
- height: 40px;
- margin-left: -20px;
- margin-top: -20px;
-}
-
-
-/* Event Selection (only for touch devices)
---------------------------------------------------------------------------------------------------*/
-
-.fc-event.fc-selected {
- z-index: 9999 !important; /* overcomes inline z-index */
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
-}
-
-.fc-event.fc-selected.fc-dragging {
- box-shadow: 0 2px 7px rgba(0, 0, 0, 0.3);
-}
-
-
-/* Horizontal Events
---------------------------------------------------------------------------------------------------*/
-
-/* bigger touch area when selected */
-.fc-h-event.fc-selected:before {
- content: "";
- position: absolute;
- z-index: 3; /* below resizers */
- top: -10px;
- bottom: -10px;
- left: 0;
- right: 0;
-}
-
-/* events that are continuing to/from another week. kill rounded corners and butt up against edge */
-
-.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; /* replace the border with padding */
- 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; /* replace the border with padding */
- border-top-right-radius: 0;
- border-bottom-right-radius: 0;
-}
-
-/* resizer (cursor AND touch devices) */
-
-/* left resizer */
-.fc-ltr .fc-h-event .fc-start-resizer,
-.fc-rtl .fc-h-event .fc-end-resizer {
- cursor: w-resize;
- left: -1px; /* overcome border */
-}
-
-/* right resizer */
-.fc-ltr .fc-h-event .fc-end-resizer,
-.fc-rtl .fc-h-event .fc-start-resizer {
- cursor: e-resize;
- right: -1px; /* overcome border */
-}
-
-/* resizer (mouse devices) */
-
-.fc-h-event.fc-allow-mouse-resize .fc-resizer {
- width: 7px;
- top: -1px; /* overcome top border */
- bottom: -1px; /* overcome bottom border */
-}
-
-/* resizer (touch devices) */
-
-.fc-h-event.fc-selected .fc-resizer {
- /* 8x8 little dot */
- border-radius: 4px;
- border-width: 1px;
- width: 6px;
- height: 6px;
- border-style: solid;
- border-color: inherit;
- background: #fff;
- /* vertically center */
- top: 50%;
- margin-top: -4px;
-}
-
-/* left resizer */
-.fc-ltr .fc-h-event.fc-selected .fc-start-resizer,
-.fc-rtl .fc-h-event.fc-selected .fc-end-resizer {
- margin-left: -4px; /* centers the 8x8 dot on the left edge */
-}
-
-/* right resizer */
-.fc-ltr .fc-h-event.fc-selected .fc-end-resizer,
-.fc-rtl .fc-h-event.fc-selected .fc-start-resizer {
- margin-right: -4px; /* centers the 8x8 dot on the right edge */
-}
-
-
-/* DayGrid events
-----------------------------------------------------------------------------------------------------
-We use the full "fc-day-grid-event" class instead of using descendants because the event won't
-be a descendant of the grid when it is being dragged.
-*/
-
-.fc-day-grid-event {
- margin: 1px 2px 0; /* spacing between events and edges */
- padding: 0 1px;
-}
-
-tr:first-child > td > .fc-day-grid-event {
- margin-top: 2px; /* a little bit more space before the first event */
-}
-
-.fc-day-grid-event.fc-selected:after {
- content: "";
- position: absolute;
- z-index: 1; /* same z-index as fc-bg, behind text */
- /* overcome the borders */
- top: -1px;
- right: -1px;
- bottom: -1px;
- left: -1px;
- /* darkening effect */
- background: #000;
- opacity: .25;
-}
-
-.fc-day-grid-event .fc-content { /* force events to be one-line tall */
- white-space: nowrap;
- overflow: hidden;
-}
-
-.fc-day-grid-event .fc-time {
- font-weight: bold;
-}
-
-/* resizer (cursor devices) */
-
-/* left resizer */
-.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer,
-.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer {
- margin-left: -2px; /* to the day cell's edge */
-}
-
-/* right resizer */
-.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer,
-.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer {
- margin-right: -2px; /* to the day cell's edge */
-}
-
-
-/* Event Limiting
---------------------------------------------------------------------------------------------------*/
-
-/* "more" link that represents hidden events */
-
-a.fc-more {
- margin: 1px 3px;
- font-size: .85em;
- cursor: pointer;
- text-decoration: none;
-}
-
-a.fc-more:hover {
- text-decoration: underline;
-}
-
-.fc-limited { /* rows and cells that are hidden because of a "more" link */
- display: none;
-}
-
-/* popover that appears when "more" link is clicked */
-
-.fc-day-grid .fc-row {
- z-index: 1; /* make the "more" popover one higher than this */
-}
-
-.fc-more-popover {
- z-index: 2;
- width: 220px;
-}
-
-.fc-more-popover .fc-event-container {
- padding: 10px;
-}
-
-
-/* Now Indicator
---------------------------------------------------------------------------------------------------*/
-
-.fc-now-indicator {
- position: absolute;
- border: 0 solid red;
-}
-
-
-/* Utilities
---------------------------------------------------------------------------------------------------*/
-
-.fc-unselectable {
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- -webkit-touch-callout: none;
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-}
-
-
-
-/* Toolbar
---------------------------------------------------------------------------------------------------*/
-
-.fc-toolbar {
- text-align: center;
-}
-
-.fc-toolbar.fc-header-toolbar {
- margin-bottom: 1em;
-}
-
-.fc-toolbar.fc-footer-toolbar {
- margin-top: 1em;
-}
-
-.fc-toolbar .fc-left {
- float: left;
-}
-
-.fc-toolbar .fc-right {
- float: right;
-}
-
-.fc-toolbar .fc-center {
- display: inline-block;
-}
-
-/* the things within each left/right/center section */
-.fc .fc-toolbar > * > * { /* extra precedence to override button border margins */
- float: left;
- margin-left: .75em;
-}
-
-/* the first thing within each left/center/right section */
-.fc .fc-toolbar > * > :first-child { /* extra precedence to override button border margins */
- margin-left: 0;
-}
-
-/* title text */
-
-.fc-toolbar h2 {
- margin: 0;
-}
-
-/* button layering (for border precedence) */
-
-.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;
-}
-
-
-/* View Structure
---------------------------------------------------------------------------------------------------*/
-
-/* undo twitter bootstrap's box-sizing rules. normalizes positioning techniques */
-/* don't do this for the toolbar because we'll want bootstrap to style those buttons as some pt */
-.fc-view-container *,
-.fc-view-container *:before,
-.fc-view-container *:after {
- -webkit-box-sizing: content-box;
- -moz-box-sizing: content-box;
- box-sizing: content-box;
-}
-
-.fc-view, /* scope positioning and z-index's for everything within the view */
-.fc-view > table { /* so dragged elements can be above the view's main element */
- position: relative;
- z-index: 1;
-}
-
-
-
-/* BasicView
---------------------------------------------------------------------------------------------------*/
-
-/* day row structure */
-
-.fc-basicWeek-view .fc-content-skeleton,
-.fc-basicDay-view .fc-content-skeleton {
- /* there may be week numbers in these views, so no padding-top */
- padding-bottom: 1em; /* ensure a space at bottom of cell for user selecting/clicking */
-}
-
-.fc-basic-view .fc-body .fc-row {
- min-height: 4em; /* ensure that all rows are at least this tall */
-}
-
-/* a "rigid" row will take up a constant amount of height because content-skeleton is absolute */
-
-.fc-row.fc-rigid {
- overflow: hidden;
-}
-
-.fc-row.fc-rigid .fc-content-skeleton {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
-}
-
-/* week and day number styling */
-
-.fc-day-top.fc-other-month {
- opacity: 0.3;
-}
-
-.fc-basic-view .fc-week-number,
-.fc-basic-view .fc-day-number {
- padding: 2px;
-}
-
-.fc-basic-view th.fc-week-number,
-.fc-basic-view th.fc-day-number {
- padding: 0 2px; /* column headers can't have as much v space */
-}
-
-.fc-ltr .fc-basic-view .fc-day-top .fc-day-number { float: right; }
-.fc-rtl .fc-basic-view .fc-day-top .fc-day-number { float: left; }
-
-.fc-ltr .fc-basic-view .fc-day-top .fc-week-number { float: left; border-radius: 0 0 3px 0; }
-.fc-rtl .fc-basic-view .fc-day-top .fc-week-number { float: right; border-radius: 0 0 0 3px; }
-
-.fc-basic-view .fc-day-top .fc-week-number {
- min-width: 1.5em;
- text-align: center;
- background-color: #f2f2f2;
- color: #808080;
-}
-
-/* when week/day number have own column */
-
-.fc-basic-view td.fc-week-number {
- text-align: center;
-}
-
-.fc-basic-view td.fc-week-number > * {
- /* work around the way we do column resizing and ensure a minimum width */
- display: inline-block;
- min-width: 1.25em;
-}
-
-
-/* AgendaView all-day area
---------------------------------------------------------------------------------------------------*/
-
-.fc-agenda-view .fc-day-grid {
- position: relative;
- z-index: 2; /* so the "more.." popover will be over the time grid */
-}
-
-.fc-agenda-view .fc-day-grid .fc-row {
- min-height: 3em; /* all-day section will never get shorter than this */
-}
-
-.fc-agenda-view .fc-day-grid .fc-row .fc-content-skeleton {
- padding-bottom: 1em; /* give space underneath events for clicking/selecting days */
-}
-
-
-/* TimeGrid axis running down the side (for both the all-day area and the slot area)
---------------------------------------------------------------------------------------------------*/
-
-.fc .fc-axis { /* .fc to overcome default cell styles */
- 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: normal; /* overcome jqui theme making it bold */
-}
-
-
-/* TimeGrid Structure
---------------------------------------------------------------------------------------------------*/
-
-.fc-time-grid-container, /* so scroll container's z-index is below all-day */
-.fc-time-grid { /* so slats/bg/content/etc positions get scoped within here */
- position: relative;
- z-index: 1;
-}
-
-.fc-time-grid {
- min-height: 100%; /* so if height setting is 'auto', .fc-bg stretches to fill height */
-}
-
-.fc-time-grid table { /* don't put outer borders on slats/bg/content/etc */
- border: 0 hidden transparent;
-}
-
-.fc-time-grid > .fc-bg {
- z-index: 1;
-}
-
-.fc-time-grid .fc-slats,
-.fc-time-grid > hr { /* the AgendaView injects when grid is shorter than scroller */
- position: relative;
- z-index: 2;
-}
-
-.fc-time-grid .fc-content-col {
- position: relative; /* because now-indicator lives directly inside */
-}
-
-.fc-time-grid .fc-content-skeleton {
- position: absolute;
- z-index: 3;
- top: 0;
- left: 0;
- right: 0;
-}
-
-/* divs within a cell within the fc-content-skeleton */
-
-.fc-time-grid .fc-business-container {
- position: relative;
- z-index: 1;
-}
-
-.fc-time-grid .fc-bgevent-container {
- position: relative;
- z-index: 2;
-}
-
-.fc-time-grid .fc-highlight-container {
- position: relative;
- z-index: 3;
-}
-
-.fc-time-grid .fc-event-container {
- position: relative;
- z-index: 4;
-}
-
-.fc-time-grid .fc-now-indicator-line {
- z-index: 5;
-}
-
-.fc-time-grid .fc-helper-container { /* also is fc-event-container */
- position: relative;
- z-index: 6;
-}
-
-
-/* TimeGrid Slats (lines that run horizontally)
---------------------------------------------------------------------------------------------------*/
-
-.fc-time-grid .fc-slats td {
- height: 1.5em;
- border-bottom: 0; /* each cell is responsible for its top border */
-}
-
-.fc-time-grid .fc-slats .fc-minor td {
- border-top-style: dotted;
-}
-
-.fc-time-grid .fc-slats .ui-widget-content { /* for jqui theme */
- background: none; /* see through to fc-bg */
-}
-
-
-/* TimeGrid Highlighting Slots
---------------------------------------------------------------------------------------------------*/
-
-.fc-time-grid .fc-highlight-container { /* a div within a cell within the fc-highlight-skeleton */
- position: relative; /* scopes the left/right of the fc-highlight to be in the column */
-}
-
-.fc-time-grid .fc-highlight {
- position: absolute;
- left: 0;
- right: 0;
- /* top and bottom will be in by JS */
-}
-
-
-/* TimeGrid Event Containment
---------------------------------------------------------------------------------------------------*/
-
-.fc-ltr .fc-time-grid .fc-event-container { /* space on the sides of events for LTR (default) */
- margin: 0 2.5% 0 2px;
-}
-
-.fc-rtl .fc-time-grid .fc-event-container { /* space on the sides of events for RTL */
- margin: 0 2px 0 2.5%;
-}
-
-.fc-time-grid .fc-event,
-.fc-time-grid .fc-bgevent {
- position: absolute;
- z-index: 1; /* scope inner z-index's */
-}
-
-.fc-time-grid .fc-bgevent {
- /* background events always span full width */
- left: 0;
- right: 0;
-}
-
-
-/* Generic Vertical Event
---------------------------------------------------------------------------------------------------*/
-
-.fc-v-event.fc-not-start { /* events that are continuing from another day */
- /* replace space made by the top border with padding */
- border-top-width: 0;
- padding-top: 1px;
-
- /* remove top rounded corners */
- border-top-left-radius: 0;
- border-top-right-radius: 0;
-}
-
-.fc-v-event.fc-not-end {
- /* replace space made by the top border with padding */
- border-bottom-width: 0;
- padding-bottom: 1px;
-
- /* remove bottom rounded corners */
- border-bottom-left-radius: 0;
- border-bottom-right-radius: 0;
-}
-
-
-/* TimeGrid Event Styling
-----------------------------------------------------------------------------------------------------
-We use the full "fc-time-grid-event" class instead of using descendants because the event won't
-be a descendant of the grid when it is being dragged.
-*/
-
-.fc-time-grid-event {
- overflow: hidden; /* don't let the bg flow over rounded corners */
-}
-
-.fc-time-grid-event.fc-selected {
- /* need to allow touch resizers to extend outside event's bounding box */
- /* common fc-selected styles hide the fc-bg, so don't need this anyway */
- overflow: visible;
-}
-
-.fc-time-grid-event.fc-selected .fc-bg {
- display: none; /* hide semi-white background, to appear darker */
-}
-
-.fc-time-grid-event .fc-content {
- overflow: hidden; /* for when .fc-selected */
-}
-
-.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;
-}
-
-/* short mode, where time and title are on the same line */
-
-.fc-time-grid-event.fc-short .fc-content {
- /* don't wrap to second line (now that contents will be inline) */
- white-space: nowrap;
-}
-
-.fc-time-grid-event.fc-short .fc-time,
-.fc-time-grid-event.fc-short .fc-title {
- /* put the time and title on the same line */
- display: inline-block;
- vertical-align: top;
-}
-
-.fc-time-grid-event.fc-short .fc-time span {
- display: none; /* don't display the full time text... */
-}
-
-.fc-time-grid-event.fc-short .fc-time:before {
- content: attr(data-start); /* ...instead, display only the start time */
-}
-
-.fc-time-grid-event.fc-short .fc-time:after {
- content: "\000A0-\000A0"; /* seperate with a dash, wrapped in nbsp's */
-}
-
-.fc-time-grid-event.fc-short .fc-title {
- font-size: .85em; /* make the title text the same size as the time */
- padding: 0; /* undo padding from above */
-}
-
-/* resizer (cursor device) */
-
-.fc-time-grid-event.fc-allow-mouse-resize .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-allow-mouse-resize .fc-resizer:after {
- content: "=";
-}
-
-/* resizer (touch device) */
-
-.fc-time-grid-event.fc-selected .fc-resizer {
- /* 10x10 dot */
- border-radius: 5px;
- border-width: 1px;
- width: 8px;
- height: 8px;
- border-style: solid;
- border-color: inherit;
- background: #fff;
- /* horizontally center */
- left: 50%;
- margin-left: -5px;
- /* center on the bottom edge */
- bottom: -5px;
-}
-
-
-/* Now Indicator
---------------------------------------------------------------------------------------------------*/
-
-.fc-time-grid .fc-now-indicator-line {
- border-top-width: 1px;
- left: 0;
- right: 0;
-}
-
-/* arrow on axis */
-
-.fc-time-grid .fc-now-indicator-arrow {
- margin-top: -5px; /* vertically center on top coordinate */
-}
-
-.fc-ltr .fc-time-grid .fc-now-indicator-arrow {
- left: 0;
- /* triangle pointing right... */
- border-width: 5px 0 5px 6px;
- border-top-color: transparent;
- border-bottom-color: transparent;
-}
-
-.fc-rtl .fc-time-grid .fc-now-indicator-arrow {
- right: 0;
- /* triangle pointing left... */
- border-width: 5px 6px 5px 0;
- border-top-color: transparent;
- border-bottom-color: transparent;
-}
-
-
-
-/* List View
---------------------------------------------------------------------------------------------------*/
-
-/* possibly reusable */
-
-.fc-event-dot {
- display: inline-block;
- width: 10px;
- height: 10px;
- border-radius: 5px;
-}
-
-/* view wrapper */
-
-.fc-rtl .fc-list-view {
- direction: rtl; /* unlike core views, leverage browser RTL */
-}
-
-.fc-list-view {
- border-width: 1px;
- border-style: solid;
-}
-
-/* table resets */
-
-.fc .fc-list-table {
- table-layout: auto; /* for shrinkwrapping cell content */
-}
-
-.fc-list-table td {
- border-width: 1px 0 0;
- padding: 8px 14px;
-}
-
-.fc-list-table tr:first-child td {
- border-top-width: 0;
-}
-
-/* day headings with the list */
-
-.fc-list-heading {
- border-bottom-width: 1px;
-}
-
-.fc-list-heading td {
- font-weight: bold;
-}
-
-.fc-ltr .fc-list-heading-main { float: left; }
-.fc-ltr .fc-list-heading-alt { float: right; }
-
-.fc-rtl .fc-list-heading-main { float: right; }
-.fc-rtl .fc-list-heading-alt { float: left; }
-
-/* event list items */
-
-.fc-list-item.fc-has-url {
- cursor: pointer; /* whole row will be clickable */
-}
-
-.fc-list-item:hover td {
- background-color: #f5f5f5;
-}
-
-.fc-list-item-marker,
-.fc-list-item-time {
- white-space: nowrap;
- width: 1px;
-}
-
-/* make the dot closer to the event title */
-.fc-ltr .fc-list-item-marker { padding-right: 0; }
-.fc-rtl .fc-list-item-marker { padding-left: 0; }
-
-.fc-list-item-title a {
- /* every event title cell has an tag */
- text-decoration: none;
- color: inherit;
-}
-
-.fc-list-item-title a[href]:hover {
- /* hover effect only on titles with hrefs */
- text-decoration: underline;
-}
-
-/* message when no events */
-
-.fc-list-empty-wrap2 {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
-}
-
-.fc-list-empty-wrap1 {
- width: 100%;
- height: 100%;
- display: table;
-}
-
-.fc-list-empty {
- display: table-cell;
- vertical-align: middle;
- text-align: center;
-}
-
-.fc-unthemed .fc-list-empty { /* theme will provide own background */
- background-color: #eee;
-}
diff --git a/src/cone/calendar/browser/static/fullcalendar/fullcalendar.js b/src/cone/calendar/browser/static/fullcalendar/fullcalendar.js
index b7371e2..9aac5a3 100644
--- a/src/cone/calendar/browser/static/fullcalendar/fullcalendar.js
+++ b/src/cone/calendar/browser/static/fullcalendar/fullcalendar.js
@@ -1,14206 +1,12813 @@
-/*!
- * FullCalendar v3.1.0
- * Docs & License: http://fullcalendar.io/
- * (c) 2016 Adam Shaw
- */
-
-(function(factory) {
- if (typeof define === 'function' && define.amd) {
- define([ 'jquery', 'moment' ], factory);
- }
- else if (typeof exports === 'object') { // Node/CommonJS
- module.exports = factory(require('jquery'), require('moment'));
- }
- else {
- factory(jQuery, moment);
- }
-})(function($, moment) {
-
-;;
-
-var FC = $.fullCalendar = {
- version: "3.1.0",
- internalApiVersion: 7
-};
-var fcViews = FC.views = {};
-
-
-$.fn.fullCalendar = function(options) {
- var args = Array.prototype.slice.call(arguments, 1); // for a possible method call
- var res = this; // what this function will return (this jQuery object by default)
-
- this.each(function(i, _element) { // loop each DOM element involved
- var element = $(_element);
- var calendar = element.data('fullCalendar'); // get the existing calendar object (if any)
- var singleRes; // the returned value of this single method call
-
- // a method call
- if (typeof options === 'string') {
- if (calendar && $.isFunction(calendar[options])) {
- singleRes = calendar[options].apply(calendar, args);
- if (!i) {
- res = singleRes; // record the first method call result
- }
- if (options === 'destroy') { // for the destroy method, must remove Calendar object data
- element.removeData('fullCalendar');
- }
- }
- }
- // a new calendar initialization
- else if (!calendar) { // don't initialize twice
- calendar = new Calendar(element, options);
- element.data('fullCalendar', calendar);
- calendar.render();
- }
- });
-
- return res;
-};
-
-
-var complexOptions = [ // names of options that are objects whose properties should be combined
- 'header',
- 'footer',
- 'buttonText',
- 'buttonIcons',
- 'themeButtonIcons'
-];
-
-
-// Merges an array of option objects into a single object
-function mergeOptions(optionObjs) {
- return mergeProps(optionObjs, complexOptions);
-}
-
-;;
-
-// exports
-FC.intersectRanges = intersectRanges;
-FC.applyAll = applyAll;
-FC.debounce = debounce;
-FC.isInt = isInt;
-FC.htmlEscape = htmlEscape;
-FC.cssToStr = cssToStr;
-FC.proxy = proxy;
-FC.capitaliseFirstLetter = capitaliseFirstLetter;
-
-
-/* FullCalendar-specific DOM Utilities
-----------------------------------------------------------------------------------------------------------------------*/
-
-
-// Given the scrollbar widths of some other container, create borders/margins on rowEls in order to match the left
-// and right space that was offset by the scrollbars. A 1-pixel border first, then margin beyond that.
-function compensateScroll(rowEls, scrollbarWidths) {
- if (scrollbarWidths.left) {
- rowEls.css({
- 'border-left-width': 1,
- 'margin-left': scrollbarWidths.left - 1
- });
- }
- if (scrollbarWidths.right) {
- rowEls.css({
- 'border-right-width': 1,
- 'margin-right': scrollbarWidths.right - 1
- });
- }
-}
-
-
-// Undoes compensateScroll and restores all borders/margins
-function uncompensateScroll(rowEls) {
- rowEls.css({
- 'margin-left': '',
- 'margin-right': '',
- 'border-left-width': '',
- 'border-right-width': ''
- });
-}
-
-
-// Make the mouse cursor express that an event is not allowed in the current area
-function disableCursor() {
- $('body').addClass('fc-not-allowed');
-}
-
-
-// Returns the mouse cursor to its original look
-function enableCursor() {
- $('body').removeClass('fc-not-allowed');
-}
-
-
-// Given a total available height to fill, have `els` (essentially child rows) expand to accomodate.
-// By default, all elements that are shorter than the recommended height are expanded uniformly, not considering
-// any other els that are already too tall. if `shouldRedistribute` is on, it considers these tall rows and
-// reduces the available height.
-function distributeHeight(els, availableHeight, shouldRedistribute) {
-
- // *FLOORING NOTE*: we floor in certain places because zoom can give inaccurate floating-point dimensions,
- // and it is better to be shorter than taller, to avoid creating unnecessary scrollbars.
-
- var minOffset1 = Math.floor(availableHeight / els.length); // for non-last element
- var minOffset2 = Math.floor(availableHeight - minOffset1 * (els.length - 1)); // for last element *FLOORING NOTE*
- var flexEls = []; // elements that are allowed to expand. array of DOM nodes
- var flexOffsets = []; // amount of vertical space it takes up
- var flexHeights = []; // actual css height
- var usedHeight = 0;
-
- undistributeHeight(els); // give all elements their natural height
-
- // find elements that are below the recommended height (expandable).
- // important to query for heights in a single first pass (to avoid reflow oscillation).
- els.each(function(i, el) {
- var minOffset = i === els.length - 1 ? minOffset2 : minOffset1;
- var naturalOffset = $(el).outerHeight(true);
-
- if (naturalOffset < minOffset) {
- flexEls.push(el);
- flexOffsets.push(naturalOffset);
- flexHeights.push($(el).height());
- }
- else {
- // this element stretches past recommended height (non-expandable). mark the space as occupied.
- usedHeight += naturalOffset;
- }
- });
-
- // readjust the recommended height to only consider the height available to non-maxed-out rows.
- if (shouldRedistribute) {
- availableHeight -= usedHeight;
- minOffset1 = Math.floor(availableHeight / flexEls.length);
- minOffset2 = Math.floor(availableHeight - minOffset1 * (flexEls.length - 1)); // *FLOORING NOTE*
- }
-
- // assign heights to all expandable elements
- $(flexEls).each(function(i, el) {
- var minOffset = i === flexEls.length - 1 ? minOffset2 : minOffset1;
- var naturalOffset = flexOffsets[i];
- var naturalHeight = flexHeights[i];
- var newHeight = minOffset - (naturalOffset - naturalHeight); // subtract the margin/padding
-
- if (naturalOffset < minOffset) { // we check this again because redistribution might have changed things
- $(el).height(newHeight);
- }
- });
-}
-
-
-// Undoes distrubuteHeight, restoring all els to their natural height
-function undistributeHeight(els) {
- els.height('');
-}
-
-
-// Given `els`, a jQuery set of cells, find the cell with the largest natural width and set the widths of all the
-// cells to be that width.
-// PREREQUISITE: if you want a cell to take up width, it needs to have a single inner element w/ display:inline
-function matchCellWidths(els) {
- var maxInnerWidth = 0;
-
- els.find('> *').each(function(i, innerEl) {
- var innerWidth = $(innerEl).outerWidth();
- if (innerWidth > maxInnerWidth) {
- maxInnerWidth = innerWidth;
- }
- });
-
- maxInnerWidth++; // sometimes not accurate of width the text needs to stay on one line. insurance
-
- els.width(maxInnerWidth);
-
- return maxInnerWidth;
-}
-
-
-// Given one element that resides inside another,
-// Subtracts the height of the inner element from the outer element.
-function subtractInnerElHeight(outerEl, innerEl) {
- var both = outerEl.add(innerEl);
- var diff;
-
- // effin' 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
- });
- diff = outerEl.outerHeight() - innerEl.outerHeight(); // grab the dimensions
- both.css({ position: '', left: '' }); // undo hack
-
- return diff;
-}
-
-
-/* Element Geom Utilities
-----------------------------------------------------------------------------------------------------------------------*/
-
-FC.getOuterRect = getOuterRect;
-FC.getClientRect = getClientRect;
-FC.getContentRect = getContentRect;
-FC.getScrollbarWidths = getScrollbarWidths;
-
-
-// borrowed from https://github.com/jquery/jquery-ui/blob/1.11.0/ui/core.js#L51
-function getScrollParent(el) {
- var position = el.css('position'),
- scrollParent = el.parents().filter(function() {
- var parent = $(this);
- return (/(auto|scroll)/).test(
- parent.css('overflow') + parent.css('overflow-y') + parent.css('overflow-x')
- );
- }).eq(0);
-
- return position === 'fixed' || !scrollParent.length ? $(el[0].ownerDocument || document) : scrollParent;
-}
-
-
-// Queries the outer bounding area of a jQuery element.
-// Returns a rectangle with absolute coordinates: left, right (exclusive), top, bottom (exclusive).
-// Origin is optional.
-function getOuterRect(el, origin) {
- var offset = el.offset();
- var left = offset.left - (origin ? origin.left : 0);
- var top = offset.top - (origin ? origin.top : 0);
-
- return {
- left: left,
- right: left + el.outerWidth(),
- top: top,
- bottom: top + el.outerHeight()
- };
-}
-
-
-// Queries the area within the margin/border/scrollbars of a jQuery element. Does not go within the padding.
-// Returns a rectangle with absolute coordinates: left, right (exclusive), top, bottom (exclusive).
-// Origin is optional.
-// NOTE: should use clientLeft/clientTop, but very unreliable cross-browser.
-function getClientRect(el, origin) {
- var offset = el.offset();
- var scrollbarWidths = getScrollbarWidths(el);
- var left = offset.left + getCssFloat(el, 'border-left-width') + scrollbarWidths.left - (origin ? origin.left : 0);
- var top = offset.top + getCssFloat(el, 'border-top-width') + scrollbarWidths.top - (origin ? origin.top : 0);
-
- return {
- left: left,
- right: left + el[0].clientWidth, // clientWidth includes padding but NOT scrollbars
- top: top,
- bottom: top + el[0].clientHeight // clientHeight includes padding but NOT scrollbars
- };
-}
-
-
-// Queries the area within the margin/border/padding of a jQuery element. Assumed not to have scrollbars.
-// Returns a rectangle with absolute coordinates: left, right (exclusive), top, bottom (exclusive).
-// Origin is optional.
-function getContentRect(el, origin) {
- var offset = el.offset(); // just outside of border, margin not included
- var left = offset.left + getCssFloat(el, 'border-left-width') + getCssFloat(el, 'padding-left') -
- (origin ? origin.left : 0);
- var top = offset.top + getCssFloat(el, 'border-top-width') + getCssFloat(el, 'padding-top') -
- (origin ? origin.top : 0);
-
- return {
- left: left,
- right: left + el.width(),
- top: top,
- bottom: top + el.height()
- };
-}
-
-
-// Returns the computed left/right/top/bottom scrollbar widths for the given jQuery element.
-// NOTE: should use clientLeft/clientTop, but very unreliable cross-browser.
-function getScrollbarWidths(el) {
- var leftRightWidth = el.innerWidth() - el[0].clientWidth; // the paddings cancel out, leaving the scrollbars
- var widths = {
- left: 0,
- right: 0,
- top: 0,
- bottom: el.innerHeight() - el[0].clientHeight // the paddings cancel out, leaving the bottom scrollbar
- };
-
- if (getIsLeftRtlScrollbars() && el.css('direction') == 'rtl') { // is the scrollbar on the left side?
- widths.left = leftRightWidth;
- }
- else {
- widths.right = leftRightWidth;
- }
-
- return widths;
-}
-
-
-// Logic for determining if, when the element is right-to-left, the scrollbar appears on the left side
-
-var _isLeftRtlScrollbars = null;
-
-function getIsLeftRtlScrollbars() { // responsible for caching the computation
- if (_isLeftRtlScrollbars === null) {
- _isLeftRtlScrollbars = computeIsLeftRtlScrollbars();
- }
- return _isLeftRtlScrollbars;
-}
-
-function computeIsLeftRtlScrollbars() { // creates an offscreen test element, then removes it
- var el = $('')
- .css({
- position: 'absolute',
- top: -1000,
- left: 0,
- border: 0,
- padding: 0,
- overflow: 'scroll',
- direction: 'rtl'
- })
- .appendTo('body');
- var innerEl = el.children();
- var res = innerEl.offset().left > el.offset().left; // is the inner div shifted to accommodate a left scrollbar?
- el.remove();
- return res;
-}
-
-
-// Retrieves a jQuery element's computed CSS value as a floating-point number.
-// If the queried value is non-numeric (ex: IE can return "medium" for border width), will just return zero.
-function getCssFloat(el, prop) {
- return parseFloat(el.css(prop)) || 0;
-}
-
-
-/* Mouse / Touch Utilities
-----------------------------------------------------------------------------------------------------------------------*/
-
-FC.preventDefault = preventDefault;
-
-
-// Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
-function isPrimaryMouseButton(ev) {
- return ev.which == 1 && !ev.ctrlKey;
-}
-
-
-function getEvX(ev) {
- if (ev.pageX !== undefined) {
- return ev.pageX;
- }
- var touches = ev.originalEvent.touches;
- if (touches) {
- return touches[0].pageX;
- }
-}
-
-
-function getEvY(ev) {
- if (ev.pageY !== undefined) {
- return ev.pageY;
- }
- var touches = ev.originalEvent.touches;
- if (touches) {
- return touches[0].pageY;
- }
-}
-
-
-function getEvIsTouch(ev) {
- return /^touch/.test(ev.type);
-}
-
-
-function preventSelection(el) {
- el.addClass('fc-unselectable')
- .on('selectstart', preventDefault);
-}
-
-
-// Stops a mouse/touch event from doing it's native browser action
-function preventDefault(ev) {
- ev.preventDefault();
-}
-
-
-// attach a handler to get called when ANY scroll action happens on the page.
-// this was impossible to do with normal on/off because 'scroll' doesn't bubble.
-// http://stackoverflow.com/a/32954565/96342
-// returns `true` on success.
-function bindAnyScroll(handler) {
- if (window.addEventListener) {
- window.addEventListener('scroll', handler, true); // useCapture=true
- return true;
- }
- return false;
-}
-
-
-// undoes bindAnyScroll. must pass in the original function.
-// returns `true` on success.
-function unbindAnyScroll(handler) {
- if (window.removeEventListener) {
- window.removeEventListener('scroll', handler, true); // useCapture=true
- return true;
- }
- return false;
-}
-
-
-/* General Geometry Utils
-----------------------------------------------------------------------------------------------------------------------*/
-
-FC.intersectRects = intersectRects;
-
-// Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
-function intersectRects(rect1, rect2) {
- var res = {
- left: Math.max(rect1.left, rect2.left),
- right: Math.min(rect1.right, rect2.right),
- top: Math.max(rect1.top, rect2.top),
- bottom: Math.min(rect1.bottom, rect2.bottom)
- };
-
- if (res.left < res.right && res.top < res.bottom) {
- return res;
- }
- return false;
-}
-
-
-// Returns a new point that will have been moved to reside within the given rectangle
-function constrainPoint(point, rect) {
- return {
- left: Math.min(Math.max(point.left, rect.left), rect.right),
- top: Math.min(Math.max(point.top, rect.top), rect.bottom)
- };
-}
-
-
-// Returns a point that is the center of the given rectangle
-function getRectCenter(rect) {
- return {
- left: (rect.left + rect.right) / 2,
- top: (rect.top + rect.bottom) / 2
- };
-}
-
-
-// Subtracts point2's coordinates from point1's coordinates, returning a delta
-function diffPoints(point1, point2) {
- return {
- left: point1.left - point2.left,
- top: point1.top - point2.top
- };
-}
-
-
-/* Object Ordering by Field
-----------------------------------------------------------------------------------------------------------------------*/
-
-FC.parseFieldSpecs = parseFieldSpecs;
-FC.compareByFieldSpecs = compareByFieldSpecs;
-FC.compareByFieldSpec = compareByFieldSpec;
-FC.flexibleCompare = flexibleCompare;
-
-
-function parseFieldSpecs(input) {
- var specs = [];
- var tokens = [];
- var i, token;
-
- if (typeof input === 'string') {
- tokens = input.split(/\s*,\s*/);
- }
- else if (typeof input === 'function') {
- tokens = [ input ];
- }
- else if ($.isArray(input)) {
- tokens = input;
- }
-
- for (i = 0; i < tokens.length; i++) {
- token = tokens[i];
-
- if (typeof token === 'string') {
- specs.push(
- token.charAt(0) == '-' ?
- { field: token.substring(1), order: -1 } :
- { field: token, order: 1 }
- );
- }
- else if (typeof token === 'function') {
- specs.push({ func: token });
- }
- }
-
- return specs;
-}
-
-
-function compareByFieldSpecs(obj1, obj2, fieldSpecs) {
- var i;
- var cmp;
-
- for (i = 0; i < fieldSpecs.length; i++) {
- cmp = compareByFieldSpec(obj1, obj2, fieldSpecs[i]);
- if (cmp) {
- return cmp;
- }
- }
-
- return 0;
-}
-
-
-function compareByFieldSpec(obj1, obj2, fieldSpec) {
- if (fieldSpec.func) {
- return fieldSpec.func(obj1, obj2);
- }
- return flexibleCompare(obj1[fieldSpec.field], obj2[fieldSpec.field]) *
- (fieldSpec.order || 1);
-}
-
-
-function flexibleCompare(a, b) {
- if (!a && !b) {
- return 0;
- }
- if (b == null) {
- return -1;
- }
- if (a == null) {
- return 1;
- }
- if ($.type(a) === 'string' || $.type(b) === 'string') {
- return String(a).localeCompare(String(b));
- }
- return a - b;
-}
-
-
-/* FullCalendar-specific Misc Utilities
-----------------------------------------------------------------------------------------------------------------------*/
-
-
-// Computes the intersection of the two ranges. Will return fresh date clones in a range.
-// Returns undefined if no intersection.
-// Expects all dates to be normalized to the same timezone beforehand.
-// TODO: move to date section?
-function intersectRanges(subjectRange, constraintRange) {
- var subjectStart = subjectRange.start;
- var subjectEnd = subjectRange.end;
- var constraintStart = constraintRange.start;
- var constraintEnd = constraintRange.end;
- var segStart, segEnd;
- var isStart, isEnd;
-
- if (subjectEnd > constraintStart && subjectStart < constraintEnd) { // in bounds at all?
-
- if (subjectStart >= constraintStart) {
- segStart = subjectStart.clone();
- isStart = true;
- }
- else {
- segStart = constraintStart.clone();
- isStart = false;
- }
-
- if (subjectEnd <= constraintEnd) {
- segEnd = subjectEnd.clone();
- isEnd = true;
- }
- else {
- segEnd = constraintEnd.clone();
- isEnd = false;
- }
-
- return {
- start: segStart,
- end: segEnd,
- isStart: isStart,
- isEnd: isEnd
- };
- }
-}
-
-
-/* Date Utilities
-----------------------------------------------------------------------------------------------------------------------*/
-
-FC.computeIntervalUnit = computeIntervalUnit;
-FC.divideRangeByDuration = divideRangeByDuration;
-FC.divideDurationByDuration = divideDurationByDuration;
-FC.multiplyDuration = multiplyDuration;
-FC.durationHasTime = durationHasTime;
-
-var dayIDs = [ 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat' ];
-var intervalUnits = [ 'year', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond' ];
-
-
-// Diffs the two moments into a Duration where full-days are recorded first, then the remaining time.
-// Moments will have their timezones normalized.
-function diffDayTime(a, b) {
- return moment.duration({
- days: a.clone().stripTime().diff(b.clone().stripTime(), 'days'),
- ms: a.time() - b.time() // time-of-day from day start. disregards timezone
- });
-}
-
-
-// Diffs the two moments via their start-of-day (regardless of timezone). Produces whole-day durations.
-function diffDay(a, b) {
- return moment.duration({
- days: a.clone().stripTime().diff(b.clone().stripTime(), 'days')
- });
-}
-
-
-// Diffs two moments, producing a duration, made of a whole-unit-increment of the given unit. Uses rounding.
-function diffByUnit(a, b, unit) {
- return moment.duration(
- Math.round(a.diff(b, unit, true)), // returnFloat=true
- unit
- );
-}
-
-
-// Computes the unit name of the largest whole-unit period of time.
-// For example, 48 hours will be "days" whereas 49 hours will be "hours".
-// Accepts start/end, a range object, or an original duration object.
-function computeIntervalUnit(start, end) {
- var i, unit;
- var val;
-
- for (i = 0; i < intervalUnits.length; i++) {
- unit = intervalUnits[i];
- val = computeRangeAs(unit, start, end);
-
- if (val >= 1 && isInt(val)) {
- break;
- }
- }
-
- return unit; // will be "milliseconds" if nothing else matches
-}
-
-
-// Computes the number of units (like "hours") in the given range.
-// Range can be a {start,end} object, separate start/end args, or a Duration.
-// Results are based on Moment's .as() and .diff() methods, so results can depend on internal handling
-// of month-diffing logic (which tends to vary from version to version).
-function computeRangeAs(unit, start, end) {
-
- if (end != null) { // given start, end
- return end.diff(start, unit, true);
- }
- else if (moment.isDuration(start)) { // given duration
- return start.as(unit);
- }
- else { // given { start, end } range object
- return start.end.diff(start.start, unit, true);
- }
-}
-
-
-// Intelligently divides a range (specified by a start/end params) by a duration
-function divideRangeByDuration(start, end, dur) {
- var months;
-
- if (durationHasTime(dur)) {
- return (end - start) / dur;
- }
- months = dur.asMonths();
- if (Math.abs(months) >= 1 && isInt(months)) {
- return end.diff(start, 'months', true) / months;
- }
- return end.diff(start, 'days', true) / dur.asDays();
-}
-
-
-// Intelligently divides one duration by another
-function divideDurationByDuration(dur1, dur2) {
- var months1, months2;
-
- if (durationHasTime(dur1) || durationHasTime(dur2)) {
- return dur1 / dur2;
- }
- months1 = dur1.asMonths();
- months2 = dur2.asMonths();
- if (
- Math.abs(months1) >= 1 && isInt(months1) &&
- Math.abs(months2) >= 1 && isInt(months2)
- ) {
- return months1 / months2;
- }
- return dur1.asDays() / dur2.asDays();
-}
-
-
-// Intelligently multiplies a duration by a number
-function multiplyDuration(dur, n) {
- var months;
-
- if (durationHasTime(dur)) {
- return moment.duration(dur * n);
- }
- months = dur.asMonths();
- if (Math.abs(months) >= 1 && isInt(months)) {
- return moment.duration({ months: months * n });
- }
- return moment.duration({ days: dur.asDays() * n });
-}
-
-
-// Returns a boolean about whether the given duration has any time parts (hours/minutes/seconds/ms)
-function durationHasTime(dur) {
- return Boolean(dur.hours() || dur.minutes() || dur.seconds() || dur.milliseconds());
-}
-
-
-function isNativeDate(input) {
- return Object.prototype.toString.call(input) === '[object Date]' || input instanceof Date;
-}
-
-
-// Returns a boolean about whether the given input is a time string, like "06:40:00" or "06:00"
-function isTimeString(str) {
- return /^\d+\:\d+(?:\:\d+\.?(?:\d{3})?)?$/.test(str);
-}
-
-
-/* Logging and Debug
-----------------------------------------------------------------------------------------------------------------------*/
-
-FC.log = function() {
- var console = window.console;
-
- if (console && console.log) {
- return console.log.apply(console, arguments);
- }
-};
-
-FC.warn = function() {
- var console = window.console;
-
- if (console && console.warn) {
- return console.warn.apply(console, arguments);
- }
- else {
- return FC.log.apply(FC, arguments);
- }
-};
-
-
-/* General Utilities
-----------------------------------------------------------------------------------------------------------------------*/
-
-var hasOwnPropMethod = {}.hasOwnProperty;
-
-
-// Merges an array of objects into a single object.
-// The second argument allows for an array of property names who's object values will be merged together.
-function mergeProps(propObjs, complexProps) {
- var dest = {};
- var i, name;
- var complexObjs;
- var j, val;
- var props;
-
- if (complexProps) {
- for (i = 0; i < complexProps.length; i++) {
- name = complexProps[i];
- complexObjs = [];
-
- // collect the trailing object values, stopping when a non-object is discovered
- for (j = propObjs.length - 1; j >= 0; j--) {
- val = propObjs[j][name];
-
- if (typeof val === 'object') {
- complexObjs.unshift(val);
- }
- else if (val !== undefined) {
- dest[name] = val; // if there were no objects, this value will be used
- break;
- }
- }
-
- // if the trailing values were objects, use the merged value
- if (complexObjs.length) {
- dest[name] = mergeProps(complexObjs);
- }
- }
- }
-
- // copy values into the destination, going from last to first
- for (i = propObjs.length - 1; i >= 0; i--) {
- props = propObjs[i];
-
- for (name in props) {
- if (!(name in dest)) { // if already assigned by previous props or complex props, don't reassign
- dest[name] = props[name];
- }
- }
- }
-
- return dest;
-}
-
-
-// Create an object that has the given prototype. Just like Object.create
-function createObject(proto) {
- var f = function() {};
- f.prototype = proto;
- return new f();
-}
-FC.createObject = createObject;
-
-
-function copyOwnProps(src, dest) {
- for (var name in src) {
- if (hasOwnProp(src, name)) {
- dest[name] = src[name];
- }
- }
-}
-
-
-function hasOwnProp(obj, name) {
- return hasOwnPropMethod.call(obj, name);
-}
-
-
-// Is the given value a non-object non-function value?
-function isAtomic(val) {
- return /undefined|null|boolean|number|string/.test($.type(val));
-}
-
-
-function applyAll(functions, thisObj, args) {
- if ($.isFunction(functions)) {
- functions = [ functions ];
- }
- if (functions) {
- var i;
- var ret;
- for (i=0; i /g, '>')
- .replace(/'/g, ''')
- .replace(/"/g, '"')
- .replace(/\n/g, ' ');
-}
-
-
-function stripHtmlEntities(text) {
- return text.replace(/&.*?;/g, '');
-}
-
-
-// Given a hash of CSS properties, returns a string of CSS.
-// Uses property names as-is (no camel-case conversion). Will not make statements for null/undefined values.
-function cssToStr(cssProps) {
- var statements = [];
-
- $.each(cssProps, function(name, val) {
- if (val != null) {
- statements.push(name + ':' + val);
- }
- });
-
- return statements.join(';');
-}
-
-
-// Given an object hash of HTML attribute names to values,
-// generates a string that can be injected between < > in HTML
-function attrsToStr(attrs) {
- var parts = [];
-
- $.each(attrs, function(name, val) {
- if (val != null) {
- parts.push(name + '="' + htmlEscape(val) + '"');
- }
- });
-
- return parts.join(' ');
-}
-
-
-function capitaliseFirstLetter(str) {
- return str.charAt(0).toUpperCase() + str.slice(1);
-}
-
-
-function compareNumbers(a, b) { // for .sort()
- return a - b;
-}
-
-
-function isInt(n) {
- return n % 1 === 0;
-}
-
-
-// Returns a method bound to the given object context.
-// Just like one of the jQuery.proxy signatures, but without the undesired behavior of treating the same method with
-// different contexts as identical when binding/unbinding events.
-function proxy(obj, methodName) {
- var method = obj[methodName];
-
- return function() {
- return method.apply(obj, arguments);
- };
-}
-
-
-// Returns a function, that, as long as it continues to be invoked, will not
-// be triggered. The function will be called after it stops being called for
-// N milliseconds. If `immediate` is passed, trigger the function on the
-// leading edge, instead of the trailing.
-// https://github.com/jashkenas/underscore/blob/1.6.0/underscore.js#L714
-function debounce(func, wait, immediate) {
- var timeout, args, context, timestamp, result;
-
- var later = function() {
- var last = +new Date() - timestamp;
- if (last < wait) {
- timeout = setTimeout(later, wait - last);
- }
- else {
- timeout = null;
- if (!immediate) {
- result = func.apply(context, args);
- context = args = null;
- }
- }
- };
-
- return function() {
- context = this;
- args = arguments;
- timestamp = +new Date();
- var callNow = immediate && !timeout;
- if (!timeout) {
- timeout = setTimeout(later, wait);
- }
- if (callNow) {
- result = func.apply(context, args);
- context = args = null;
- }
- return result;
- };
-}
-
-;;
-
-/*
-GENERAL NOTE on moments throughout the *entire rest* of the codebase:
-All moments are assumed to be ambiguously-zoned unless otherwise noted,
-with the NOTABLE EXCEOPTION of start/end dates that live on *Event Objects*.
-Ambiguously-TIMED moments are assumed to be ambiguously-zoned by nature.
-*/
-
-var ambigDateOfMonthRegex = /^\s*\d{4}-\d\d$/;
-var ambigTimeOrZoneRegex =
- /^\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+)?)?)?)?)?$/;
-var newMomentProto = moment.fn; // where we will attach our new methods
-var oldMomentProto = $.extend({}, newMomentProto); // copy of original moment methods
-
-// tell momentjs to transfer these properties upon clone
-var momentProperties = moment.momentProperties;
-momentProperties.push('_fullCalendar');
-momentProperties.push('_ambigTime');
-momentProperties.push('_ambigZone');
-
-
-// Creating
-// -------------------------------------------------------------------------------------------------
-
-// Creates a new moment, similar to the vanilla moment(...) constructor, but with
-// extra features (ambiguous time, enhanced formatting). When given an existing moment,
-// it will function as a clone (and retain the zone of the moment). Anything else will
-// result in a moment in the local zone.
-FC.moment = function() {
- return makeMoment(arguments);
-};
-
-// Sames as FC.moment, but forces the resulting moment to be in the UTC timezone.
-FC.moment.utc = function() {
- var mom = makeMoment(arguments, true);
-
- // Force it into UTC because makeMoment doesn't guarantee it
- // (if given a pre-existing moment for example)
- if (mom.hasTime()) { // don't give ambiguously-timed moments a UTC zone
- mom.utc();
- }
-
- return mom;
-};
-
-// Same as FC.moment, but when given an ISO8601 string, the timezone offset is preserved.
-// ISO8601 strings with no timezone offset will become ambiguously zoned.
-FC.moment.parseZone = function() {
- return makeMoment(arguments, true, true);
-};
-
-// Builds an enhanced moment from args. When given an existing moment, it clones. When given a
-// native Date, or called with no arguments (the current time), the resulting moment will be local.
-// Anything else needs to be "parsed" (a string or an array), and will be affected by:
-// parseAsUTC - if there is no zone information, should we parse the input in UTC?
-// parseZone - if there is zone information, should we force the zone of the moment?
-function makeMoment(args, parseAsUTC, parseZone) {
- var input = args[0];
- var isSingleString = args.length == 1 && typeof input === 'string';
- var isAmbigTime;
- var isAmbigZone;
- var ambigMatch;
- var mom;
-
- if (moment.isMoment(input) || isNativeDate(input) || input === undefined) {
- mom = moment.apply(null, args);
- }
- else { // "parsing" is required
- isAmbigTime = false;
- isAmbigZone = false;
-
- if (isSingleString) {
- if (ambigDateOfMonthRegex.test(input)) {
- // accept strings like '2014-05', but convert to the first of the month
- input += '-01';
- args = [ input ]; // for when we pass it on to moment's constructor
- isAmbigTime = true;
- isAmbigZone = true;
- }
- else if ((ambigMatch = ambigTimeOrZoneRegex.exec(input))) {
- isAmbigTime = !ambigMatch[5]; // no time part?
- isAmbigZone = true;
- }
- }
- else if ($.isArray(input)) {
- // arrays have no timezone information, so assume ambiguous zone
- isAmbigZone = true;
- }
- // otherwise, probably a string with a format
-
- if (parseAsUTC || isAmbigTime) {
- mom = moment.utc.apply(moment, args);
- }
- else {
- mom = moment.apply(null, args);
- }
-
- if (isAmbigTime) {
- mom._ambigTime = true;
- mom._ambigZone = true; // ambiguous time always means ambiguous zone
- }
- else if (parseZone) { // let's record the inputted zone somehow
- if (isAmbigZone) {
- mom._ambigZone = true;
- }
- else if (isSingleString) {
- mom.utcOffset(input); // if not a valid zone, will assign UTC
- }
- }
- }
-
- mom._fullCalendar = true; // flag for extended functionality
-
- return mom;
-}
-
-
-// Week Number
-// -------------------------------------------------------------------------------------------------
-
-
-// Returns the week number, considering the locale's custom week number calcuation
-// `weeks` is an alias for `week`
-newMomentProto.week = newMomentProto.weeks = function(input) {
- var weekCalc = this._locale._fullCalendar_weekCalc;
-
- if (input == null && typeof weekCalc === 'function') { // custom function only works for getter
- return weekCalc(this);
- }
- else if (weekCalc === 'ISO') {
- return oldMomentProto.isoWeek.apply(this, arguments); // ISO getter/setter
- }
-
- return oldMomentProto.week.apply(this, arguments); // local getter/setter
-};
-
-
-// Time-of-day
-// -------------------------------------------------------------------------------------------------
-
-// GETTER
-// Returns a Duration with the hours/minutes/seconds/ms values of the moment.
-// If the moment has an ambiguous time, a duration of 00:00 will be returned.
-//
-// SETTER
-// You can supply a Duration, a Moment, or a Duration-like argument.
-// When setting the time, and the moment has an ambiguous time, it then becomes unambiguous.
-newMomentProto.time = function(time) {
-
- // Fallback to the original method (if there is one) if this moment wasn't created via FullCalendar.
- // `time` is a generic enough method name where this precaution is necessary to avoid collisions w/ other plugins.
- if (!this._fullCalendar) {
- return oldMomentProto.time.apply(this, arguments);
- }
-
- if (time == null) { // getter
- return moment.duration({
- hours: this.hours(),
- minutes: this.minutes(),
- seconds: this.seconds(),
- milliseconds: this.milliseconds()
- });
- }
- else { // setter
-
- this._ambigTime = false; // mark that the moment now has a time
-
- if (!moment.isDuration(time) && !moment.isMoment(time)) {
- time = moment.duration(time);
- }
-
- // The day value should cause overflow (so 24 hours becomes 00:00:00 of next day).
- // Only for Duration times, not Moment times.
- var dayHours = 0;
- if (moment.isDuration(time)) {
- dayHours = Math.floor(time.asDays()) * 24;
- }
-
- // We need to set the individual fields.
- // Can't use startOf('day') then add duration. In case of DST at start of day.
- return this.hours(dayHours + time.hours())
- .minutes(time.minutes())
- .seconds(time.seconds())
- .milliseconds(time.milliseconds());
- }
-};
-
-// Converts the moment to UTC, stripping out its time-of-day and timezone offset,
-// but preserving its YMD. A moment with a stripped time will display no time
-// nor timezone offset when .format() is called.
-newMomentProto.stripTime = function() {
-
- if (!this._ambigTime) {
-
- this.utc(true); // keepLocalTime=true (for keeping *date* value)
-
- // set time to zero
- this.set({
- hours: 0,
- minutes: 0,
- seconds: 0,
- ms: 0
- });
-
- // Mark the time as ambiguous. This needs to happen after the .utc() call, which might call .utcOffset(),
- // which clears all ambig flags.
- this._ambigTime = true;
- this._ambigZone = true; // if ambiguous time, also ambiguous timezone offset
- }
-
- return this; // for chaining
-};
-
-// Returns if the moment has a non-ambiguous time (boolean)
-newMomentProto.hasTime = function() {
- return !this._ambigTime;
-};
-
-
-// Timezone
-// -------------------------------------------------------------------------------------------------
-
-// Converts the moment to UTC, stripping out its timezone offset, but preserving its
-// YMD and time-of-day. A moment with a stripped timezone offset will display no
-// timezone offset when .format() is called.
-newMomentProto.stripZone = function() {
- var wasAmbigTime;
-
- if (!this._ambigZone) {
-
- wasAmbigTime = this._ambigTime;
-
- this.utc(true); // keepLocalTime=true (for keeping date and time values)
-
- // the above call to .utc()/.utcOffset() unfortunately might clear the ambig flags, so restore
- this._ambigTime = wasAmbigTime || false;
-
- // Mark the zone as ambiguous. This needs to happen after the .utc() call, which might call .utcOffset(),
- // which clears the ambig flags.
- this._ambigZone = true;
- }
-
- return this; // for chaining
-};
-
-// Returns of the moment has a non-ambiguous timezone offset (boolean)
-newMomentProto.hasZone = function() {
- return !this._ambigZone;
-};
-
-
-// implicitly marks a zone
-newMomentProto.local = function(keepLocalTime) {
-
- // for when converting from ambiguously-zoned to local,
- // keep the time values when converting from UTC -> local
- oldMomentProto.local.call(this, this._ambigZone || keepLocalTime);
-
- // ensure non-ambiguous
- // this probably already happened via local() -> utcOffset(), but don't rely on Moment's internals
- this._ambigTime = false;
- this._ambigZone = false;
-
- return this; // for chaining
-};
-
-
-// implicitly marks a zone
-newMomentProto.utc = function(keepLocalTime) {
-
- oldMomentProto.utc.call(this, keepLocalTime);
-
- // ensure non-ambiguous
- // this probably already happened via utc() -> utcOffset(), but don't rely on Moment's internals
- this._ambigTime = false;
- this._ambigZone = false;
-
- return this;
-};
-
-
-// implicitly marks a zone (will probably get called upon .utc() and .local())
-newMomentProto.utcOffset = function(tzo) {
-
- if (tzo != null) { // setter
- // these assignments needs to happen before the original zone method is called.
- // I forget why, something to do with a browser crash.
- this._ambigTime = false;
- this._ambigZone = false;
- }
-
- return oldMomentProto.utcOffset.apply(this, arguments);
-};
-
-
-// Formatting
-// -------------------------------------------------------------------------------------------------
-
-newMomentProto.format = function() {
- if (this._fullCalendar && arguments[0]) { // an enhanced moment? and a format string provided?
- return formatDate(this, arguments[0]); // our extended formatting
- }
- if (this._ambigTime) {
- return oldMomentFormat(this, 'YYYY-MM-DD');
- }
- if (this._ambigZone) {
- return oldMomentFormat(this, 'YYYY-MM-DD[T]HH:mm:ss');
- }
- return oldMomentProto.format.apply(this, arguments);
-};
-
-newMomentProto.toISOString = function() {
- if (this._ambigTime) {
- return oldMomentFormat(this, 'YYYY-MM-DD');
- }
- if (this._ambigZone) {
- return oldMomentFormat(this, 'YYYY-MM-DD[T]HH:mm:ss');
- }
- return oldMomentProto.toISOString.apply(this, arguments);
-};
-
-;;
-
-// Single Date Formatting
-// -------------------------------------------------------------------------------------------------
-
-
-// call this if you want Moment's original format method to be used
-function oldMomentFormat(mom, formatStr) {
- return oldMomentProto.format.call(mom, formatStr); // oldMomentProto defined in moment-ext.js
-}
-
-
-// Formats `date` with a Moment formatting string, but allow our non-zero areas and
-// additional token.
-function formatDate(date, formatStr) {
- return formatDateWithChunks(date, getFormatStringChunks(formatStr));
-}
-
-
-function formatDateWithChunks(date, chunks) {
- var s = '';
- var i;
-
- for (i=0; i "MMMM D YYYY"
- formatStr = localeData.longDateFormat(formatStr) || formatStr;
- // BTW, this is not important for `formatDate` because it is impossible to put custom tokens
- // or non-zero areas in Moment's localized format strings.
-
- separator = separator || ' - ';
-
- return formatRangeWithChunks(
- date1,
- date2,
- getFormatStringChunks(formatStr),
- separator,
- isRTL
- );
-}
-FC.formatRange = formatRange; // expose
-
-
-function formatRangeWithChunks(date1, date2, chunks, separator, isRTL) {
- var unzonedDate1 = date1.clone().stripZone(); // for formatSimilarChunk
- var unzonedDate2 = date2.clone().stripZone(); // "
- var chunkStr; // the rendering of the chunk
- var leftI;
- var leftStr = '';
- var rightI;
- var rightStr = '';
- var middleI;
- var middleStr1 = '';
- var middleStr2 = '';
- var middleStr = '';
-
- // Start at the leftmost side of the formatting string and continue until you hit a token
- // that is not the same between dates.
- for (leftI=0; leftIleftI; rightI--) {
- chunkStr = formatSimilarChunk(date1, date2, unzonedDate1, unzonedDate2, chunks[rightI]);
- if (chunkStr === false) {
- break;
- }
- rightStr = chunkStr + rightStr;
- }
-
- // The area in the middle is different for both of the dates.
- // Collect them distinctly so we can jam them together later.
- for (middleI=leftI; middleI<=rightI; middleI++) {
- middleStr1 += formatDateWithChunk(date1, chunks[middleI]);
- middleStr2 += formatDateWithChunk(date2, chunks[middleI]);
- }
-
- if (middleStr1 || middleStr2) {
- if (isRTL) {
- middleStr = middleStr2 + separator + middleStr1;
- }
- else {
- middleStr = middleStr1 + separator + middleStr2;
- }
- }
-
- return leftStr + middleStr + rightStr;
-}
-
-
-var similarUnitMap = {
- Y: 'year',
- M: 'month',
- D: 'day', // day of month
- d: 'day', // day of week
- // prevents a separator between anything time-related...
- A: 'second', // AM/PM
- a: 'second', // am/pm
- T: 'second', // A/P
- t: 'second', // a/p
- H: 'second', // hour (24)
- h: 'second', // hour (12)
- m: 'second', // minute
- s: 'second' // second
-};
-// TODO: week maybe?
-
-
-// Given a formatting chunk, and given that both dates are similar in the regard the
-// formatting chunk is concerned, format date1 against `chunk`. Otherwise, return `false`.
-function formatSimilarChunk(date1, date2, unzonedDate1, unzonedDate2, chunk) {
- var token;
- var unit;
-
- if (typeof chunk === 'string') { // a literal string
- return chunk;
- }
- else if ((token = chunk.token)) {
- unit = similarUnitMap[token.charAt(0)];
-
- // are the dates the same for this unit of measurement?
- // use the unzoned dates for this calculation because unreliable when near DST (bug #2396)
- if (unit && unzonedDate1.isSame(unzonedDate2, unit)) {
- return oldMomentFormat(date1, token); // would be the same if we used `date2`
- // BTW, don't support custom tokens
- }
- }
-
- return false; // the chunk is NOT the same for the two dates
- // BTW, don't support splitting on non-zero areas
-}
-
-
-// Chunking Utils
-// -------------------------------------------------------------------------------------------------
-
-
-var formatStringChunkCache = {};
-
-
-function getFormatStringChunks(formatStr) {
- if (formatStr in formatStringChunkCache) {
- return formatStringChunkCache[formatStr];
- }
- return (formatStringChunkCache[formatStr] = chunkFormatString(formatStr));
-}
-
-
-// Break the formatting string into an array of chunks
-function chunkFormatString(formatStr) {
- var chunks = [];
- var chunker = /\[([^\]]*)\]|\(([^\)]*)\)|(LTS|LT|(\w)\4*o?)|([^\w\[\(]+)/g; // TODO: more descrimination
- var match;
-
- while ((match = chunker.exec(formatStr))) {
- if (match[1]) { // a literal string inside [ ... ]
- chunks.push(match[1]);
- }
- else if (match[2]) { // non-zero formatting inside ( ... )
- chunks.push({ maybe: chunkFormatString(match[2]) });
- }
- else if (match[3]) { // a formatting token
- chunks.push({ token: match[3] });
- }
- else if (match[5]) { // an unenclosed literal string
- chunks.push(match[5]);
- }
- }
-
- return chunks;
-}
-
-
-// Misc Utils
-// -------------------------------------------------------------------------------------------------
-
-
-// granularity only goes up until day
-// TODO: unify with similarUnitMap
-var tokenGranularities = {
- Y: { value: 1, unit: 'year' },
- M: { value: 2, unit: 'month' },
- W: { value: 3, unit: 'week' },
- w: { value: 3, unit: 'week' },
- D: { value: 4, unit: 'day' }, // day of month
- d: { value: 4, unit: 'day' } // day of week
-};
-
-// returns a unit string, either 'year', 'month', 'day', or null
-// for the most granular formatting token in the string.
-FC.queryMostGranularFormatUnit = function(formatStr) {
- var chunks = getFormatStringChunks(formatStr);
- var i, chunk;
- var candidate;
- var best;
-
- for (i = 0; i < chunks.length; i++) {
- chunk = chunks[i];
- if (chunk.token) {
- candidate = tokenGranularities[chunk.token.charAt(0)];
- if (candidate) {
- if (!best || candidate.value > best.value) {
- best = candidate;
- }
- }
- }
- }
-
- if (best) {
- return best.unit;
- }
-
- return null;
-};
-
-;;
-
-FC.Class = Class; // export
-
-// Class that all other classes will inherit from
-function Class() { }
-
-
-// Called on a class to create a subclass.
-// Last argument contains instance methods. Any argument before the last are considered mixins.
-Class.extend = function() {
- var len = arguments.length;
- var i;
- var members;
-
- for (i = 0; i < len; i++) {
- members = arguments[i];
- if (i < len - 1) { // not the last argument?
- mixIntoClass(this, members);
- }
- }
-
- return extendClass(this, members || {}); // members will be undefined if no arguments
-};
-
-
-// Adds new member variables/methods to the class's prototype.
-// Can be called with another class, or a plain object hash containing new members.
-Class.mixin = function(members) {
- mixIntoClass(this, members);
-};
-
-
-function extendClass(superClass, members) {
- var subClass;
-
- // ensure a constructor for the subclass, forwarding all arguments to the super-constructor if it doesn't exist
- if (hasOwnProp(members, 'constructor')) {
- subClass = members.constructor;
- }
- if (typeof subClass !== 'function') {
- subClass = members.constructor = function() {
- superClass.apply(this, arguments);
- };
- }
-
- // build the base prototype for the subclass, which is an new object chained to the superclass's prototype
- subClass.prototype = createObject(superClass.prototype);
-
- // copy each member variable/method onto the the subclass's prototype
- copyOwnProps(members, subClass.prototype);
-
- // copy over all class variables/methods to the subclass, such as `extend` and `mixin`
- copyOwnProps(superClass, subClass);
-
- return subClass;
-}
-
-
-function mixIntoClass(theClass, members) {
- copyOwnProps(members, theClass.prototype);
-}
-;;
-
-/*
-Wrap jQuery's Deferred Promise object to be slightly more Promise/A+ compliant.
-With the added non-standard feature of synchronously executing handlers on resolved promises,
-which doesn't always happen otherwise (esp with nested .then handlers!?),
-so, this makes things a lot easier, esp because jQuery 3 changed the synchronicity for Deferred objects.
-
-TODO: write tests and more comments
-*/
-
-function Promise(executor) {
- var deferred = $.Deferred();
- var promise = deferred.promise();
-
- if (typeof executor === 'function') {
- executor(
- function(value) { // resolve
- if (Promise.immediate) {
- promise._value = value;
- }
- deferred.resolve(value);
- },
- function() { // reject
- deferred.reject();
- }
- );
- }
-
- if (Promise.immediate) {
- var origThen = promise.then;
-
- promise.then = function(onFulfilled, onRejected) {
- var state = promise.state();
-
- if (state === 'resolved') {
- if (typeof onFulfilled === 'function') {
- return Promise.resolve(onFulfilled(promise._value));
- }
- }
- else if (state === 'rejected') {
- if (typeof onRejected === 'function') {
- onRejected();
- return promise; // already rejected
- }
- }
-
- return origThen.call(promise, onFulfilled, onRejected);
- };
- }
-
- return promise; // instanceof Promise will break :( TODO: make Promise a real class
-}
-
-FC.Promise = Promise;
-
-Promise.immediate = true;
-
-
-Promise.resolve = function(value) {
- if (value && typeof value.resolve === 'function') {
- return value.promise();
- }
- if (value && typeof value.then === 'function') {
- return value;
- }
- else {
- var deferred = $.Deferred().resolve(value);
- var promise = deferred.promise();
-
- if (Promise.immediate) {
- var origThen = promise.then;
-
- promise._value = value;
-
- promise.then = function(onFulfilled, onRejected) {
- if (typeof onFulfilled === 'function') {
- return Promise.resolve(onFulfilled(value));
- }
- return origThen.call(promise, onFulfilled, onRejected);
- };
- }
-
- return promise;
- }
-};
-
-
-Promise.reject = function() {
- return $.Deferred().reject().promise();
-};
-
-
-Promise.all = function(inputs) {
- var hasAllValues = false;
- var values;
- var i, input;
-
- if (Promise.immediate) {
- hasAllValues = true;
- values = [];
-
- for (i = 0; i < inputs.length; i++) {
- input = inputs[i];
-
- if (input && typeof input.state === 'function' && input.state() === 'resolved' && ('_value' in input)) {
- values.push(input._value);
- }
- else if (input && typeof input.then === 'function') {
- hasAllValues = false;
- break;
- }
- else {
- values.push(input);
- }
- }
- }
-
- if (hasAllValues) {
- return Promise.resolve(values);
- }
- else {
- return $.when.apply($.when, inputs).then(function() {
- return $.when($.makeArray(arguments));
- });
- }
-};
-
-;;
-
-// TODO: write tests and clean up code
-
-function TaskQueue(debounceWait) {
- var q = []; // array of runFuncs
-
- function addTask(taskFunc) {
- return new Promise(function(resolve) {
-
- // should run this function when it's taskFunc's turn to run.
- // responsible for popping itself off the queue.
- var runFunc = function() {
- Promise.resolve(taskFunc()) // result might be async, coerce to promise
- .then(resolve) // resolve TaskQueue::push's promise, for the caller. will receive result of taskFunc.
- .then(function() {
- q.shift(); // pop itself off
-
- // run the next task, if any
- if (q.length) {
- q[0]();
- }
- });
- };
-
- // always put the task at the end of the queue, BEFORE running the task
- q.push(runFunc);
-
- // if it's the only task in the queue, run immediately
- if (q.length === 1) {
- runFunc();
- }
- });
- }
-
- this.add = // potentially debounce, for the public method
- typeof debounceWait === 'number' ?
- debounce(addTask, debounceWait) :
- addTask; // if not a number (null/undefined/false), no debounce at all
-
- this.addQuickly = addTask; // guaranteed no debounce
-}
-
-FC.TaskQueue = TaskQueue;
-
-/*
-q = new TaskQueue();
-
-function work(i) {
- return q.push(function() {
- trigger();
- console.log('work' + i);
- });
-}
-
-var cnt = 0;
-
-function trigger() {
- if (cnt < 5) {
- cnt++;
- work(cnt);
- }
-}
-
-work(9);
-*/
-
-;;
-
-var EmitterMixin = FC.EmitterMixin = {
-
- // jQuery-ification via $(this) allows a non-DOM object to have
- // the same event handling capabilities (including namespaces).
-
-
- on: function(types, handler) {
- $(this).on(types, this._prepareIntercept(handler));
- return this; // for chaining
- },
-
-
- one: function(types, handler) {
- $(this).one(types, this._prepareIntercept(handler));
- return this; // for chaining
- },
-
-
- _prepareIntercept: function(handler) {
- // handlers are always called with an "event" object as their first param.
- // sneak the `this` context and arguments into the extra parameter object
- // and forward them on to the original handler.
- var intercept = function(ev, extra) {
- return handler.apply(
- extra.context || this,
- extra.args || []
- );
- };
-
- // mimick jQuery's internal "proxy" system (risky, I know)
- // causing all functions with the same .guid to appear to be the same.
- // https://github.com/jquery/jquery/blob/2.2.4/src/core.js#L448
- // this is needed for calling .off with the original non-intercept handler.
- if (!handler.guid) {
- handler.guid = $.guid++;
- }
- intercept.guid = handler.guid;
-
- return intercept;
- },
-
-
- off: function(types, handler) {
- $(this).off(types, handler);
-
- return this; // for chaining
- },
-
-
- trigger: function(types) {
- var args = Array.prototype.slice.call(arguments, 1); // arguments after the first
-
- // pass in "extra" info to the intercept
- $(this).triggerHandler(types, { args: args });
-
- return this; // for chaining
- },
-
-
- triggerWith: function(types, context, args) {
-
- // `triggerHandler` is less reliant on the DOM compared to `trigger`.
- // pass in "extra" info to the intercept.
- $(this).triggerHandler(types, { context: context, args: args });
-
- return this; // for chaining
- }
-
-};
-
-;;
-
-/*
-Utility methods for easily listening to events on another object,
-and more importantly, easily unlistening from them.
-*/
-var ListenerMixin = FC.ListenerMixin = (function() {
- var guid = 0;
- var ListenerMixin = {
-
- listenerId: null,
-
- /*
- Given an `other` object that has on/off methods, bind the given `callback` to an event by the given name.
- The `callback` will be called with the `this` context of the object that .listenTo is being called on.
- Can be called:
- .listenTo(other, eventName, callback)
- OR
- .listenTo(other, {
- eventName1: callback1,
- eventName2: callback2
- })
- */
- listenTo: function(other, arg, callback) {
- if (typeof arg === 'object') { // given dictionary of callbacks
- for (var eventName in arg) {
- if (arg.hasOwnProperty(eventName)) {
- this.listenTo(other, eventName, arg[eventName]);
- }
- }
- }
- else if (typeof arg === 'string') {
- other.on(
- arg + '.' + this.getListenerNamespace(), // use event namespacing to identify this object
- $.proxy(callback, this) // always use `this` context
- // the usually-undesired jQuery guid behavior doesn't matter,
- // because we always unbind via namespace
- );
- }
- },
-
- /*
- Causes the current object to stop listening to events on the `other` object.
- `eventName` is optional. If omitted, will stop listening to ALL events on `other`.
- */
- stopListeningTo: function(other, eventName) {
- other.off((eventName || '') + '.' + this.getListenerNamespace());
- },
-
- /*
- Returns a string, unique to this object, to be used for event namespacing
- */
- getListenerNamespace: function() {
- if (this.listenerId == null) {
- this.listenerId = guid++;
- }
- return '_listener' + this.listenerId;
- }
-
- };
- return ListenerMixin;
-})();
-;;
-
-// simple class for toggle a `isIgnoringMouse` flag on delay
-// initMouseIgnoring must first be called, with a millisecond delay setting.
-var MouseIgnorerMixin = {
-
- isIgnoringMouse: false, // bool
- delayUnignoreMouse: null, // method
-
-
- initMouseIgnoring: function(delay) {
- this.delayUnignoreMouse = debounce(proxy(this, 'unignoreMouse'), delay || 1000);
- },
-
-
- // temporarily ignore mouse actions on segments
- tempIgnoreMouse: function() {
- this.isIgnoringMouse = true;
- this.delayUnignoreMouse();
- },
-
-
- // delayUnignoreMouse eventually calls this
- unignoreMouse: function() {
- this.isIgnoringMouse = false;
- }
-
-};
-
-;;
-
-/* A rectangular panel that is absolutely positioned over other content
-------------------------------------------------------------------------------------------------------------------------
-Options:
- - className (string)
- - content (HTML string or jQuery element set)
- - parentEl
- - top
- - left
- - right (the x coord of where the right edge should be. not a "CSS" right)
- - autoHide (boolean)
- - show (callback)
- - hide (callback)
-*/
-
-var Popover = Class.extend(ListenerMixin, {
-
- isHidden: true,
- options: null,
- el: null, // the container element for the popover. generated by this object
- margin: 10, // the space required between the popover and the edges of the scroll container
-
-
- constructor: function(options) {
- this.options = options || {};
- },
-
-
- // Shows the popover on the specified position. Renders it if not already
- show: function() {
- if (this.isHidden) {
- if (!this.el) {
- this.render();
- }
- this.el.show();
- this.position();
- this.isHidden = false;
- this.trigger('show');
- }
- },
-
-
- // Hides the popover, through CSS, but does not remove it from the DOM
- hide: function() {
- if (!this.isHidden) {
- this.el.hide();
- this.isHidden = true;
- this.trigger('hide');
- }
- },
-
-
- // Creates `this.el` and renders content inside of it
- render: function() {
- var _this = this;
- var options = this.options;
-
- this.el = $('
')
- .addClass(options.className || '')
- .css({
- // position initially to the top left to avoid creating scrollbars
- top: 0,
- left: 0
- })
- .append(options.content)
- .appendTo(options.parentEl);
-
- // when a click happens on anything inside with a 'fc-close' className, hide the popover
- this.el.on('click', '.fc-close', function() {
- _this.hide();
- });
-
- if (options.autoHide) {
- this.listenTo($(document), 'mousedown', this.documentMousedown);
- }
- },
-
-
- // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
- documentMousedown: function(ev) {
- // only hide the popover if the click happened outside the popover
- if (this.el && !$(ev.target).closest(this.el).length) {
- this.hide();
- }
- },
-
-
- // Hides and unregisters any handlers
- removeElement: function() {
- this.hide();
-
- if (this.el) {
- this.el.remove();
- this.el = null;
- }
-
- this.stopListeningTo($(document), 'mousedown');
- },
-
-
- // Positions the popover optimally, using the top/left/right options
- position: function() {
- var options = this.options;
- var origin = this.el.offsetParent().offset();
- var width = this.el.outerWidth();
- var height = this.el.outerHeight();
- var windowEl = $(window);
- var viewportEl = getScrollParent(this.el);
- var viewportTop;
- var viewportLeft;
- var viewportOffset;
- var top; // the "position" (not "offset") values for the popover
- var left; //
-
- // compute top and left
- top = options.top || 0;
- if (options.left !== undefined) {
- left = options.left;
- }
- else if (options.right !== undefined) {
- left = options.right - width; // derive the left value from the right value
- }
- else {
- left = 0;
- }
-
- if (viewportEl.is(window) || viewportEl.is(document)) { // normalize getScrollParent's result
- viewportEl = windowEl;
- viewportTop = 0; // the window is always at the top left
- viewportLeft = 0; // (and .offset() won't work if called here)
- }
- else {
- viewportOffset = viewportEl.offset();
- viewportTop = viewportOffset.top;
- viewportLeft = viewportOffset.left;
- }
-
- // if the window is scrolled, it causes the visible area to be further down
- viewportTop += windowEl.scrollTop();
- viewportLeft += windowEl.scrollLeft();
-
- // constrain to the view port. if constrained by two edges, give precedence to top/left
- if (options.viewportConstrain !== false) {
- top = Math.min(top, viewportTop + viewportEl.outerHeight() - height - this.margin);
- top = Math.max(top, viewportTop + this.margin);
- left = Math.min(left, viewportLeft + viewportEl.outerWidth() - width - this.margin);
- left = Math.max(left, viewportLeft + this.margin);
- }
-
- this.el.css({
- top: top - origin.top,
- left: left - origin.left
- });
- },
-
-
- // Triggers a callback. Calls a function in the option hash of the same name.
- // Arguments beyond the first `name` are forwarded on.
- // TODO: better code reuse for this. Repeat code
- trigger: function(name) {
- if (this.options[name]) {
- this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
- }
- }
-
-});
-
-;;
-
-/*
-A cache for the left/right/top/bottom/width/height values for one or more elements.
-Works with both offset (from topleft document) and position (from offsetParent).
-
-options:
-- els
-- isHorizontal
-- isVertical
-*/
-var CoordCache = FC.CoordCache = Class.extend({
-
- els: null, // jQuery set (assumed to be siblings)
- forcedOffsetParentEl: null, // options can override the natural offsetParent
- origin: null, // {left,top} position of offsetParent of els
- boundingRect: null, // constrain cordinates to this rectangle. {left,right,top,bottom} or null
- isHorizontal: false, // whether to query for left/right/width
- isVertical: false, // whether to query for top/bottom/height
-
- // arrays of coordinates (offsets from topleft of document)
- lefts: null,
- rights: null,
- tops: null,
- bottoms: null,
-
-
- constructor: function(options) {
- this.els = $(options.els);
- this.isHorizontal = options.isHorizontal;
- this.isVertical = options.isVertical;
- this.forcedOffsetParentEl = options.offsetParent ? $(options.offsetParent) : null;
- },
-
-
- // Queries the els for coordinates and stores them.
- // Call this method before using and of the get* methods below.
- build: function() {
- var offsetParentEl = this.forcedOffsetParentEl;
- if (!offsetParentEl && this.els.length > 0) {
- offsetParentEl = this.els.eq(0).offsetParent();
- }
-
- this.origin = offsetParentEl ?
- offsetParentEl.offset() :
- null;
-
- this.boundingRect = this.queryBoundingRect();
-
- if (this.isHorizontal) {
- this.buildElHorizontals();
- }
- if (this.isVertical) {
- this.buildElVerticals();
- }
- },
-
-
- // Destroys all internal data about coordinates, freeing memory
- clear: function() {
- this.origin = null;
- this.boundingRect = null;
- this.lefts = null;
- this.rights = null;
- this.tops = null;
- this.bottoms = null;
- },
-
-
- // When called, if coord caches aren't built, builds them
- ensureBuilt: function() {
- if (!this.origin) {
- this.build();
- }
- },
-
-
- // Populates the left/right internal coordinate arrays
- buildElHorizontals: function() {
- var lefts = [];
- var rights = [];
-
- this.els.each(function(i, node) {
- var el = $(node);
- var left = el.offset().left;
- var width = el.outerWidth();
-
- lefts.push(left);
- rights.push(left + width);
- });
-
- this.lefts = lefts;
- this.rights = rights;
- },
-
-
- // Populates the top/bottom internal coordinate arrays
- buildElVerticals: function() {
- var tops = [];
- var bottoms = [];
-
- this.els.each(function(i, node) {
- var el = $(node);
- var top = el.offset().top;
- var height = el.outerHeight();
-
- tops.push(top);
- bottoms.push(top + height);
- });
-
- this.tops = tops;
- this.bottoms = bottoms;
- },
-
-
- // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
- // If no intersection is made, returns undefined.
- getHorizontalIndex: function(leftOffset) {
- this.ensureBuilt();
-
- var lefts = this.lefts;
- var rights = this.rights;
- var len = lefts.length;
- var i;
-
- for (i = 0; i < len; i++) {
- if (leftOffset >= lefts[i] && leftOffset < rights[i]) {
- return i;
- }
- }
- },
-
-
- // Given a top offset (from document top), returns the index of the el that it vertically intersects.
- // If no intersection is made, returns undefined.
- getVerticalIndex: function(topOffset) {
- this.ensureBuilt();
-
- var tops = this.tops;
- var bottoms = this.bottoms;
- var len = tops.length;
- var i;
-
- for (i = 0; i < len; i++) {
- if (topOffset >= tops[i] && topOffset < bottoms[i]) {
- return i;
- }
- }
- },
-
-
- // Gets the left offset (from document left) of the element at the given index
- getLeftOffset: function(leftIndex) {
- this.ensureBuilt();
- return this.lefts[leftIndex];
- },
-
-
- // Gets the left position (from offsetParent left) of the element at the given index
- getLeftPosition: function(leftIndex) {
- this.ensureBuilt();
- return this.lefts[leftIndex] - this.origin.left;
- },
-
-
- // Gets the right offset (from document left) of the element at the given index.
- // This value is NOT relative to the document's right edge, like the CSS concept of "right" would be.
- getRightOffset: function(leftIndex) {
- this.ensureBuilt();
- return this.rights[leftIndex];
- },
-
-
- // Gets the right position (from offsetParent left) of the element at the given index.
- // This value is NOT relative to the offsetParent's right edge, like the CSS concept of "right" would be.
- getRightPosition: function(leftIndex) {
- this.ensureBuilt();
- return this.rights[leftIndex] - this.origin.left;
- },
-
-
- // Gets the width of the element at the given index
- getWidth: function(leftIndex) {
- this.ensureBuilt();
- return this.rights[leftIndex] - this.lefts[leftIndex];
- },
-
-
- // Gets the top offset (from document top) of the element at the given index
- getTopOffset: function(topIndex) {
- this.ensureBuilt();
- return this.tops[topIndex];
- },
-
-
- // Gets the top position (from offsetParent top) of the element at the given position
- getTopPosition: function(topIndex) {
- this.ensureBuilt();
- return this.tops[topIndex] - this.origin.top;
- },
-
- // Gets the bottom offset (from the document top) of the element at the given index.
- // This value is NOT relative to the offsetParent's bottom edge, like the CSS concept of "bottom" would be.
- getBottomOffset: function(topIndex) {
- this.ensureBuilt();
- return this.bottoms[topIndex];
- },
-
-
- // Gets the bottom position (from the offsetParent top) of the element at the given index.
- // This value is NOT relative to the offsetParent's bottom edge, like the CSS concept of "bottom" would be.
- getBottomPosition: function(topIndex) {
- this.ensureBuilt();
- return this.bottoms[topIndex] - this.origin.top;
- },
-
-
- // Gets the height of the element at the given index
- getHeight: function(topIndex) {
- this.ensureBuilt();
- return this.bottoms[topIndex] - this.tops[topIndex];
- },
-
-
- // Bounding Rect
- // TODO: decouple this from CoordCache
-
- // Compute and return what the elements' bounding rectangle is, from the user's perspective.
- // Right now, only returns a rectangle if constrained by an overflow:scroll element.
- // Returns null if there are no elements
- queryBoundingRect: function() {
- var scrollParentEl;
-
- if (this.els.length > 0) {
- scrollParentEl = getScrollParent(this.els.eq(0));
-
- if (!scrollParentEl.is(document)) {
- return getClientRect(scrollParentEl);
- }
- }
-
- return null;
- },
-
- isPointInBounds: function(leftOffset, topOffset) {
- return this.isLeftInBounds(leftOffset) && this.isTopInBounds(topOffset);
- },
-
- isLeftInBounds: function(leftOffset) {
- return !this.boundingRect || (leftOffset >= this.boundingRect.left && leftOffset < this.boundingRect.right);
- },
-
- isTopInBounds: function(topOffset) {
- return !this.boundingRect || (topOffset >= this.boundingRect.top && topOffset < this.boundingRect.bottom);
- }
-
-});
-
-;;
-
-/* Tracks a drag's mouse movement, firing various handlers
-----------------------------------------------------------------------------------------------------------------------*/
-// TODO: use Emitter
-
-var DragListener = FC.DragListener = Class.extend(ListenerMixin, MouseIgnorerMixin, {
-
- options: null,
- subjectEl: null,
-
- // coordinates of the initial mousedown
- originX: null,
- originY: null,
-
- // the wrapping element that scrolls, or MIGHT scroll if there's overflow.
- // TODO: do this for wrappers that have overflow:hidden as well.
- scrollEl: null,
-
- isInteracting: false,
- isDistanceSurpassed: false,
- isDelayEnded: false,
- isDragging: false,
- isTouch: false,
-
- delay: null,
- delayTimeoutId: null,
- minDistance: null,
-
- handleTouchScrollProxy: null, // calls handleTouchScroll, always bound to `this`
-
-
- constructor: function(options) {
- this.options = options || {};
- this.handleTouchScrollProxy = proxy(this, 'handleTouchScroll');
- this.initMouseIgnoring(500);
- },
-
-
- // Interaction (high-level)
- // -----------------------------------------------------------------------------------------------------------------
-
-
- startInteraction: function(ev, extraOptions) {
- var isTouch = getEvIsTouch(ev);
-
- if (ev.type === 'mousedown') {
- if (this.isIgnoringMouse) {
- return;
- }
- else if (!isPrimaryMouseButton(ev)) {
- return;
- }
- else {
- ev.preventDefault(); // prevents native selection in most browsers
- }
- }
-
- if (!this.isInteracting) {
-
- // process options
- extraOptions = extraOptions || {};
- this.delay = firstDefined(extraOptions.delay, this.options.delay, 0);
- this.minDistance = firstDefined(extraOptions.distance, this.options.distance, 0);
- this.subjectEl = this.options.subjectEl;
-
- this.isInteracting = true;
- this.isTouch = isTouch;
- this.isDelayEnded = false;
- this.isDistanceSurpassed = false;
-
- this.originX = getEvX(ev);
- this.originY = getEvY(ev);
- this.scrollEl = getScrollParent($(ev.target));
-
- this.bindHandlers();
- this.initAutoScroll();
- this.handleInteractionStart(ev);
- this.startDelay(ev);
-
- if (!this.minDistance) {
- this.handleDistanceSurpassed(ev);
- }
- }
- },
-
-
- handleInteractionStart: function(ev) {
- this.trigger('interactionStart', ev);
- },
-
-
- endInteraction: function(ev, isCancelled) {
- if (this.isInteracting) {
- this.endDrag(ev);
-
- if (this.delayTimeoutId) {
- clearTimeout(this.delayTimeoutId);
- this.delayTimeoutId = null;
- }
-
- this.destroyAutoScroll();
- this.unbindHandlers();
-
- this.isInteracting = false;
- this.handleInteractionEnd(ev, isCancelled);
-
- // a touchstart+touchend on the same element will result in the following addition simulated events:
- // mouseover + mouseout + click
- // let's ignore these bogus events
- if (this.isTouch) {
- this.tempIgnoreMouse();
- }
- }
- },
-
-
- handleInteractionEnd: function(ev, isCancelled) {
- this.trigger('interactionEnd', ev, isCancelled || false);
- },
-
-
- // Binding To DOM
- // -----------------------------------------------------------------------------------------------------------------
-
-
- bindHandlers: function() {
- var _this = this;
- var touchStartIgnores = 1;
-
- if (this.isTouch) {
- this.listenTo($(document), {
- touchmove: this.handleTouchMove,
- touchend: this.endInteraction,
- touchcancel: this.endInteraction,
-
- // Sometimes touchend doesn't fire
- // (can't figure out why. touchcancel doesn't fire either. has to do with scrolling?)
- // If another touchstart happens, we know it's bogus, so cancel the drag.
- // touchend will continue to be broken until user does a shorttap/scroll, but this is best we can do.
- touchstart: function(ev) {
- if (touchStartIgnores) { // bindHandlers is called from within a touchstart,
- touchStartIgnores--; // and we don't want this to fire immediately, so ignore.
- }
- else {
- _this.endInteraction(ev, true); // isCancelled=true
- }
- }
- });
-
- // listen to ALL scroll actions on the page
- if (
- !bindAnyScroll(this.handleTouchScrollProxy) && // hopefully this works and short-circuits the rest
- this.scrollEl // otherwise, attach a single handler to this
- ) {
- this.listenTo(this.scrollEl, 'scroll', this.handleTouchScroll);
- }
- }
- else {
- this.listenTo($(document), {
- mousemove: this.handleMouseMove,
- mouseup: this.endInteraction
- });
- }
-
- this.listenTo($(document), {
- selectstart: preventDefault, // don't allow selection while dragging
- contextmenu: preventDefault // long taps would open menu on Chrome dev tools
- });
- },
-
-
- unbindHandlers: function() {
- this.stopListeningTo($(document));
-
- // unbind scroll listening
- unbindAnyScroll(this.handleTouchScrollProxy);
- if (this.scrollEl) {
- this.stopListeningTo(this.scrollEl, 'scroll');
- }
- },
-
-
- // Drag (high-level)
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // extraOptions ignored if drag already started
- startDrag: function(ev, extraOptions) {
- this.startInteraction(ev, extraOptions); // ensure interaction began
-
- if (!this.isDragging) {
- this.isDragging = true;
- this.handleDragStart(ev);
- }
- },
-
-
- handleDragStart: function(ev) {
- this.trigger('dragStart', ev);
- },
-
-
- handleMove: function(ev) {
- var dx = getEvX(ev) - this.originX;
- var dy = getEvY(ev) - this.originY;
- var minDistance = this.minDistance;
- var distanceSq; // current distance from the origin, squared
-
- if (!this.isDistanceSurpassed) {
- distanceSq = dx * dx + dy * dy;
- if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
- this.handleDistanceSurpassed(ev);
- }
- }
-
- if (this.isDragging) {
- this.handleDrag(dx, dy, ev);
- }
- },
-
-
- // Called while the mouse is being moved and when we know a legitimate drag is taking place
- handleDrag: function(dx, dy, ev) {
- this.trigger('drag', dx, dy, ev);
- this.updateAutoScroll(ev); // will possibly cause scrolling
- },
-
-
- endDrag: function(ev) {
- if (this.isDragging) {
- this.isDragging = false;
- this.handleDragEnd(ev);
- }
- },
-
-
- handleDragEnd: function(ev) {
- this.trigger('dragEnd', ev);
- },
-
-
- // Delay
- // -----------------------------------------------------------------------------------------------------------------
-
-
- startDelay: function(initialEv) {
- var _this = this;
-
- if (this.delay) {
- this.delayTimeoutId = setTimeout(function() {
- _this.handleDelayEnd(initialEv);
- }, this.delay);
- }
- else {
- this.handleDelayEnd(initialEv);
- }
- },
-
-
- handleDelayEnd: function(initialEv) {
- this.isDelayEnded = true;
-
- if (this.isDistanceSurpassed) {
- this.startDrag(initialEv);
- }
- },
-
-
- // Distance
- // -----------------------------------------------------------------------------------------------------------------
-
-
- handleDistanceSurpassed: function(ev) {
- this.isDistanceSurpassed = true;
-
- if (this.isDelayEnded) {
- this.startDrag(ev);
- }
- },
-
-
- // Mouse / Touch
- // -----------------------------------------------------------------------------------------------------------------
-
-
- handleTouchMove: function(ev) {
- // prevent inertia and touchmove-scrolling while dragging
- if (this.isDragging) {
- ev.preventDefault();
- }
-
- this.handleMove(ev);
- },
-
-
- handleMouseMove: function(ev) {
- this.handleMove(ev);
- },
-
-
- // Scrolling (unrelated to auto-scroll)
- // -----------------------------------------------------------------------------------------------------------------
-
-
- handleTouchScroll: function(ev) {
- // if the drag is being initiated by touch, but a scroll happens before
- // the drag-initiating delay is over, cancel the drag
- if (!this.isDragging) {
- this.endInteraction(ev, true); // isCancelled=true
- }
- },
-
-
- // Utils
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // Triggers a callback. Calls a function in the option hash of the same name.
- // Arguments beyond the first `name` are forwarded on.
- trigger: function(name) {
- if (this.options[name]) {
- this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
- }
- // makes _methods callable by event name. TODO: kill this
- if (this['_' + name]) {
- this['_' + name].apply(this, Array.prototype.slice.call(arguments, 1));
- }
- }
-
-
-});
-
-;;
-/*
-this.scrollEl is set in DragListener
-*/
-DragListener.mixin({
-
- isAutoScroll: false,
-
- scrollBounds: null, // { top, bottom, left, right }
- scrollTopVel: null, // pixels per second
- scrollLeftVel: null, // pixels per second
- scrollIntervalId: null, // ID of setTimeout for scrolling animation loop
-
- // defaults
- scrollSensitivity: 30, // pixels from edge for scrolling to start
- scrollSpeed: 200, // pixels per second, at maximum speed
- scrollIntervalMs: 50, // millisecond wait between scroll increment
-
-
- initAutoScroll: function() {
- var scrollEl = this.scrollEl;
-
- this.isAutoScroll =
- this.options.scroll &&
- scrollEl &&
- !scrollEl.is(window) &&
- !scrollEl.is(document);
-
- if (this.isAutoScroll) {
- // debounce makes sure rapid calls don't happen
- this.listenTo(scrollEl, 'scroll', debounce(this.handleDebouncedScroll, 100));
- }
- },
-
-
- destroyAutoScroll: function() {
- this.endAutoScroll(); // kill any animation loop
-
- // remove the scroll handler if there is a scrollEl
- if (this.isAutoScroll) {
- this.stopListeningTo(this.scrollEl, 'scroll'); // will probably get removed by unbindHandlers too :(
- }
- },
-
-
- // Computes and stores the bounding rectangle of scrollEl
- computeScrollBounds: function() {
- if (this.isAutoScroll) {
- this.scrollBounds = getOuterRect(this.scrollEl);
- // TODO: use getClientRect in future. but prevents auto scrolling when on top of scrollbars
- }
- },
-
-
- // Called when the dragging is in progress and scrolling should be updated
- updateAutoScroll: function(ev) {
- var sensitivity = this.scrollSensitivity;
- var bounds = this.scrollBounds;
- var topCloseness, bottomCloseness;
- var leftCloseness, rightCloseness;
- var topVel = 0;
- var leftVel = 0;
-
- if (bounds) { // only scroll if scrollEl exists
-
- // compute closeness to edges. valid range is from 0.0 - 1.0
- topCloseness = (sensitivity - (getEvY(ev) - bounds.top)) / sensitivity;
- bottomCloseness = (sensitivity - (bounds.bottom - getEvY(ev))) / sensitivity;
- leftCloseness = (sensitivity - (getEvX(ev) - bounds.left)) / sensitivity;
- rightCloseness = (sensitivity - (bounds.right - getEvX(ev))) / sensitivity;
-
- // translate vertical closeness into velocity.
- // mouse must be completely in bounds for velocity to happen.
- if (topCloseness >= 0 && topCloseness <= 1) {
- topVel = topCloseness * this.scrollSpeed * -1; // negative. for scrolling up
- }
- else if (bottomCloseness >= 0 && bottomCloseness <= 1) {
- topVel = bottomCloseness * this.scrollSpeed;
- }
-
- // translate horizontal closeness into velocity
- if (leftCloseness >= 0 && leftCloseness <= 1) {
- leftVel = leftCloseness * this.scrollSpeed * -1; // negative. for scrolling left
- }
- else if (rightCloseness >= 0 && rightCloseness <= 1) {
- leftVel = rightCloseness * this.scrollSpeed;
- }
- }
-
- this.setScrollVel(topVel, leftVel);
- },
-
-
- // Sets the speed-of-scrolling for the scrollEl
- setScrollVel: function(topVel, leftVel) {
-
- this.scrollTopVel = topVel;
- this.scrollLeftVel = leftVel;
-
- this.constrainScrollVel(); // massages into realistic values
-
- // if there is non-zero velocity, and an animation loop hasn't already started, then START
- if ((this.scrollTopVel || this.scrollLeftVel) && !this.scrollIntervalId) {
- this.scrollIntervalId = setInterval(
- proxy(this, 'scrollIntervalFunc'), // scope to `this`
- this.scrollIntervalMs
- );
- }
- },
-
-
- // Forces scrollTopVel and scrollLeftVel to be zero if scrolling has already gone all the way
- constrainScrollVel: function() {
- var el = this.scrollEl;
-
- if (this.scrollTopVel < 0) { // scrolling up?
- if (el.scrollTop() <= 0) { // already scrolled all the way up?
- this.scrollTopVel = 0;
- }
- }
- else if (this.scrollTopVel > 0) { // scrolling down?
- if (el.scrollTop() + el[0].clientHeight >= el[0].scrollHeight) { // already scrolled all the way down?
- this.scrollTopVel = 0;
- }
- }
-
- if (this.scrollLeftVel < 0) { // scrolling left?
- if (el.scrollLeft() <= 0) { // already scrolled all the left?
- this.scrollLeftVel = 0;
- }
- }
- else if (this.scrollLeftVel > 0) { // scrolling right?
- if (el.scrollLeft() + el[0].clientWidth >= el[0].scrollWidth) { // already scrolled all the way right?
- this.scrollLeftVel = 0;
- }
- }
- },
-
-
- // This function gets called during every iteration of the scrolling animation loop
- scrollIntervalFunc: function() {
- var el = this.scrollEl;
- var frac = this.scrollIntervalMs / 1000; // considering animation frequency, what the vel should be mult'd by
-
- // change the value of scrollEl's scroll
- if (this.scrollTopVel) {
- el.scrollTop(el.scrollTop() + this.scrollTopVel * frac);
- }
- if (this.scrollLeftVel) {
- el.scrollLeft(el.scrollLeft() + this.scrollLeftVel * frac);
- }
-
- this.constrainScrollVel(); // since the scroll values changed, recompute the velocities
-
- // if scrolled all the way, which causes the vels to be zero, stop the animation loop
- if (!this.scrollTopVel && !this.scrollLeftVel) {
- this.endAutoScroll();
- }
- },
-
-
- // Kills any existing scrolling animation loop
- endAutoScroll: function() {
- if (this.scrollIntervalId) {
- clearInterval(this.scrollIntervalId);
- this.scrollIntervalId = null;
-
- this.handleScrollEnd();
- }
- },
-
-
- // Get called when the scrollEl is scrolled (NOTE: this is delayed via debounce)
- handleDebouncedScroll: function() {
- // recompute all coordinates, but *only* if this is *not* part of our scrolling animation
- if (!this.scrollIntervalId) {
- this.handleScrollEnd();
- }
- },
-
-
- // Called when scrolling has stopped, whether through auto scroll, or the user scrolling
- handleScrollEnd: function() {
- }
-
-});
-;;
-
-/* Tracks mouse movements over a component and raises events about which hit the mouse is over.
-------------------------------------------------------------------------------------------------------------------------
-options:
-- subjectEl
-- subjectCenter
-*/
-
-var HitDragListener = DragListener.extend({
-
- component: null, // converts coordinates to hits
- // methods: prepareHits, releaseHits, queryHit
-
- origHit: null, // the hit the mouse was over when listening started
- hit: null, // the hit the mouse is over
- coordAdjust: null, // delta that will be added to the mouse coordinates when computing collisions
-
-
- constructor: function(component, options) {
- DragListener.call(this, options); // call the super-constructor
-
- this.component = component;
- },
-
-
- // Called when drag listening starts (but a real drag has not necessarily began).
- // ev might be undefined if dragging was started manually.
- handleInteractionStart: function(ev) {
- var subjectEl = this.subjectEl;
- var subjectRect;
- var origPoint;
- var point;
-
- this.computeCoords();
-
- if (ev) {
- origPoint = { left: getEvX(ev), top: getEvY(ev) };
- point = origPoint;
-
- // constrain the point to bounds of the element being dragged
- if (subjectEl) {
- subjectRect = getOuterRect(subjectEl); // used for centering as well
- point = constrainPoint(point, subjectRect);
- }
-
- this.origHit = this.queryHit(point.left, point.top);
-
- // treat the center of the subject as the collision point?
- if (subjectEl && this.options.subjectCenter) {
-
- // only consider the area the subject overlaps the hit. best for large subjects.
- // TODO: skip this if hit didn't supply left/right/top/bottom
- if (this.origHit) {
- subjectRect = intersectRects(this.origHit, subjectRect) ||
- subjectRect; // in case there is no intersection
- }
-
- point = getRectCenter(subjectRect);
- }
-
- this.coordAdjust = diffPoints(point, origPoint); // point - origPoint
- }
- else {
- this.origHit = null;
- this.coordAdjust = null;
- }
-
- // call the super-method. do it after origHit has been computed
- DragListener.prototype.handleInteractionStart.apply(this, arguments);
- },
-
-
- // Recomputes the drag-critical positions of elements
- computeCoords: function() {
- this.component.prepareHits();
- this.computeScrollBounds(); // why is this here??????
- },
-
-
- // Called when the actual drag has started
- handleDragStart: function(ev) {
- var hit;
-
- DragListener.prototype.handleDragStart.apply(this, arguments); // call the super-method
-
- // might be different from this.origHit if the min-distance is large
- hit = this.queryHit(getEvX(ev), getEvY(ev));
-
- // report the initial hit the mouse is over
- // especially important if no min-distance and drag starts immediately
- if (hit) {
- this.handleHitOver(hit);
- }
- },
-
-
- // Called when the drag moves
- handleDrag: function(dx, dy, ev) {
- var hit;
-
- DragListener.prototype.handleDrag.apply(this, arguments); // call the super-method
-
- hit = this.queryHit(getEvX(ev), getEvY(ev));
-
- if (!isHitsEqual(hit, this.hit)) { // a different hit than before?
- if (this.hit) {
- this.handleHitOut();
- }
- if (hit) {
- this.handleHitOver(hit);
- }
- }
- },
-
-
- // Called when dragging has been stopped
- handleDragEnd: function() {
- this.handleHitDone();
- DragListener.prototype.handleDragEnd.apply(this, arguments); // call the super-method
- },
-
-
- // Called when a the mouse has just moved over a new hit
- handleHitOver: function(hit) {
- var isOrig = isHitsEqual(hit, this.origHit);
-
- this.hit = hit;
-
- this.trigger('hitOver', this.hit, isOrig, this.origHit);
- },
-
-
- // Called when the mouse has just moved out of a hit
- handleHitOut: function() {
- if (this.hit) {
- this.trigger('hitOut', this.hit);
- this.handleHitDone();
- this.hit = null;
- }
- },
-
-
- // Called after a hitOut. Also called before a dragStop
- handleHitDone: function() {
- if (this.hit) {
- this.trigger('hitDone', this.hit);
- }
- },
-
-
- // Called when the interaction ends, whether there was a real drag or not
- handleInteractionEnd: function() {
- DragListener.prototype.handleInteractionEnd.apply(this, arguments); // call the super-method
-
- this.origHit = null;
- this.hit = null;
-
- this.component.releaseHits();
- },
-
-
- // Called when scrolling has stopped, whether through auto scroll, or the user scrolling
- handleScrollEnd: function() {
- DragListener.prototype.handleScrollEnd.apply(this, arguments); // call the super-method
-
- this.computeCoords(); // hits' absolute positions will be in new places. recompute
- },
-
-
- // Gets the hit underneath the coordinates for the given mouse event
- queryHit: function(left, top) {
-
- if (this.coordAdjust) {
- left += this.coordAdjust.left;
- top += this.coordAdjust.top;
- }
-
- return this.component.queryHit(left, top);
- }
-
-});
-
-
-// Returns `true` if the hits are identically equal. `false` otherwise. Must be from the same component.
-// Two null values will be considered equal, as two "out of the component" states are the same.
-function isHitsEqual(hit0, hit1) {
-
- if (!hit0 && !hit1) {
- return true;
- }
-
- if (hit0 && hit1) {
- return hit0.component === hit1.component &&
- isHitPropsWithin(hit0, hit1) &&
- isHitPropsWithin(hit1, hit0); // ensures all props are identical
- }
-
- return false;
-}
-
-
-// Returns true if all of subHit's non-standard properties are within superHit
-function isHitPropsWithin(subHit, superHit) {
- for (var propName in subHit) {
- if (!/^(component|left|right|top|bottom)$/.test(propName)) {
- if (subHit[propName] !== superHit[propName]) {
- return false;
- }
- }
- }
- return true;
-}
-
-;;
-
-/* Creates a clone of an element and lets it track the mouse as it moves
-----------------------------------------------------------------------------------------------------------------------*/
-
-var MouseFollower = Class.extend(ListenerMixin, {
-
- options: null,
-
- sourceEl: null, // the element that will be cloned and made to look like it is dragging
- el: null, // the clone of `sourceEl` that will track the mouse
- parentEl: null, // the element that `el` (the clone) will be attached to
-
- // the initial position of el, relative to the offset parent. made to match the initial offset of sourceEl
- top0: null,
- left0: null,
-
- // the absolute coordinates of the initiating touch/mouse action
- y0: null,
- x0: null,
-
- // the number of pixels the mouse has moved from its initial position
- topDelta: null,
- leftDelta: null,
-
- isFollowing: false,
- isHidden: false,
- isAnimating: false, // doing the revert animation?
-
- constructor: function(sourceEl, options) {
- this.options = options = options || {};
- this.sourceEl = sourceEl;
- this.parentEl = options.parentEl ? $(options.parentEl) : sourceEl.parent(); // default to sourceEl's parent
- },
-
-
- // Causes the element to start following the mouse
- start: function(ev) {
- if (!this.isFollowing) {
- this.isFollowing = true;
-
- this.y0 = getEvY(ev);
- this.x0 = getEvX(ev);
- this.topDelta = 0;
- this.leftDelta = 0;
-
- if (!this.isHidden) {
- this.updatePosition();
- }
-
- if (getEvIsTouch(ev)) {
- this.listenTo($(document), 'touchmove', this.handleMove);
- }
- else {
- this.listenTo($(document), 'mousemove', this.handleMove);
- }
- }
- },
-
-
- // Causes the element to stop following the mouse. If shouldRevert is true, will animate back to original position.
- // `callback` gets invoked when the animation is complete. If no animation, it is invoked immediately.
- stop: function(shouldRevert, callback) {
- var _this = this;
- var revertDuration = this.options.revertDuration;
-
- function complete() { // might be called by .animate(), which might change `this` context
- _this.isAnimating = false;
- _this.removeElement();
-
- _this.top0 = _this.left0 = null; // reset state for future updatePosition calls
-
- if (callback) {
- callback();
- }
- }
-
- if (this.isFollowing && !this.isAnimating) { // disallow more than one stop animation at a time
- this.isFollowing = false;
-
- this.stopListeningTo($(document));
-
- if (shouldRevert && revertDuration && !this.isHidden) { // do a revert animation?
- this.isAnimating = true;
- this.el.animate({
- top: this.top0,
- left: this.left0
- }, {
- duration: revertDuration,
- complete: complete
- });
- }
- else {
- complete();
- }
- }
- },
-
-
- // Gets the tracking element. Create it if necessary
- getEl: function() {
- var el = this.el;
-
- if (!el) {
- el = this.el = this.sourceEl.clone()
- .addClass(this.options.additionalClass || '')
- .css({
- position: 'absolute',
- visibility: '', // in case original element was hidden (commonly through hideEvents())
- display: this.isHidden ? 'none' : '', // for when initially hidden
- margin: 0,
- right: 'auto', // erase and set width instead
- bottom: 'auto', // erase and set height instead
- width: this.sourceEl.width(), // explicit height in case there was a 'right' value
- height: this.sourceEl.height(), // explicit width in case there was a 'bottom' value
- opacity: this.options.opacity || '',
- zIndex: this.options.zIndex
- });
-
- // we don't want long taps or any mouse interaction causing selection/menus.
- // would use preventSelection(), but that prevents selectstart, causing problems.
- el.addClass('fc-unselectable');
-
- el.appendTo(this.parentEl);
- }
-
- return el;
- },
-
-
- // Removes the tracking element if it has already been created
- removeElement: function() {
- if (this.el) {
- this.el.remove();
- this.el = null;
- }
- },
-
-
- // Update the CSS position of the tracking element
- updatePosition: function() {
- var sourceOffset;
- var origin;
-
- this.getEl(); // ensure this.el
-
- // make sure origin info was computed
- if (this.top0 === null) {
- sourceOffset = this.sourceEl.offset();
- origin = this.el.offsetParent().offset();
- this.top0 = sourceOffset.top - origin.top;
- this.left0 = sourceOffset.left - origin.left;
- }
-
- this.el.css({
- top: this.top0 + this.topDelta,
- left: this.left0 + this.leftDelta
- });
- },
-
-
- // Gets called when the user moves the mouse
- handleMove: function(ev) {
- this.topDelta = getEvY(ev) - this.y0;
- this.leftDelta = getEvX(ev) - this.x0;
-
- if (!this.isHidden) {
- this.updatePosition();
- }
- },
-
-
- // Temporarily makes the tracking element invisible. Can be called before following starts
- hide: function() {
- if (!this.isHidden) {
- this.isHidden = true;
- if (this.el) {
- this.el.hide();
- }
- }
- },
-
-
- // Show the tracking element after it has been temporarily hidden
- show: function() {
- if (this.isHidden) {
- this.isHidden = false;
- this.updatePosition();
- this.getEl().show();
- }
- }
-
-});
-
-;;
-
-/* An abstract class comprised of a "grid" of areas that each represent a specific datetime
-----------------------------------------------------------------------------------------------------------------------*/
-
-var Grid = FC.Grid = Class.extend(ListenerMixin, MouseIgnorerMixin, {
-
- // self-config, overridable by subclasses
- hasDayInteractions: true, // can user click/select ranges of time?
-
- view: null, // a View object
- isRTL: null, // shortcut to the view's isRTL option
-
- start: null,
- end: null,
-
- el: null, // the containing element
- elsByFill: null, // a hash of jQuery element sets used for rendering each fill. Keyed by fill name.
-
- // derived from options
- eventTimeFormat: null,
- displayEventTime: null,
- displayEventEnd: null,
-
- minResizeDuration: null, // TODO: hack. set by subclasses. minumum event resize duration
-
- // if defined, holds the unit identified (ex: "year" or "month") that determines the level of granularity
- // of the date areas. if not defined, assumes to be day and time granularity.
- // TODO: port isTimeScale into same system?
- largeUnit: null,
-
- dayDragListener: null,
- segDragListener: null,
- segResizeListener: null,
- externalDragListener: null,
-
-
- constructor: function(view) {
- this.view = view;
- this.isRTL = view.opt('isRTL');
- this.elsByFill = {};
-
- this.dayDragListener = this.buildDayDragListener();
- this.initMouseIgnoring();
- },
-
-
- /* Options
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Generates the format string used for event time text, if not explicitly defined by 'timeFormat'
- computeEventTimeFormat: function() {
- return this.view.opt('smallTimeFormat');
- },
-
-
- // Determines whether events should have their end times displayed, if not explicitly defined by 'displayEventTime'.
- // Only applies to non-all-day events.
- computeDisplayEventTime: function() {
- return true;
- },
-
-
- // Determines whether events should have their end times displayed, if not explicitly defined by 'displayEventEnd'
- computeDisplayEventEnd: function() {
- return true;
- },
-
-
- /* Dates
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Tells the grid about what period of time to display.
- // Any date-related internal data should be generated.
- setRange: function(range) {
- this.start = range.start.clone();
- this.end = range.end.clone();
-
- this.rangeUpdated();
- this.processRangeOptions();
- },
-
-
- // Called when internal variables that rely on the range should be updated
- rangeUpdated: function() {
- },
-
-
- // Updates values that rely on options and also relate to range
- processRangeOptions: function() {
- var view = this.view;
- var displayEventTime;
- var displayEventEnd;
-
- this.eventTimeFormat =
- view.opt('eventTimeFormat') ||
- view.opt('timeFormat') || // deprecated
- this.computeEventTimeFormat();
-
- displayEventTime = view.opt('displayEventTime');
- if (displayEventTime == null) {
- displayEventTime = this.computeDisplayEventTime(); // might be based off of range
- }
-
- displayEventEnd = view.opt('displayEventEnd');
- if (displayEventEnd == null) {
- displayEventEnd = this.computeDisplayEventEnd(); // might be based off of range
- }
-
- this.displayEventTime = displayEventTime;
- this.displayEventEnd = displayEventEnd;
- },
-
-
- // Converts a span (has unzoned start/end and any other grid-specific location information)
- // into an array of segments (pieces of events whose format is decided by the grid).
- spanToSegs: function(span) {
- // subclasses must implement
- },
-
-
- // Diffs the two dates, returning a duration, based on granularity of the grid
- // TODO: port isTimeScale into this system?
- diffDates: function(a, b) {
- if (this.largeUnit) {
- return diffByUnit(a, b, this.largeUnit);
- }
- else {
- return diffDayTime(a, b);
- }
- },
-
-
- /* Hit Area
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Called before one or more queryHit calls might happen. Should prepare any cached coordinates for queryHit
- prepareHits: function() {
- },
-
-
- // Called when queryHit calls have subsided. Good place to clear any coordinate caches.
- releaseHits: function() {
- },
-
-
- // Given coordinates from the topleft of the document, return data about the date-related area underneath.
- // Can return an object with arbitrary properties (although top/right/left/bottom are encouraged).
- // Must have a `grid` property, a reference to this current grid. TODO: avoid this
- // The returned object will be processed by getHitSpan and getHitEl.
- queryHit: function(leftOffset, topOffset) {
- },
-
-
- // Given position-level information about a date-related area within the grid,
- // should return an object with at least a start/end date. Can provide other information as well.
- getHitSpan: function(hit) {
- },
-
-
- // Given position-level information about a date-related area within the grid,
- // should return a jQuery element that best represents it. passed to dayClick callback.
- getHitEl: function(hit) {
- },
-
-
- /* Rendering
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Sets the container element that the grid should render inside of.
- // Does other DOM-related initializations.
- setElement: function(el) {
- this.el = el;
-
- if (this.hasDayInteractions) {
- preventSelection(el);
-
- this.bindDayHandler('touchstart', this.dayTouchStart);
- this.bindDayHandler('mousedown', this.dayMousedown);
- }
-
- // attach event-element-related handlers. in Grid.events
- // same garbage collection note as above.
- this.bindSegHandlers();
-
- this.bindGlobalHandlers();
- },
-
-
- bindDayHandler: function(name, handler) {
- var _this = this;
-
- // attach a handler to the grid's root element.
- // jQuery will take care of unregistering them when removeElement gets called.
- this.el.on(name, function(ev) {
- if (
- !$(ev.target).is(
- _this.segSelector + ',' + // directly on an event element
- _this.segSelector + ' *,' + // within an event element
- '.fc-more,' + // a "more.." link
- 'a[data-goto]' // a clickable nav link
- )
- ) {
- return handler.call(_this, ev);
- }
- });
- },
-
-
- // Removes the grid's container element from the DOM. Undoes any other DOM-related attachments.
- // DOES NOT remove any content beforehand (doesn't clear events or call unrenderDates), unlike View
- removeElement: function() {
- this.unbindGlobalHandlers();
- this.clearDragListeners();
-
- this.el.remove();
-
- // NOTE: we don't null-out this.el for the same reasons we don't do it within View::removeElement
- },
-
-
- // Renders the basic structure of grid view before any content is rendered
- renderSkeleton: function() {
- // subclasses should implement
- },
-
-
- // Renders the grid's date-related content (like areas that represent days/times).
- // Assumes setRange has already been called and the skeleton has already been rendered.
- renderDates: function() {
- // subclasses should implement
- },
-
-
- // Unrenders the grid's date-related content
- unrenderDates: function() {
- // subclasses should implement
- },
-
-
- /* Handlers
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Binds DOM handlers to elements that reside outside the grid, such as the document
- bindGlobalHandlers: function() {
- this.listenTo($(document), {
- dragstart: this.externalDragStart, // jqui
- sortstart: this.externalDragStart // jqui
- });
- },
-
-
- // Unbinds DOM handlers from elements that reside outside the grid
- unbindGlobalHandlers: function() {
- this.stopListeningTo($(document));
- },
-
-
- // Process a mousedown on an element that represents a day. For day clicking and selecting.
- dayMousedown: function(ev) {
- if (!this.isIgnoringMouse) {
- this.dayDragListener.startInteraction(ev, {
- //distance: 5, // needs more work if we want dayClick to fire correctly
- });
- }
- },
-
-
- dayTouchStart: function(ev) {
- var view = this.view;
- var selectLongPressDelay = view.opt('selectLongPressDelay');
-
- // HACK to prevent a user's clickaway for unselecting a range or an event
- // from causing a dayClick.
- if (view.isSelected || view.selectedEvent) {
- this.tempIgnoreMouse();
- }
-
- if (selectLongPressDelay == null) {
- selectLongPressDelay = view.opt('longPressDelay'); // fallback
- }
-
- this.dayDragListener.startInteraction(ev, {
- delay: selectLongPressDelay
- });
- },
-
-
- // Creates a listener that tracks the user's drag across day elements.
- // For day clicking and selecting.
- buildDayDragListener: function() {
- var _this = this;
- var view = this.view;
- var isSelectable = view.opt('selectable');
- var dayClickHit; // null if invalid dayClick
- var selectionSpan; // null if invalid selection
-
- // this listener tracks a mousedown on a day element, and a subsequent drag.
- // if the drag ends on the same day, it is a 'dayClick'.
- // if 'selectable' is enabled, this listener also detects selections.
- var dragListener = new HitDragListener(this, {
- scroll: view.opt('dragScroll'),
- interactionStart: function() {
- dayClickHit = dragListener.origHit; // for dayClick, where no dragging happens
- selectionSpan = null;
- },
- dragStart: function() {
- view.unselect(); // since we could be rendering a new selection, we want to clear any old one
- },
- hitOver: function(hit, isOrig, origHit) {
- if (origHit) { // click needs to have started on a hit
-
- // if user dragged to another cell at any point, it can no longer be a dayClick
- if (!isOrig) {
- dayClickHit = null;
- }
-
- if (isSelectable) {
- selectionSpan = _this.computeSelection(
- _this.getHitSpan(origHit),
- _this.getHitSpan(hit)
- );
- if (selectionSpan) {
- _this.renderSelection(selectionSpan);
- }
- else if (selectionSpan === false) {
- disableCursor();
- }
- }
- }
- },
- hitOut: function() { // called before mouse moves to a different hit OR moved out of all hits
- dayClickHit = null;
- selectionSpan = null;
- _this.unrenderSelection();
- },
- hitDone: function() { // called after a hitOut OR before a dragEnd
- enableCursor();
- },
- interactionEnd: function(ev, isCancelled) {
- if (!isCancelled) {
- if (
- dayClickHit &&
- !_this.isIgnoringMouse // see hack in dayTouchStart
- ) {
- view.triggerDayClick(
- _this.getHitSpan(dayClickHit),
- _this.getHitEl(dayClickHit),
- ev
- );
- }
- if (selectionSpan) {
- // the selection will already have been rendered. just report it
- view.reportSelection(selectionSpan, ev);
- }
- }
- }
- });
-
- return dragListener;
- },
-
-
- // Kills all in-progress dragging.
- // Useful for when public API methods that result in re-rendering are invoked during a drag.
- // Also useful for when touch devices misbehave and don't fire their touchend.
- clearDragListeners: function() {
- this.dayDragListener.endInteraction();
-
- if (this.segDragListener) {
- this.segDragListener.endInteraction(); // will clear this.segDragListener
- }
- if (this.segResizeListener) {
- this.segResizeListener.endInteraction(); // will clear this.segResizeListener
- }
- if (this.externalDragListener) {
- this.externalDragListener.endInteraction(); // will clear this.externalDragListener
- }
- },
-
-
- /* Event Helper
- ------------------------------------------------------------------------------------------------------------------*/
- // TODO: should probably move this to Grid.events, like we did event dragging / resizing
-
-
- // Renders a mock event at the given event location, which contains zoned start/end properties.
- // Returns all mock event elements.
- renderEventLocationHelper: function(eventLocation, sourceSeg) {
- var fakeEvent = this.fabricateHelperEvent(eventLocation, sourceSeg);
-
- return this.renderHelper(fakeEvent, sourceSeg); // do the actual rendering
- },
-
-
- // Builds a fake event given zoned event date properties and a segment is should be inspired from.
- // The range's end can be null, in which case the mock event that is rendered will have a null end time.
- // `sourceSeg` is the internal segment object involved in the drag. If null, something external is dragging.
- fabricateHelperEvent: function(eventLocation, sourceSeg) {
- var fakeEvent = sourceSeg ? createObject(sourceSeg.event) : {}; // mask the original event object if possible
-
- fakeEvent.start = eventLocation.start.clone();
- fakeEvent.end = eventLocation.end ? eventLocation.end.clone() : null;
- fakeEvent.allDay = null; // force it to be freshly computed by normalizeEventDates
- this.view.calendar.normalizeEventDates(fakeEvent);
-
- // this extra className will be useful for differentiating real events from mock events in CSS
- fakeEvent.className = (fakeEvent.className || []).concat('fc-helper');
-
- // if something external is being dragged in, don't render a resizer
- if (!sourceSeg) {
- fakeEvent.editable = false;
- }
-
- return fakeEvent;
- },
-
-
- // Renders a mock event. Given zoned event date properties.
- // Must return all mock event elements.
- renderHelper: function(eventLocation, sourceSeg) {
- // subclasses must implement
- },
-
-
- // Unrenders a mock event
- unrenderHelper: function() {
- // subclasses must implement
- },
-
-
- /* Selection
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Renders a visual indication of a selection. Will highlight by default but can be overridden by subclasses.
- // Given a span (unzoned start/end and other misc data)
- renderSelection: function(span) {
- this.renderHighlight(span);
- },
-
-
- // Unrenders any visual indications of a selection. Will unrender a highlight by default.
- unrenderSelection: function() {
- this.unrenderHighlight();
- },
-
-
- // Given the first and last date-spans of a selection, returns another date-span object.
- // Subclasses can override and provide additional data in the span object. Will be passed to renderSelection().
- // Will return false if the selection is invalid and this should be indicated to the user.
- // Will return null/undefined if a selection invalid but no error should be reported.
- computeSelection: function(span0, span1) {
- var span = this.computeSelectionSpan(span0, span1);
-
- if (span && !this.view.calendar.isSelectionSpanAllowed(span)) {
- return false;
- }
-
- return span;
- },
-
-
- // Given two spans, must return the combination of the two.
- // TODO: do this separation of concerns (combining VS validation) for event dnd/resize too.
- computeSelectionSpan: function(span0, span1) {
- var dates = [ span0.start, span0.end, span1.start, span1.end ];
-
- dates.sort(compareNumbers); // sorts chronologically. works with Moments
-
- return { start: dates[0].clone(), end: dates[3].clone() };
- },
-
-
- /* Highlight
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Renders an emphasis on the given date range. Given a span (unzoned start/end and other misc data)
- renderHighlight: function(span) {
- this.renderFill('highlight', this.spanToSegs(span));
- },
-
-
- // Unrenders the emphasis on a date range
- unrenderHighlight: function() {
- this.unrenderFill('highlight');
- },
-
-
- // Generates an array of classNames for rendering the highlight. Used by the fill system.
- highlightSegClasses: function() {
- return [ 'fc-highlight' ];
- },
-
-
- /* Business Hours
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderBusinessHours: function() {
- },
-
-
- unrenderBusinessHours: function() {
- },
-
-
- /* Now Indicator
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- getNowIndicatorUnit: function() {
- },
-
-
- renderNowIndicator: function(date) {
- },
-
-
- unrenderNowIndicator: function() {
- },
-
-
- /* Fill System (highlight, background events, business hours)
- --------------------------------------------------------------------------------------------------------------------
- TODO: remove this system. like we did in TimeGrid
- */
-
-
- // Renders a set of rectangles over the given segments of time.
- // MUST RETURN a subset of segs, the segs that were actually rendered.
- // Responsible for populating this.elsByFill. TODO: better API for expressing this requirement
- renderFill: function(type, segs) {
- // subclasses must implement
- },
-
-
- // Unrenders a specific type of fill that is currently rendered on the grid
- unrenderFill: function(type) {
- var el = this.elsByFill[type];
-
- if (el) {
- el.remove();
- delete this.elsByFill[type];
- }
- },
-
-
- // Renders and assigns an `el` property for each fill segment. Generic enough to work with different types.
- // Only returns segments that successfully rendered.
- // To be harnessed by renderFill (implemented by subclasses).
- // Analagous to renderFgSegEls.
- renderFillSegEls: function(type, segs) {
- var _this = this;
- var segElMethod = this[type + 'SegEl'];
- var html = '';
- var renderedSegs = [];
- var i;
-
- if (segs.length) {
-
- // build a large concatenation of segment HTML
- for (i = 0; i < segs.length; i++) {
- html += this.fillSegHtml(type, segs[i]);
- }
-
- // Grab individual elements from the combined HTML string. Use each as the default rendering.
- // Then, compute the 'el' for each segment.
- $(html).each(function(i, node) {
- var seg = segs[i];
- var el = $(node);
-
- // allow custom filter methods per-type
- if (segElMethod) {
- el = segElMethod.call(_this, seg, el);
- }
-
- if (el) { // custom filters did not cancel the render
- el = $(el); // allow custom filter to return raw DOM node
-
- // correct element type? (would be bad if a non-TD were inserted into a table for example)
- if (el.is(_this.fillSegTag)) {
- seg.el = el;
- renderedSegs.push(seg);
- }
- }
- });
- }
-
- return renderedSegs;
- },
-
-
- fillSegTag: 'div', // subclasses can override
-
-
- // Builds the HTML needed for one fill segment. Generic enough to work with different types.
- fillSegHtml: function(type, seg) {
-
- // custom hooks per-type
- var classesMethod = this[type + 'SegClasses'];
- var cssMethod = this[type + 'SegCss'];
-
- var classes = classesMethod ? classesMethod.call(this, seg) : [];
- var css = cssToStr(cssMethod ? cssMethod.call(this, seg) : {});
-
- return '<' + this.fillSegTag +
- (classes.length ? ' class="' + classes.join(' ') + '"' : '') +
- (css ? ' style="' + css + '"' : '') +
- ' />';
- },
-
-
-
- /* Generic rendering utilities for subclasses
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Computes HTML classNames for a single-day element
- getDayClasses: function(date, noThemeHighlight) {
- var view = this.view;
- var today = view.calendar.getNow();
- var classes = [ 'fc-' + dayIDs[date.day()] ];
-
- if (
- view.intervalDuration.as('months') == 1 &&
- date.month() != view.intervalStart.month()
- ) {
- classes.push('fc-other-month');
- }
-
- if (date.isSame(today, 'day')) {
- classes.push('fc-today');
-
- if (noThemeHighlight !== true) {
- classes.push(view.highlightStateClass);
- }
- }
- else if (date < today) {
- classes.push('fc-past');
- }
- else {
- classes.push('fc-future');
- }
-
- return classes;
- }
-
-});
-
-;;
-
-/* Event-rendering and event-interaction methods for the abstract Grid class
-----------------------------------------------------------------------------------------------------------------------*/
-
-Grid.mixin({
-
- // self-config, overridable by subclasses
- segSelector: '.fc-event-container > *', // what constitutes an event element?
-
- mousedOverSeg: null, // the segment object the user's mouse is over. null if over nothing
- isDraggingSeg: false, // is a segment being dragged? boolean
- isResizingSeg: false, // is a segment being resized? boolean
- isDraggingExternal: false, // jqui-dragging an external element? boolean
- segs: null, // the *event* segments currently rendered in the grid. TODO: rename to `eventSegs`
-
-
- // Renders the given events onto the grid
- renderEvents: function(events) {
- var bgEvents = [];
- var fgEvents = [];
- var i;
-
- for (i = 0; i < events.length; i++) {
- (isBgEvent(events[i]) ? bgEvents : fgEvents).push(events[i]);
- }
-
- this.segs = [].concat( // record all segs
- this.renderBgEvents(bgEvents),
- this.renderFgEvents(fgEvents)
- );
- },
-
-
- renderBgEvents: function(events) {
- var segs = this.eventsToSegs(events);
-
- // renderBgSegs might return a subset of segs, segs that were actually rendered
- return this.renderBgSegs(segs) || segs;
- },
-
-
- renderFgEvents: function(events) {
- var segs = this.eventsToSegs(events);
-
- // renderFgSegs might return a subset of segs, segs that were actually rendered
- return this.renderFgSegs(segs) || segs;
- },
-
-
- // Unrenders all events currently rendered on the grid
- unrenderEvents: function() {
- this.handleSegMouseout(); // trigger an eventMouseout if user's mouse is over an event
- this.clearDragListeners();
-
- this.unrenderFgSegs();
- this.unrenderBgSegs();
-
- this.segs = null;
- },
-
-
- // Retrieves all rendered segment objects currently rendered on the grid
- getEventSegs: function() {
- return this.segs || [];
- },
-
-
- /* Foreground Segment Rendering
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Renders foreground event segments onto the grid. May return a subset of segs that were rendered.
- renderFgSegs: function(segs) {
- // subclasses must implement
- },
-
-
- // Unrenders all currently rendered foreground segments
- unrenderFgSegs: function() {
- // subclasses must implement
- },
-
-
- // Renders and assigns an `el` property for each foreground event segment.
- // Only returns segments that successfully rendered.
- // A utility that subclasses may use.
- renderFgSegEls: function(segs, disableResizing) {
- var view = this.view;
- var html = '';
- var renderedSegs = [];
- var i;
-
- if (segs.length) { // don't build an empty html string
-
- // build a large concatenation of event segment HTML
- for (i = 0; i < segs.length; i++) {
- html += this.fgSegHtml(segs[i], disableResizing);
- }
-
- // Grab individual elements from the combined HTML string. Use each as the default rendering.
- // Then, compute the 'el' for each segment. An el might be null if the eventRender callback returned false.
- $(html).each(function(i, node) {
- var seg = segs[i];
- var el = view.resolveEventEl(seg.event, $(node));
-
- if (el) {
- el.data('fc-seg', seg); // used by handlers
- seg.el = el;
- renderedSegs.push(seg);
- }
- });
- }
-
- return renderedSegs;
- },
-
-
- // Generates the HTML for the default rendering of a foreground event segment. Used by renderFgSegEls()
- fgSegHtml: function(seg, disableResizing) {
- // subclasses should implement
- },
-
-
- /* Background Segment Rendering
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Renders the given background event segments onto the grid.
- // Returns a subset of the segs that were actually rendered.
- renderBgSegs: function(segs) {
- return this.renderFill('bgEvent', segs);
- },
-
-
- // Unrenders all the currently rendered background event segments
- unrenderBgSegs: function() {
- this.unrenderFill('bgEvent');
- },
-
-
- // Renders a background event element, given the default rendering. Called by the fill system.
- bgEventSegEl: function(seg, el) {
- return this.view.resolveEventEl(seg.event, el); // will filter through eventRender
- },
-
-
- // Generates an array of classNames to be used for the default rendering of a background event.
- // Called by fillSegHtml.
- bgEventSegClasses: function(seg) {
- var event = seg.event;
- var source = event.source || {};
-
- return [ 'fc-bgevent' ].concat(
- event.className,
- source.className || []
- );
- },
-
-
- // Generates a semicolon-separated CSS string to be used for the default rendering of a background event.
- // Called by fillSegHtml.
- bgEventSegCss: function(seg) {
- return {
- 'background-color': this.getSegSkinCss(seg)['background-color']
- };
- },
-
-
- // Generates an array of classNames to be used for the rendering business hours overlay. Called by the fill system.
- // Called by fillSegHtml.
- businessHoursSegClasses: function(seg) {
- return [ 'fc-nonbusiness', 'fc-bgevent' ];
- },
-
-
- /* Business Hours
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Compute business hour segs for the grid's current date range.
- // Caller must ask if whole-day business hours are needed.
- // If no `businessHours` configuration value is specified, assumes the calendar default.
- buildBusinessHourSegs: function(wholeDay, businessHours) {
- return this.eventsToSegs(
- this.buildBusinessHourEvents(wholeDay, businessHours)
- );
- },
-
-
- // Compute business hour *events* for the grid's current date range.
- // Caller must ask if whole-day business hours are needed.
- // If no `businessHours` configuration value is specified, assumes the calendar default.
- buildBusinessHourEvents: function(wholeDay, businessHours) {
- var calendar = this.view.calendar;
- var events;
-
- if (businessHours == null) {
- // fallback
- // access from calendawr. don't access from view. doesn't update with dynamic options.
- businessHours = calendar.options.businessHours;
- }
-
- events = calendar.computeBusinessHourEvents(wholeDay, businessHours);
-
- // HACK. Eventually refactor business hours "events" system.
- // If no events are given, but businessHours is activated, this means the entire visible range should be
- // marked as *not* business-hours, via inverse-background rendering.
- if (!events.length && businessHours) {
- events = [
- $.extend({}, BUSINESS_HOUR_EVENT_DEFAULTS, {
- start: this.view.end, // guaranteed out-of-range
- end: this.view.end, // "
- dow: null
- })
- ];
- }
-
- return events;
- },
-
-
- /* Handlers
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Attaches event-element-related handlers for *all* rendered event segments of the view.
- bindSegHandlers: function() {
- this.bindSegHandlersToEl(this.el);
- },
-
-
- // Attaches event-element-related handlers to an arbitrary container element. leverages bubbling.
- bindSegHandlersToEl: function(el) {
- this.bindSegHandlerToEl(el, 'touchstart', this.handleSegTouchStart);
- this.bindSegHandlerToEl(el, 'touchend', this.handleSegTouchEnd);
- this.bindSegHandlerToEl(el, 'mouseenter', this.handleSegMouseover);
- this.bindSegHandlerToEl(el, 'mouseleave', this.handleSegMouseout);
- this.bindSegHandlerToEl(el, 'mousedown', this.handleSegMousedown);
- this.bindSegHandlerToEl(el, 'click', this.handleSegClick);
- },
-
-
- // Executes a handler for any a user-interaction on a segment.
- // Handler gets called with (seg, ev), and with the `this` context of the Grid
- bindSegHandlerToEl: function(el, name, handler) {
- var _this = this;
-
- el.on(name, this.segSelector, 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 handler.call(_this, seg, ev); // context will be the Grid
- }
- });
- },
-
-
- handleSegClick: function(seg, ev) {
- var res = this.view.publiclyTrigger('eventClick', seg.el[0], seg.event, ev); // can return `false` to cancel
- if (res === false) {
- ev.preventDefault();
- }
- },
-
-
- // Updates internal state and triggers handlers for when an event element is moused over
- handleSegMouseover: function(seg, ev) {
- if (
- !this.isIgnoringMouse &&
- !this.mousedOverSeg
- ) {
- this.mousedOverSeg = seg;
- if (this.view.isEventResizable(seg.event)) {
- seg.el.addClass('fc-allow-mouse-resize');
- }
- this.view.publiclyTrigger('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.
- handleSegMouseout: 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;
- if (this.view.isEventResizable(seg.event)) {
- seg.el.removeClass('fc-allow-mouse-resize');
- }
- this.view.publiclyTrigger('eventMouseout', seg.el[0], seg.event, ev);
- }
- },
-
-
- handleSegMousedown: function(seg, ev) {
- var isResizing = this.startSegResize(seg, ev, { distance: 5 });
-
- if (!isResizing && this.view.isEventDraggable(seg.event)) {
- this.buildSegDragListener(seg)
- .startInteraction(ev, {
- distance: 5
- });
- }
- },
-
-
- handleSegTouchStart: function(seg, ev) {
- var view = this.view;
- var event = seg.event;
- var isSelected = view.isEventSelected(event);
- var isDraggable = view.isEventDraggable(event);
- var isResizable = view.isEventResizable(event);
- var isResizing = false;
- var dragListener;
- var eventLongPressDelay;
-
- if (isSelected && isResizable) {
- // only allow resizing of the event is selected
- isResizing = this.startSegResize(seg, ev);
- }
-
- if (!isResizing && (isDraggable || isResizable)) { // allowed to be selected?
-
- eventLongPressDelay = view.opt('eventLongPressDelay');
- if (eventLongPressDelay == null) {
- eventLongPressDelay = view.opt('longPressDelay'); // fallback
- }
-
- dragListener = isDraggable ?
- this.buildSegDragListener(seg) :
- this.buildSegSelectListener(seg); // seg isn't draggable, but still needs to be selected
-
- dragListener.startInteraction(ev, { // won't start if already started
- delay: isSelected ? 0 : eventLongPressDelay // do delay if not already selected
- });
- }
-
- // a long tap simulates a mouseover. ignore this bogus mouseover.
- this.tempIgnoreMouse();
- },
-
-
- handleSegTouchEnd: function(seg, ev) {
- // touchstart+touchend = click, which simulates a mouseover.
- // ignore this bogus mouseover.
- this.tempIgnoreMouse();
- },
-
-
- // returns boolean whether resizing actually started or not.
- // assumes the seg allows resizing.
- // `dragOptions` are optional.
- startSegResize: function(seg, ev, dragOptions) {
- if ($(ev.target).is('.fc-resizer')) {
- this.buildSegResizeListener(seg, $(ev.target).is('.fc-start-resizer'))
- .startInteraction(ev, dragOptions);
- return true;
- }
- return false;
- },
-
-
-
- /* Event Dragging
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Builds a listener that will track user-dragging on an event segment.
- // Generic enough to work with any type of Grid.
- // Has side effect of setting/unsetting `segDragListener`
- buildSegDragListener: function(seg) {
- var _this = this;
- var view = this.view;
- var calendar = view.calendar;
- var el = seg.el;
- var event = seg.event;
- var isDragging;
- var mouseFollower; // A clone of the original element that will move with the mouse
- var dropLocation; // zoned event date properties
-
- if (this.segDragListener) {
- return this.segDragListener;
- }
-
- // Tracks mouse movement over the *view's* coordinate map. Allows dragging and dropping between subcomponents
- // of the view.
- var dragListener = this.segDragListener = new HitDragListener(view, {
- scroll: view.opt('dragScroll'),
- subjectEl: el,
- subjectCenter: true,
- interactionStart: function(ev) {
- seg.component = _this; // for renderDrag
- isDragging = false;
- mouseFollower = new MouseFollower(seg.el, {
- additionalClass: 'fc-dragging',
- parentEl: view.el,
- opacity: dragListener.isTouch ? null : view.opt('dragOpacity'),
- revertDuration: view.opt('dragRevertDuration'),
- zIndex: 2 // one above the .fc-view
- });
- mouseFollower.hide(); // don't show until we know this is a real drag
- mouseFollower.start(ev);
- },
- dragStart: function(ev) {
- if (dragListener.isTouch && !view.isEventSelected(event)) {
- // if not previously selected, will fire after a delay. then, select the event
- view.selectEvent(event);
- }
- isDragging = true;
- _this.handleSegMouseout(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) {
- var dragHelperEls;
-
- // 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.isEventSpanAllowed(_this.eventToSpan(dropLocation), event)) {
- disableCursor();
- dropLocation = null;
- }
-
- // if a valid drop location, have the subclass render a visual indication
- if (dropLocation && (dragHelperEls = view.renderDrag(dropLocation, seg))) {
-
- dragHelperEls.addClass('fc-dragging');
- if (!dragListener.isTouch) {
- _this.applyDragOpacity(dragHelperEls);
- }
-
- 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 dragEnd
- enableCursor();
- },
- interactionEnd: function(ev) {
- delete seg.component; // prevent side effects
-
- // do revert animation if hasn't changed. calls a callback when finished (whether animation or not)
- mouseFollower.stop(!dropLocation, function() {
- if (isDragging) {
- view.unrenderDrag();
- _this.segDragStop(seg, ev);
- }
-
- if (dropLocation) {
- // no need to re-show original, will rerender all anyways. esp important if eventRenderWait
- view.reportEventDrop(event, dropLocation, _this.largeUnit, el, ev);
- }
- else {
- view.showEvent(event);
- }
- });
- _this.segDragListener = null;
- }
- });
-
- return dragListener;
- },
-
-
- // seg isn't draggable, but let's use a generic DragListener
- // simply for the delay, so it can be selected.
- // Has side effect of setting/unsetting `segDragListener`
- buildSegSelectListener: function(seg) {
- var _this = this;
- var view = this.view;
- var event = seg.event;
-
- if (this.segDragListener) {
- return this.segDragListener;
- }
-
- var dragListener = this.segDragListener = new DragListener({
- dragStart: function(ev) {
- if (dragListener.isTouch && !view.isEventSelected(event)) {
- // if not previously selected, will fire after a delay. then, select the event
- view.selectEvent(event);
- }
- },
- interactionEnd: function(ev) {
- _this.segDragListener = null;
- }
- });
-
- return dragListener;
- },
-
-
- // Called before event segment dragging starts
- segDragStart: function(seg, ev) {
- this.isDraggingSeg = true;
- this.view.publiclyTrigger('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.publiclyTrigger('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 zoned 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.
- // DOES NOT consider overlap/constraint.
- computeEventDrop: function(startSpan, endSpan, event) {
- var calendar = this.view.calendar;
- var dragStart = startSpan.start;
- var dragEnd = endSpan.start;
- var delta;
- var dropLocation; // zoned event date properties
-
- 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 normalizeEventTimes
- };
- calendar.normalizeEventTimes(dropLocation);
- }
- // othewise, work off existing values
- else {
- dropLocation = pluckEventDateProps(event);
- }
-
- 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.css('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 calendar = this.view.calendar;
- 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 = _this.externalDragListener = new HitDragListener(this, {
- interactionStart: 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 ( // invalid hit?
- dropLocation &&
- !calendar.isExternalSpanAllowed(_this.eventToSpan(dropLocation), dropLocation, meta.eventProps)
- ) {
- disableCursor();
- dropLocation = null;
- }
-
- if (dropLocation) {
- _this.renderDrag(dropLocation); // called without a seg parameter
- }
- },
- hitOut: function() {
- dropLocation = null; // signal unsuccessful
- },
- hitDone: function() { // Called after a hitOut OR before a dragEnd
- enableCursor();
- _this.unrenderDrag();
- },
- interactionEnd: function(ev) {
- if (dropLocation) { // element was dropped on a valid hit
- _this.view.reportExternalDrop(meta, dropLocation, el, ev, ui);
- }
- _this.isDraggingExternal = false;
- _this.externalDragListener = null;
- }
- });
-
- 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 the zoned 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.
- // DOES NOT consider overlap/constraint.
- computeExternalDrop: function(span, meta) {
- var calendar = this.view.calendar;
- var dropLocation = {
- start: calendar.applyTimezone(span.start), // simulate a zoned event start date
- 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);
- }
-
- 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.
- // Must return elements used for any mock events.
- 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
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Creates a listener that tracks the user as they resize an event segment.
- // Generic enough to work with any type of Grid.
- buildSegResizeListener: function(seg, 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 isDragging;
- var resizeLocation; // zoned event date properties. falsy if invalid resize
-
- // Tracks mouse movement over the *grid's* coordinate map
- var dragListener = this.segResizeListener = new HitDragListener(this, {
- scroll: view.opt('dragScroll'),
- subjectEl: el,
- interactionStart: function() {
- isDragging = false;
- },
- dragStart: function(ev) {
- isDragging = true;
- _this.handleSegMouseout(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.isEventSpanAllowed(_this.eventToSpan(resizeLocation), event)) {
- disableCursor();
- resizeLocation = null;
- }
- // no change? (FYI, event dates might have zones)
- else if (
- resizeLocation.start.isSame(event.start.clone().stripZone()) &&
- resizeLocation.end.isSame(eventEnd.clone().stripZone())
- ) {
- 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;
- view.showEvent(event); // for when out-of-bounds. show original
- },
- hitDone: function() { // resets the rendering to show the original event
- _this.unrenderEventResize();
- enableCursor();
- },
- interactionEnd: function(ev) {
- if (isDragging) {
- _this.segResizeStop(seg, ev);
- }
-
- if (resizeLocation) { // valid date to resize to?
- // no need to re-show original, will rerender all anyways. esp important if eventRenderWait
- view.reportEventResize(event, resizeLocation, _this.largeUnit, el, ev);
- }
- else {
- view.showEvent(event);
- }
- _this.segResizeListener = null;
- }
- });
-
- return dragListener;
- },
-
-
- // Called before event segment resizing starts
- segResizeStart: function(seg, ev) {
- this.isResizingSeg = true;
- this.view.publiclyTrigger('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.publiclyTrigger('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 zoned date information for an event segment being resized from its start OR end
- // `type` is either 'start' or 'end'.
- // DOES NOT consider overlap/constraint.
- computeEventResize: function(type, startSpan, endSpan, event) {
- var calendar = this.view.calendar;
- var delta = this.diffDates(endSpan[type], startSpan[type]);
- var resizeLocation; // zoned event date properties
- var defaultDuration;
-
- // build original values to work from, guaranteeing a start and end
- resizeLocation = {
- 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 (resizeLocation.allDay && durationHasTime(delta)) {
- resizeLocation.allDay = false;
- calendar.normalizeEventTimes(resizeLocation);
- }
-
- resizeLocation[type].add(delta); // apply delta to start or end
-
- // if the event was compressed too small, find a new reasonable duration for it
- if (!resizeLocation.start.isBefore(resizeLocation.end)) {
-
- defaultDuration =
- this.minResizeDuration || // TODO: hack
- (event.allDay ?
- calendar.defaultAllDayEventDuration :
- calendar.defaultTimedEventDuration);
-
- if (type == 'start') { // resizing the start?
- resizeLocation.start = resizeLocation.end.clone().subtract(defaultDuration);
- }
- else { // resizing the end?
- resizeLocation.end = resizeLocation.start.clone().add(defaultDuration);
- }
- }
-
- return resizeLocation;
- },
-
-
- // 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.
- // Must return elements used for any mock events.
- 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 view = this.view;
- var classes = [
- 'fc-event',
- seg.isStart ? 'fc-start' : 'fc-not-start',
- seg.isEnd ? 'fc-end' : 'fc-not-end'
- ].concat(this.getSegCustomClasses(seg));
-
- if (isDraggable) {
- classes.push('fc-draggable');
- }
- if (isResizable) {
- classes.push('fc-resizable');
- }
-
- // event is currently selected? attach a className.
- if (view.isEventSelected(seg.event)) {
- classes.push('fc-selected');
- }
-
- return classes;
- },
-
-
- // List of classes that were defined by the caller of the API in some way
- getSegCustomClasses: function(seg) {
- var event = seg.event;
-
- return [].concat(
- event.className, // guaranteed to be an array
- event.source ? event.source.className : []
- );
- },
-
-
- // Utility for generating event skin-related CSS properties
- getSegSkinCss: function(seg) {
- return {
- 'background-color': this.getSegBackgroundColor(seg),
- 'border-color': this.getSegBorderColor(seg),
- color: this.getSegTextColor(seg)
- };
- },
-
-
- // Queries for caller-specified color, then falls back to default
- getSegBackgroundColor: function(seg) {
- return seg.event.backgroundColor ||
- seg.event.color ||
- this.getSegDefaultBackgroundColor(seg);
- },
-
-
- getSegDefaultBackgroundColor: function(seg) {
- var source = seg.event.source || {};
-
- return source.backgroundColor ||
- source.color ||
- this.view.opt('eventBackgroundColor') ||
- this.view.opt('eventColor');
- },
-
-
- // Queries for caller-specified color, then falls back to default
- getSegBorderColor: function(seg) {
- return seg.event.borderColor ||
- seg.event.color ||
- this.getSegDefaultBorderColor(seg);
- },
-
-
- getSegDefaultBorderColor: function(seg) {
- var source = seg.event.source || {};
-
- return source.borderColor ||
- source.color ||
- this.view.opt('eventBorderColor') ||
- this.view.opt('eventColor');
- },
-
-
- // Queries for caller-specified color, then falls back to default
- getSegTextColor: function(seg) {
- return seg.event.textColor ||
- this.getSegDefaultTextColor(seg);
- },
-
-
- getSegDefaultTextColor: function(seg) {
- var source = seg.event.source || {};
-
- return source.textColor ||
- this.view.opt('eventTextColor');
- },
-
-
- /* Converting events -> eventRange -> eventSpan -> eventSegs
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Generates an array of segments for the given single event
- // Can accept an event "location" as well (which only has start/end and no allDay)
- eventToSegs: function(event) {
- return this.eventsToSegs([ event ]);
- },
-
-
- eventToSpan: function(event) {
- return this.eventToSpans(event)[0];
- },
-
-
- // Generates spans (always unzoned) for the given event.
- // Does not do any inverting for inverse-background events.
- // Can accept an event "location" as well (which only has start/end and no allDay)
- eventToSpans: function(event) {
- var range = this.eventToRange(event);
- return this.eventRangeToSpans(range, event);
- },
-
-
-
- // Converts an array of event objects into an array of event segment objects.
- // A custom `segSliceFunc` may be given for arbitrarily slicing up events.
- // Doesn't guarantee an order for the resulting array.
- eventsToSegs: function(allEvents, segSliceFunc) {
- var _this = this;
- var eventsById = groupEventsById(allEvents);
- var segs = [];
-
- $.each(eventsById, function(id, events) {
- var ranges = [];
- var i;
-
- for (i = 0; i < events.length; i++) {
- ranges.push(_this.eventToRange(events[i]));
- }
-
- // inverse-background events (utilize only the first event in calculations)
- if (isInverseBgEvent(events[0])) {
- ranges = _this.invertRanges(ranges);
-
- for (i = 0; i < ranges.length; i++) {
- segs.push.apply(segs, // append to
- _this.eventRangeToSegs(ranges[i], events[0], segSliceFunc));
- }
- }
- // normal event ranges
- else {
- for (i = 0; i < ranges.length; i++) {
- segs.push.apply(segs, // append to
- _this.eventRangeToSegs(ranges[i], events[i], segSliceFunc));
- }
- }
- });
-
- return segs;
- },
-
-
- // Generates the unzoned start/end dates an event appears to occupy
- // Can accept an event "location" as well (which only has start/end and no allDay)
- eventToRange: function(event) {
- var calendar = this.view.calendar;
- var start = event.start.clone().stripZone();
- var end = (
- event.end ?
- event.end.clone() :
- // derive the end from the start and allDay. compute allDay if necessary
- calendar.getDefaultEventEnd(
- event.allDay != null ?
- event.allDay :
- !event.start.hasTime(),
- event.start
- )
- ).stripZone();
-
- // hack: dynamic locale change forgets to upate stored event localed
- calendar.localizeMoment(start);
- calendar.localizeMoment(end);
-
- return { start: start, end: end };
- },
-
-
- // Given an event's range (unzoned start/end), and the event itself,
- // slice into segments (using the segSliceFunc function if specified)
- eventRangeToSegs: function(range, event, segSliceFunc) {
- var spans = this.eventRangeToSpans(range, event);
- var segs = [];
- var i;
-
- for (i = 0; i < spans.length; i++) {
- segs.push.apply(segs, // append to
- this.eventSpanToSegs(spans[i], event, segSliceFunc));
- }
-
- return segs;
- },
-
-
- // Given an event's unzoned date range, return an array of "span" objects.
- // Subclasses can override.
- eventRangeToSpans: function(range, event) {
- return [ $.extend({}, range) ]; // copy into a single-item array
- },
-
-
- // Given an event's span (unzoned start/end and other misc data), and the event itself,
- // slices into segments and attaches event-derived properties to them.
- eventSpanToSegs: function(span, event, segSliceFunc) {
- var segs = segSliceFunc ? segSliceFunc(span) : this.spanToSegs(span);
- var i, seg;
-
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
- seg.event = event;
- seg.eventStartMS = +span.start; // TODO: not the best name after making spans unzoned
- seg.eventDurationMS = span.end - span.start;
- }
-
- return segs;
- },
-
-
- // Produces a new array of range objects that will cover all the time NOT covered by the given ranges.
- // SIDE EFFECT: will mutate the given array and will use its date references.
- invertRanges: function(ranges) {
- var view = this.view;
- var viewStart = view.start.clone(); // need a copy
- var viewEnd = view.end.clone(); // need a copy
- var inverseRanges = [];
- var start = viewStart; // the end of the previous range. the start of the new range
- var i, range;
-
- // ranges need to be in order. required for our date-walking algorithm
- ranges.sort(compareRanges);
-
- for (i = 0; i < ranges.length; i++) {
- range = ranges[i];
-
- // add the span of time before the event (if there is any)
- if (range.start > start) { // compare millisecond time (skip any ambig logic)
- inverseRanges.push({
- start: start,
- end: range.start
- });
- }
-
- start = range.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({
- start: start,
- end: viewEnd
- });
- }
-
- return inverseRanges;
- },
-
-
- sortEventSegs: function(segs) {
- segs.sort(proxy(this, 'compareEventSegs'));
- },
-
-
- // A cmp function for determining which segments should take visual priority
- compareEventSegs: 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 pluckEventDateProps(event) {
- return {
- start: event.start.clone(),
- end: event.end ? event.end.clone() : null,
- allDay: event.allDay // keep it the same
- };
-}
-FC.pluckEventDateProps = pluckEventDateProps;
-
-
-function isBgEvent(event) { // returns true if background OR inverse-background
- var rendering = getEventRendering(event);
- return rendering === 'background' || rendering === 'inverse-background';
-}
-FC.isBgEvent = isBgEvent; // export
-
-
-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 compareRanges(range1, range2) {
- return range1.start - range2.start; // 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('');
- },
-
-
- // TODO: when internalApiVersion, accept an object for HTML attributes
- // (colspan should be no different)
- renderHeadDateCellHtml: function(date, colspan, otherAttrs) {
- var view = this.view;
- var classNames = [
- 'fc-day-header',
- view.widgetHeaderClass
- ];
-
- // if only one row of days, the classNames on the header can represent the specific days beneath
- if (this.rowCnt === 1) {
- classNames = classNames.concat(
- // includes the day-of-week class
- // noThemeHighlight=true (don't highlight the header)
- this.getDayClasses(date, true)
- );
- }
- else {
- classNames.push('fc-' + dayIDs[date.day()]); // only add the day-of-week class
- }
-
- return '' +
- ' 1 ?
- ' colspan="' + colspan + '"' :
- '') +
- (otherAttrs ?
- ' ' + otherAttrs :
- '') +
- '>' +
- // don't make a link if the heading could represent multiple days, or if there's only one day (forceOff)
- view.buildGotoAnchorHtml(
- { date: date, forceOff: this.rowCnt > 1 || this.colCnt === 1 },
- htmlEscape(date.format(this.colHeadFormat)) // inner HTML
- ) +
- ' ';
- },
-
-
- /* 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, otherAttrs) {
- 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() {
- },
-
-
- // TODO: a generic method for dealing with , RTL, intro
- // when increment internalApiVersion
- // wrapTr (scheduler)
-
-
- /* 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.publiclyTrigger(
- 'dayRender',
- null,
- this.getCellDate(row, col),
- this.getCellEl(row, col)
- );
- }
- }
- },
-
-
- unrenderDates: function() {
- this.removeSegPopover();
- },
-
-
- renderBusinessHours: function() {
- var segs = this.buildBusinessHourSegs(true); // wholeDay=true
- this.renderFill('businessHours', segs, 'bgevent');
- },
-
-
- unrenderBusinessHours: function() {
- this.unrenderFill('businessHours');
- },
-
-
- // 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 html = '';
- var classes;
- var weekCalcFirstDoW;
-
- if (!this.view.dayNumbersVisible && !this.view.cellWeekNumbersVisible) {
- // no numbers in day cell (week number must be along the side)
- return ' '; // will create an empty space above events :(
- }
-
- classes = this.getDayClasses(date);
- classes.unshift('fc-day-top');
-
- if (this.view.cellWeekNumbersVisible) {
- // To determine the day of week number change under ISO, we cannot
- // rely on moment.js methods such as firstDayOfWeek() or weekday(),
- // because they rely on the locale's dow (possibly overridden by
- // our firstDay option), which may not be Monday. We cannot change
- // dow, because that would affect the calendar start day as well.
- if (date._locale._fullCalendar_weekCalc === 'ISO') {
- weekCalcFirstDoW = 1; // Monday by ISO 8601 definition
- }
- else {
- weekCalcFirstDoW = date._locale.firstDayOfWeek();
- }
- }
-
- html += '';
-
- if (this.view.cellWeekNumbersVisible && (date.day() == weekCalcFirstDoW)) {
- html += this.view.buildGotoAnchorHtml(
- { date: date, type: 'week' },
- { 'class': 'fc-week-number' },
- date.format('w') // inner HTML
- );
- }
-
- if (this.view.dayNumbersVisible) {
- html += this.view.buildGotoAnchorHtml(
- date,
- { 'class': 'fc-day-number' },
- date.date() // inner HTML
- );
- }
-
- html += ' ';
-
- return html;
- },
-
-
- /* 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 the given span (unzoned start/end with other misc data) into an array of segments
- spanToSegs: function(span) {
- var segs = this.sliceRangeByRow(span);
- 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) {
- if (this.colCoordCache.isLeftInBounds(leftOffset) && this.rowCoordCache.isTopInBounds(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.
- // `eventLocation` has zoned start and end (optional)
- renderDrag: function(eventLocation, seg) {
-
- // always render a highlight underneath
- this.renderHighlight(this.eventToSpan(eventLocation));
-
- // if a segment from the same calendar but another component is being dragged, render a helper event
- if (seg && seg.component !== this) {
- return this.renderEventLocationHelper(eventLocation, seg); // returns mock event elements
- }
- },
-
-
- // 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(eventLocation, seg) {
- this.renderHighlight(this.eventToSpan(eventLocation));
- return this.renderEventLocationHelper(eventLocation, seg); // returns mock event elements
- },
-
-
- // 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.eventToSegs(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]);
- });
-
- return ( // must return the elements rendered
- 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.getSegSkinCss(seg));
- 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.sortEventSegs(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.publiclyTrigger('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.view.el, // attach to root of view. guarantees outside of scrollbars.
- 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
- // notify events to be removed
- if (_this.popoverSegs) {
- var seg;
- for (var i = 0; i < _this.popoverSegs.length; ++i) {
- seg = _this.popoverSegs[i];
- view.publiclyTrigger('eventDestroy', seg.event, seg.event, seg.el);
- }
- }
- _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();
-
- // the popover doesn't live within the grid's container element, and thus won't get the event
- // delegated-handlers for free. attach event-related handlers to the popover.
- this.bindSegHandlersToEl(this.segPopover.el);
- },
-
-
- // 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();
- 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 = intersectRanges(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.sortEventSegs(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
- slatContainerEl: null, // div that wraps all the slat rows
- slatEls: null, // elements running horizontally across all columns
- nowIndicatorEls: null,
-
- colCoordCache: null,
- slatCoordCache: 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.slatContainerEl = this.el.find('.fc-slats');
- this.slatEls = this.slatContainerEl.find('tr');
-
- this.colCoordCache = new CoordCache({
- els: this.colEls,
- isHorizontal: true
- });
- this.slatCoordCache = new CoordCache({
- els: this.slatEls,
- isVertical: true
- });
-
- this.renderContentSkeleton();
- },
-
-
- // 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);
- 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('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;
-
- if (colCoordCache.isLeftInBounds(leftOffset) && slatCoordCache.isTopInBounds(topOffset)) {
- 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 start = this.getCellDate(0, hit.col); // row=0
- var time = this.computeSnapTime(hit.snap); // pass in the snap-index
- 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 the given span (unzoned start/end with other misc data) into an array of segments
- spanToSegs: function(span) {
- var segs = this.sliceRangeByTimes(span);
- 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;
-
- 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 = intersectRanges(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(
- [].concat(this.fgSegs || [], this.bgSegs || [], this.businessSegs || [])
- );
- }
- },
-
-
- getTotalSlatHeight: function() {
- return this.slatContainerEl.outerHeight();
- },
-
-
- // 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 - 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).
- // A returned value of `true` signals that a mock "helper" event has been rendered.
- renderDrag: function(eventLocation, seg) {
-
- if (seg) { // if there is event information for this drag, render a helper event
-
- // returns mock event elements
- // signal that a helper has been rendered
- return this.renderEventLocationHelper(eventLocation, seg);
- }
- else {
- // otherwise, just render a highlight
- this.renderHighlight(this.eventToSpan(eventLocation));
- }
- },
-
-
- // 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(eventLocation, seg) {
- return this.renderEventLocationHelper(eventLocation, seg); // returns mock event elements
- },
-
-
- // 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) {
- return this.renderHelperSegs(this.eventToSegs(event), sourceSeg); // returns mock event elements
- },
-
-
- // Unrenders any mock helper event
- unrenderHelper: function() {
- this.unrenderHelperSegs();
- },
-
-
- /* Business Hours
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderBusinessHours: function() {
- this.renderBusinessSegs(
- this.buildBusinessHourSegs()
- );
- },
-
-
- unrenderBusinessHours: function() {
- this.unrenderBusinessSegs();
- },
-
-
- /* Now Indicator
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- getNowIndicatorUnit: function() {
- return 'minute'; // will refresh on the minute
- },
-
-
- renderNowIndicator: function(date) {
- // seg system might be overkill, but it handles scenario where line needs to be rendered
- // more than once because of columns with the same date (resources columns for example)
- var segs = this.spanToSegs({ start: date, end: date });
- var top = this.computeDateTop(date, date);
- var nodes = [];
- var i;
-
- // render lines within the columns
- for (i = 0; i < segs.length; i++) {
- nodes.push($('
')
- .css('top', top)
- .appendTo(this.colContainerEls.eq(segs[i].col))[0]);
- }
-
- // render an arrow over the axis
- if (segs.length > 0) { // is the current time in view?
- nodes.push($('
')
- .css('top', top)
- .appendTo(this.el.find('.fc-content-skeleton'))[0]);
- }
-
- this.nowIndicatorEls = $(nodes);
- },
-
-
- unrenderNowIndicator: function() {
- if (this.nowIndicatorEls) {
- this.nowIndicatorEls.remove();
- this.nowIndicatorEls = null;
- }
- },
-
-
- /* Selection
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Renders a visual indication of a selection. Overrides the default, which was to simply render a highlight.
- renderSelection: function(span) {
- if (this.view.opt('selectHelper')) { // this setting signals that a mock helper event should be rendered
-
- // normally acceps an eventLocation, span has a start/end, which is good enough
- this.renderEventLocationHelper(span);
- }
- else {
- this.renderHighlight(span);
- }
- },
-
-
- // Unrenders any visual indication of a selection
- unrenderSelection: function() {
- this.unrenderHelper();
- this.unrenderHighlight();
- },
-
-
- /* Highlight
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderHighlight: function(span) {
- this.renderHighlightSegs(this.spanToSegs(span));
- },
-
-
- unrenderHighlight: function() {
- this.unrenderHighlightSegs();
- }
-
-});
-
-;;
-
-/* Methods for rendering SEGMENTS, pieces of content that live on the view
- ( this file is no longer just for events )
-----------------------------------------------------------------------------------------------------------------------*/
-
-TimeGrid.mixin({
-
- colContainerEls: null, // containers for each column
-
- // inner-containers for each column where different types of segs live
- fgContainerEls: null,
- bgContainerEls: null,
- helperContainerEls: null,
- highlightContainerEls: null,
- businessContainerEls: null,
-
- // arrays of different types of displayed segments
- fgSegs: null,
- bgSegs: null,
- helperSegs: null,
- highlightSegs: null,
- businessSegs: null,
-
-
- // Renders the DOM that the view's content will live in
- renderContentSkeleton: function() {
- var cellHtml = '';
- var i;
- var skeletonEl;
-
- for (i = 0; i < this.colCnt; i++) {
- cellHtml +=
- '
' +
- '' +
- '
' +
- '
' +
- '
' +
- '
' +
- '
' +
- '
' +
- ' ';
- }
-
- skeletonEl = $(
- '
' +
- '
' +
- '' + cellHtml + ' ' +
- '
' +
- '
'
- );
-
- this.colContainerEls = skeletonEl.find('.fc-content-col');
- this.helperContainerEls = skeletonEl.find('.fc-helper-container');
- this.fgContainerEls = skeletonEl.find('.fc-event-container:not(.fc-helper-container)');
- this.bgContainerEls = skeletonEl.find('.fc-bgevent-container');
- this.highlightContainerEls = skeletonEl.find('.fc-highlight-container');
- this.businessContainerEls = skeletonEl.find('.fc-business-container');
-
- this.bookendCells(skeletonEl.find('tr')); // TODO: do this on string level
- this.el.append(skeletonEl);
- },
-
-
- /* Foreground Events
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderFgSegs: function(segs) {
- segs = this.renderFgSegsIntoContainers(segs, this.fgContainerEls);
- this.fgSegs = segs;
- return segs; // needed for Grid::renderEvents
- },
-
-
- unrenderFgSegs: function() {
- this.unrenderNamedSegs('fgSegs');
- },
-
-
- /* Foreground Helper Events
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderHelperSegs: function(segs, sourceSeg) {
- var helperEls = [];
- var i, seg;
- var sourceEl;
-
- segs = this.renderFgSegsIntoContainers(segs, this.helperContainerEls);
-
- // 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')
- });
- }
- helperEls.push(seg.el[0]);
- }
-
- this.helperSegs = segs;
-
- return $(helperEls); // must return rendered helpers
- },
-
-
- unrenderHelperSegs: function() {
- this.unrenderNamedSegs('helperSegs');
- },
-
-
- /* Background Events
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderBgSegs: function(segs) {
- segs = this.renderFillSegEls('bgEvent', segs); // TODO: old fill system
- this.updateSegVerticals(segs);
- this.attachSegsByCol(this.groupSegsByCol(segs), this.bgContainerEls);
- this.bgSegs = segs;
- return segs; // needed for Grid::renderEvents
- },
-
-
- unrenderBgSegs: function() {
- this.unrenderNamedSegs('bgSegs');
- },
-
-
- /* Highlight
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderHighlightSegs: function(segs) {
- segs = this.renderFillSegEls('highlight', segs); // TODO: old fill system
- this.updateSegVerticals(segs);
- this.attachSegsByCol(this.groupSegsByCol(segs), this.highlightContainerEls);
- this.highlightSegs = segs;
- },
-
-
- unrenderHighlightSegs: function() {
- this.unrenderNamedSegs('highlightSegs');
- },
-
-
- /* Business Hours
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderBusinessSegs: function(segs) {
- segs = this.renderFillSegEls('businessHours', segs); // TODO: old fill system
- this.updateSegVerticals(segs);
- this.attachSegsByCol(this.groupSegsByCol(segs), this.businessContainerEls);
- this.businessSegs = segs;
- },
-
-
- unrenderBusinessSegs: function() {
- this.unrenderNamedSegs('businessSegs');
- },
-
-
- /* Seg Rendering Utils
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's col
- groupSegsByCol: function(segs) {
- var segsByCol = [];
- var i;
-
- for (i = 0; i < this.colCnt; i++) {
- segsByCol.push([]);
- }
-
- for (i = 0; i < segs.length; i++) {
- segsByCol[segs[i].col].push(segs[i]);
- }
-
- return segsByCol;
- },
-
-
- // Given segments grouped by column, insert the segments' elements into a parallel array of container
- // elements, each living within a column.
- attachSegsByCol: function(segsByCol, containerEls) {
- var col;
- var segs;
- var i;
-
- for (col = 0; col < this.colCnt; col++) { // iterate each column grouping
- segs = segsByCol[col];
-
- for (i = 0; i < segs.length; i++) {
- containerEls.eq(col).append(segs[i].el);
- }
- }
- },
-
-
- // Given the name of a property of `this` object, assumed to be an array of segments,
- // loops through each segment and removes from DOM. Will null-out the property afterwards.
- unrenderNamedSegs: function(propName) {
- var segs = this[propName];
- var i;
-
- if (segs) {
- for (i = 0; i < segs.length; i++) {
- segs[i].el.remove();
- }
- this[propName] = null;
- }
- },
-
-
-
- /* Foreground Event Rendering Utils
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Given an array of foreground segments, render a DOM element for each, computes position,
- // and attaches to the column inner-container elements.
- renderFgSegsIntoContainers: function(segs, containerEls) {
- var segsByCol;
- var col;
-
- segs = this.renderFgSegEls(segs); // will call fgSegHtml
- segsByCol = this.groupSegsByCol(segs);
-
- for (col = 0; col < this.colCnt; col++) {
- this.updateFgSegCoords(segsByCol[col]);
- }
-
- this.attachSegsByCol(segsByCol, containerEls);
-
- return segs;
- },
-
-
- // Renders the HTML for a single event segment's default rendering
- fgSegHtml: function(seg, disableResizing) {
- var view = this.view;
- var event = seg.event;
- var isDraggable = view.isEventDraggable(event);
- var isResizableFromStart = !disableResizing && seg.isStart && view.isEventResizableFromStart(event);
- var isResizableFromEnd = !disableResizing && seg.isEnd && view.isEventResizableFromEnd(event);
- var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd);
- var skinCss = cssToStr(this.getSegSkinCss(seg));
- var timeText;
- var fullTimeText; // more verbose time text. for the print stylesheet
- var startTimeText; // just the start time text
-
- classes.unshift('fc-time-grid-event', 'fc-v-event');
-
- if (view.isMultiDayEvent(event)) { // if the event appears to span more than one day...
- // Don't display time text on segments that run entirely through a day.
- // That would appear as midnight-midnight and would look dumb.
- // Otherwise, display the time text for the *segment's* times (like 6pm-midnight or midnight-10am)
- if (seg.isStart || seg.isEnd) {
- timeText = this.getEventTimeText(seg);
- fullTimeText = this.getEventTimeText(seg, 'LT');
- startTimeText = this.getEventTimeText(seg, null, false); // displayEnd=false
- }
- } else {
- // Display the normal time text for the *event's* times
- timeText = this.getEventTimeText(event);
- fullTimeText = this.getEventTimeText(event, 'LT');
- startTimeText = this.getEventTimeText(event, null, false); // displayEnd=false
- }
-
- return '
' +
- '' +
- (timeText ?
- '
' +
- '' + htmlEscape(timeText) + ' ' +
- '
' :
- ''
- ) +
- (event.title ?
- '
' +
- htmlEscape(event.title) +
- '
' :
- ''
- ) +
- '
' +
- '
' +
- /* TODO: write CSS for this
- (isResizableFromStart ?
- '
' :
- ''
- ) +
- */
- (isResizableFromEnd ?
- '
' :
- ''
- ) +
- ' ';
- },
-
-
- /* Seg Position Utils
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Refreshes the CSS top/bottom coordinates for each segment element.
- // Works when called after initial render, after a window resize/zoom for example.
- updateSegVerticals: function(segs) {
- this.computeSegVerticals(segs);
- this.assignSegVerticals(segs);
- },
-
-
- // For each segment in an array, computes and assigns its top and bottom properties
- computeSegVerticals: function(segs) {
- var i, seg;
-
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
- seg.top = this.computeDateTop(seg.start, seg.start);
- seg.bottom = this.computeDateTop(seg.end, seg.start);
- }
- },
-
-
- // Given segments that already have their top/bottom properties computed, applies those values to
- // the segments' elements.
- assignSegVerticals: function(segs) {
- var i, seg;
-
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
- seg.el.css(this.generateSegVerticalCss(seg));
- }
- },
-
-
- // 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
- };
- },
-
-
- /* Foreground Event Positioning Utils
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Given segments that are assumed to all live in the *same column*,
- // compute their verical/horizontal coordinates and assign to their elements.
- updateFgSegCoords: function(segs) {
- this.computeSegVerticals(segs); // horizontals relies on this
- this.computeFgSegHorizontals(segs); // compute horizontal coordinates, z-index's, and reorder the array
- this.assignSegVerticals(segs);
- this.assignFgSegHorizontals(segs);
- },
-
-
- // 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!
- computeFgSegHorizontals: function(segs) {
- var levels;
- var level0;
- var i;
-
- this.sortEventSegs(segs); // order by certain criteria
- 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.computeFgSegForwardBack(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.
- computeFgSegForwardBack: 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.sortForwardSegs(forwardSegs);
-
- // this segment's forwardCoord will be calculated from the backwardCoord of the
- // highest-pressure forward segment.
- this.computeFgSegForwardBack(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
seg2.top && seg1.top < seg2.bottom;
-}
-
-;;
-
-/* An abstract class from which other views inherit from
-----------------------------------------------------------------------------------------------------------------------*/
-
-var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
-
- 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
-
- isDateSet: false,
- isDateRendered: false,
- dateRenderQueue: null,
-
- isEventsBound: false,
- isEventsSet: false,
- isEventsRendered: false,
- eventRenderQueue: null,
-
- // 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
- selectedEvent: null,
-
- eventOrderSpecs: null, // criteria for ordering events when they have same date/time
-
- // classNames styled by jqui themes
- widgetHeaderClass: null,
- widgetContentClass: null,
- highlightStateClass: null,
-
- // for date utils, computed from options
- nextDayThreshold: null,
- isHiddenDayHash: null,
-
- // now indicator
- isNowIndicatorRendered: null,
- initialNowDate: null, // result first getNow call
- initialNowQueriedMs: null, // ms time the getNow was called
- nowIndicatorTimeoutID: null, // for refresh timing of now indicator
- nowIndicatorIntervalID: null, // "
-
-
- 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.dateRenderQueue = new TaskQueue();
- this.eventRenderQueue = new TaskQueue(this.opt('eventRenderWait'));
-
- 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.
- publiclyTrigger: function(name, thisObj) { // arguments beyond thisObj are passed along
- var calendar = this.calendar;
-
- return calendar.publiclyTrigger.apply(
- calendar,
- [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
- )
- );
- },
-
-
- // Returns a proxy of the given promise that will be rejected if the given event fires
- // before the promise resolves.
- rejectOn: function(eventName, promise) {
- var _this = this;
-
- return new Promise(function(resolve, reject) {
- _this.one(eventName, reject);
-
- function cleanup() {
- _this.off(eventName, reject);
- }
-
- promise.then(function(res) { // success
- cleanup();
- resolve(res);
- }, function() { // failure
- cleanup();
- reject();
- });
- });
- },
-
-
- /* Date Computation
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Updates all internal dates for displaying the given unzoned range.
- setRange: function(range) {
- $.extend(this, range); // assigns every property to this object's member variables
- this.updateTitle();
- },
-
-
- // Given a single current unzoned date, produce information about what range to display.
- // Subclasses can override. Must return all properties.
- computeRange: function(date) {
- var intervalUnit = computeIntervalUnit(this.intervalDuration);
- var intervalStart = date.clone().startOf(intervalUnit);
- var intervalEnd = intervalStart.clone().add(this.intervalDuration);
- var start, end;
-
- // normalize the range's time-ambiguity
- if (/year|month|week|day/.test(intervalUnit)) { // whole-days?
- intervalStart.stripTime();
- intervalEnd.stripTime();
- }
- else { // needs to have a time?
- if (!intervalStart.hasTime()) {
- intervalStart = this.calendar.time(0); // give 00:00 time
- }
- if (!intervalEnd.hasTime()) {
- intervalEnd = this.calendar.time(0); // give 00:00 time
- }
- }
-
- start = intervalStart.clone();
- start = this.skipHiddenDays(start);
- end = intervalEnd.clone();
- end = this.skipHiddenDays(end, -1, true); // exclusively move backwards
-
- return {
- intervalUnit: intervalUnit,
- intervalStart: intervalStart,
- intervalEnd: intervalEnd,
- start: start,
- end: end
- };
- },
-
-
- // Computes the new date when the user hits the prev button, given the current date
- computePrevDate: function(date) {
- return this.massageCurrentDate(
- date.clone().startOf(this.intervalUnit).subtract(this.intervalDuration), -1
- );
- },
-
-
- // Computes the new date when the user hits the next button, given the current date
- computeNextDate: function(date) {
- return this.massageCurrentDate(
- date.clone().startOf(this.intervalUnit).add(this.intervalDuration)
- );
- },
-
-
- // Given an arbitrarily calculated current date of the calendar, returns a date that is ensured to be completely
- // visible. `direction` is optional and indicates which direction the current date was being
- // incremented or decremented (1 or -1).
- massageCurrentDate: function(date, direction) {
- if (this.intervalDuration.as('days') <= 1) { // if the view displays a single day or smaller
- if (this.isHiddenDay(date)) {
- date = this.skipHiddenDays(date, direction);
- date.startOf('day');
- }
- }
-
- return date;
- },
-
-
- /* Title and Date Formatting
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Sets the view's title property to the most updated computed value
- updateTitle: function() {
- this.title = this.computeTitle();
- this.calendar.setToolbarsTitle(this.title);
- },
-
-
- // Computes what the title at the top of the calendar should be for this view
- computeTitle: function() {
- return this.formatRange(
- {
- // in case intervalStart/End has a time, make sure timezone is correct
- start: this.calendar.applyTimezone(this.intervalStart),
- end: this.calendar.applyTimezone(this.intervalEnd)
- },
- this.opt('titleFormat') || this.computeTitleFormat(),
- this.opt('titleRangeSeparator')
- );
- },
-
-
- // Generates the format string that should be used to generate the title for the current date range.
- // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
- computeTitleFormat: function() {
- if (this.intervalUnit == 'year') {
- return 'YYYY';
- }
- else if (this.intervalUnit == 'month') {
- return this.opt('monthYearFormat'); // like "September 2014"
- }
- else if (this.intervalDuration.as('days') > 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.
- // The timezones of the dates within `range` will be respected.
- 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'));
- },
-
-
- getAllDayHtml: function() {
- return this.opt('allDayHtml') || htmlEscape(this.opt('allDayText'));
- },
-
-
- /* Navigation
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Generates HTML for an anchor to another view into the calendar.
- // Will either generate an tag or a non-clickable tag, depending on enabled settings.
- // `gotoOptions` can either be a moment input, or an object with the form:
- // { date, type, forceOff }
- // `type` is a view-type like "day" or "week". default value is "day".
- // `attrs` and `innerHtml` are use to generate the rest of the HTML tag.
- buildGotoAnchorHtml: function(gotoOptions, attrs, innerHtml) {
- var date, type, forceOff;
- var finalOptions;
-
- if ($.isPlainObject(gotoOptions)) {
- date = gotoOptions.date;
- type = gotoOptions.type;
- forceOff = gotoOptions.forceOff;
- }
- else {
- date = gotoOptions; // a single moment input
- }
- date = FC.moment(date); // if a string, parse it
-
- finalOptions = { // for serialization into the link
- date: date.format('YYYY-MM-DD'),
- type: type || 'day'
- };
-
- if (typeof attrs === 'string') {
- innerHtml = attrs;
- attrs = null;
- }
-
- attrs = attrs ? ' ' + attrsToStr(attrs) : ''; // will have a leading space
- innerHtml = innerHtml || '';
-
- if (!forceOff && this.opt('navLinks')) {
- return '' +
- innerHtml +
- ' ';
- }
- else {
- return '' +
- innerHtml +
- ' ';
- }
- },
-
-
- // Rendering Non-date-related Content
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // Sets the container element that the view should render inside of, does global DOM-related initializations,
- // and renders all the non-date-related content inside.
- setElement: function(el) {
- this.el = el;
- this.bindGlobalHandlers();
- this.renderSkeleton();
- },
-
-
- // Removes the view's container element from the DOM, clearing any content beforehand.
- // Undoes any other DOM-related attachments.
- removeElement: function() {
- this.unsetDate();
- this.unrenderSkeleton();
-
- 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.
- },
-
-
- // 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
- },
-
-
- // Date Setting/Unsetting
- // -----------------------------------------------------------------------------------------------------------------
-
-
- setDate: function(date) {
- var isReset = this.isDateSet;
-
- this.isDateSet = true;
- this.handleDate(date, isReset);
- this.trigger(isReset ? 'dateReset' : 'dateSet', date);
- },
-
-
- unsetDate: function() {
- if (this.isDateSet) {
- this.isDateSet = false;
- this.handleDateUnset();
- this.trigger('dateUnset');
- }
- },
-
-
- // Date Handling
- // -----------------------------------------------------------------------------------------------------------------
-
-
- handleDate: function(date, isReset) {
- var _this = this;
-
- this.unbindEvents(); // will do nothing if not already bound
- this.requestDateRender(date).then(function() {
- // wish we could start earlier, but setRange/computeRange needs to execute first
- _this.bindEvents(); // will request events
- });
- },
-
-
- handleDateUnset: function() {
- this.unbindEvents();
- this.requestDateUnrender();
- },
-
-
- // Date Render Queuing
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // if date not specified, uses current
- requestDateRender: function(date) {
- var _this = this;
-
- return this.dateRenderQueue.add(function() {
- return _this.executeDateRender(date);
- });
- },
-
-
- requestDateUnrender: function() {
- var _this = this;
-
- return this.dateRenderQueue.add(function() {
- return _this.executeDateUnrender();
- });
- },
-
-
- // Date High-level Rendering
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // if date not specified, uses current
- executeDateRender: function(date) {
- var _this = this;
-
- // if rendering a new date, reset scroll to initial state (scrollTime)
- if (date) {
- this.captureInitialScroll();
- }
- else {
- this.captureScroll(); // a rerender of the current date
- }
-
- this.freezeHeight();
-
- return this.executeDateUnrender().then(function() {
-
- if (date) {
- _this.setRange(_this.computeRange(date));
- }
-
- if (_this.render) {
- _this.render(); // TODO: deprecate
- }
-
- _this.renderDates();
- _this.updateSize();
- _this.renderBusinessHours(); // might need coordinates, so should go after updateSize()
- _this.startNowIndicator();
-
- _this.thawHeight();
- _this.releaseScroll();
-
- _this.isDateRendered = true;
- _this.onDateRender();
- _this.trigger('dateRender');
- });
- },
-
-
- executeDateUnrender: function() {
- var _this = this;
-
- if (_this.isDateRendered) {
- return this.requestEventsUnrender().then(function() {
-
- _this.unselect();
- _this.stopNowIndicator();
- _this.triggerUnrender();
- _this.unrenderBusinessHours();
- _this.unrenderDates();
-
- if (_this.destroy) {
- _this.destroy(); // TODO: deprecate
- }
-
- _this.isDateRendered = false;
- _this.trigger('dateUnrender');
- });
- }
- else {
- return Promise.resolve();
- }
- },
-
-
- // Date Rendering Triggers
- // -----------------------------------------------------------------------------------------------------------------
-
-
- onDateRender: function() {
- this.triggerRender();
- },
-
-
- // Date Low-level Rendering
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // date-cell content only
- renderDates: function() {
- // subclasses should implement
- },
-
-
- // date-cell content only
- unrenderDates: function() {
- // subclasses should override
- },
-
-
- // Misc view rendering utils
- // -------------------------
-
-
- // Signals that the view's content has been rendered
- triggerRender: function() {
- this.publiclyTrigger('viewRender', this, this, this.el);
- },
-
-
- // Signals that the view's content is about to be unrendered
- triggerUnrender: function() {
- this.publiclyTrigger('viewDestroy', this, this, this.el);
- },
-
-
- // Binds DOM handlers to elements that reside outside the view container, such as the document
- bindGlobalHandlers: function() {
- this.listenTo($(document), 'mousedown', this.handleDocumentMousedown);
- this.listenTo($(document), 'touchstart', this.processUnselect);
- },
-
-
- // Unbinds DOM handlers from elements that reside outside the view container
- unbindGlobalHandlers: function() {
- this.stopListeningTo($(document));
- },
-
-
- // 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';
- },
-
-
- /* Business Hours
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // 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
- },
-
-
- /* Now Indicator
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Immediately render the current time indicator and begins re-rendering it at an interval,
- // which is defined by this.getNowIndicatorUnit().
- // TODO: somehow do this for the current whole day's background too
- startNowIndicator: function() {
- var _this = this;
- var unit;
- var update;
- var delay; // ms wait value
-
- if (this.opt('nowIndicator')) {
- unit = this.getNowIndicatorUnit();
- if (unit) {
- update = proxy(this, 'updateNowIndicator'); // bind to `this`
-
- this.initialNowDate = this.calendar.getNow();
- this.initialNowQueriedMs = +new Date();
- this.renderNowIndicator(this.initialNowDate);
- this.isNowIndicatorRendered = true;
-
- // wait until the beginning of the next interval
- delay = this.initialNowDate.clone().startOf(unit).add(1, unit) - this.initialNowDate;
- this.nowIndicatorTimeoutID = setTimeout(function() {
- _this.nowIndicatorTimeoutID = null;
- update();
- delay = +moment.duration(1, unit);
- delay = Math.max(100, delay); // prevent too frequent
- _this.nowIndicatorIntervalID = setInterval(update, delay); // update every interval
- }, delay);
- }
- }
- },
-
-
- // rerenders the now indicator, computing the new current time from the amount of time that has passed
- // since the initial getNow call.
- updateNowIndicator: function() {
- if (this.isNowIndicatorRendered) {
- this.unrenderNowIndicator();
- this.renderNowIndicator(
- this.initialNowDate.clone().add(new Date() - this.initialNowQueriedMs) // add ms
- );
- }
- },
-
-
- // Immediately unrenders the view's current time indicator and stops any re-rendering timers.
- // Won't cause side effects if indicator isn't rendered.
- stopNowIndicator: function() {
- if (this.isNowIndicatorRendered) {
-
- if (this.nowIndicatorTimeoutID) {
- clearTimeout(this.nowIndicatorTimeoutID);
- this.nowIndicatorTimeoutID = null;
- }
- if (this.nowIndicatorIntervalID) {
- clearTimeout(this.nowIndicatorIntervalID);
- this.nowIndicatorIntervalID = null;
- }
-
- this.unrenderNowIndicator();
- this.isNowIndicatorRendered = false;
- }
- },
-
-
- // Returns a string unit, like 'second' or 'minute' that defined how often the current time indicator
- // should be refreshed. If something falsy is returned, no time indicator is rendered at all.
- getNowIndicatorUnit: function() {
- // subclasses should implement
- },
-
-
- // Renders a current time indicator at the given datetime
- renderNowIndicator: function(date) {
- // subclasses should implement
- },
-
-
- // Undoes the rendering actions from renderNowIndicator
- unrenderNowIndicator: function() {
- // subclasses should implement
- },
-
-
- /* Dimensions
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Refreshes anything dependant upon sizing of the container element of the grid
- updateSize: function(isResize) {
-
- if (isResize) {
- this.captureScroll();
- }
-
- this.updateHeight(isResize);
- this.updateWidth(isResize);
- this.updateNowIndicator();
-
- if (isResize) {
- this.releaseScroll();
- }
- },
-
-
- // 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
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- capturedScroll: null,
- capturedScrollDepth: 0,
-
-
- captureScroll: function() {
- if (!(this.capturedScrollDepth++)) {
- this.capturedScroll = this.isDateRendered ? this.queryScroll() : {}; // require a render first
- return true; // root?
- }
- return false;
- },
-
-
- captureInitialScroll: function(forcedScroll) {
- if (this.captureScroll()) { // root?
- this.capturedScroll.isInitial = true;
-
- if (forcedScroll) {
- $.extend(this.capturedScroll, forcedScroll);
- }
- else {
- this.capturedScroll.isComputed = true;
- }
- }
- },
-
-
- releaseScroll: function() {
- var scroll = this.capturedScroll;
- var isRoot = this.discardScroll();
-
- if (scroll.isComputed) {
- if (isRoot) {
- // only compute initial scroll if it will actually be used (is the root capture)
- $.extend(scroll, this.computeInitialScroll());
- }
- else {
- scroll = null; // scroll couldn't be computed. don't apply it to the DOM
- }
- }
-
- if (scroll) {
- // we act immediately on a releaseScroll operation, as opposed to captureScroll.
- // if capture/release wraps a render operation that screws up the scroll,
- // we still want to restore it a good state after, regardless of depth.
-
- if (scroll.isInitial) {
- this.hardSetScroll(scroll); // outsmart how browsers set scroll on initial DOM
- }
- else {
- this.setScroll(scroll);
- }
- }
- },
-
-
- discardScroll: function() {
- if (!(--this.capturedScrollDepth)) {
- this.capturedScroll = null;
- return true; // root?
- }
- return false;
- },
-
-
- computeInitialScroll: function() {
- return {};
- },
-
-
- queryScroll: function() {
- return {};
- },
-
-
- hardSetScroll: function(scroll) {
- var _this = this;
- var exec = function() { _this.setScroll(scroll); };
- exec();
- setTimeout(exec, 0); // to surely clear the browser's initial scroll for the DOM
- },
-
-
- setScroll: function(scroll) {
- },
-
-
- /* Height Freezing
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- freezeHeight: function() {
- this.calendar.freezeContentHeight();
- },
-
-
- thawHeight: function() {
- this.calendar.thawContentHeight();
- },
-
-
- // Event Binding/Unbinding
- // -----------------------------------------------------------------------------------------------------------------
-
-
- bindEvents: function() {
- var _this = this;
-
- if (!this.isEventsBound) {
- this.isEventsBound = true;
- this.rejectOn('eventsUnbind', this.requestEvents()).then(function(events) { // TODO: test rejection
- _this.listenTo(_this.calendar, 'eventsReset', _this.setEvents);
- _this.setEvents(events);
- });
- }
- },
-
-
- unbindEvents: function() {
- if (this.isEventsBound) {
- this.isEventsBound = false;
- this.stopListeningTo(this.calendar, 'eventsReset');
- this.unsetEvents();
- this.trigger('eventsUnbind');
- }
- },
-
-
- // Event Setting/Unsetting
- // -----------------------------------------------------------------------------------------------------------------
-
-
- setEvents: function(events) {
- var isReset = this.isEventSet;
-
- this.isEventsSet = true;
- this.handleEvents(events, isReset);
- this.trigger(isReset ? 'eventsReset' : 'eventsSet', events);
- },
-
-
- unsetEvents: function() {
- if (this.isEventsSet) {
- this.isEventsSet = false;
- this.handleEventsUnset();
- this.trigger('eventsUnset');
- }
- },
-
-
- whenEventsSet: function() {
- var _this = this;
-
- if (this.isEventsSet) {
- return Promise.resolve(this.getCurrentEvents());
- }
- else {
- return new Promise(function(resolve) {
- _this.one('eventsSet', resolve);
- });
- }
- },
-
-
- // Event Handling
- // -----------------------------------------------------------------------------------------------------------------
-
-
- handleEvents: function(events, isReset) {
- this.requestEventsRender(events);
- },
-
-
- handleEventsUnset: function() {
- this.requestEventsUnrender();
- },
-
-
- // Event Render Queuing
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // assumes any previous event renders have been cleared already
- requestEventsRender: function(events) {
- var _this = this;
-
- return this.eventRenderQueue.add(function() { // might not return a promise if debounced!? bad
- return _this.executeEventsRender(events);
- });
- },
-
-
- requestEventsUnrender: function() {
- var _this = this;
-
- if (this.isEventsRendered) {
- return this.eventRenderQueue.addQuickly(function() {
- return _this.executeEventsUnrender();
- });
- }
- else {
- return Promise.resolve();
- }
- },
-
-
- requestCurrentEventsRender: function() {
- if (this.isEventsSet) {
- this.requestEventsRender(this.getCurrentEvents());
- }
- else {
- return Promise.reject();
- }
- },
-
-
- // Event High-level Rendering
- // -----------------------------------------------------------------------------------------------------------------
-
-
- executeEventsRender: function(events) {
- var _this = this;
-
- this.captureScroll();
- this.freezeHeight();
-
- return this.executeEventsUnrender().then(function() {
- _this.renderEvents(events);
-
- _this.thawHeight();
- _this.releaseScroll();
-
- _this.isEventsRendered = true;
- _this.onEventsRender();
- _this.trigger('eventsRender');
- });
- },
-
-
- executeEventsUnrender: function() {
- if (this.isEventsRendered) {
- this.onBeforeEventsUnrender();
-
- this.captureScroll();
- this.freezeHeight();
-
- if (this.destroyEvents) {
- this.destroyEvents(); // TODO: deprecate
- }
-
- this.unrenderEvents();
-
- this.thawHeight();
- this.releaseScroll();
-
- this.isEventsRendered = false;
- this.trigger('eventsUnrender');
- }
-
- return Promise.resolve(); // always synchronous
- },
-
-
- // Event Rendering Triggers
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // Signals that all events have been rendered
- onEventsRender: function() {
- this.renderedEventSegEach(function(seg) {
- this.publiclyTrigger('eventAfterRender', seg.event, seg.event, seg.el);
- });
- this.publiclyTrigger('eventAfterAllRender');
- },
-
-
- // Signals that all event elements are about to be removed
- onBeforeEventsUnrender: function() {
- this.renderedEventSegEach(function(seg) {
- this.publiclyTrigger('eventDestroy', seg.event, seg.event, seg.el);
- });
- },
-
-
- // Event Low-level Rendering
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // Renders the events onto the view.
- renderEvents: function(events) {
- // subclasses should implement
- },
-
-
- // Removes event elements from the view.
- unrenderEvents: function() {
- // subclasses should implement
- },
-
-
- // Event Data Access
- // -----------------------------------------------------------------------------------------------------------------
-
-
- requestEvents: function() {
- return this.calendar.requestEvents(this.start, this.end);
- },
-
-
- getCurrentEvents: function() {
- return this.calendar.getPrunedEventCache();
- },
-
-
- // Event Rendering Utils
- // -----------------------------------------------------------------------------------------------------------------
-
-
- // 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.publiclyTrigger('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) {
- return this.isEventStartEditable(event);
- },
-
-
- isEventStartEditable: function(event) {
- return firstDefined(
- event.startEditable,
- (event.source || {}).startEditable,
- this.opt('eventStartEditable'),
- this.isEventGenerallyEditable(event)
- );
- },
-
-
- isEventGenerallyEditable: function(event) {
- return firstDefined(
- event.editable,
- (event.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 zoned 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.publiclyTrigger('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 zoned 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.publiclyTrigger('drop', el[0], dropLocation.start, ev, ui);
-
- if (event) {
- this.publiclyTrigger('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`.
- // Must return elements used for any mock events.
- 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.publiclyTrigger('eventResize', el[0], event, durationDelta, undoFunc, ev, {}); // {} = jqui dummy
- },
-
-
- /* Selection (time range)
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Selects a date span on the view. `start` and `end` are both Moments.
- // `ev` is the native mouse event that begin the interaction.
- select: function(span, ev) {
- this.unselect(ev);
- this.renderSelection(span);
- this.reportSelection(span, ev);
- },
-
-
- // Renders a visual indication of the selection
- renderSelection: function(span) {
- // subclasses should implement
- },
-
-
- // Called when a new selection is made. Updates internal state and triggers handlers.
- reportSelection: function(span, ev) {
- this.isSelected = true;
- this.triggerSelect(span, ev);
- },
-
-
- // Triggers handlers to 'select'
- triggerSelect: function(span, ev) {
- this.publiclyTrigger(
- 'select',
- null,
- this.calendar.applyTimezone(span.start), // convert to calendar's tz for external API
- this.calendar.applyTimezone(span.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.publiclyTrigger('unselect', null, ev);
- }
- },
-
-
- // Unrenders a visual indication of selection
- unrenderSelection: function() {
- // subclasses should implement
- },
-
-
- /* Event Selection
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- selectEvent: function(event) {
- if (!this.selectedEvent || this.selectedEvent !== event) {
- this.unselectEvent();
- this.renderedEventSegEach(function(seg) {
- seg.el.addClass('fc-selected');
- }, event);
- this.selectedEvent = event;
- }
- },
-
-
- unselectEvent: function() {
- if (this.selectedEvent) {
- this.renderedEventSegEach(function(seg) {
- seg.el.removeClass('fc-selected');
- }, this.selectedEvent);
- this.selectedEvent = null;
- }
- },
-
-
- isEventSelected: function(event) {
- // event references might change on refetchEvents(), while selectedEvent doesn't,
- // so compare IDs
- return this.selectedEvent && this.selectedEvent._id === event._id;
- },
-
-
- /* Mouse / Touch Unselecting (time range & event unselection)
- ------------------------------------------------------------------------------------------------------------------*/
- // TODO: move consistently to down/start or up/end?
- // TODO: don't kill previous selection if touch scrolling
-
-
- handleDocumentMousedown: function(ev) {
- if (isPrimaryMouseButton(ev)) {
- this.processUnselect(ev);
- }
- },
-
-
- processUnselect: function(ev) {
- this.processRangeUnselect(ev);
- this.processEventUnselect(ev);
- },
-
-
- processRangeUnselect: function(ev) {
- var ignore;
-
- // is there a time-range selection?
- if (this.isSelected && this.opt('unselectAuto')) {
- // 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);
- }
- }
- },
-
-
- processEventUnselect: function(ev) {
- if (this.selectedEvent) {
- if (!$(ev.target).closest('.fc-selected').length) {
- this.unselectEvent();
- }
- }
- },
-
-
- /* Day Click
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // Triggers handlers to 'dayClick'
- // Span has start/end of the clicked area. Only the start is useful.
- triggerDayClick: function(span, dayEl, ev) {
- this.publiclyTrigger(
- 'dayClick',
- dayEl,
- this.calendar.applyTimezone(span.start), // convert to calendar's timezone for external API
- 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;
- }
-
-});
-
-;;
-
-/*
-Embodies a div that has potential scrollbars
-*/
-var Scroller = FC.Scroller = Class.extend({
-
- el: null, // the guaranteed outer element
- scrollEl: null, // the element with the scrollbars
- overflowX: null,
- overflowY: null,
-
-
- constructor: function(options) {
- options = options || {};
- this.overflowX = options.overflowX || options.overflow || 'auto';
- this.overflowY = options.overflowY || options.overflow || 'auto';
- },
-
-
- render: function() {
- this.el = this.renderEl();
- this.applyOverflow();
- },
-
-
- renderEl: function() {
- return (this.scrollEl = $('
'));
- },
-
-
- // sets to natural height, unlocks overflow
- clear: function() {
- this.setHeight('auto');
- this.applyOverflow();
- },
-
-
- destroy: function() {
- this.el.remove();
- },
-
-
- // Overflow
- // -----------------------------------------------------------------------------------------------------------------
-
-
- applyOverflow: function() {
- this.scrollEl.css({
- 'overflow-x': this.overflowX,
- 'overflow-y': this.overflowY
- });
- },
-
-
- // Causes any 'auto' overflow values to resolves to 'scroll' or 'hidden'.
- // Useful for preserving scrollbar widths regardless of future resizes.
- // Can pass in scrollbarWidths for optimization.
- lockOverflow: function(scrollbarWidths) {
- var overflowX = this.overflowX;
- var overflowY = this.overflowY;
-
- scrollbarWidths = scrollbarWidths || this.getScrollbarWidths();
-
- if (overflowX === 'auto') {
- overflowX = (
- scrollbarWidths.top || scrollbarWidths.bottom || // horizontal scrollbars?
- // OR scrolling pane with massless scrollbars?
- this.scrollEl[0].scrollWidth - 1 > this.scrollEl[0].clientWidth
- // subtract 1 because of IE off-by-one issue
- ) ? 'scroll' : 'hidden';
- }
-
- if (overflowY === 'auto') {
- overflowY = (
- scrollbarWidths.left || scrollbarWidths.right || // vertical scrollbars?
- // OR scrolling pane with massless scrollbars?
- this.scrollEl[0].scrollHeight - 1 > this.scrollEl[0].clientHeight
- // subtract 1 because of IE off-by-one issue
- ) ? 'scroll' : 'hidden';
- }
-
- this.scrollEl.css({ 'overflow-x': overflowX, 'overflow-y': overflowY });
- },
-
-
- // Getters / Setters
- // -----------------------------------------------------------------------------------------------------------------
-
-
- setHeight: function(height) {
- this.scrollEl.height(height);
- },
-
-
- getScrollTop: function() {
- return this.scrollEl.scrollTop();
- },
-
-
- setScrollTop: function(top) {
- this.scrollEl.scrollTop(top);
- },
-
-
- getClientWidth: function() {
- return this.scrollEl[0].clientWidth;
- },
-
-
- getClientHeight: function() {
- return this.scrollEl[0].clientHeight;
- },
-
-
- getScrollbarWidths: function() {
- return getScrollbarWidths(this.scrollEl);
- }
-
-});
-
-;;
-function Iterator(items) {
- this.items = items || [];
-}
-
-
-/* Calls a method on every item passing the arguments through */
-Iterator.prototype.proxyCall = function(methodName) {
- var args = Array.prototype.slice.call(arguments, 1);
- var results = [];
-
- this.items.forEach(function(item) {
- results.push(item[methodName].apply(item, args));
- });
-
- return results;
-};
-
-;;
-
-/* Toolbar with buttons and title
-----------------------------------------------------------------------------------------------------------------------*/
-
-function Toolbar(calendar, toolbarOptions) {
- var t = this;
-
- // exports
- t.setToolbarOptions = setToolbarOptions;
- t.render = render;
- t.removeElement = removeElement;
- t.updateTitle = updateTitle;
- t.activateButton = activateButton;
- t.deactivateButton = deactivateButton;
- t.disableButton = disableButton;
- t.enableButton = enableButton;
- t.getViewsWithButtons = getViewsWithButtons;
- t.el = null; // mirrors local `el`
-
- // locals
- var el;
- var viewsWithButtons = [];
- var tm;
-
- // method to update toolbar-specific options, not calendar-wide options
- function setToolbarOptions(newToolbarOptions) {
- toolbarOptions = newToolbarOptions;
- }
-
- // can be called repeatedly and will rerender
- function render() {
- var sections = toolbarOptions.layout;
-
- tm = calendar.options.theme ? 'ui' : 'fc';
-
- if (sections) {
- if (!el) {
- el = this.el = $("");
- }
- else {
- el.empty();
- }
- el.append(renderSection('left'))
- .append(renderSection('right'))
- .append(renderSection('center'))
- .append('
');
- }
- else {
- removeElement();
- }
- }
-
-
- function removeElement() {
- if (el) {
- el.remove();
- el = t.el = null;
- }
- }
-
-
- function renderSection(position) {
- var sectionEl = $('
');
- var buttonStr = toolbarOptions.layout[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 = calendar.options.buttonText[buttonName]; // everything else is considered default
- }
-
- if (buttonClick) {
-
- themeIcon =
- customButtonProps ?
- customButtonProps.themeIcon :
- calendar.options.themeButtonIcons[buttonName];
-
- normalIcon =
- customButtonProps ?
- customButtonProps.icon :
- calendar.options.buttonIcons[buttonName];
-
- if (overrideText) {
- innerHtml = htmlEscape(overrideText);
- }
- else if (themeIcon && calendar.options.theme) {
- innerHtml = " ";
- }
- else if (normalIcon && !calendar.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
- '' +
- innerHtml +
- ' '
- )
- .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) {
- if (el) {
- el.find('h2').text(text);
- }
- }
-
-
- function activateButton(buttonName) {
- if (el) {
- el.find('.fc-' + buttonName + '-button')
- .addClass(tm + '-state-active');
- }
- }
-
-
- function deactivateButton(buttonName) {
- if (el) {
- el.find('.fc-' + buttonName + '-button')
- .removeClass(tm + '-state-active');
- }
- }
-
-
- function disableButton(buttonName) {
- if (el) {
- el.find('.fc-' + buttonName + '-button')
- .prop('disabled', true)
- .addClass(tm + '-state-disabled');
- }
- }
-
-
- function enableButton(buttonName) {
- if (el) {
- el.find('.fc-' + buttonName + '-button')
- .prop('disabled', false)
- .removeClass(tm + '-state-disabled');
- }
- }
-
-
- function getViewsWithButtons() {
- return viewsWithButtons;
- }
-
-}
-
-;;
-
-var Calendar = FC.Calendar = Class.extend({
-
- dirDefaults: null, // option defaults related to LTR or RTL
- localeDefaults: null, // option defaults related to current locale
- overrides: null, // option overrides given to the fullCalendar constructor
- dynamicOverrides: null, // options set with dynamic setter method. higher precedence than view overrides.
- options: null, // all defaults combined with overrides
- viewSpecCache: null, // cache of view definitions
- view: null, // current View object
- header: null,
- footer: 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() {
- },
-
-
- // Computes the flattened options hash for the calendar and assigns to `this.options`.
- // Assumes this.overrides and this.dynamicOverrides have already been initialized.
- populateOptionsHash: function() {
- var locale, localeDefaults;
- var isRTL, dirDefaults;
-
- locale = firstDefined( // explicit locale option given?
- this.dynamicOverrides.locale,
- this.overrides.locale
- );
- localeDefaults = localeOptionHash[locale];
- if (!localeDefaults) { // explicit locale option not given or invalid?
- locale = Calendar.defaults.locale;
- localeDefaults = localeOptionHash[locale] || {};
- }
-
- isRTL = firstDefined( // based on options computed so far, is direction RTL?
- this.dynamicOverrides.isRTL,
- this.overrides.isRTL,
- localeDefaults.isRTL,
- Calendar.defaults.isRTL
- );
- dirDefaults = isRTL ? Calendar.rtlDefaults : {};
-
- this.dirDefaults = dirDefaults;
- this.localeDefaults = localeDefaults;
- this.options = mergeOptions([ // merge defaults and overrides. lowest to highest precedence
- Calendar.defaults, // global defaults
- dirDefaults,
- localeDefaults,
- this.overrides,
- this.dynamicOverrides
- ]);
- populateInstanceComputableOptions(this.options); // fill in gaps with computed options
- },
-
-
- // 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(); // TODO: include footer as well?
- $.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.localeDefaults, // 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)
- this.dynamicOverrides // dynamically set via setter. highest precedence
- ]);
- 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] ||
- // view can decide to look up a certain key
- (spec.buttonTextKey ? buttonText[spec.buttonTextKey] : null) ||
- // a key like "month"
- (spec.singleUnit ? buttonText[spec.singleUnit] : null);
- }
-
- // highest to lowest priority
- spec.buttonTextOverride =
- queryButtonText(this.dynamicOverrides) ||
- 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.localeDefaults) ||
- 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.publiclyTrigger('loading', null, true, this.view);
- }
- },
-
-
- // Should be called when any type of async data fetching completes
- popLoading: function() {
- if (!(--this.loadingLevel)) {
- this.publiclyTrigger('loading', null, false, this.view);
- }
- },
-
-
- // Given arguments to the select method in the API, returns a span (unzoned start/end and other info)
- buildSelectSpan: function(zonedStartInput, zonedEndInput) {
- var start = this.moment(zonedStartInput).stripZone();
- var end;
-
- if (zonedEndInput) {
- end = this.moment(zonedEndInput).stripZone();
- }
- else if (start.hasTime()) {
- end = start.clone().add(this.defaultTimedEventDuration);
- }
- else {
- end = start.clone().add(this.defaultAllDayEventDuration);
- }
-
- return { start: start, end: end };
- }
-
-});
-
-
-Calendar.mixin(EmitterMixin);
-
-
-function Calendar_constructor(element, overrides) {
- var t = this;
-
-
- // Exports
- // -----------------------------------------------------------------------------------
-
- t.render = render;
- t.destroy = destroy;
- t.rerenderEvents = rerenderEvents;
- 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; // getter/setter method
- t.publiclyTrigger = publiclyTrigger;
-
-
- // Options
- // -----------------------------------------------------------------------------------
-
- t.dynamicOverrides = {};
- t.viewSpecCache = {};
- t.optionHandlers = {}; // for Calendar.options.js
- t.overrides = $.extend({}, overrides); // make a copy
-
- t.populateOptionsHash(); // sets this.options
-
-
-
- // Locale-data Internals
- // -----------------------------------------------------------------------------------
- // Apply overrides to the current locale's data
-
- var localeData;
-
- // Called immediately, and when any of the options change.
- // Happens before any internal objects rebuild or rerender, because this is very core.
- t.bindOptions([
- 'locale', 'monthNames', 'monthNamesShort', 'dayNames', 'dayNamesShort', 'firstDay', 'weekNumberCalculation'
- ], function(locale, monthNames, monthNamesShort, dayNames, dayNamesShort, firstDay, weekNumberCalculation) {
-
- // normalize
- if (weekNumberCalculation === 'iso') {
- weekNumberCalculation = 'ISO'; // normalize
- }
-
- localeData = createObject( // make a cheap copy
- getMomentLocaleData(locale) // will fall back to en
- );
-
- if (monthNames) {
- localeData._months = monthNames;
- }
- if (monthNamesShort) {
- localeData._monthsShort = monthNamesShort;
- }
- if (dayNames) {
- localeData._weekdays = dayNames;
- }
- if (dayNamesShort) {
- localeData._weekdaysShort = dayNamesShort;
- }
-
- if (firstDay == null && weekNumberCalculation === 'ISO') {
- firstDay = 1;
- }
- if (firstDay != null) {
- var _week = createObject(localeData._week); // _week: { dow: # }
- _week.dow = firstDay;
- localeData._week = _week;
- }
-
- if ( // whitelist certain kinds of input
- weekNumberCalculation === 'ISO' ||
- weekNumberCalculation === 'local' ||
- typeof weekNumberCalculation === 'function'
- ) {
- localeData._fullCalendar_weekCalc = weekNumberCalculation; // moment-ext will know what to do with it
- }
-
- // If the internal current date object already exists, move to new locale.
- // We do NOT need to do this technique for event dates, because this happens when converting to "segments".
- if (date) {
- localizeMoment(date); // sets to localeData
- }
- });
-
-
- // Calendar-specific Date Utilities
- // -----------------------------------------------------------------------------------
-
-
- t.defaultAllDayEventDuration = moment.duration(t.options.defaultAllDayEventDuration);
- t.defaultTimedEventDuration = moment.duration(t.options.defaultTimedEventDuration);
-
-
- // Builds a moment using the settings of the current calendar: timezone and locale.
- // Accepts anything the vanilla moment() constructor accepts.
- t.moment = function() {
- var mom;
-
- if (t.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 (t.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
- }
-
- localizeMoment(mom);
-
- return mom;
- };
-
-
- // Updates the given moment's locale settings to the current calendar locale settings.
- function localizeMoment(mom) {
- mom._locale = localeData;
- }
- t.localizeMoment = localizeMoment;
-
-
- // 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 t.options.timezone !== 'local' && t.options.timezone !== 'UTC';
- };
-
-
- // Returns a copy of the given date in the current timezone. Has no effect on dates without times.
- t.applyTimezone = function(date) {
- if (!date.hasTime()) {
- return date.clone();
- }
-
- var zonedDate = t.moment(date.toArray());
- var timeAdjust = date.time() - zonedDate.time();
- var adjustedZonedDate;
-
- // Safari sometimes has problems with this coersion when near DST. Adjust if necessary. (bug #2396)
- if (timeAdjust) { // is the time result different than expected?
- adjustedZonedDate = zonedDate.clone().add(timeAdjust); // add milliseconds
- if (date.time() - adjustedZonedDate.time() === 0) { // does it match perfectly now?
- zonedDate = adjustedZonedDate;
- }
- }
-
- return zonedDate;
- };
-
-
- // Returns a moment for the current date, as defined by the client's computer or from the `now` option.
- // Will return an moment with an ambiguous timezone.
- t.getNow = function() {
- var now = t.options.now;
- if (typeof now === 'function') {
- now = now();
- }
- return t.moment(now).stripZone();
- };
-
-
- // 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 what its fallback end date should be.
- // TODO: rename to computeDefaultEventEnd
- t.getDefaultEventEnd = function(allDay, zonedStart) {
- var end = zonedStart.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(t.options.locale).humanize();
- };
-
-
-
- // Imports
- // -----------------------------------------------------------------------------------
-
-
- EventManager.call(t);
-
-
-
- // Locals
- // -----------------------------------------------------------------------------------
-
-
- var _element = element[0];
- var toolbarsManager;
- var header;
- var footer;
- 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; // unzoned
-
-
-
- // Main Rendering
- // -----------------------------------------------------------------------------------
-
-
- // compute the initial ambig-timezone date
- if (t.options.defaultDate != null) {
- date = t.moment(t.options.defaultDate).stripZone();
- }
- else {
- date = t.getNow(); // getNow already returns unzoned
- }
-
-
- function render() {
- if (!content) {
- initialRender();
- }
- else if (elementVisible()) {
- // mainly for the public API
- calcSize();
- renderView();
- }
- }
-
-
- function initialRender() {
- element.addClass('fc');
-
- // event delegation for nav links
- element.on('click.fc', 'a[data-goto]', function(ev) {
- var anchorEl = $(this);
- var gotoOptions = anchorEl.data('goto'); // will automatically parse JSON
- var date = t.moment(gotoOptions.date);
- var viewType = gotoOptions.type;
-
- // property like "navLinkDayClick". might be a string or a function
- var customAction = currentView.opt('navLink' + capitaliseFirstLetter(viewType) + 'Click');
-
- if (typeof customAction === 'function') {
- customAction(date, ev);
- }
- else {
- if (typeof customAction === 'string') {
- viewType = customAction;
- }
- zoomTo(date, viewType);
- }
- });
-
- // called immediately, and upon option change
- t.bindOption('theme', function(theme) {
- tm = theme ? 'ui' : 'fc'; // affects a larger scope
- element.toggleClass('ui-widget', theme);
- element.toggleClass('fc-unthemed', !theme);
- });
-
- // called immediately, and upon option change.
- // HACK: locale often affects isRTL, so we explicitly listen to that too.
- t.bindOptions([ 'isRTL', 'locale' ], function(isRTL) {
- element.toggleClass('fc-ltr', !isRTL);
- element.toggleClass('fc-rtl', isRTL);
- });
-
- content = $("
").prependTo(element);
-
- var toolbars = buildToolbars();
- toolbarsManager = new Iterator(toolbars);
-
- header = t.header = toolbars[0];
- footer = t.footer = toolbars[1];
-
- renderHeader();
- renderFooter();
- renderView(t.options.defaultView);
-
- if (t.options.handleWindowResize) {
- windowResizeProxy = debounce(windowResize, t.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.
- }
-
- toolbarsManager.proxyCall('removeElement');
- content.remove();
- element.removeClass('fc fc-ltr fc-rtl fc-unthemed ui-widget');
-
- element.off('.fc'); // unbind nav link handlers
-
- 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.
- // Accepts an optional scroll state to restore to.
- function renderView(viewType, forcedScroll) {
- ignoreWindowResize++;
-
- var needsClearView = currentView && viewType && currentView.type !== viewType;
-
- // if viewType is changing, remove the old view's rendering
- if (needsClearView) {
- freezeContentHeight(); // prevent a scroll jump when view element is removed
- clearView();
- }
-
- // 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)
- );
- toolbarsManager.proxyCall('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.isDateSet ||
- !( // NOT within interval range signals an implicit date window change
- date >= currentView.intervalStart &&
- date < currentView.intervalEnd
- )
- ) {
- if (elementVisible()) {
-
- if (forcedScroll) {
- currentView.captureInitialScroll(forcedScroll);
- }
-
- currentView.setDate(date, forcedScroll);
-
- if (forcedScroll) {
- currentView.releaseScroll();
- }
-
- // need to do this after View::render, so dates are calculated
- // NOTE: view updates title text proactively
- updateToolbarsTodayButton();
- }
- }
- }
-
- if (needsClearView) {
- thawContentHeight();
- }
-
- ignoreWindowResize--;
- }
-
-
- // Unrenders the current view and reflects this change in the Header.
- // Unregsiters the `currentView`, but does not remove from viewByType hash.
- function clearView() {
- toolbarsManager.proxyCall('deactivateButton', currentView.type);
- currentView.removeElement();
- currentView = t.view = null;
- }
-
-
- // Destroys the view, including the view object. Then, re-instantiates it and renders it.
- // Maintains the same scroll state.
- // TODO: maintain any other user-manipulated state.
- function reinitView() {
- ignoreWindowResize++;
- freezeContentHeight();
-
- var viewType = currentView.type;
- var scrollState = currentView.queryScroll();
- clearView();
- calcSize();
- renderView(viewType, scrollState);
-
- thawContentHeight();
- ignoreWindowResize--;
- }
-
-
-
- // Resizing
- // -----------------------------------------------------------------------------------
-
-
- t.getSuggestedViewHeight = function() {
- if (suggestedViewHeight === undefined) {
- calcSize();
- }
- return suggestedViewHeight;
- };
-
-
- t.isHeightAuto = function() {
- return t.options.contentHeight === 'auto' || t.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
- var contentHeightInput = t.options.contentHeight;
- var heightInput = t.options.height;
-
- if (typeof contentHeightInput === 'number') { // exists and not 'auto'
- suggestedViewHeight = contentHeightInput;
- }
- else if (typeof contentHeightInput === 'function') { // exists and is a function
- suggestedViewHeight = contentHeightInput();
- }
- else if (typeof heightInput === 'number') { // exists and not 'auto'
- suggestedViewHeight = heightInput - queryToolbarsHeight();
- }
- else if (typeof heightInput === 'function') { // exists and is a function
- suggestedViewHeight = heightInput() - queryToolbarsHeight();
- }
- else if (heightInput === 'parent') { // set to height of parent element
- suggestedViewHeight = element.parent().height() - queryToolbarsHeight();
- }
- else {
- suggestedViewHeight = Math.round(content.width() / Math.max(t.options.aspectRatio, .5));
- }
- }
-
-
- function queryToolbarsHeight() {
- return toolbarsManager.items.reduce(function(accumulator, toolbar) {
- var toolbarHeight = toolbar.el ? toolbar.el.outerHeight(true) : 0; // includes margin
- return accumulator + toolbarHeight;
- }, 0);
- }
-
-
- 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.publiclyTrigger('windowResize', _element);
- }
- }
- }
-
-
-
- /* Event Rendering
- -----------------------------------------------------------------------------*/
-
-
- function rerenderEvents() { // API method. destroys old events if previously rendered.
- if (elementVisible()) {
- t.reportEventChange(); // will re-trasmit events to the view, causing a rerender
- }
- }
-
-
-
- /* Toolbars
- -----------------------------------------------------------------------------*/
-
-
- function buildToolbars() {
- return [
- new Toolbar(t, computeHeaderOptions()),
- new Toolbar(t, computeFooterOptions())
- ];
- }
-
-
- function computeHeaderOptions() {
- return {
- extraClasses: 'fc-header-toolbar',
- layout: t.options.header
- };
- }
-
-
- function computeFooterOptions() {
- return {
- extraClasses: 'fc-footer-toolbar',
- layout: t.options.footer
- };
- }
-
-
- // can be called repeatedly and Header will rerender
- function renderHeader() {
- header.setToolbarOptions(computeHeaderOptions());
- header.render();
- if (header.el) {
- element.prepend(header.el);
- }
- }
-
-
- // can be called repeatedly and Footer will rerender
- function renderFooter() {
- footer.setToolbarOptions(computeFooterOptions());
- footer.render();
- if (footer.el) {
- element.append(footer.el);
- }
- }
-
-
- t.setToolbarsTitle = function(title) {
- toolbarsManager.proxyCall('updateTitle', title);
- };
-
-
- function updateToolbarsTodayButton() {
- var now = t.getNow();
- if (now >= currentView.intervalStart && now < currentView.intervalEnd) {
- toolbarsManager.proxyCall('disableButton', 'today');
- }
- else {
- toolbarsManager.proxyCall('enableButton', 'today');
- }
- }
-
-
-
- /* Selection
- -----------------------------------------------------------------------------*/
-
-
- // this public method receives start/end dates in any format, with any timezone
- function select(zonedStartInput, zonedEndInput) {
- currentView.select(
- t.buildSelectSpan.apply(t, arguments)
- );
- }
-
-
- function unselect() { // safe to be called before renderView
- if (currentView) {
- currentView.unselect();
- }
- }
-
-
-
- /* Date
- -----------------------------------------------------------------------------*/
-
-
- function prev() {
- date = currentView.computePrevDate(date);
- renderView();
- }
-
-
- function next() {
- date = currentView.computeNextDate(date);
- renderView();
- }
-
-
- function prevYear() {
- date.add(-1, 'years');
- renderView();
- }
-
-
- function nextYear() {
- date.add(1, 'years');
- renderView();
- }
-
-
- function today() {
- date = t.getNow();
- renderView();
- }
-
-
- function gotoDate(zonedDateInput) {
- date = t.moment(zonedDateInput).stripZone();
- renderView();
- }
-
-
- function incrementDate(delta) {
- date.add(moment.duration(delta));
- renderView();
- }
-
-
- // Forces navigation to a view for the given date.
- // `viewType` can be a specific view name or a generic one like "week" or "day".
- function zoomTo(newDate, viewType) {
- var spec;
-
- viewType = viewType || 'day'; // day is default zoom
- spec = t.getViewSpec(viewType) || t.getUnitViewSpec(viewType);
-
- date = newDate.clone();
- renderView(spec ? spec.type : null);
- }
-
-
- // for external API
- function getDate() {
- return t.applyTimezone(date); // infuse the calendar's timezone
- }
-
-
-
- /* Height "Freezing"
- -----------------------------------------------------------------------------*/
-
-
- t.freezeContentHeight = freezeContentHeight;
- t.thawContentHeight = thawContentHeight;
-
- var freezeContentHeightDepth = 0;
-
-
- function freezeContentHeight() {
- if (!(freezeContentHeightDepth++)) {
- content.css({
- width: '100%',
- height: content.height(),
- overflow: 'hidden'
- });
- }
- }
-
-
- function thawContentHeight() {
- if (!(--freezeContentHeightDepth)) {
- content.css({
- width: '',
- height: '',
- overflow: ''
- });
- }
- }
-
-
-
- /* Misc
- -----------------------------------------------------------------------------*/
-
-
- function getCalendar() {
- return t;
- }
-
-
- function getView() {
- return currentView;
- }
-
-
- function option(name, value) {
- var newOptionHash;
-
- if (typeof name === 'string') {
- if (value === undefined) { // getter
- return t.options[name];
- }
- else { // setter for individual option
- newOptionHash = {};
- newOptionHash[name] = value;
- setOptions(newOptionHash);
- }
- }
- else if (typeof name === 'object') { // compound setter with object input
- setOptions(name);
- }
- }
-
-
- function setOptions(newOptionHash) {
- var optionCnt = 0;
- var optionName;
-
- for (optionName in newOptionHash) {
- t.dynamicOverrides[optionName] = newOptionHash[optionName];
- }
-
- t.viewSpecCache = {}; // the dynamic override invalidates the options in this cache, so just clear it
- t.populateOptionsHash(); // this.options needs to be recomputed after the dynamic override
-
- // trigger handlers after this.options has been updated
- for (optionName in newOptionHash) {
- t.triggerOptionHandlers(optionName); // recall bindOption/bindOptions
- optionCnt++;
- }
-
- // special-case handling of single option change.
- // if only one option change, `optionName` will be its name.
- if (optionCnt === 1) {
- if (optionName === 'height' || optionName === 'contentHeight' || optionName === 'aspectRatio') {
- updateSize(true); // true = allow recalculation of height
- return;
- }
- else if (optionName === 'defaultDate') {
- return; // can't change date this way. use gotoDate instead
- }
- else if (optionName === 'businessHours') {
- if (currentView) {
- currentView.unrenderBusinessHours();
- currentView.renderBusinessHours();
- }
- return;
- }
- else if (optionName === 'timezone') {
- t.rezoneArrayEventSources();
- t.refetchEvents();
- return;
- }
- }
-
- // catch-all. rerender the header and footer and rebuild/rerender the current view
- renderHeader();
- renderFooter();
- viewsByType = {}; // even non-current views will be affected by this option change. do before rerender
- reinitView();
- }
-
-
- function publiclyTrigger(name, thisObj) {
- var args = Array.prototype.slice.call(arguments, 2);
-
- thisObj = thisObj || _element;
- this.triggerWith(name, thisObj, args); // Emitter's method
-
- if (t.options[name]) {
- return t.options[name].apply(thisObj, args);
- }
- }
-
- t.initialize();
-}
-
-;;
-/*
-Options binding/triggering system.
-*/
-Calendar.mixin({
-
- // A map of option names to arrays of handler objects. Initialized to {} in Calendar.
- // Format for a handler object:
- // {
- // func // callback function to be called upon change
- // names // option names whose values should be given to func
- // }
- optionHandlers: null,
-
- // Calls handlerFunc immediately, and when the given option has changed.
- // handlerFunc will be given the option value.
- bindOption: function(optionName, handlerFunc) {
- this.bindOptions([ optionName ], handlerFunc);
- },
-
- // Calls handlerFunc immediately, and when any of the given options change.
- // handlerFunc will be given each option value as ordered function arguments.
- bindOptions: function(optionNames, handlerFunc) {
- var handlerObj = { func: handlerFunc, names: optionNames };
- var i;
-
- for (i = 0; i < optionNames.length; i++) {
- this.registerOptionHandlerObj(optionNames[i], handlerObj);
- }
-
- this.triggerOptionHandlerObj(handlerObj);
- },
-
- // Puts the given handler object into the internal hash
- registerOptionHandlerObj: function(optionName, handlerObj) {
- (this.optionHandlers[optionName] || (this.optionHandlers[optionName] = []))
- .push(handlerObj);
- },
-
- // Reports that the given option has changed, and calls all appropriate handlers.
- triggerOptionHandlers: function(optionName) {
- var handlerObjs = this.optionHandlers[optionName] || [];
- var i;
-
- for (i = 0; i < handlerObjs.length; i++) {
- this.triggerOptionHandlerObj(handlerObjs[i]);
- }
- },
-
- // Calls the callback for a specific handler object, passing in the appropriate arguments.
- triggerOptionHandlerObj: function(handlerObj) {
- var optionNames = handlerObj.names;
- var optionValues = [];
- var i;
-
- for (i = 0; i < optionNames.length; i++) {
- optionValues.push(this.options[optionNames[i]]);
- }
-
- handlerObj.func.apply(this, optionValues); // maintain the Calendar's `this` context
- }
-
-});
-
-;;
-
-Calendar.defaults = {
-
- titleRangeSeparator: ' \u2013 ', // en dash
- monthYearFormat: 'MMMM YYYY', // required for en. other locales 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,
-
- //nowIndicator: 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'
- },
-
- allDayText: 'all-day',
-
- // 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',
- //eventRenderWait: null,
-
- eventLimit: false,
- eventLimitText: 'more',
- eventLimitClick: 'popover',
- dayPopoverFormat: 'LL',
-
- handleWindowResize: true,
- windowResizeDelay: 100, // milliseconds before an updateSize happens
-
- longPressDelay: 1000
-
-};
-
-
-Calendar.englishDefaults = { // used by locale.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 localeOptionHash = FC.locales = {}; // initialize and expose
-
-
-// TODO: document the structure and ordering of a FullCalendar locale file
-
-
-// Initialize jQuery UI datepicker translations while using some of the translations
-// Will set this as the default locales for datepicker.
-FC.datepickerLocale = function(localeCode, dpLocaleCode, dpOptions) {
-
- // get the FullCalendar internal option hash for this locale. create if necessary
- var fcOptions = localeOptionHash[localeCode] || (localeOptionHash[localeCode] = {});
-
- // 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 locale data.
- // FullCalendar and MomentJS use locale codes like "pt-br" but Datepicker
- // does it like "pt-BR" or if it doesn't have the locale, maybe just "pt".
- // Make an alias so the locale can be referenced either way.
- $.datepicker.regional[dpLocaleCode] =
- $.datepicker.regional[localeCode] = // alias
- dpOptions;
-
- // Alias 'en' to the default locale 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 locales as the global default.
-FC.locale = function(localeCode, newFcOptions) {
- var fcOptions;
- var momOptions;
-
- // get the FullCalendar internal option hash for this locale. create if necessary
- fcOptions = localeOptionHash[localeCode] || (localeOptionHash[localeCode] = {});
-
- // provided new options for this locales? merge them in
- if (newFcOptions) {
- fcOptions = localeOptionHash[localeCode] = mergeOptions([ fcOptions, newFcOptions ]);
- }
-
- // compute locale 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(localeCode); // will fall back to en
- $.each(momComputableOptions, function(name, func) {
- if (fcOptions[name] == null) {
- fcOptions[name] = func(momOptions, fcOptions);
- }
- });
-
- // set it as the default locale for FullCalendar
- Calendar.defaults.locale = localeCode;
-};
-
-
-// NOTE: can't guarantee any of these computations will run because not every locale 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 locales
- .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 locales
- .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 locales
- .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 locale?
-// 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.
-function getMomentLocaleData(localeCode) {
- return moment.localeData(localeCode) || moment.localeData('en');
-}
-
-
-// Initialize English by forcing computation of moment-derived options.
-// Also, sets it as the default.
-FC.locale('en', Calendar.englishDefaults);
-
-;;
-
-FC.sourceNormalizers = [];
-FC.sourceFetchers = [];
-
-var ajaxDefaults = {
- dataType: 'json',
- cache: false
-};
-
-var eventGUID = 1;
-
-
-function EventManager() { // assumed to be a calendar
- var t = this;
-
-
- // exports
- t.requestEvents = requestEvents;
- t.reportEventChange = reportEventChange;
- t.isFetchNeeded = isFetchNeeded;
- t.fetchEvents = fetchEvents;
- t.fetchEventSources = fetchEventSources;
- t.refetchEvents = refetchEvents;
- t.refetchEventSources = refetchEventSources;
- t.getEventSources = getEventSources;
- t.getEventSourceById = getEventSourceById;
- t.addEventSource = addEventSource;
- t.removeEventSource = removeEventSource;
- t.removeEventSources = removeEventSources;
- t.updateEvent = updateEvent;
- t.updateEvents = updateEvents;
- t.renderEvent = renderEvent;
- t.renderEvents = renderEvents;
- t.removeEvents = removeEvents;
- t.clientEvents = clientEvents;
- t.mutateEvent = mutateEvent;
- t.normalizeEventDates = normalizeEventDates;
- t.normalizeEventTimes = normalizeEventTimes;
-
-
- // locals
- var stickySource = { events: [] };
- var sources = [ stickySource ];
- var rangeStart, rangeEnd;
- var pendingSourceCnt = 0; // outstanding fetch requests, max one per source
- var cache = []; // holds events that have already been expanded
- var prunedCache; // like cache, but only events that intersect with rangeStart/rangeEnd
-
-
- $.each(
- (t.options.events ? [ t.options.events ] : []).concat(t.options.eventSources || []),
- function(i, sourceInput) {
- var source = buildEventSource(sourceInput);
- if (source) {
- sources.push(source);
- }
- }
- );
-
-
-
- function requestEvents(start, end) {
- if (!t.options.lazyFetching || isFetchNeeded(start, end)) {
- return fetchEvents(start, end);
- }
- else {
- return Promise.resolve(prunedCache);
- }
- }
-
-
- function reportEventChange() {
- prunedCache = filterEventsWithinRange(cache);
- t.trigger('eventsReset', prunedCache);
- }
-
-
- function filterEventsWithinRange(events) {
- var filteredEvents = [];
- var i, event;
-
- for (i = 0; i < events.length; i++) {
- event = events[i];
-
- if (
- event.start.clone().stripZone() < rangeEnd &&
- t.getEventEnd(event).stripZone() > rangeStart
- ) {
- filteredEvents.push(event);
- }
- }
-
- return filteredEvents;
- }
-
-
- t.getEventCache = function() {
- return cache;
- };
-
-
- t.getPrunedEventCache = function() {
- return prunedCache;
- };
-
-
-
- /* Fetching
- -----------------------------------------------------------------------------*/
-
-
- // start and end are assumed to be unzoned
- function isFetchNeeded(start, end) {
- return !rangeStart || // nothing has been fetched yet?
- start < rangeStart || end > rangeEnd; // is part of the new range outside of the old range?
- }
-
-
- function fetchEvents(start, end) {
- rangeStart = start;
- rangeEnd = end;
- return refetchEvents();
- }
-
-
- // poorly named. fetches all sources with current `rangeStart` and `rangeEnd`.
- function refetchEvents() {
- return fetchEventSources(sources, 'reset');
- }
-
-
- // poorly named. fetches a subset of event sources.
- function refetchEventSources(matchInputs) {
- return fetchEventSources(getEventSourcesByMatchArray(matchInputs));
- }
-
-
- // expects an array of event source objects (the originals, not copies)
- // `specialFetchType` is an optimization parameter that affects purging of the event cache.
- function fetchEventSources(specificSources, specialFetchType) {
- var i, source;
-
- if (specialFetchType === 'reset') {
- cache = [];
- }
- else if (specialFetchType !== 'add') {
- cache = excludeEventsBySources(cache, specificSources);
- }
-
- for (i = 0; i < specificSources.length; i++) {
- source = specificSources[i];
-
- // already-pending sources have already been accounted for in pendingSourceCnt
- if (source._status !== 'pending') {
- pendingSourceCnt++;
- }
-
- source._fetchId = (source._fetchId || 0) + 1;
- source._status = 'pending';
- }
-
- for (i = 0; i < specificSources.length; i++) {
- source = specificSources[i];
- tryFetchEventSource(source, source._fetchId);
- }
-
- if (pendingSourceCnt) {
- return new Promise(function(resolve) {
- t.one('eventsReceived', resolve); // will send prunedCache
- });
- }
- else { // executed all synchronously, or no sources at all
- return Promise.resolve(prunedCache);
- }
- }
-
-
- // fetches an event source and processes its result ONLY if it is still the current fetch.
- // caller is responsible for incrementing pendingSourceCnt first.
- function tryFetchEventSource(source, fetchId) {
- _fetchEventSource(source, function(eventInputs) {
- var isArraySource = $.isArray(source.events);
- var i, eventInput;
- var abstractEvent;
-
- if (
- // is this the source's most recent fetch?
- // if not, rely on an upcoming fetch of this source to decrement pendingSourceCnt
- fetchId === source._fetchId &&
- // event source no longer valid?
- source._status !== 'rejected'
- ) {
- source._status = 'resolved';
-
- if (eventInputs) {
- for (i = 0; i < eventInputs.length; i++) {
- eventInput = eventInputs[i];
-
- if (isArraySource) { // array sources have already been convert to Event Objects
- abstractEvent = eventInput;
- }
- else {
- abstractEvent = buildEventFromInput(eventInput, source);
- }
-
- if (abstractEvent) { // not false (an invalid event)
- cache.push.apply( // append
- cache,
- expandEvent(abstractEvent) // add individual expanded events to the cache
- );
- }
- }
- }
-
- decrementPendingSourceCnt();
- }
- });
- }
-
-
- function rejectEventSource(source) {
- var wasPending = source._status === 'pending';
-
- source._status = 'rejected';
-
- if (wasPending) {
- decrementPendingSourceCnt();
- }
- }
-
-
- function decrementPendingSourceCnt() {
- pendingSourceCnt--;
- if (!pendingSourceCnt) {
- reportEventChange(cache); // updates prunedCache
- t.trigger('eventsReceived', prunedCache);
- }
- }
-
-
- function _fetchEventSource(source, callback) {
- var i;
- var fetchers = FC.sourceFetchers;
- var res;
-
- for (i=0; i= eventStart && innerSpan.end <= eventEnd;
-};
-
-
-// Returns a list of events that the given event should be compared against when being considered for a move to
-// the specified span. Attached to the Calendar's prototype because EventManager is a mixin for a Calendar.
-Calendar.prototype.getPeerEvents = function(span, event) {
- var cache = this.getEventCache();
- var peerEvents = [];
- var i, otherEvent;
-
- 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);
- }
- }
-
- return peerEvents;
-};
-
-
-// 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;
-}
-
-
-/* Overlapping / Constraining
------------------------------------------------------------------------------------------*/
-
-
-// Determines if the given event can be relocated to the given span (unzoned start/end with other misc data)
-Calendar.prototype.isEventSpanAllowed = function(span, event) {
- var source = event.source || {};
-
- var constraint = firstDefined(
- event.constraint,
- source.constraint,
- this.options.eventConstraint
- );
-
- var overlap = firstDefined(
- event.overlap,
- source.overlap,
- this.options.eventOverlap
- );
-
- return this.isSpanAllowed(span, constraint, overlap, event) &&
- (!this.options.eventAllow || this.options.eventAllow(span, event) !== false);
-};
-
-
-// Determines if an external event can be relocated to the given span (unzoned start/end with other misc data)
-Calendar.prototype.isExternalSpanAllowed = function(eventSpan, eventLocation, eventProps) {
- var eventInput;
- var event;
-
- // note: very similar logic is in View's reportExternalDrop
- if (eventProps) {
- eventInput = $.extend({}, eventProps, eventLocation);
- event = this.expandEvent(
- this.buildEventFromInput(eventInput)
- )[0];
- }
-
- if (event) {
- return this.isEventSpanAllowed(eventSpan, event);
- }
- else { // treat it as a selection
-
- return this.isSelectionSpanAllowed(eventSpan);
- }
-};
-
-
-// Determines the given span (unzoned start/end with other misc data) can be selected.
-Calendar.prototype.isSelectionSpanAllowed = function(span) {
- return this.isSpanAllowed(span, this.options.selectConstraint, this.options.selectOverlap) &&
- (!this.options.selectAllow || this.options.selectAllow(span) !== false);
-};
-
-
-// Returns true if the given span (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.
-Calendar.prototype.isSpanAllowed = function(span, constraint, overlap, event) {
- var constraintEvents;
- var anyContainment;
- var peerEvents;
- var i, peerEvent;
- var peerOverlap;
-
- // 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 = this.constraintToEvents(constraint);
- if (constraintEvents) { // not invalid
-
- anyContainment = false;
- for (i = 0; i < constraintEvents.length; i++) {
- if (this.spanContainsSpan(constraintEvents[i], span)) {
- anyContainment = true;
- break;
- }
- }
-
- if (!anyContainment) {
- return false;
- }
- }
- }
-
- peerEvents = this.getPeerEvents(span, event);
-
- for (i = 0; i < peerEvents.length; i++) {
- peerEvent = peerEvents[i];
-
- // there needs to be an actual intersection before disallowing anything
- if (this.eventIntersectsRange(peerEvent, span)) {
-
- // 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)
-Calendar.prototype.constraintToEvents = function(constraintInput) {
-
- if (constraintInput === 'businessHours') {
- return this.getCurrentBusinessHourEvents();
- }
-
- if (typeof constraintInput === 'object') {
- if (constraintInput.start != null) { // needs to be event-like input
- return this.expandEvent(this.buildEventFromInput(constraintInput));
- }
- else {
- return null; // invalid
- }
- }
-
- return this.clientEvents(constraintInput); // probably an ID
-};
-
-
-// Does the event's date range intersect with the given range?
-// start/end already assumed to have stripped zones :(
-Calendar.prototype.eventIntersectsRange = function(event, range) {
- var eventStart = event.start.clone().stripZone();
- var eventEnd = this.getEventEnd(event).stripZone();
-
- return range.start < eventEnd && range.end > eventStart;
-};
-
-
-/* Business Hours
------------------------------------------------------------------------------------------*/
-
-var BUSINESS_HOUR_EVENT_DEFAULTS = {
- id: '_fcBusinessHours', // will relate events from different calls to expandEvent
- start: '09:00',
- end: '17:00',
- dow: [ 1, 2, 3, 4, 5 ], // monday - friday
- rendering: 'inverse-background'
- // classNames are defined in businessHoursSegClasses
-};
-
-// Return events objects for business hours within the current view.
-// Abuse of our event system :(
-Calendar.prototype.getCurrentBusinessHourEvents = function(wholeDay) {
- return this.computeBusinessHourEvents(wholeDay, this.options.businessHours);
-};
-
-// Given a raw input value from options, return events objects for business hours within the current view.
-Calendar.prototype.computeBusinessHourEvents = function(wholeDay, input) {
- if (input === true) {
- return this.expandBusinessHourEvents(wholeDay, [ {} ]);
- }
- else if ($.isPlainObject(input)) {
- return this.expandBusinessHourEvents(wholeDay, [ input ]);
- }
- else if ($.isArray(input)) {
- return this.expandBusinessHourEvents(wholeDay, input, true);
- }
- else {
- return [];
- }
-};
-
-// inputs expected to be an array of objects.
-// if ignoreNoDow is true, will ignore entries that don't specify a day-of-week (dow) key.
-Calendar.prototype.expandBusinessHourEvents = function(wholeDay, inputs, ignoreNoDow) {
- var view = this.getView();
- var events = [];
- var i, input;
-
- for (i = 0; i < inputs.length; i++) {
- input = inputs[i];
-
- if (ignoreNoDow && !input.dow) {
- continue;
- }
-
- // give defaults. will make a copy
- input = $.extend({}, BUSINESS_HOUR_EVENT_DEFAULTS, input);
-
- // if a whole-day series is requested, clear the start/end times
- if (wholeDay) {
- input.start = null;
- input.end = null;
- }
-
- events.push.apply(events, // append
- this.expandEvent(
- this.buildEventFromInput(input),
- view.start,
- view.end
- )
- );
- }
-
- return events;
-};
-
-;;
-
-/* 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({
-
- scroller: null,
-
- 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?
- colWeekNumbersVisible: false, // display week numbers along the side?
- cellWeekNumbersVisible: false, // display week numbers in day cell?
-
- 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();
-
- this.scroller = new Scroller({
- overflowX: 'hidden',
- overflowY: 'auto'
- });
- },
-
-
- // 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
- if (this.opt('weekNumbers')) {
- if (this.opt('weekNumbersWithinDays')) {
- this.cellWeekNumbersVisible = true;
- this.colWeekNumbersVisible = false;
- }
- else {
- this.cellWeekNumbersVisible = false;
- this.colWeekNumbersVisible = true;
- };
- }
- this.dayGrid.numbersVisible = this.dayNumbersVisible ||
- this.cellWeekNumbersVisible || this.colWeekNumbersVisible;
-
- this.el.addClass('fc-basic-view').html(this.renderSkeletonHtml());
- this.renderHead();
-
- this.scroller.render();
- var dayGridContainerEl = this.scroller.el.addClass('fc-day-grid-container');
- var dayGridEl = $('
').appendTo(dayGridContainerEl);
- this.el.find('.fc-body > tr > td').append(dayGridContainerEl);
-
- this.dayGrid.setElement(dayGridEl);
- 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();
- this.scroller.destroy();
- },
-
-
- renderBusinessHours: function() {
- this.dayGrid.renderBusinessHours();
- },
-
-
- unrenderBusinessHours: function() {
- this.dayGrid.unrenderBusinessHours();
- },
-
-
- // 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.colWeekNumbersVisible) {
- // 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;
- var scrollbarWidths;
-
- // reset all heights to be natural
- this.scroller.clear();
- 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
- }
-
- // distribute the height to the rows
- // (totalHeight is a "recommended" value if isAuto)
- 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) { // should we force dimensions of the scroll container?
-
- this.scroller.setHeight(scrollerHeight);
- scrollbarWidths = this.scroller.getScrollbarWidths();
-
- if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
-
- compensateScroll(this.headRowEl, scrollbarWidths);
-
- // doing the scrollbar compensation might have created text overflow which created more height. redo
- scrollerHeight = this.computeScrollerHeight(totalHeight);
- this.scroller.setHeight(scrollerHeight);
- }
-
- // guarantees the same scrollbar widths
- this.scroller.lockOverflow(scrollbarWidths);
- }
- },
-
-
- // given a desired total height of the view, returns what the height of the scroller should be
- computeScrollerHeight: function(totalHeight) {
- return totalHeight -
- subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
- },
-
-
- // 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
- }
- },
-
-
- /* Scroll
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- computeInitialScroll: function() {
- return { top: 0 };
- },
-
-
- queryScroll: function() {
- return { top: this.scroller.getScrollTop() };
- },
-
-
- setScroll: function(scroll) {
- this.scroller.setScrollTop(scroll.top);
- },
-
-
- /* 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 renderEvents() call always happens after this, which will eventually call updateHeight()
- },
-
-
- /* 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(span) {
- this.dayGrid.renderSelection(span);
- },
-
-
- // 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.colWeekNumbersVisible) {
- 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;
- var weekStart = this.getCellDate(row, 0);
-
- if (view.colWeekNumbersVisible) {
- return '' +
- '' +
- view.buildGotoAnchorHtml( // aside from link, important for matchCellWidths
- { date: weekStart, type: 'week', forceOff: this.colCnt === 1 },
- weekStart.format('w') // inner HTML
- ) +
- ' ';
- }
-
- return '';
- },
-
-
- // Generates the HTML that goes before the day bg cells for each day-row
- renderBgIntroHtml: function() {
- var view = this.view;
-
- if (view.colWeekNumbersVisible) {
- 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.colWeekNumbersVisible) {
- 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) {
-
- // 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() {
- 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({
-
- scroller: null,
-
- 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 scroller has scrollbars
-
- // when the time-grid isn't tall enough to occupy the given height, we render an underneath
- bottomRuleEl: 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
- }
-
- this.scroller = new Scroller({
- overflowX: 'hidden',
- overflowY: 'auto'
- });
- },
-
-
- // 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();
-
- this.scroller.render();
- var timeGridWrapEl = this.scroller.el.addClass('fc-time-grid-container');
- var timeGridEl = $('
').appendTo(timeGridWrapEl);
- this.el.find('.fc-body > tr > td').append(timeGridWrapEl);
-
- this.timeGrid.setElement(timeGridEl);
- 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();
- }
-
- this.scroller.destroy();
- },
-
-
- // 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 '';
- },
-
-
- /* Business Hours
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- renderBusinessHours: function() {
- this.timeGrid.renderBusinessHours();
-
- if (this.dayGrid) {
- this.dayGrid.renderBusinessHours();
- }
- },
-
-
- unrenderBusinessHours: function() {
- this.timeGrid.unrenderBusinessHours();
-
- if (this.dayGrid) {
- this.dayGrid.unrenderBusinessHours();
- }
- },
-
-
- /* Now Indicator
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- getNowIndicatorUnit: function() {
- return this.timeGrid.getNowIndicatorUnit();
- },
-
-
- renderNowIndicator: function(date) {
- this.timeGrid.renderNowIndicator(date);
- },
-
-
- unrenderNowIndicator: function() {
- this.timeGrid.unrenderNowIndicator();
- },
-
-
- /* 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;
- var scrollbarWidths;
-
- // reset all dimensions back to the original state
- this.bottomRuleEl.hide(); // .show() will be called later if this is necessary
- this.scroller.clear(); // sets height to 'auto' and clears overflow
- 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?
-
- scrollerHeight = this.computeScrollerHeight(totalHeight);
- this.scroller.setHeight(scrollerHeight);
- scrollbarWidths = this.scroller.getScrollbarWidths();
-
- if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
-
- // make the all-day and header rows lines up
- compensateScroll(this.noScrollRowEls, scrollbarWidths);
-
- // 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.scroller.setHeight(scrollerHeight);
- }
-
- // guarantees the same scrollbar widths
- this.scroller.lockOverflow(scrollbarWidths);
-
- // if there's any space below the slats, show the horizontal rule.
- // this won't cause any new overflow, because lockOverflow already called.
- if (this.timeGrid.getTotalSlatHeight() < scrollerHeight) {
- this.bottomRuleEl.show();
- }
- }
- },
-
-
- // given a desired total height of the view, returns what the height of the scroller should be
- computeScrollerHeight: function(totalHeight) {
- return totalHeight -
- subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
- },
-
-
- /* Scroll
- ------------------------------------------------------------------------------------------------------------------*/
-
-
- // 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: top };
- },
-
-
- queryScroll: function() {
- return { top: this.scroller.getScrollTop() };
- },
-
-
- setScroll: function(scroll) {
- this.scroller.setScrollTop(scroll.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 renderEvents() call always happens after this, which will eventually call updateHeight()
- },
-
-
- /* 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(span) {
- if (span.start.hasTime() || span.end.hasTime()) {
- this.timeGrid.renderSelection(span);
- }
- else if (this.dayGrid) {
- this.dayGrid.renderSelection(span);
- }
- },
-
-
- // 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
-// TODO: move into 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.getAllDayHtml() +
- ' ' +
- ' ';
- },
-
-
- // 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,
- 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 }
-};
-;;
-
-/*
-Responsible for the scroller, and forwarding event-related actions into the "grid"
-*/
-var ListView = View.extend({
-
- grid: null,
- scroller: null,
-
- initialize: function() {
- this.grid = new ListViewGrid(this);
- this.scroller = new Scroller({
- overflowX: 'hidden',
- overflowY: 'auto'
- });
- },
-
- setRange: function(range) {
- View.prototype.setRange.call(this, range); // super
-
- this.grid.setRange(range); // needs to process range-related options
- },
-
- renderSkeleton: function() {
- this.el.addClass(
- 'fc-list-view ' +
- this.widgetContentClass
- );
-
- this.scroller.render();
- this.scroller.el.appendTo(this.el);
-
- this.grid.setElement(this.scroller.scrollEl);
- },
-
- unrenderSkeleton: function() {
- this.scroller.destroy(); // will remove the Grid too
- },
-
- setHeight: function(totalHeight, isAuto) {
- this.scroller.setHeight(this.computeScrollerHeight(totalHeight));
- },
-
- computeScrollerHeight: function(totalHeight) {
- return totalHeight -
- subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
- },
-
- renderEvents: function(events) {
- this.grid.renderEvents(events);
- },
-
- unrenderEvents: function() {
- this.grid.unrenderEvents();
- },
-
- isEventResizable: function(event) {
- return false;
- },
-
- isEventDraggable: function(event) {
- return false;
- }
-
-});
-
-/*
-Responsible for event rendering and user-interaction.
-Its "el" is the inner-content of the above view's scroller.
-*/
-var ListViewGrid = Grid.extend({
-
- segSelector: '.fc-list-item', // which elements accept event actions
- hasDayInteractions: false, // no day selection or day clicking
-
- // slices by day
- spanToSegs: function(span) {
- var view = this.view;
- var dayStart = view.start.clone().time(0); // timed, so segs get times!
- var dayIndex = 0;
- var seg;
- var segs = [];
-
- while (dayStart < view.end) {
-
- seg = intersectRanges(span, {
- start: dayStart,
- end: dayStart.clone().add(1, 'day')
- });
-
- if (seg) {
- seg.dayIndex = dayIndex;
- segs.push(seg);
- }
-
- dayStart.add(1, 'day');
- dayIndex++;
-
- // detect when span won't go fully into the next day,
- // and mutate the latest seg to the be the end.
- if (
- seg && !seg.isEnd && span.end.hasTime() &&
- span.end < dayStart.clone().add(this.view.nextDayThreshold)
- ) {
- seg.end = span.end.clone();
- seg.isEnd = true;
- break;
- }
- }
-
- return segs;
- },
-
- // like "4:00am"
- computeEventTimeFormat: function() {
- return this.view.opt('mediumTimeFormat');
- },
-
- // for events with a url, the whole should be clickable,
- // but it's impossible to wrap with an tag. simulate this.
- handleSegClick: function(seg, ev) {
- var url;
-
- Grid.prototype.handleSegClick.apply(this, arguments); // super. might prevent the default action
-
- // not clicking on or within an with an href
- if (!$(ev.target).closest('a[href]').length) {
- url = seg.event.url;
- if (url && !ev.isDefaultPrevented()) { // jsEvent not cancelled in handler
- window.location.href = url; // simulate link click
- }
- }
- },
-
- // returns list of foreground segs that were actually rendered
- renderFgSegs: function(segs) {
- segs = this.renderFgSegEls(segs); // might filter away hidden events
-
- if (!segs.length) {
- this.renderEmptyMessage();
- }
- else {
- this.renderSegList(segs);
- }
-
- return segs;
- },
-
- renderEmptyMessage: function() {
- this.el.html(
- '' + // TODO: try less wraps
- '
' +
- '
' +
- htmlEscape(this.view.opt('noEventsMessage')) +
- '
' +
- '
' +
- '
'
- );
- },
-
- // render the event segments in the view
- renderSegList: function(allSegs) {
- var segsByDay = this.groupSegsByDay(allSegs); // sparse array
- var dayIndex;
- var daySegs;
- var i;
- var tableEl = $(' ');
- var tbodyEl = tableEl.find('tbody');
-
- for (dayIndex = 0; dayIndex < segsByDay.length; dayIndex++) {
- daySegs = segsByDay[dayIndex];
- if (daySegs) { // sparse array, so might be undefined
-
- // append a day header
- tbodyEl.append(this.dayHeaderHtml(
- this.view.start.clone().add(dayIndex, 'days')
- ));
-
- this.sortEventSegs(daySegs);
-
- for (i = 0; i < daySegs.length; i++) {
- tbodyEl.append(daySegs[i].el); // append event row
- }
- }
- }
-
- this.el.empty().append(tableEl);
- },
-
- // Returns a sparse array of arrays, segs grouped by their dayIndex
- groupSegsByDay: function(segs) {
- var segsByDay = []; // sparse array
- var i, seg;
-
- for (i = 0; i < segs.length; i++) {
- seg = segs[i];
- (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
- .push(seg);
- }
-
- return segsByDay;
- },
-
- // generates the HTML for the day headers that live amongst the event rows
- dayHeaderHtml: function(dayDate) {
- var view = this.view;
- var mainFormat = view.opt('listDayFormat');
- var altFormat = view.opt('listDayAltFormat');
-
- return ' ' +
- '' +
- ' ';
- },
-
- // generates the HTML for a single event row
- fgSegHtml: function(seg) {
- var view = this.view;
- var classes = [ 'fc-list-item' ].concat(this.getSegCustomClasses(seg));
- var bgColor = this.getSegBackgroundColor(seg);
- var event = seg.event;
- var url = event.url;
- var timeHtml;
-
- if (event.allDay) {
- timeHtml = view.getAllDayHtml();
- }
- else if (view.isMultiDayEvent(event)) { // if the event appears to span more than one day
- if (seg.isStart || seg.isEnd) { // outer segment that probably lasts part of the day
- timeHtml = htmlEscape(this.getEventTimeText(seg));
- }
- else { // inner segment that lasts the whole day
- timeHtml = view.getAllDayHtml();
- }
- }
- else {
- // Display the normal time text for the *event's* times
- timeHtml = htmlEscape(this.getEventTimeText(event));
- }
-
- if (url) {
- classes.push('fc-has-url');
- }
-
- return '' +
- (this.displayEventTime ?
- '' +
- (timeHtml || '') +
- ' ' :
- '') +
- '' +
- ' ' +
- ' ' +
- '' +
- '' +
- htmlEscape(seg.event.title || '') +
- ' ' +
- ' ' +
- ' ';
- }
+var fullcalendar = (function (exports) {
+ 'use strict';
+
+ var n,l$1,u$1,i$1,t,r$1,o,f$1,e$1,c$1={},s=[],a$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function h(n,l){for(var u in l)n[u]=l[u];return n}function v$1(n){var l=n.parentNode;l&&l.removeChild(n);}function y(l,u,i){var t,r,o,f={};for(o in u)"key"==o?t=u[o]:"ref"==o?r=u[o]:f[o]=u[o];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===f[o]&&(f[o]=l.defaultProps[o]);return p(l,f,t,r,null)}function p(n,i,t,r,o){var f={type:n,props:i,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++u$1:o};return null==o&&null!=l$1.vnode&&l$1.vnode(f),f}function d(){return {current:null}}function _(n){return n.children}function k$1(n,l,u,i,t){var r;for(r in u)"children"===r||"key"===r||r in l||g$2(n,r,null,u[r],i);for(r in l)t&&"function"!=typeof l[r]||"children"===r||"key"===r||"value"===r||"checked"===r||u[r]===l[r]||g$2(n,r,l[r],u[r],i);}function b$1(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||a$1.test(l)?u:u+"px";}function g$2(n,l,u,i,t){var r;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||b$1(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||b$1(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])r=l!==(l=l.replace(/Capture$/,"")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+r]=u,u?i||n.addEventListener(l,r?w$2:m$1,r):n.removeEventListener(l,r?w$2:m$1,r);else if("dangerouslySetInnerHTML"!==l){if(t)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==l&&"height"!==l&&"href"!==l&&"list"!==l&&"form"!==l&&"tabIndex"!==l&&"download"!==l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&-1==l.indexOf("-")?n.removeAttribute(l):n.setAttribute(l,u));}}function m$1(n){t=!0;try{return this.l[n.type+!1](l$1.event?l$1.event(n):n)}finally{t=!1;}}function w$2(n){t=!0;try{return this.l[n.type+!0](l$1.event?l$1.event(n):n)}finally{t=!1;}}function x$1(n,l){this.props=n,this.context=l;}function A(n,l){if(null==l)return n.__?A(n.__,n.__.__k.indexOf(n)+1):null;for(var u;ll&&r$1.sort(function(n,l){return n.__v.__b-l.__v.__b}));$$1.__r=0;}function H$1(n,l,u,i,t,r,o,f,e,a){var h,v,y,d,k,b,g,m=i&&i.__k||s,w=m.length;for(u.__k=[],h=0;h0?p(d.type,d.props,d.key,d.ref?d.ref:null,d.__v):d)){if(d.__=u,d.__b=u.__b+1,null===(y=m[h])||y&&d.key==y.key&&d.type===y.type)m[h]=void 0;else for(v=0;v=0;l--)if((u=n.__k[l])&&(i=L$1(u)))return i;return null}function M(n,u,i,t,r,o,f,e,c){var s,a,v,y,p,d,k,b,g,m,w,A,P,C,T,$=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,o=[e]),(s=l$1.__b)&&s(u);try{n:if("function"==typeof $){if(b=u.props,g=(s=$.contextType)&&t[s.__c],m=s?g?g.props.value:s.__:t,i.__c?k=(a=u.__c=i.__c).__=a.__E:("prototype"in $&&$.prototype.render?u.__c=a=new $(b,m):(u.__c=a=new x$1(b,m),a.constructor=$,a.render=B$1),g&&g.sub(a),a.props=b,a.state||(a.state={}),a.context=m,a.__n=t,v=a.__d=!0,a.__h=[],a._sb=[]),null==a.__s&&(a.__s=a.state),null!=$.getDerivedStateFromProps&&(a.__s==a.state&&(a.__s=h({},a.__s)),h(a.__s,$.getDerivedStateFromProps(b,a.__s))),y=a.props,p=a.state,a.__v=u,v)null==$.getDerivedStateFromProps&&null!=a.componentWillMount&&a.componentWillMount(),null!=a.componentDidMount&&a.__h.push(a.componentDidMount);else {if(null==$.getDerivedStateFromProps&&b!==y&&null!=a.componentWillReceiveProps&&a.componentWillReceiveProps(b,m),!a.__e&&null!=a.shouldComponentUpdate&&!1===a.shouldComponentUpdate(b,a.__s,m)||u.__v===i.__v){for(u.__v!==i.__v&&(a.props=b,a.state=a.__s,a.__d=!1),u.__e=i.__e,u.__k=i.__k,u.__k.forEach(function(n){n&&(n.__=u);}),w=0;w3;)e.pop()();if(e[1]>>1,1),e.i.removeChild(n);}}),D$1(y(P,{context:e.context},n.__v),e.l)):e.l&&e.componentWillUnmount();}function j(n,e){var r=y($,{__v:n,i:e});return r.containerInfo=e,r}(V.prototype=new x$1).__a=function(n){var t=this,e=F(t.__v),r=t.o.get(n);return r[0]++,function(u){var o=function(){t.props.revealOrder?(r.push(u),W(t,n,r)):u();};e?e(o):o();}},V.prototype.render=function(n){this.u=null,this.o=new Map;var t=j$2(n.children);n.revealOrder&&"b"===n.revealOrder[0]&&t.reverse();for(var e=t.length;e--;)this.o.set(t[e],this.u=[1,0,this.u]);return n.children},V.prototype.componentDidUpdate=V.prototype.componentDidMount=function(){var n=this;this.o.forEach(function(t,e){W(n,e,t);});};var z="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,B=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,H="undefined"!=typeof document,Z=function(n){return ("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/i:/fil|che|ra/i).test(n)};x$1.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(x$1.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n});}});});var G=l$1.event;function J(){}function K(){return this.cancelBubble}function Q(){return this.defaultPrevented}l$1.event=function(n){return G&&(n=G(n)),n.persist=J,n.isPropagationStopped=K,n.isDefaultPrevented=Q,n.nativeEvent=n};var nn={configurable:!0,get:function(){return this.class}},tn=l$1.vnode;l$1.vnode=function(n){var t=n.type,e=n.props,u=e;if("string"==typeof t){var o=-1===t.indexOf("-");for(var i in u={},e){var l=e[i];H&&"children"===i&&"noscript"===t||"value"===i&&"defaultValue"in e&&null==l||("defaultValue"===i&&"value"in e&&null==e.value?i="value":"download"===i&&!0===l?l="":/ondoubleclick/i.test(i)?i="ondblclick":/^onchange(textarea|input)/i.test(i+t)&&!Z(e.type)?i="oninput":/^onfocus$/i.test(i)?i="onfocusin":/^onblur$/i.test(i)?i="onfocusout":/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(i)?i=i.toLowerCase():o&&B.test(i)?i=i.replace(/[A-Z0-9]/g,"-$&").toLowerCase():null===l&&(l=void 0),/^oninput$/i.test(i)&&(i=i.toLowerCase(),u[i]&&(i="oninputCapture")),u[i]=l);}"select"==t&&u.multiple&&Array.isArray(u.value)&&(u.value=j$2(e.children).forEach(function(n){n.props.selected=-1!=u.value.indexOf(n.props.value);})),"select"==t&&null!=u.defaultValue&&(u.value=j$2(e.children).forEach(function(n){n.props.selected=u.multiple?-1!=u.defaultValue.indexOf(n.props.value):u.defaultValue==n.props.value;})),n.props=u,e.class!=e.className&&(nn.enumerable="className"in e,null!=e.className&&(u.class=e.className),Object.defineProperty(u,"className",nn));}n.$$typeof=z,tn&&tn(n);};var en=l$1.__r;l$1.__r=function(n){en&&en(n),n.__c;};
+
+ const styleTexts = [];
+ const styleEls = new Map();
+ function injectStyles(styleText) {
+ styleTexts.push(styleText);
+ styleEls.forEach((styleEl) => {
+ appendStylesTo(styleEl, styleText);
+ });
+ }
+ function ensureElHasStyles(el) {
+ if (el.isConnected &&
+ el.getRootNode
+ ) {
+ registerStylesRoot(el.getRootNode());
+ }
+ }
+ function registerStylesRoot(rootNode) {
+ let styleEl = styleEls.get(rootNode);
+ if (!styleEl || !styleEl.isConnected) {
+ styleEl = rootNode.querySelector('style[data-fullcalendar]');
+ if (!styleEl) {
+ styleEl = document.createElement('style');
+ styleEl.setAttribute('data-fullcalendar', '');
+ const nonce = getNonceValue();
+ if (nonce) {
+ styleEl.nonce = nonce;
+ }
+ const parentEl = rootNode === document ? document.head : rootNode;
+ const insertBefore = rootNode === document
+ ? parentEl.querySelector('script,link[rel=stylesheet],link[as=style],style')
+ : parentEl.firstChild;
+ parentEl.insertBefore(styleEl, insertBefore);
+ }
+ styleEls.set(rootNode, styleEl);
+ hydrateStylesRoot(styleEl);
+ }
+ }
+ function hydrateStylesRoot(styleEl) {
+ for (const styleText of styleTexts) {
+ appendStylesTo(styleEl, styleText);
+ }
+ }
+ function appendStylesTo(styleEl, styleText) {
+ const { sheet } = styleEl;
+ const ruleCnt = sheet.cssRules.length;
+ styleText.split('}').forEach((styleStr, i) => {
+ styleStr = styleStr.trim();
+ if (styleStr) {
+ sheet.insertRule(styleStr + '}', ruleCnt + i);
+ }
+ });
+ }
+ let queriedNonceValue;
+ function getNonceValue() {
+ if (queriedNonceValue === undefined) {
+ queriedNonceValue = queryNonceValue();
+ }
+ return queriedNonceValue;
+ }
+ function queryNonceValue() {
+ const metaWithNonce = document.querySelector('meta[name="csp-nonce"]');
+ if (metaWithNonce && metaWithNonce.hasAttribute('content')) {
+ return metaWithNonce.getAttribute('content');
+ }
+ const elWithNonce = document.querySelector('script[nonce]');
+ if (elWithNonce) {
+ return elWithNonce.nonce || '';
+ }
+ return '';
+ }
+ if (typeof document !== 'undefined') {
+ registerStylesRoot(document);
+ }
+ var css_248z$4 = ":root{--fc-small-font-size:.85em;--fc-page-bg-color:#fff;--fc-neutral-bg-color:hsla(0,0%,82%,.3);--fc-neutral-text-color:grey;--fc-border-color:#ddd;--fc-button-text-color:#fff;--fc-button-bg-color:#2c3e50;--fc-button-border-color:#2c3e50;--fc-button-hover-bg-color:#1e2b37;--fc-button-hover-border-color:#1a252f;--fc-button-active-bg-color:#1a252f;--fc-button-active-border-color:#151e27;--fc-event-bg-color:#3788d8;--fc-event-border-color:#3788d8;--fc-event-text-color:#fff;--fc-event-selected-overlay-color:rgba(0,0,0,.25);--fc-more-link-bg-color:#d0d0d0;--fc-more-link-text-color:inherit;--fc-event-resizer-thickness:8px;--fc-event-resizer-dot-total-width:8px;--fc-event-resizer-dot-border-width:1px;--fc-non-business-color:hsla(0,0%,84%,.3);--fc-bg-event-color:#8fdf82;--fc-bg-event-opacity:0.3;--fc-highlight-color:rgba(188,232,241,.3);--fc-today-bg-color:rgba(255,220,40,.15);--fc-now-indicator-color:red}.fc-not-allowed,.fc-not-allowed .fc-event{cursor:not-allowed}.fc{display:flex;flex-direction:column;font-size:1em}.fc,.fc *,.fc :after,.fc :before{box-sizing:border-box}.fc table{border-collapse:collapse;border-spacing:0;font-size:1em}.fc th{text-align:center}.fc td,.fc th{padding:0;vertical-align:top}.fc a[data-navlink]{cursor:pointer}.fc a[data-navlink]:hover{text-decoration:underline}.fc-direction-ltr{direction:ltr;text-align:left}.fc-direction-rtl{direction:rtl;text-align:right}.fc-theme-standard td,.fc-theme-standard th{border:1px solid var(--fc-border-color)}.fc-liquid-hack td,.fc-liquid-hack th{position:relative}@font-face{font-family:fcicons;font-style:normal;font-weight:400;src:url(\"data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBfAAAAC8AAAAYGNtYXAXVtKNAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5ZgYydxIAAAF4AAAFNGhlYWQUJ7cIAAAGrAAAADZoaGVhB20DzAAABuQAAAAkaG10eCIABhQAAAcIAAAALGxvY2ED4AU6AAAHNAAAABhtYXhwAA8AjAAAB0wAAAAgbmFtZXsr690AAAdsAAABhnBvc3QAAwAAAAAI9AAAACAAAwPAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpBgPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6Qb//f//AAAAAAAg6QD//f//AAH/4xcEAAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAWIAjQKeAskAEwAAJSc3NjQnJiIHAQYUFwEWMjc2NCcCnuLiDQ0MJAz/AA0NAQAMJAwNDcni4gwjDQwM/wANIwz/AA0NDCMNAAAAAQFiAI0CngLJABMAACUBNjQnASYiBwYUHwEHBhQXFjI3AZ4BAA0N/wAMJAwNDeLiDQ0MJAyNAQAMIw0BAAwMDSMM4uINIwwNDQAAAAIA4gC3Ax4CngATACcAACUnNzY0JyYiDwEGFB8BFjI3NjQnISc3NjQnJiIPAQYUHwEWMjc2NCcB87e3DQ0MIw3VDQ3VDSMMDQ0BK7e3DQ0MJAzVDQ3VDCQMDQ3zuLcMJAwNDdUNIwzWDAwNIwy4twwkDA0N1Q0jDNYMDA0jDAAAAgDiALcDHgKeABMAJwAAJTc2NC8BJiIHBhQfAQcGFBcWMjchNzY0LwEmIgcGFB8BBwYUFxYyNwJJ1Q0N1Q0jDA0Nt7cNDQwjDf7V1Q0N1QwkDA0Nt7cNDQwkDLfWDCMN1Q0NDCQMt7gMIw0MDNYMIw3VDQ0MJAy3uAwjDQwMAAADAFUAAAOrA1UAMwBoAHcAABMiBgcOAQcOAQcOARURFBYXHgEXHgEXHgEzITI2Nz4BNz4BNz4BNRE0JicuAScuAScuASMFITIWFx4BFx4BFx4BFREUBgcOAQcOAQcOASMhIiYnLgEnLgEnLgE1ETQ2Nz4BNz4BNz4BMxMhMjY1NCYjISIGFRQWM9UNGAwLFQkJDgUFBQUFBQ4JCRULDBgNAlYNGAwLFQkJDgUFBQUFBQ4JCRULDBgN/aoCVgQIBAQHAwMFAQIBAQIBBQMDBwQECAT9qgQIBAQHAwMFAQIBAQIBBQMDBwQECASAAVYRGRkR/qoRGRkRA1UFBAUOCQkVDAsZDf2rDRkLDBUJCA4FBQUFBQUOCQgVDAsZDQJVDRkLDBUJCQ4FBAVVAgECBQMCBwQECAX9qwQJAwQHAwMFAQICAgIBBQMDBwQDCQQCVQUIBAQHAgMFAgEC/oAZEhEZGRESGQAAAAADAFUAAAOrA1UAMwBoAIkAABMiBgcOAQcOAQcOARURFBYXHgEXHgEXHgEzITI2Nz4BNz4BNz4BNRE0JicuAScuAScuASMFITIWFx4BFx4BFx4BFREUBgcOAQcOAQcOASMhIiYnLgEnLgEnLgE1ETQ2Nz4BNz4BNz4BMxMzFRQWMzI2PQEzMjY1NCYrATU0JiMiBh0BIyIGFRQWM9UNGAwLFQkJDgUFBQUFBQ4JCRULDBgNAlYNGAwLFQkJDgUFBQUFBQ4JCRULDBgN/aoCVgQIBAQHAwMFAQIBAQIBBQMDBwQECAT9qgQIBAQHAwMFAQIBAQIBBQMDBwQECASAgBkSEhmAERkZEYAZEhIZgBEZGREDVQUEBQ4JCRUMCxkN/asNGQsMFQkIDgUFBQUFBQ4JCBUMCxkNAlUNGQsMFQkJDgUEBVUCAQIFAwIHBAQIBf2rBAkDBAcDAwUBAgICAgEFAwMHBAMJBAJVBQgEBAcCAwUCAQL+gIASGRkSgBkSERmAEhkZEoAZERIZAAABAOIAjQMeAskAIAAAExcHBhQXFjI/ARcWMjc2NC8BNzY0JyYiDwEnJiIHBhQX4uLiDQ0MJAzi4gwkDA0N4uINDQwkDOLiDCQMDQ0CjeLiDSMMDQ3h4Q0NDCMN4uIMIw0MDOLiDAwNIwwAAAABAAAAAQAAa5n0y18PPPUACwQAAAAAANivOVsAAAAA2K85WwAAAAADqwNVAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAOrAAEAAAAAAAAAAAAAAAAAAAALBAAAAAAAAAAAAAAAAgAAAAQAAWIEAAFiBAAA4gQAAOIEAABVBAAAVQQAAOIAAAAAAAoAFAAeAEQAagCqAOoBngJkApoAAQAAAAsAigADAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGZjaWNvbnMAZgBjAGkAYwBvAG4Ac1ZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGZjaWNvbnMAZgBjAGkAYwBvAG4Ac2ZjaWNvbnMAZgBjAGkAYwBvAG4Ac1JlZ3VsYXIAUgBlAGcAdQBsAGEAcmZjaWNvbnMAZgBjAGkAYwBvAG4Ac0ZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\") format(\"truetype\")}.fc-icon{speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;display:inline-block;font-family:fcicons!important;font-style:normal;font-variant:normal;font-weight:400;height:1em;line-height:1;text-align:center;text-transform:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:1em}.fc-icon-chevron-left:before{content:\"\\e900\"}.fc-icon-chevron-right:before{content:\"\\e901\"}.fc-icon-chevrons-left:before{content:\"\\e902\"}.fc-icon-chevrons-right:before{content:\"\\e903\"}.fc-icon-minus-square:before{content:\"\\e904\"}.fc-icon-plus-square:before{content:\"\\e905\"}.fc-icon-x:before{content:\"\\e906\"}.fc .fc-button{border-radius:0;font-family:inherit;font-size:inherit;line-height:inherit;margin:0;overflow:visible;text-transform:none}.fc .fc-button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}.fc .fc-button{-webkit-appearance:button}.fc .fc-button:not(:disabled){cursor:pointer}.fc .fc-button{background-color:transparent;border:1px solid transparent;border-radius:.25em;display:inline-block;font-size:1em;font-weight:400;line-height:1.5;padding:.4em .65em;text-align:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle}.fc .fc-button:hover{text-decoration:none}.fc .fc-button:focus{box-shadow:0 0 0 .2rem rgba(44,62,80,.25);outline:0}.fc .fc-button:disabled{opacity:.65}.fc .fc-button-primary{background-color:var(--fc-button-bg-color);border-color:var(--fc-button-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:hover{background-color:var(--fc-button-hover-bg-color);border-color:var(--fc-button-hover-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:disabled{background-color:var(--fc-button-bg-color);border-color:var(--fc-button-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:focus{box-shadow:0 0 0 .2rem rgba(76,91,106,.5)}.fc .fc-button-primary:not(:disabled).fc-button-active,.fc .fc-button-primary:not(:disabled):active{background-color:var(--fc-button-active-bg-color);border-color:var(--fc-button-active-border-color);color:var(--fc-button-text-color)}.fc .fc-button-primary:not(:disabled).fc-button-active:focus,.fc .fc-button-primary:not(:disabled):active:focus{box-shadow:0 0 0 .2rem rgba(76,91,106,.5)}.fc .fc-button .fc-icon{font-size:1.5em;vertical-align:middle}.fc .fc-button-group{display:inline-flex;position:relative;vertical-align:middle}.fc .fc-button-group>.fc-button{flex:1 1 auto;position:relative}.fc .fc-button-group>.fc-button.fc-button-active,.fc .fc-button-group>.fc-button:active,.fc .fc-button-group>.fc-button:focus,.fc .fc-button-group>.fc-button:hover{z-index:1}.fc-direction-ltr .fc-button-group>.fc-button:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0;margin-left:-1px}.fc-direction-ltr .fc-button-group>.fc-button:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.fc-direction-rtl .fc-button-group>.fc-button:not(:first-child){border-bottom-right-radius:0;border-top-right-radius:0;margin-right:-1px}.fc-direction-rtl .fc-button-group>.fc-button:not(:last-child){border-bottom-left-radius:0;border-top-left-radius:0}.fc .fc-toolbar{align-items:center;display:flex;justify-content:space-between}.fc .fc-toolbar.fc-header-toolbar{margin-bottom:1.5em}.fc .fc-toolbar.fc-footer-toolbar{margin-top:1.5em}.fc .fc-toolbar-title{font-size:1.75em;margin:0}.fc-direction-ltr .fc-toolbar>*>:not(:first-child){margin-left:.75em}.fc-direction-rtl .fc-toolbar>*>:not(:first-child){margin-right:.75em}.fc-direction-rtl .fc-toolbar-ltr{flex-direction:row-reverse}.fc .fc-scroller{-webkit-overflow-scrolling:touch;position:relative}.fc .fc-scroller-liquid{height:100%}.fc .fc-scroller-liquid-absolute{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-scroller-harness{direction:ltr;overflow:hidden;position:relative}.fc .fc-scroller-harness-liquid{height:100%}.fc-direction-rtl .fc-scroller-harness>.fc-scroller{direction:rtl}.fc-theme-standard .fc-scrollgrid{border:1px solid var(--fc-border-color)}.fc .fc-scrollgrid,.fc .fc-scrollgrid table{table-layout:fixed;width:100%}.fc .fc-scrollgrid table{border-left-style:hidden;border-right-style:hidden;border-top-style:hidden}.fc .fc-scrollgrid{border-bottom-width:0;border-collapse:separate;border-right-width:0}.fc .fc-scrollgrid-liquid{height:100%}.fc .fc-scrollgrid-section,.fc .fc-scrollgrid-section table,.fc .fc-scrollgrid-section>td{height:1px}.fc .fc-scrollgrid-section-liquid>td{height:100%}.fc .fc-scrollgrid-section>*{border-left-width:0;border-top-width:0}.fc .fc-scrollgrid-section-footer>*,.fc .fc-scrollgrid-section-header>*{border-bottom-width:0}.fc .fc-scrollgrid-section-body table,.fc .fc-scrollgrid-section-footer table{border-bottom-style:hidden}.fc .fc-scrollgrid-section-sticky>*{background:var(--fc-page-bg-color);position:sticky;z-index:3}.fc .fc-scrollgrid-section-header.fc-scrollgrid-section-sticky>*{top:0}.fc .fc-scrollgrid-section-footer.fc-scrollgrid-section-sticky>*{bottom:0}.fc .fc-scrollgrid-sticky-shim{height:1px;margin-bottom:-1px}.fc-sticky{position:sticky}.fc .fc-view-harness{flex-grow:1;position:relative}.fc .fc-view-harness-active>.fc-view{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-col-header-cell-cushion{display:inline-block;padding:2px 4px}.fc .fc-bg-event,.fc .fc-highlight,.fc .fc-non-business{bottom:0;left:0;position:absolute;right:0;top:0}.fc .fc-non-business{background:var(--fc-non-business-color)}.fc .fc-bg-event{background:var(--fc-bg-event-color);opacity:var(--fc-bg-event-opacity)}.fc .fc-bg-event .fc-event-title{font-size:var(--fc-small-font-size);font-style:italic;margin:.5em}.fc .fc-highlight{background:var(--fc-highlight-color)}.fc .fc-cell-shaded,.fc .fc-day-disabled{background:var(--fc-neutral-bg-color)}a.fc-event,a.fc-event:hover{text-decoration:none}.fc-event.fc-event-draggable,.fc-event[href]{cursor:pointer}.fc-event .fc-event-main{position:relative;z-index:2}.fc-event-dragging:not(.fc-event-selected){opacity:.75}.fc-event-dragging.fc-event-selected{box-shadow:0 2px 7px rgba(0,0,0,.3)}.fc-event .fc-event-resizer{display:none;position:absolute;z-index:4}.fc-event-selected .fc-event-resizer,.fc-event:hover .fc-event-resizer{display:block}.fc-event-selected .fc-event-resizer{background:var(--fc-page-bg-color);border-color:inherit;border-radius:calc(var(--fc-event-resizer-dot-total-width)/2);border-style:solid;border-width:var(--fc-event-resizer-dot-border-width);height:var(--fc-event-resizer-dot-total-width);width:var(--fc-event-resizer-dot-total-width)}.fc-event-selected .fc-event-resizer:before{bottom:-20px;content:\"\";left:-20px;position:absolute;right:-20px;top:-20px}.fc-event-selected,.fc-event:focus{box-shadow:0 2px 5px rgba(0,0,0,.2)}.fc-event-selected:before,.fc-event:focus:before{bottom:0;content:\"\";left:0;position:absolute;right:0;top:0;z-index:3}.fc-event-selected:after,.fc-event:focus:after{background:var(--fc-event-selected-overlay-color);bottom:-1px;content:\"\";left:-1px;position:absolute;right:-1px;top:-1px;z-index:1}.fc-h-event{background-color:var(--fc-event-bg-color);border:1px solid var(--fc-event-border-color);display:block}.fc-h-event .fc-event-main{color:var(--fc-event-text-color)}.fc-h-event .fc-event-main-frame{display:flex}.fc-h-event .fc-event-time{max-width:100%;overflow:hidden}.fc-h-event .fc-event-title-container{flex-grow:1;flex-shrink:1;min-width:0}.fc-h-event .fc-event-title{display:inline-block;left:0;max-width:100%;overflow:hidden;right:0;vertical-align:top}.fc-h-event.fc-event-selected:before{bottom:-10px;top:-10px}.fc-direction-ltr .fc-daygrid-block-event:not(.fc-event-start),.fc-direction-rtl .fc-daygrid-block-event:not(.fc-event-end){border-bottom-left-radius:0;border-left-width:0;border-top-left-radius:0}.fc-direction-ltr .fc-daygrid-block-event:not(.fc-event-end),.fc-direction-rtl .fc-daygrid-block-event:not(.fc-event-start){border-bottom-right-radius:0;border-right-width:0;border-top-right-radius:0}.fc-h-event:not(.fc-event-selected) .fc-event-resizer{bottom:0;top:0;width:var(--fc-event-resizer-thickness)}.fc-direction-ltr .fc-h-event:not(.fc-event-selected) .fc-event-resizer-start,.fc-direction-rtl .fc-h-event:not(.fc-event-selected) .fc-event-resizer-end{cursor:w-resize;left:calc(var(--fc-event-resizer-thickness)*-.5)}.fc-direction-ltr .fc-h-event:not(.fc-event-selected) .fc-event-resizer-end,.fc-direction-rtl .fc-h-event:not(.fc-event-selected) .fc-event-resizer-start{cursor:e-resize;right:calc(var(--fc-event-resizer-thickness)*-.5)}.fc-h-event.fc-event-selected .fc-event-resizer{margin-top:calc(var(--fc-event-resizer-dot-total-width)*-.5);top:50%}.fc-direction-ltr .fc-h-event.fc-event-selected .fc-event-resizer-start,.fc-direction-rtl .fc-h-event.fc-event-selected .fc-event-resizer-end{left:calc(var(--fc-event-resizer-dot-total-width)*-.5)}.fc-direction-ltr .fc-h-event.fc-event-selected .fc-event-resizer-end,.fc-direction-rtl .fc-h-event.fc-event-selected .fc-event-resizer-start{right:calc(var(--fc-event-resizer-dot-total-width)*-.5)}.fc .fc-popover{box-shadow:0 2px 6px rgba(0,0,0,.15);position:absolute;z-index:9999}.fc .fc-popover-header{align-items:center;display:flex;flex-direction:row;justify-content:space-between;padding:3px 4px}.fc .fc-popover-title{margin:0 2px}.fc .fc-popover-close{cursor:pointer;font-size:1.1em;opacity:.65}.fc-theme-standard .fc-popover{background:var(--fc-page-bg-color);border:1px solid var(--fc-border-color)}.fc-theme-standard .fc-popover-header{background:var(--fc-neutral-bg-color)}";
+ injectStyles(css_248z$4);
+ class DelayedRunner {
+ constructor(drainedOption) {
+ this.drainedOption = drainedOption;
+ this.isRunning = false;
+ this.isDirty = false;
+ this.pauseDepths = {};
+ this.timeoutId = 0;
+ }
+ request(delay) {
+ this.isDirty = true;
+ if (!this.isPaused()) {
+ this.clearTimeout();
+ if (delay == null) {
+ this.tryDrain();
+ }
+ else {
+ this.timeoutId = setTimeout(
+ this.tryDrain.bind(this), delay);
+ }
+ }
+ }
+ pause(scope = '') {
+ let { pauseDepths } = this;
+ pauseDepths[scope] = (pauseDepths[scope] || 0) + 1;
+ this.clearTimeout();
+ }
+ resume(scope = '', force) {
+ let { pauseDepths } = this;
+ if (scope in pauseDepths) {
+ if (force) {
+ delete pauseDepths[scope];
+ }
+ else {
+ pauseDepths[scope] -= 1;
+ let depth = pauseDepths[scope];
+ if (depth <= 0) {
+ delete pauseDepths[scope];
+ }
+ }
+ this.tryDrain();
+ }
+ }
+ isPaused() {
+ return Object.keys(this.pauseDepths).length;
+ }
+ tryDrain() {
+ if (!this.isRunning && !this.isPaused()) {
+ this.isRunning = true;
+ while (this.isDirty) {
+ this.isDirty = false;
+ this.drained();
+ }
+ this.isRunning = false;
+ }
+ }
+ clear() {
+ this.clearTimeout();
+ this.isDirty = false;
+ this.pauseDepths = {};
+ }
+ clearTimeout() {
+ if (this.timeoutId) {
+ clearTimeout(this.timeoutId);
+ this.timeoutId = 0;
+ }
+ }
+ drained() {
+ if (this.drainedOption) {
+ this.drainedOption();
+ }
+ }
+ }
+ function removeElement(el) {
+ if (el.parentNode) {
+ el.parentNode.removeChild(el);
+ }
+ }
+ function elementClosest(el, selector) {
+ if (el.closest) {
+ return el.closest(selector);
+ }
+ if (!document.documentElement.contains(el)) {
+ return null;
+ }
+ do {
+ if (elementMatches(el, selector)) {
+ return el;
+ }
+ el = (el.parentElement || el.parentNode);
+ } while (el !== null && el.nodeType === 1);
+ return null;
+ }
+ function elementMatches(el, selector) {
+ let method = el.matches || el.matchesSelector || el.msMatchesSelector;
+ return method.call(el, selector);
+ }
+ function findElements(container, selector) {
+ let containers = container instanceof HTMLElement ? [container] : container;
+ let allMatches = [];
+ for (let i = 0; i < containers.length; i += 1) {
+ let matches = containers[i].querySelectorAll(selector);
+ for (let j = 0; j < matches.length; j += 1) {
+ allMatches.push(matches[j]);
+ }
+ }
+ return allMatches;
+ }
+ const PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
+ function applyStyle(el, props) {
+ for (let propName in props) {
+ applyStyleProp(el, propName, props[propName]);
+ }
+ }
+ function applyStyleProp(el, name, val) {
+ if (val == null) {
+ el.style[name] = '';
+ }
+ else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
+ el.style[name] = `${val}px`;
+ }
+ else {
+ el.style[name] = val;
+ }
+ }
+ function getEventTargetViaRoot(ev) {
+ var _a, _b;
+ return (_b = (_a = ev.composedPath) === null || _a === void 0 ? void 0 : _a.call(ev)[0]) !== null && _b !== void 0 ? _b : ev.target;
+ }
+ let guid$1 = 0;
+ function getUniqueDomId() {
+ guid$1 += 1;
+ return 'fc-dom-' + guid$1;
+ }
+ function preventDefault(ev) {
+ ev.preventDefault();
+ }
+ function buildDelegationHandler(selector, handler) {
+ return (ev) => {
+ let matchedChild = elementClosest(ev.target, selector);
+ if (matchedChild) {
+ handler.call(matchedChild, ev, matchedChild);
+ }
+ };
+ }
+ function listenBySelector(container, eventType, selector, handler) {
+ let attachedHandler = buildDelegationHandler(selector, handler);
+ container.addEventListener(eventType, attachedHandler);
+ return () => {
+ container.removeEventListener(eventType, attachedHandler);
+ };
+ }
+ function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
+ let currentMatchedChild;
+ return listenBySelector(container, 'mouseover', selector, (mouseOverEv, matchedChild) => {
+ if (matchedChild !== currentMatchedChild) {
+ currentMatchedChild = matchedChild;
+ onMouseEnter(mouseOverEv, matchedChild);
+ let realOnMouseLeave = (mouseLeaveEv) => {
+ currentMatchedChild = null;
+ onMouseLeave(mouseLeaveEv, matchedChild);
+ matchedChild.removeEventListener('mouseleave', realOnMouseLeave);
+ };
+ matchedChild.addEventListener('mouseleave', realOnMouseLeave);
+ }
+ });
+ }
+ const transitionEventNames = [
+ 'webkitTransitionEnd',
+ 'otransitionend',
+ 'oTransitionEnd',
+ 'msTransitionEnd',
+ 'transitionend',
+ ];
+ function whenTransitionDone(el, callback) {
+ let realCallback = (ev) => {
+ callback(ev);
+ transitionEventNames.forEach((eventName) => {
+ el.removeEventListener(eventName, realCallback);
+ });
+ };
+ transitionEventNames.forEach((eventName) => {
+ el.addEventListener(eventName, realCallback);
+ });
+ }
+ function createAriaClickAttrs(handler) {
+ return Object.assign({ onClick: handler }, createAriaKeyboardAttrs(handler));
+ }
+ function createAriaKeyboardAttrs(handler) {
+ return {
+ tabIndex: 0,
+ onKeyDown(ev) {
+ if (ev.key === 'Enter' || ev.key === ' ') {
+ handler(ev);
+ ev.preventDefault();
+ }
+ },
+ };
+ }
+ let guidNumber = 0;
+ function guid() {
+ guidNumber += 1;
+ return String(guidNumber);
+ }
+ function disableCursor() {
+ document.body.classList.add('fc-not-allowed');
+ }
+ function enableCursor() {
+ document.body.classList.remove('fc-not-allowed');
+ }
+ function preventSelection(el) {
+ el.style.userSelect = 'none';
+ el.style.webkitUserSelect = 'none';
+ el.addEventListener('selectstart', preventDefault);
+ }
+ function allowSelection(el) {
+ el.style.userSelect = '';
+ el.style.webkitUserSelect = '';
+ el.removeEventListener('selectstart', preventDefault);
+ }
+ function preventContextMenu(el) {
+ el.addEventListener('contextmenu', preventDefault);
+ }
+ function allowContextMenu(el) {
+ el.removeEventListener('contextmenu', preventDefault);
+ }
+ function parseFieldSpecs(input) {
+ let specs = [];
+ let tokens = [];
+ let i;
+ let token;
+ if (typeof input === 'string') {
+ tokens = input.split(/\s*,\s*/);
+ }
+ else if (typeof input === 'function') {
+ tokens = [input];
+ }
+ else if (Array.isArray(input)) {
+ tokens = input;
+ }
+ for (i = 0; i < tokens.length; i += 1) {
+ token = tokens[i];
+ if (typeof token === 'string') {
+ specs.push(token.charAt(0) === '-' ?
+ { field: token.substring(1), order: -1 } :
+ { field: token, order: 1 });
+ }
+ else if (typeof token === 'function') {
+ specs.push({ func: token });
+ }
+ }
+ return specs;
+ }
+ function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
+ let i;
+ let cmp;
+ for (i = 0; i < fieldSpecs.length; i += 1) {
+ cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
+ if (cmp) {
+ return cmp;
+ }
+ }
+ return 0;
+ }
+ function compareByFieldSpec(obj0, obj1, fieldSpec) {
+ if (fieldSpec.func) {
+ return fieldSpec.func(obj0, obj1);
+ }
+ return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
+ * (fieldSpec.order || 1);
+ }
+ function flexibleCompare(a, b) {
+ if (!a && !b) {
+ return 0;
+ }
+ if (b == null) {
+ return -1;
+ }
+ if (a == null) {
+ return 1;
+ }
+ if (typeof a === 'string' || typeof b === 'string') {
+ return String(a).localeCompare(String(b));
+ }
+ return a - b;
+ }
+ function padStart(val, len) {
+ let s = String(val);
+ return '000'.substr(0, len - s.length) + s;
+ }
+ function formatWithOrdinals(formatter, args, fallbackText) {
+ if (typeof formatter === 'function') {
+ return formatter(...args);
+ }
+ if (typeof formatter === 'string') {
+ return args.reduce((str, arg, index) => (str.replace('$' + index, arg || '')), formatter);
+ }
+ return fallbackText;
+ }
+ function compareNumbers(a, b) {
+ return a - b;
+ }
+ function isInt(n) {
+ return n % 1 === 0;
+ }
+ function computeSmallestCellWidth(cellEl) {
+ let allWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-frame');
+ let contentWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-cushion');
+ if (!allWidthEl) {
+ throw new Error('needs fc-scrollgrid-shrink-frame className');
+ }
+ if (!contentWidthEl) {
+ throw new Error('needs fc-scrollgrid-shrink-cushion className');
+ }
+ return cellEl.getBoundingClientRect().width - allWidthEl.getBoundingClientRect().width +
+ contentWidthEl.getBoundingClientRect().width;
+ }
+ const INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
+ const PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
+ function createDuration(input, unit) {
+ if (typeof input === 'string') {
+ return parseString(input);
+ }
+ if (typeof input === 'object' && input) {
+ return parseObject(input);
+ }
+ if (typeof input === 'number') {
+ return parseObject({ [unit || 'milliseconds']: input });
+ }
+ return null;
+ }
+ function parseString(s) {
+ let m = PARSE_RE.exec(s);
+ if (m) {
+ let sign = m[1] ? -1 : 1;
+ return {
+ years: 0,
+ months: 0,
+ days: sign * (m[2] ? parseInt(m[2], 10) : 0),
+ milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 +
+ (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 +
+ (m[5] ? parseInt(m[5], 10) : 0) * 1000 +
+ (m[6] ? parseInt(m[6], 10) : 0)
+ ),
+ };
+ }
+ return null;
+ }
+ function parseObject(obj) {
+ let duration = {
+ years: obj.years || obj.year || 0,
+ months: obj.months || obj.month || 0,
+ days: obj.days || obj.day || 0,
+ milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 +
+ (obj.minutes || obj.minute || 0) * 60 * 1000 +
+ (obj.seconds || obj.second || 0) * 1000 +
+ (obj.milliseconds || obj.millisecond || obj.ms || 0),
+ };
+ let weeks = obj.weeks || obj.week;
+ if (weeks) {
+ duration.days += weeks * 7;
+ duration.specifiedWeeks = true;
+ }
+ return duration;
+ }
+ function durationsEqual(d0, d1) {
+ return d0.years === d1.years &&
+ d0.months === d1.months &&
+ d0.days === d1.days &&
+ d0.milliseconds === d1.milliseconds;
+ }
+ function addDurations(d0, d1) {
+ return {
+ years: d0.years + d1.years,
+ months: d0.months + d1.months,
+ days: d0.days + d1.days,
+ milliseconds: d0.milliseconds + d1.milliseconds,
+ };
+ }
+ function subtractDurations(d1, d0) {
+ return {
+ years: d1.years - d0.years,
+ months: d1.months - d0.months,
+ days: d1.days - d0.days,
+ milliseconds: d1.milliseconds - d0.milliseconds,
+ };
+ }
+ function multiplyDuration(d, n) {
+ return {
+ years: d.years * n,
+ months: d.months * n,
+ days: d.days * n,
+ milliseconds: d.milliseconds * n,
+ };
+ }
+ function asRoughYears(dur) {
+ return asRoughDays(dur) / 365;
+ }
+ function asRoughMonths(dur) {
+ return asRoughDays(dur) / 30;
+ }
+ function asRoughDays(dur) {
+ return asRoughMs(dur) / 864e5;
+ }
+ function asRoughMs(dur) {
+ return dur.years * (365 * 864e5) +
+ dur.months * (30 * 864e5) +
+ dur.days * 864e5 +
+ dur.milliseconds;
+ }
+ function wholeDivideDurations(numerator, denominator) {
+ let res = null;
+ for (let i = 0; i < INTERNAL_UNITS.length; i += 1) {
+ let unit = INTERNAL_UNITS[i];
+ if (denominator[unit]) {
+ let localRes = numerator[unit] / denominator[unit];
+ if (!isInt(localRes) || (res !== null && res !== localRes)) {
+ return null;
+ }
+ res = localRes;
+ }
+ else if (numerator[unit]) {
+ return null;
+ }
+ }
+ return res;
+ }
+ function greatestDurationDenominator(dur) {
+ let ms = dur.milliseconds;
+ if (ms) {
+ if (ms % 1000 !== 0) {
+ return { unit: 'millisecond', value: ms };
+ }
+ if (ms % (1000 * 60) !== 0) {
+ return { unit: 'second', value: ms / 1000 };
+ }
+ if (ms % (1000 * 60 * 60) !== 0) {
+ return { unit: 'minute', value: ms / (1000 * 60) };
+ }
+ if (ms) {
+ return { unit: 'hour', value: ms / (1000 * 60 * 60) };
+ }
+ }
+ if (dur.days) {
+ if (dur.specifiedWeeks && dur.days % 7 === 0) {
+ return { unit: 'week', value: dur.days / 7 };
+ }
+ return { unit: 'day', value: dur.days };
+ }
+ if (dur.months) {
+ return { unit: 'month', value: dur.months };
+ }
+ if (dur.years) {
+ return { unit: 'year', value: dur.years };
+ }
+ return { unit: 'millisecond', value: 0 };
+ }
+ function isArraysEqual(a0, a1, equalityFunc) {
+ if (a0 === a1) {
+ return true;
+ }
+ let len = a0.length;
+ let i;
+ if (len !== a1.length) {
+ return false;
+ }
+ for (i = 0; i < len; i += 1) {
+ if (!(equalityFunc ? equalityFunc(a0[i], a1[i]) : a0[i] === a1[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ const DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
+ function addWeeks(m, n) {
+ let a = dateToUtcArray(m);
+ a[2] += n * 7;
+ return arrayToUtcDate(a);
+ }
+ function addDays(m, n) {
+ let a = dateToUtcArray(m);
+ a[2] += n;
+ return arrayToUtcDate(a);
+ }
+ function addMs(m, n) {
+ let a = dateToUtcArray(m);
+ a[6] += n;
+ return arrayToUtcDate(a);
+ }
+ function diffWeeks(m0, m1) {
+ return diffDays(m0, m1) / 7;
+ }
+ function diffDays(m0, m1) {
+ return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
+ }
+ function diffHours(m0, m1) {
+ return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
+ }
+ function diffMinutes(m0, m1) {
+ return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
+ }
+ function diffSeconds(m0, m1) {
+ return (m1.valueOf() - m0.valueOf()) / 1000;
+ }
+ function diffDayAndTime(m0, m1) {
+ let m0day = startOfDay(m0);
+ let m1day = startOfDay(m1);
+ return {
+ years: 0,
+ months: 0,
+ days: Math.round(diffDays(m0day, m1day)),
+ milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf()),
+ };
+ }
+ function diffWholeWeeks(m0, m1) {
+ let d = diffWholeDays(m0, m1);
+ if (d !== null && d % 7 === 0) {
+ return d / 7;
+ }
+ return null;
+ }
+ function diffWholeDays(m0, m1) {
+ if (timeAsMs(m0) === timeAsMs(m1)) {
+ return Math.round(diffDays(m0, m1));
+ }
+ return null;
+ }
+ function startOfDay(m) {
+ return arrayToUtcDate([
+ m.getUTCFullYear(),
+ m.getUTCMonth(),
+ m.getUTCDate(),
+ ]);
+ }
+ function startOfHour(m) {
+ return arrayToUtcDate([
+ m.getUTCFullYear(),
+ m.getUTCMonth(),
+ m.getUTCDate(),
+ m.getUTCHours(),
+ ]);
+ }
+ function startOfMinute(m) {
+ return arrayToUtcDate([
+ m.getUTCFullYear(),
+ m.getUTCMonth(),
+ m.getUTCDate(),
+ m.getUTCHours(),
+ m.getUTCMinutes(),
+ ]);
+ }
+ function startOfSecond(m) {
+ return arrayToUtcDate([
+ m.getUTCFullYear(),
+ m.getUTCMonth(),
+ m.getUTCDate(),
+ m.getUTCHours(),
+ m.getUTCMinutes(),
+ m.getUTCSeconds(),
+ ]);
+ }
+ function weekOfYear(marker, dow, doy) {
+ let y = marker.getUTCFullYear();
+ let w = weekOfGivenYear(marker, y, dow, doy);
+ if (w < 1) {
+ return weekOfGivenYear(marker, y - 1, dow, doy);
+ }
+ let nextW = weekOfGivenYear(marker, y + 1, dow, doy);
+ if (nextW >= 1) {
+ return Math.min(w, nextW);
+ }
+ return w;
+ }
+ function weekOfGivenYear(marker, year, dow, doy) {
+ let firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
+ let dayStart = startOfDay(marker);
+ let days = Math.round(diffDays(firstWeekStart, dayStart));
+ return Math.floor(days / 7) + 1;
+ }
+ function firstWeekOffset(year, dow, doy) {
+ let fwd = 7 + dow - doy;
+ let fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
+ return -fwdlw + fwd - 1;
+ }
+ function dateToLocalArray(date) {
+ return [
+ date.getFullYear(),
+ date.getMonth(),
+ date.getDate(),
+ date.getHours(),
+ date.getMinutes(),
+ date.getSeconds(),
+ date.getMilliseconds(),
+ ];
+ }
+ function arrayToLocalDate(a) {
+ return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2],
+ a[3] || 0, a[4] || 0, a[5] || 0);
+ }
+ function dateToUtcArray(date) {
+ return [
+ date.getUTCFullYear(),
+ date.getUTCMonth(),
+ date.getUTCDate(),
+ date.getUTCHours(),
+ date.getUTCMinutes(),
+ date.getUTCSeconds(),
+ date.getUTCMilliseconds(),
+ ];
+ }
+ function arrayToUtcDate(a) {
+ if (a.length === 1) {
+ a = a.concat([0]);
+ }
+ return new Date(Date.UTC(...a));
+ }
+ function isValidDate(m) {
+ return !isNaN(m.valueOf());
+ }
+ function timeAsMs(m) {
+ return m.getUTCHours() * 1000 * 60 * 60 +
+ m.getUTCMinutes() * 1000 * 60 +
+ m.getUTCSeconds() * 1000 +
+ m.getUTCMilliseconds();
+ }
+ function buildIsoString(marker, timeZoneOffset, stripZeroTime = false) {
+ let s = marker.toISOString();
+ s = s.replace('.000', '');
+ if (stripZeroTime) {
+ s = s.replace('T00:00:00Z', '');
+ }
+ if (s.length > 10) {
+ if (timeZoneOffset == null) {
+ s = s.replace('Z', '');
+ }
+ else if (timeZoneOffset !== 0) {
+ s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
+ }
+ }
+ return s;
+ }
+ function formatDayString(marker) {
+ return marker.toISOString().replace(/T.*$/, '');
+ }
+ function formatIsoMonthStr(marker) {
+ return marker.toISOString().match(/^\d{4}-\d{2}/)[0];
+ }
+ function formatIsoTimeString(marker) {
+ return padStart(marker.getUTCHours(), 2) + ':' +
+ padStart(marker.getUTCMinutes(), 2) + ':' +
+ padStart(marker.getUTCSeconds(), 2);
+ }
+ function formatTimeZoneOffset(minutes, doIso = false) {
+ let sign = minutes < 0 ? '-' : '+';
+ let abs = Math.abs(minutes);
+ let hours = Math.floor(abs / 60);
+ let mins = Math.round(abs % 60);
+ if (doIso) {
+ return `${sign + padStart(hours, 2)}:${padStart(mins, 2)}`;
+ }
+ return `GMT${sign}${hours}${mins ? `:${padStart(mins, 2)}` : ''}`;
+ }
+ function memoize(workerFunc, resEquality, teardownFunc) {
+ let currentArgs;
+ let currentRes;
+ return function (...newArgs) {
+ if (!currentArgs) {
+ currentRes = workerFunc.apply(this, newArgs);
+ }
+ else if (!isArraysEqual(currentArgs, newArgs)) {
+ if (teardownFunc) {
+ teardownFunc(currentRes);
+ }
+ let res = workerFunc.apply(this, newArgs);
+ if (!resEquality || !resEquality(res, currentRes)) {
+ currentRes = res;
+ }
+ }
+ currentArgs = newArgs;
+ return currentRes;
+ };
+ }
+ function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
+ let currentArg;
+ let currentRes;
+ return (newArg) => {
+ if (!currentArg) {
+ currentRes = workerFunc.call(this, newArg);
+ }
+ else if (!isPropsEqual(currentArg, newArg)) {
+ if (teardownFunc) {
+ teardownFunc(currentRes);
+ }
+ let res = workerFunc.call(this, newArg);
+ if (!resEquality || !resEquality(res, currentRes)) {
+ currentRes = res;
+ }
+ }
+ currentArg = newArg;
+ return currentRes;
+ };
+ }
+ const EXTENDED_SETTINGS_AND_SEVERITIES = {
+ week: 3,
+ separator: 9,
+ omitZeroMinute: 9,
+ meridiem: 9,
+ omitCommas: 9,
+ };
+ const STANDARD_DATE_PROP_SEVERITIES = {
+ timeZoneName: 7,
+ era: 6,
+ year: 5,
+ month: 4,
+ day: 2,
+ weekday: 2,
+ hour: 1,
+ minute: 1,
+ second: 1,
+ };
+ const MERIDIEM_RE = /\s*([ap])\.?m\.?/i;
+ const COMMA_RE = /,/g;
+ const MULTI_SPACE_RE = /\s+/g;
+ const LTR_RE = /\u200e/g;
+ const UTC_RE = /UTC|GMT/;
+ class NativeFormatter {
+ constructor(formatSettings) {
+ let standardDateProps = {};
+ let extendedSettings = {};
+ let smallestUnitNum = 9;
+ for (let name in formatSettings) {
+ if (name in EXTENDED_SETTINGS_AND_SEVERITIES) {
+ extendedSettings[name] = formatSettings[name];
+ const severity = EXTENDED_SETTINGS_AND_SEVERITIES[name];
+ if (severity < 9) {
+ smallestUnitNum = Math.min(EXTENDED_SETTINGS_AND_SEVERITIES[name], smallestUnitNum);
+ }
+ }
+ else {
+ standardDateProps[name] = formatSettings[name];
+ if (name in STANDARD_DATE_PROP_SEVERITIES) {
+ smallestUnitNum = Math.min(STANDARD_DATE_PROP_SEVERITIES[name], smallestUnitNum);
+ }
+ }
+ }
+ this.standardDateProps = standardDateProps;
+ this.extendedSettings = extendedSettings;
+ this.smallestUnitNum = smallestUnitNum;
+ this.buildFormattingFunc = memoize(buildFormattingFunc);
+ }
+ format(date, context) {
+ return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
+ }
+ formatRange(start, end, context, betterDefaultSeparator) {
+ let { standardDateProps, extendedSettings } = this;
+ let diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
+ if (!diffSeverity) {
+ return this.format(start, context);
+ }
+ let biggestUnitForPartial = diffSeverity;
+ if (biggestUnitForPartial > 1 &&
+ (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
+ (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
+ (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
+ biggestUnitForPartial = 1;
+ }
+ let full0 = this.format(start, context);
+ let full1 = this.format(end, context);
+ if (full0 === full1) {
+ return full0;
+ }
+ let partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
+ let partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
+ let partial0 = partialFormattingFunc(start);
+ let partial1 = partialFormattingFunc(end);
+ let insertion = findCommonInsertion(full0, partial0, full1, partial1);
+ let separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || '';
+ if (insertion) {
+ return insertion.before + partial0 + separator + partial1 + insertion.after;
+ }
+ return full0 + separator + full1;
+ }
+ getSmallestUnit() {
+ switch (this.smallestUnitNum) {
+ case 7:
+ case 6:
+ case 5:
+ return 'year';
+ case 4:
+ return 'month';
+ case 3:
+ return 'week';
+ case 2:
+ return 'day';
+ default:
+ return 'time';
+ }
+ }
+ }
+ function buildFormattingFunc(standardDateProps, extendedSettings, context) {
+ let standardDatePropCnt = Object.keys(standardDateProps).length;
+ if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
+ return (date) => (formatTimeZoneOffset(date.timeZoneOffset));
+ }
+ if (standardDatePropCnt === 0 && extendedSettings.week) {
+ return (date) => (formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.weekTextLong, context.locale, extendedSettings.week));
+ }
+ return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
+ }
+ function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
+ standardDateProps = Object.assign({}, standardDateProps);
+ extendedSettings = Object.assign({}, extendedSettings);
+ sanitizeSettings(standardDateProps, extendedSettings);
+ standardDateProps.timeZone = 'UTC';
+ let normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
+ let zeroFormat;
+ if (extendedSettings.omitZeroMinute) {
+ let zeroProps = Object.assign({}, standardDateProps);
+ delete zeroProps.minute;
+ zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
+ }
+ return (date) => {
+ let { marker } = date;
+ let format;
+ if (zeroFormat && !marker.getUTCMinutes()) {
+ format = zeroFormat;
+ }
+ else {
+ format = normalFormat;
+ }
+ let s = format.format(marker);
+ return postProcess(s, date, standardDateProps, extendedSettings, context);
+ };
+ }
+ function sanitizeSettings(standardDateProps, extendedSettings) {
+ if (standardDateProps.timeZoneName) {
+ if (!standardDateProps.hour) {
+ standardDateProps.hour = '2-digit';
+ }
+ if (!standardDateProps.minute) {
+ standardDateProps.minute = '2-digit';
+ }
+ }
+ if (standardDateProps.timeZoneName === 'long') {
+ standardDateProps.timeZoneName = 'short';
+ }
+ if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
+ delete extendedSettings.omitZeroMinute;
+ }
+ }
+ function postProcess(s, date, standardDateProps, extendedSettings, context) {
+ s = s.replace(LTR_RE, '');
+ if (standardDateProps.timeZoneName === 'short') {
+ s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
+ 'UTC' :
+ formatTimeZoneOffset(date.timeZoneOffset));
+ }
+ if (extendedSettings.omitCommas) {
+ s = s.replace(COMMA_RE, '').trim();
+ }
+ if (extendedSettings.omitZeroMinute) {
+ s = s.replace(':00', '');
+ }
+ if (extendedSettings.meridiem === false) {
+ s = s.replace(MERIDIEM_RE, '').trim();
+ }
+ else if (extendedSettings.meridiem === 'narrow') {
+ s = s.replace(MERIDIEM_RE, (m0, m1) => m1.toLocaleLowerCase());
+ }
+ else if (extendedSettings.meridiem === 'short') {
+ s = s.replace(MERIDIEM_RE, (m0, m1) => `${m1.toLocaleLowerCase()}m`);
+ }
+ else if (extendedSettings.meridiem === 'lowercase') {
+ s = s.replace(MERIDIEM_RE, (m0) => m0.toLocaleLowerCase());
+ }
+ s = s.replace(MULTI_SPACE_RE, ' ');
+ s = s.trim();
+ return s;
+ }
+ function injectTzoStr(s, tzoStr) {
+ let replaced = false;
+ s = s.replace(UTC_RE, () => {
+ replaced = true;
+ return tzoStr;
+ });
+ if (!replaced) {
+ s += ` ${tzoStr}`;
+ }
+ return s;
+ }
+ function formatWeekNumber(num, weekText, weekTextLong, locale, display) {
+ let parts = [];
+ if (display === 'long') {
+ parts.push(weekTextLong);
+ }
+ else if (display === 'short' || display === 'narrow') {
+ parts.push(weekText);
+ }
+ if (display === 'long' || display === 'short') {
+ parts.push(' ');
+ }
+ parts.push(locale.simpleNumberFormat.format(num));
+ if (locale.options.direction === 'rtl') {
+ parts.reverse();
+ }
+ return parts.join('');
+ }
+ function computeMarkerDiffSeverity(d0, d1, ca) {
+ if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
+ return 5;
+ }
+ if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
+ return 4;
+ }
+ if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
+ return 2;
+ }
+ if (timeAsMs(d0) !== timeAsMs(d1)) {
+ return 1;
+ }
+ return 0;
+ }
+ function computePartialFormattingOptions(options, biggestUnit) {
+ let partialOptions = {};
+ for (let name in options) {
+ if (!(name in STANDARD_DATE_PROP_SEVERITIES) ||
+ STANDARD_DATE_PROP_SEVERITIES[name] <= biggestUnit) {
+ partialOptions[name] = options[name];
+ }
+ }
+ return partialOptions;
+ }
+ function findCommonInsertion(full0, partial0, full1, partial1) {
+ let i0 = 0;
+ while (i0 < full0.length) {
+ let found0 = full0.indexOf(partial0, i0);
+ if (found0 === -1) {
+ break;
+ }
+ let before0 = full0.substr(0, found0);
+ i0 = found0 + partial0.length;
+ let after0 = full0.substr(i0);
+ let i1 = 0;
+ while (i1 < full1.length) {
+ let found1 = full1.indexOf(partial1, i1);
+ if (found1 === -1) {
+ break;
+ }
+ let before1 = full1.substr(0, found1);
+ i1 = found1 + partial1.length;
+ let after1 = full1.substr(i1);
+ if (before0 === before1 && after0 === after1) {
+ return {
+ before: before0,
+ after: after0,
+ };
+ }
+ }
+ }
+ return null;
+ }
+ function expandZonedMarker(dateInfo, calendarSystem) {
+ let a = calendarSystem.markerToArray(dateInfo.marker);
+ return {
+ marker: dateInfo.marker,
+ timeZoneOffset: dateInfo.timeZoneOffset,
+ array: a,
+ year: a[0],
+ month: a[1],
+ day: a[2],
+ hour: a[3],
+ minute: a[4],
+ second: a[5],
+ millisecond: a[6],
+ };
+ }
+ function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
+ let startInfo = expandZonedMarker(start, context.calendarSystem);
+ let endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
+ return {
+ date: startInfo,
+ start: startInfo,
+ end: endInfo,
+ timeZone: context.timeZone,
+ localeCodes: context.locale.codes,
+ defaultSeparator: betterDefaultSeparator || context.defaultSeparator,
+ };
+ }
+ class CmdFormatter {
+ constructor(cmdStr) {
+ this.cmdStr = cmdStr;
+ }
+ format(date, context, betterDefaultSeparator) {
+ return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
+ }
+ formatRange(start, end, context, betterDefaultSeparator) {
+ return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
+ }
+ }
+ class FuncFormatter {
+ constructor(func) {
+ this.func = func;
+ }
+ format(date, context, betterDefaultSeparator) {
+ return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
+ }
+ formatRange(start, end, context, betterDefaultSeparator) {
+ return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
+ }
+ }
+ function createFormatter(input) {
+ if (typeof input === 'object' && input) {
+ return new NativeFormatter(input);
+ }
+ if (typeof input === 'string') {
+ return new CmdFormatter(input);
+ }
+ if (typeof input === 'function') {
+ return new FuncFormatter(input);
+ }
+ return null;
+ }
+ const BASE_OPTION_REFINERS = {
+ navLinkDayClick: identity,
+ navLinkWeekClick: identity,
+ duration: createDuration,
+ bootstrapFontAwesome: identity,
+ buttonIcons: identity,
+ customButtons: identity,
+ defaultAllDayEventDuration: createDuration,
+ defaultTimedEventDuration: createDuration,
+ nextDayThreshold: createDuration,
+ scrollTime: createDuration,
+ scrollTimeReset: Boolean,
+ slotMinTime: createDuration,
+ slotMaxTime: createDuration,
+ dayPopoverFormat: createFormatter,
+ slotDuration: createDuration,
+ snapDuration: createDuration,
+ headerToolbar: identity,
+ footerToolbar: identity,
+ defaultRangeSeparator: String,
+ titleRangeSeparator: String,
+ forceEventDuration: Boolean,
+ dayHeaders: Boolean,
+ dayHeaderFormat: createFormatter,
+ dayHeaderClassNames: identity,
+ dayHeaderContent: identity,
+ dayHeaderDidMount: identity,
+ dayHeaderWillUnmount: identity,
+ dayCellClassNames: identity,
+ dayCellContent: identity,
+ dayCellDidMount: identity,
+ dayCellWillUnmount: identity,
+ initialView: String,
+ aspectRatio: Number,
+ weekends: Boolean,
+ weekNumberCalculation: identity,
+ weekNumbers: Boolean,
+ weekNumberClassNames: identity,
+ weekNumberContent: identity,
+ weekNumberDidMount: identity,
+ weekNumberWillUnmount: identity,
+ editable: Boolean,
+ viewClassNames: identity,
+ viewDidMount: identity,
+ viewWillUnmount: identity,
+ nowIndicator: Boolean,
+ nowIndicatorSnap: identity,
+ nowIndicatorClassNames: identity,
+ nowIndicatorContent: identity,
+ nowIndicatorDidMount: identity,
+ nowIndicatorWillUnmount: identity,
+ showNonCurrentDates: Boolean,
+ lazyFetching: Boolean,
+ startParam: String,
+ endParam: String,
+ timeZoneParam: String,
+ timeZone: String,
+ locales: identity,
+ locale: identity,
+ themeSystem: String,
+ dragRevertDuration: Number,
+ dragScroll: Boolean,
+ allDayMaintainDuration: Boolean,
+ unselectAuto: Boolean,
+ dropAccept: identity,
+ eventOrder: parseFieldSpecs,
+ eventOrderStrict: Boolean,
+ handleWindowResize: Boolean,
+ windowResizeDelay: Number,
+ longPressDelay: Number,
+ eventDragMinDistance: Number,
+ expandRows: Boolean,
+ height: identity,
+ contentHeight: identity,
+ direction: String,
+ weekNumberFormat: createFormatter,
+ eventResizableFromStart: Boolean,
+ displayEventTime: Boolean,
+ displayEventEnd: Boolean,
+ weekText: String,
+ weekTextLong: String,
+ progressiveEventRendering: Boolean,
+ businessHours: identity,
+ initialDate: identity,
+ now: identity,
+ eventDataTransform: identity,
+ stickyHeaderDates: identity,
+ stickyFooterScrollbar: identity,
+ viewHeight: identity,
+ defaultAllDay: Boolean,
+ eventSourceFailure: identity,
+ eventSourceSuccess: identity,
+ eventDisplay: String,
+ eventStartEditable: Boolean,
+ eventDurationEditable: Boolean,
+ eventOverlap: identity,
+ eventConstraint: identity,
+ eventAllow: identity,
+ eventBackgroundColor: String,
+ eventBorderColor: String,
+ eventTextColor: String,
+ eventColor: String,
+ eventClassNames: identity,
+ eventContent: identity,
+ eventDidMount: identity,
+ eventWillUnmount: identity,
+ selectConstraint: identity,
+ selectOverlap: identity,
+ selectAllow: identity,
+ droppable: Boolean,
+ unselectCancel: String,
+ slotLabelFormat: identity,
+ slotLaneClassNames: identity,
+ slotLaneContent: identity,
+ slotLaneDidMount: identity,
+ slotLaneWillUnmount: identity,
+ slotLabelClassNames: identity,
+ slotLabelContent: identity,
+ slotLabelDidMount: identity,
+ slotLabelWillUnmount: identity,
+ dayMaxEvents: identity,
+ dayMaxEventRows: identity,
+ dayMinWidth: Number,
+ slotLabelInterval: createDuration,
+ allDayText: String,
+ allDayClassNames: identity,
+ allDayContent: identity,
+ allDayDidMount: identity,
+ allDayWillUnmount: identity,
+ slotMinWidth: Number,
+ navLinks: Boolean,
+ eventTimeFormat: createFormatter,
+ rerenderDelay: Number,
+ moreLinkText: identity,
+ moreLinkHint: identity,
+ selectMinDistance: Number,
+ selectable: Boolean,
+ selectLongPressDelay: Number,
+ eventLongPressDelay: Number,
+ selectMirror: Boolean,
+ eventMaxStack: Number,
+ eventMinHeight: Number,
+ eventMinWidth: Number,
+ eventShortHeight: Number,
+ slotEventOverlap: Boolean,
+ plugins: identity,
+ firstDay: Number,
+ dayCount: Number,
+ dateAlignment: String,
+ dateIncrement: createDuration,
+ hiddenDays: identity,
+ fixedWeekCount: Boolean,
+ validRange: identity,
+ visibleRange: identity,
+ titleFormat: identity,
+ eventInteractive: Boolean,
+ noEventsText: String,
+ viewHint: identity,
+ navLinkHint: identity,
+ closeHint: String,
+ timeHint: String,
+ eventHint: String,
+ moreLinkClick: identity,
+ moreLinkClassNames: identity,
+ moreLinkContent: identity,
+ moreLinkDidMount: identity,
+ moreLinkWillUnmount: identity,
+ monthStartFormat: createFormatter,
+ handleCustomRendering: identity,
+ customRenderingMetaMap: identity,
+ customRenderingReplaces: Boolean,
+ };
+ const BASE_OPTION_DEFAULTS = {
+ eventDisplay: 'auto',
+ defaultRangeSeparator: ' - ',
+ titleRangeSeparator: ' \u2013 ',
+ defaultTimedEventDuration: '01:00:00',
+ defaultAllDayEventDuration: { day: 1 },
+ forceEventDuration: false,
+ nextDayThreshold: '00:00:00',
+ dayHeaders: true,
+ initialView: '',
+ aspectRatio: 1.35,
+ headerToolbar: {
+ start: 'title',
+ center: '',
+ end: 'today prev,next',
+ },
+ weekends: true,
+ weekNumbers: false,
+ weekNumberCalculation: 'local',
+ editable: false,
+ nowIndicator: false,
+ scrollTime: '06:00:00',
+ scrollTimeReset: true,
+ slotMinTime: '00:00:00',
+ slotMaxTime: '24:00:00',
+ showNonCurrentDates: true,
+ lazyFetching: true,
+ startParam: 'start',
+ endParam: 'end',
+ timeZoneParam: 'timeZone',
+ timeZone: 'local',
+ locales: [],
+ locale: '',
+ themeSystem: 'standard',
+ dragRevertDuration: 500,
+ dragScroll: true,
+ allDayMaintainDuration: false,
+ unselectAuto: true,
+ dropAccept: '*',
+ eventOrder: 'start,-duration,allDay,title',
+ dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
+ handleWindowResize: true,
+ windowResizeDelay: 100,
+ longPressDelay: 1000,
+ eventDragMinDistance: 5,
+ expandRows: false,
+ navLinks: false,
+ selectable: false,
+ eventMinHeight: 15,
+ eventMinWidth: 30,
+ eventShortHeight: 30,
+ monthStartFormat: { month: 'long', day: 'numeric' },
+ nowIndicatorSnap: 'auto',
+ };
+ const CALENDAR_LISTENER_REFINERS = {
+ datesSet: identity,
+ eventsSet: identity,
+ eventAdd: identity,
+ eventChange: identity,
+ eventRemove: identity,
+ windowResize: identity,
+ eventClick: identity,
+ eventMouseEnter: identity,
+ eventMouseLeave: identity,
+ select: identity,
+ unselect: identity,
+ loading: identity,
+ _unmount: identity,
+ _beforeprint: identity,
+ _afterprint: identity,
+ _noEventDrop: identity,
+ _noEventResize: identity,
+ _resize: identity,
+ _scrollRequest: identity,
+ };
+ const CALENDAR_OPTION_REFINERS = {
+ buttonText: identity,
+ buttonHints: identity,
+ views: identity,
+ plugins: identity,
+ initialEvents: identity,
+ events: identity,
+ eventSources: identity,
+ };
+ const COMPLEX_OPTION_COMPARATORS = {
+ headerToolbar: isMaybeObjectsEqual,
+ footerToolbar: isMaybeObjectsEqual,
+ buttonText: isMaybeObjectsEqual,
+ buttonHints: isMaybeObjectsEqual,
+ buttonIcons: isMaybeObjectsEqual,
+ dateIncrement: isMaybeObjectsEqual,
+ plugins: isMaybeArraysEqual,
+ events: isMaybeArraysEqual,
+ eventSources: isMaybeArraysEqual,
+ ['resources']: isMaybeArraysEqual,
+ };
+ function isMaybeObjectsEqual(a, b) {
+ if (typeof a === 'object' && typeof b === 'object' && a && b) {
+ return isPropsEqual(a, b);
+ }
+ return a === b;
+ }
+ function isMaybeArraysEqual(a, b) {
+ if (Array.isArray(a) && Array.isArray(b)) {
+ return isArraysEqual(a, b);
+ }
+ return a === b;
+ }
+ const VIEW_OPTION_REFINERS = {
+ type: String,
+ component: identity,
+ buttonText: String,
+ buttonTextKey: String,
+ dateProfileGeneratorClass: identity,
+ usesMinMaxTime: Boolean,
+ classNames: identity,
+ content: identity,
+ didMount: identity,
+ willUnmount: identity,
+ };
+ function mergeRawOptions(optionSets) {
+ return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
+ }
+ function refineProps(input, refiners) {
+ let refined = {};
+ let extra = {};
+ for (let propName in refiners) {
+ if (propName in input) {
+ refined[propName] = refiners[propName](input[propName]);
+ }
+ }
+ for (let propName in input) {
+ if (!(propName in refiners)) {
+ extra[propName] = input[propName];
+ }
+ }
+ return { refined, extra };
+ }
+ function identity(raw) {
+ return raw;
+ }
+ const { hasOwnProperty } = Object.prototype;
+ function mergeProps(propObjs, complexPropsMap) {
+ let dest = {};
+ if (complexPropsMap) {
+ for (let name in complexPropsMap) {
+ if (complexPropsMap[name] === isMaybeObjectsEqual) {
+ let complexObjs = [];
+ for (let i = propObjs.length - 1; i >= 0; i -= 1) {
+ let val = propObjs[i][name];
+ if (typeof val === 'object' && val) {
+ complexObjs.unshift(val);
+ }
+ else if (val !== undefined) {
+ dest[name] = val;
+ break;
+ }
+ }
+ if (complexObjs.length) {
+ dest[name] = mergeProps(complexObjs);
+ }
+ }
+ }
+ }
+ for (let i = propObjs.length - 1; i >= 0; i -= 1) {
+ let props = propObjs[i];
+ for (let name in props) {
+ if (!(name in dest)) {
+ dest[name] = props[name];
+ }
+ }
+ }
+ return dest;
+ }
+ function filterHash(hash, func) {
+ let filtered = {};
+ for (let key in hash) {
+ if (func(hash[key], key)) {
+ filtered[key] = hash[key];
+ }
+ }
+ return filtered;
+ }
+ function mapHash(hash, func) {
+ let newHash = {};
+ for (let key in hash) {
+ newHash[key] = func(hash[key], key);
+ }
+ return newHash;
+ }
+ function arrayToHash(a) {
+ let hash = {};
+ for (let item of a) {
+ hash[item] = true;
+ }
+ return hash;
+ }
+ function hashValuesToArray(obj) {
+ let a = [];
+ for (let key in obj) {
+ a.push(obj[key]);
+ }
+ return a;
+ }
+ function isPropsEqual(obj0, obj1) {
+ if (obj0 === obj1) {
+ return true;
+ }
+ for (let key in obj0) {
+ if (hasOwnProperty.call(obj0, key)) {
+ if (!(key in obj1)) {
+ return false;
+ }
+ }
+ }
+ for (let key in obj1) {
+ if (hasOwnProperty.call(obj1, key)) {
+ if (obj0[key] !== obj1[key]) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ const HANDLER_RE = /^on[A-Z]/;
+ function isNonHandlerPropsEqual(obj0, obj1) {
+ const keys = getUnequalProps(obj0, obj1);
+ for (let key of keys) {
+ if (!HANDLER_RE.test(key)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ function getUnequalProps(obj0, obj1) {
+ let keys = [];
+ for (let key in obj0) {
+ if (hasOwnProperty.call(obj0, key)) {
+ if (!(key in obj1)) {
+ keys.push(key);
+ }
+ }
+ }
+ for (let key in obj1) {
+ if (hasOwnProperty.call(obj1, key)) {
+ if (obj0[key] !== obj1[key]) {
+ keys.push(key);
+ }
+ }
+ }
+ return keys;
+ }
+ function compareObjs(oldProps, newProps, equalityFuncs = {}) {
+ if (oldProps === newProps) {
+ return true;
+ }
+ for (let key in newProps) {
+ if (key in oldProps && isObjValsEqual(oldProps[key], newProps[key], equalityFuncs[key])) ;
+ else {
+ return false;
+ }
+ }
+ for (let key in oldProps) {
+ if (!(key in newProps)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ function isObjValsEqual(val0, val1, comparator) {
+ if (val0 === val1 || comparator === true) {
+ return true;
+ }
+ if (comparator) {
+ return comparator(val0, val1);
+ }
+ return false;
+ }
+ function collectFromHash(hash, startIndex = 0, endIndex, step = 1) {
+ let res = [];
+ if (endIndex == null) {
+ endIndex = Object.keys(hash).length;
+ }
+ for (let i = startIndex; i < endIndex; i += step) {
+ let val = hash[i];
+ if (val !== undefined) {
+ res.push(val);
+ }
+ }
+ return res;
+ }
+ let calendarSystemClassMap = {};
+ function registerCalendarSystem(name, theClass) {
+ calendarSystemClassMap[name] = theClass;
+ }
+ function createCalendarSystem(name) {
+ return new calendarSystemClassMap[name]();
+ }
+ class GregorianCalendarSystem {
+ getMarkerYear(d) {
+ return d.getUTCFullYear();
+ }
+ getMarkerMonth(d) {
+ return d.getUTCMonth();
+ }
+ getMarkerDay(d) {
+ return d.getUTCDate();
+ }
+ arrayToMarker(arr) {
+ return arrayToUtcDate(arr);
+ }
+ markerToArray(marker) {
+ return dateToUtcArray(marker);
+ }
+ }
+ registerCalendarSystem('gregory', GregorianCalendarSystem);
+ const ISO_RE = /^\s*(\d{4})(-?(\d{2})(-?(\d{2})([T ](\d{2}):?(\d{2})(:?(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
+ function parse(str) {
+ let m = ISO_RE.exec(str);
+ if (m) {
+ let marker = new Date(Date.UTC(Number(m[1]), m[3] ? Number(m[3]) - 1 : 0, Number(m[5] || 1), Number(m[7] || 0), Number(m[8] || 0), Number(m[10] || 0), m[12] ? Number(`0.${m[12]}`) * 1000 : 0));
+ if (isValidDate(marker)) {
+ let timeZoneOffset = null;
+ if (m[13]) {
+ timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
+ Number(m[18] || 0));
+ }
+ return {
+ marker,
+ isTimeUnspecified: !m[6],
+ timeZoneOffset,
+ };
+ }
+ }
+ return null;
+ }
+ class DateEnv {
+ constructor(settings) {
+ let timeZone = this.timeZone = settings.timeZone;
+ let isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
+ if (settings.namedTimeZoneImpl && isNamedTimeZone) {
+ this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
+ }
+ this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
+ this.calendarSystem = createCalendarSystem(settings.calendarSystem);
+ this.locale = settings.locale;
+ this.weekDow = settings.locale.week.dow;
+ this.weekDoy = settings.locale.week.doy;
+ if (settings.weekNumberCalculation === 'ISO') {
+ this.weekDow = 1;
+ this.weekDoy = 4;
+ }
+ if (typeof settings.firstDay === 'number') {
+ this.weekDow = settings.firstDay;
+ }
+ if (typeof settings.weekNumberCalculation === 'function') {
+ this.weekNumberFunc = settings.weekNumberCalculation;
+ }
+ this.weekText = settings.weekText != null ? settings.weekText : settings.locale.options.weekText;
+ this.weekTextLong = (settings.weekTextLong != null ? settings.weekTextLong : settings.locale.options.weekTextLong) || this.weekText;
+ this.cmdFormatter = settings.cmdFormatter;
+ this.defaultSeparator = settings.defaultSeparator;
+ }
+ createMarker(input) {
+ let meta = this.createMarkerMeta(input);
+ if (meta === null) {
+ return null;
+ }
+ return meta.marker;
+ }
+ createNowMarker() {
+ if (this.canComputeOffset) {
+ return this.timestampToMarker(new Date().valueOf());
+ }
+ return arrayToUtcDate(dateToLocalArray(new Date()));
+ }
+ createMarkerMeta(input) {
+ if (typeof input === 'string') {
+ return this.parse(input);
+ }
+ let marker = null;
+ if (typeof input === 'number') {
+ marker = this.timestampToMarker(input);
+ }
+ else if (input instanceof Date) {
+ input = input.valueOf();
+ if (!isNaN(input)) {
+ marker = this.timestampToMarker(input);
+ }
+ }
+ else if (Array.isArray(input)) {
+ marker = arrayToUtcDate(input);
+ }
+ if (marker === null || !isValidDate(marker)) {
+ return null;
+ }
+ return { marker, isTimeUnspecified: false, forcedTzo: null };
+ }
+ parse(s) {
+ let parts = parse(s);
+ if (parts === null) {
+ return null;
+ }
+ let { marker } = parts;
+ let forcedTzo = null;
+ if (parts.timeZoneOffset !== null) {
+ if (this.canComputeOffset) {
+ marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
+ }
+ else {
+ forcedTzo = parts.timeZoneOffset;
+ }
+ }
+ return { marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo };
+ }
+ getYear(marker) {
+ return this.calendarSystem.getMarkerYear(marker);
+ }
+ getMonth(marker) {
+ return this.calendarSystem.getMarkerMonth(marker);
+ }
+ getDay(marker) {
+ return this.calendarSystem.getMarkerDay(marker);
+ }
+ add(marker, dur) {
+ let a = this.calendarSystem.markerToArray(marker);
+ a[0] += dur.years;
+ a[1] += dur.months;
+ a[2] += dur.days;
+ a[6] += dur.milliseconds;
+ return this.calendarSystem.arrayToMarker(a);
+ }
+ subtract(marker, dur) {
+ let a = this.calendarSystem.markerToArray(marker);
+ a[0] -= dur.years;
+ a[1] -= dur.months;
+ a[2] -= dur.days;
+ a[6] -= dur.milliseconds;
+ return this.calendarSystem.arrayToMarker(a);
+ }
+ addYears(marker, n) {
+ let a = this.calendarSystem.markerToArray(marker);
+ a[0] += n;
+ return this.calendarSystem.arrayToMarker(a);
+ }
+ addMonths(marker, n) {
+ let a = this.calendarSystem.markerToArray(marker);
+ a[1] += n;
+ return this.calendarSystem.arrayToMarker(a);
+ }
+ diffWholeYears(m0, m1) {
+ let { calendarSystem } = this;
+ if (timeAsMs(m0) === timeAsMs(m1) &&
+ calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
+ calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
+ return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
+ }
+ return null;
+ }
+ diffWholeMonths(m0, m1) {
+ let { calendarSystem } = this;
+ if (timeAsMs(m0) === timeAsMs(m1) &&
+ calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
+ return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
+ (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
+ }
+ return null;
+ }
+ greatestWholeUnit(m0, m1) {
+ let n = this.diffWholeYears(m0, m1);
+ if (n !== null) {
+ return { unit: 'year', value: n };
+ }
+ n = this.diffWholeMonths(m0, m1);
+ if (n !== null) {
+ return { unit: 'month', value: n };
+ }
+ n = diffWholeWeeks(m0, m1);
+ if (n !== null) {
+ return { unit: 'week', value: n };
+ }
+ n = diffWholeDays(m0, m1);
+ if (n !== null) {
+ return { unit: 'day', value: n };
+ }
+ n = diffHours(m0, m1);
+ if (isInt(n)) {
+ return { unit: 'hour', value: n };
+ }
+ n = diffMinutes(m0, m1);
+ if (isInt(n)) {
+ return { unit: 'minute', value: n };
+ }
+ n = diffSeconds(m0, m1);
+ if (isInt(n)) {
+ return { unit: 'second', value: n };
+ }
+ return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
+ }
+ countDurationsBetween(m0, m1, d) {
+ let diff;
+ if (d.years) {
+ diff = this.diffWholeYears(m0, m1);
+ if (diff !== null) {
+ return diff / asRoughYears(d);
+ }
+ }
+ if (d.months) {
+ diff = this.diffWholeMonths(m0, m1);
+ if (diff !== null) {
+ return diff / asRoughMonths(d);
+ }
+ }
+ if (d.days) {
+ diff = diffWholeDays(m0, m1);
+ if (diff !== null) {
+ return diff / asRoughDays(d);
+ }
+ }
+ return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
+ }
+ startOf(m, unit) {
+ if (unit === 'year') {
+ return this.startOfYear(m);
+ }
+ if (unit === 'month') {
+ return this.startOfMonth(m);
+ }
+ if (unit === 'week') {
+ return this.startOfWeek(m);
+ }
+ if (unit === 'day') {
+ return startOfDay(m);
+ }
+ if (unit === 'hour') {
+ return startOfHour(m);
+ }
+ if (unit === 'minute') {
+ return startOfMinute(m);
+ }
+ if (unit === 'second') {
+ return startOfSecond(m);
+ }
+ return null;
+ }
+ startOfYear(m) {
+ return this.calendarSystem.arrayToMarker([
+ this.calendarSystem.getMarkerYear(m),
+ ]);
+ }
+ startOfMonth(m) {
+ return this.calendarSystem.arrayToMarker([
+ this.calendarSystem.getMarkerYear(m),
+ this.calendarSystem.getMarkerMonth(m),
+ ]);
+ }
+ startOfWeek(m) {
+ return this.calendarSystem.arrayToMarker([
+ this.calendarSystem.getMarkerYear(m),
+ this.calendarSystem.getMarkerMonth(m),
+ m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7),
+ ]);
+ }
+ computeWeekNumber(marker) {
+ if (this.weekNumberFunc) {
+ return this.weekNumberFunc(this.toDate(marker));
+ }
+ return weekOfYear(marker, this.weekDow, this.weekDoy);
+ }
+ format(marker, formatter, dateOptions = {}) {
+ return formatter.format({
+ marker,
+ timeZoneOffset: dateOptions.forcedTzo != null ?
+ dateOptions.forcedTzo :
+ this.offsetForMarker(marker),
+ }, this);
+ }
+ formatRange(start, end, formatter, dateOptions = {}) {
+ if (dateOptions.isEndExclusive) {
+ end = addMs(end, -1);
+ }
+ return formatter.formatRange({
+ marker: start,
+ timeZoneOffset: dateOptions.forcedStartTzo != null ?
+ dateOptions.forcedStartTzo :
+ this.offsetForMarker(start),
+ }, {
+ marker: end,
+ timeZoneOffset: dateOptions.forcedEndTzo != null ?
+ dateOptions.forcedEndTzo :
+ this.offsetForMarker(end),
+ }, this, dateOptions.defaultSeparator);
+ }
+ formatIso(marker, extraOptions = {}) {
+ let timeZoneOffset = null;
+ if (!extraOptions.omitTimeZoneOffset) {
+ if (extraOptions.forcedTzo != null) {
+ timeZoneOffset = extraOptions.forcedTzo;
+ }
+ else {
+ timeZoneOffset = this.offsetForMarker(marker);
+ }
+ }
+ return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
+ }
+ timestampToMarker(ms) {
+ if (this.timeZone === 'local') {
+ return arrayToUtcDate(dateToLocalArray(new Date(ms)));
+ }
+ if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
+ return new Date(ms);
+ }
+ return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
+ }
+ offsetForMarker(m) {
+ if (this.timeZone === 'local') {
+ return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset();
+ }
+ if (this.timeZone === 'UTC') {
+ return 0;
+ }
+ if (this.namedTimeZoneImpl) {
+ return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
+ }
+ return null;
+ }
+ toDate(m, forcedTzo) {
+ if (this.timeZone === 'local') {
+ return arrayToLocalDate(dateToUtcArray(m));
+ }
+ if (this.timeZone === 'UTC') {
+ return new Date(m.valueOf());
+ }
+ if (!this.namedTimeZoneImpl) {
+ return new Date(m.valueOf() - (forcedTzo || 0));
+ }
+ return new Date(m.valueOf() -
+ this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60);
+ }
+ }
+ class Theme {
+ constructor(calendarOptions) {
+ if (this.iconOverrideOption) {
+ this.setIconOverride(calendarOptions[this.iconOverrideOption]);
+ }
+ }
+ setIconOverride(iconOverrideHash) {
+ let iconClassesCopy;
+ let buttonName;
+ if (typeof iconOverrideHash === 'object' && iconOverrideHash) {
+ iconClassesCopy = Object.assign({}, this.iconClasses);
+ for (buttonName in iconOverrideHash) {
+ iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
+ }
+ this.iconClasses = iconClassesCopy;
+ }
+ else if (iconOverrideHash === false) {
+ this.iconClasses = {};
+ }
+ }
+ applyIconOverridePrefix(className) {
+ let prefix = this.iconOverridePrefix;
+ if (prefix && className.indexOf(prefix) !== 0) {
+ className = prefix + className;
+ }
+ return className;
+ }
+ getClass(key) {
+ return this.classes[key] || '';
+ }
+ getIconClass(buttonName, isRtl) {
+ let className;
+ if (isRtl && this.rtlIconClasses) {
+ className = this.rtlIconClasses[buttonName] || this.iconClasses[buttonName];
+ }
+ else {
+ className = this.iconClasses[buttonName];
+ }
+ if (className) {
+ return `${this.baseIconClass} ${className}`;
+ }
+ return '';
+ }
+ getCustomButtonIconClass(customButtonProps) {
+ let className;
+ if (this.iconOverrideCustomButtonOption) {
+ className = customButtonProps[this.iconOverrideCustomButtonOption];
+ if (className) {
+ return `${this.baseIconClass} ${this.applyIconOverridePrefix(className)}`;
+ }
+ }
+ return '';
+ }
+ }
+ Theme.prototype.classes = {};
+ Theme.prototype.iconClasses = {};
+ Theme.prototype.baseIconClass = '';
+ Theme.prototype.iconOverridePrefix = '';
+ function flushSync(runBeforeFlush) {
+ runBeforeFlush();
+ let oldDebounceRendering = l$1.debounceRendering;
+ let callbackQ = [];
+ function execCallbackSync(callback) {
+ callbackQ.push(callback);
+ }
+ l$1.debounceRendering = execCallbackSync;
+ D$1(y(FakeComponent, {}), document.createElement('div'));
+ while (callbackQ.length) {
+ callbackQ.shift()();
+ }
+ l$1.debounceRendering = oldDebounceRendering;
+ }
+ class FakeComponent extends x$1 {
+ render() { return y('div', {}); }
+ componentDidMount() { this.setState({}); }
+ }
+ function createContext(defaultValue) {
+ let ContextType = G$1(defaultValue);
+ let origProvider = ContextType.Provider;
+ ContextType.Provider = function () {
+ let isNew = !this.getChildContext;
+ let children = origProvider.apply(this, arguments);
+ if (isNew) {
+ let subs = [];
+ this.shouldComponentUpdate = (_props) => {
+ if (this.props.value !== _props.value) {
+ subs.forEach((c) => {
+ c.context = _props.value;
+ c.forceUpdate();
+ });
+ }
+ };
+ this.sub = (c) => {
+ subs.push(c);
+ let old = c.componentWillUnmount;
+ c.componentWillUnmount = () => {
+ subs.splice(subs.indexOf(c), 1);
+ old && old.call(c);
+ };
+ };
+ }
+ return children;
+ };
+ return ContextType;
+ }
+ class ScrollResponder {
+ constructor(execFunc, emitter, scrollTime, scrollTimeReset) {
+ this.execFunc = execFunc;
+ this.emitter = emitter;
+ this.scrollTime = scrollTime;
+ this.scrollTimeReset = scrollTimeReset;
+ this.handleScrollRequest = (request) => {
+ this.queuedRequest = Object.assign({}, this.queuedRequest || {}, request);
+ this.drain();
+ };
+ emitter.on('_scrollRequest', this.handleScrollRequest);
+ this.fireInitialScroll();
+ }
+ detach() {
+ this.emitter.off('_scrollRequest', this.handleScrollRequest);
+ }
+ update(isDatesNew) {
+ if (isDatesNew && this.scrollTimeReset) {
+ this.fireInitialScroll();
+ }
+ else {
+ this.drain();
+ }
+ }
+ fireInitialScroll() {
+ this.handleScrollRequest({
+ time: this.scrollTime,
+ });
+ }
+ drain() {
+ if (this.queuedRequest && this.execFunc(this.queuedRequest)) {
+ this.queuedRequest = null;
+ }
+ }
+ }
+ const ViewContextType = createContext({});
+ function buildViewContext(viewSpec, viewApi, viewOptions, dateProfileGenerator, dateEnv, nowManager, theme, pluginHooks, dispatch, getCurrentData, emitter, calendarApi, registerInteractiveComponent, unregisterInteractiveComponent) {
+ return {
+ dateEnv,
+ nowManager,
+ options: viewOptions,
+ pluginHooks,
+ emitter,
+ dispatch,
+ getCurrentData,
+ calendarApi,
+ viewSpec,
+ viewApi,
+ dateProfileGenerator,
+ theme,
+ isRtl: viewOptions.direction === 'rtl',
+ addResizeHandler(handler) {
+ emitter.on('_resize', handler);
+ },
+ removeResizeHandler(handler) {
+ emitter.off('_resize', handler);
+ },
+ createScrollResponder(execFunc) {
+ return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime), viewOptions.scrollTimeReset);
+ },
+ registerInteractiveComponent,
+ unregisterInteractiveComponent,
+ };
+ }
+ class PureComponent extends x$1 {
+ shouldComponentUpdate(nextProps, nextState) {
+ const shouldUpdate = !compareObjs(this.props, nextProps, this.propEquality ) ||
+ !compareObjs(this.state, nextState, this.stateEquality );
+ return shouldUpdate;
+ }
+ safeSetState(newState) {
+ if (!compareObjs(this.state, Object.assign(Object.assign({}, this.state), newState), this.stateEquality)) {
+ this.setState(newState);
+ }
+ }
+ }
+ PureComponent.addPropsEquality = addPropsEquality;
+ PureComponent.addStateEquality = addStateEquality;
+ PureComponent.contextType = ViewContextType;
+ PureComponent.prototype.propEquality = {};
+ PureComponent.prototype.stateEquality = {};
+ class BaseComponent extends PureComponent {
+ }
+ BaseComponent.contextType = ViewContextType;
+ function addPropsEquality(propEquality) {
+ let hash = Object.create(this.prototype.propEquality);
+ Object.assign(hash, propEquality);
+ this.prototype.propEquality = hash;
+ }
+ function addStateEquality(stateEquality) {
+ let hash = Object.create(this.prototype.stateEquality);
+ Object.assign(hash, stateEquality);
+ this.prototype.stateEquality = hash;
+ }
+ function setRef(ref, current) {
+ if (typeof ref === 'function') {
+ ref(current);
+ }
+ else if (ref) {
+ ref.current = current;
+ }
+ }
+ class ContentInjector extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.id = guid();
+ this.queuedDomNodes = [];
+ this.currentDomNodes = [];
+ this.handleEl = (el) => {
+ const { options } = this.context;
+ const { generatorName } = this.props;
+ if (!options.customRenderingReplaces || !hasCustomRenderingHandler(generatorName, options)) {
+ this.updateElRef(el);
+ }
+ };
+ this.updateElRef = (el) => {
+ if (this.props.elRef) {
+ setRef(this.props.elRef, el);
+ }
+ };
+ }
+ render() {
+ const { props, context } = this;
+ const { options } = context;
+ const { customGenerator, defaultGenerator, renderProps } = props;
+ const attrs = buildElAttrs(props, [], this.handleEl);
+ let useDefault = false;
+ let innerContent;
+ let queuedDomNodes = [];
+ let currentGeneratorMeta;
+ if (customGenerator != null) {
+ const customGeneratorRes = typeof customGenerator === 'function' ?
+ customGenerator(renderProps, y) :
+ customGenerator;
+ if (customGeneratorRes === true) {
+ useDefault = true;
+ }
+ else {
+ const isObject = customGeneratorRes && typeof customGeneratorRes === 'object';
+ if (isObject && ('html' in customGeneratorRes)) {
+ attrs.dangerouslySetInnerHTML = { __html: customGeneratorRes.html };
+ }
+ else if (isObject && ('domNodes' in customGeneratorRes)) {
+ queuedDomNodes = Array.prototype.slice.call(customGeneratorRes.domNodes);
+ }
+ else if (isObject
+ ? i$1(customGeneratorRes)
+ : typeof customGeneratorRes !== 'function'
+ ) {
+ innerContent = customGeneratorRes;
+ }
+ else {
+ currentGeneratorMeta = customGeneratorRes;
+ }
+ }
+ }
+ else {
+ useDefault = !hasCustomRenderingHandler(props.generatorName, options);
+ }
+ if (useDefault && defaultGenerator) {
+ innerContent = defaultGenerator(renderProps);
+ }
+ this.queuedDomNodes = queuedDomNodes;
+ this.currentGeneratorMeta = currentGeneratorMeta;
+ return y(props.elTag, attrs, innerContent);
+ }
+ componentDidMount() {
+ this.applyQueueudDomNodes();
+ this.triggerCustomRendering(true);
+ }
+ componentDidUpdate() {
+ this.applyQueueudDomNodes();
+ this.triggerCustomRendering(true);
+ }
+ componentWillUnmount() {
+ this.triggerCustomRendering(false);
+ }
+ triggerCustomRendering(isActive) {
+ var _a;
+ const { props, context } = this;
+ const { handleCustomRendering, customRenderingMetaMap } = context.options;
+ if (handleCustomRendering) {
+ const generatorMeta = (_a = this.currentGeneratorMeta) !== null && _a !== void 0 ? _a : customRenderingMetaMap === null || customRenderingMetaMap === void 0 ? void 0 : customRenderingMetaMap[props.generatorName];
+ if (generatorMeta) {
+ handleCustomRendering(Object.assign(Object.assign({ id: this.id, isActive, containerEl: this.base, reportNewContainerEl: this.updateElRef,
+ generatorMeta }, props), { elClasses: (props.elClasses || []).filter(isTruthy) }));
+ }
+ }
+ }
+ applyQueueudDomNodes() {
+ const { queuedDomNodes, currentDomNodes } = this;
+ const el = this.base;
+ if (!isArraysEqual(queuedDomNodes, currentDomNodes)) {
+ currentDomNodes.forEach(removeElement);
+ for (let newNode of queuedDomNodes) {
+ el.appendChild(newNode);
+ }
+ this.currentDomNodes = queuedDomNodes;
+ }
+ }
+ }
+ ContentInjector.addPropsEquality({
+ elClasses: isArraysEqual,
+ elStyle: isPropsEqual,
+ elAttrs: isNonHandlerPropsEqual,
+ renderProps: isPropsEqual,
+ });
+ function hasCustomRenderingHandler(generatorName, options) {
+ var _a;
+ return Boolean(options.handleCustomRendering &&
+ generatorName &&
+ ((_a = options.customRenderingMetaMap) === null || _a === void 0 ? void 0 : _a[generatorName]));
+ }
+ function buildElAttrs(props, extraClassNames, elRef) {
+ const attrs = Object.assign(Object.assign({}, props.elAttrs), { ref: elRef });
+ if (props.elClasses || extraClassNames) {
+ attrs.className = (props.elClasses || [])
+ .concat(extraClassNames || [])
+ .concat(attrs.className || [])
+ .filter(Boolean)
+ .join(' ');
+ }
+ if (props.elStyle) {
+ attrs.style = props.elStyle;
+ }
+ return attrs;
+ }
+ function isTruthy(val) {
+ return Boolean(val);
+ }
+ const RenderId = createContext(0);
+ class ContentContainer extends x$1 {
+ constructor() {
+ super(...arguments);
+ this.InnerContent = InnerContentInjector.bind(undefined, this);
+ this.handleEl = (el) => {
+ this.el = el;
+ if (this.props.elRef) {
+ setRef(this.props.elRef, el);
+ if (el && this.didMountMisfire) {
+ this.componentDidMount();
+ }
+ }
+ };
+ }
+ render() {
+ const { props } = this;
+ const generatedClassNames = generateClassNames(props.classNameGenerator, props.renderProps);
+ if (props.children) {
+ const elAttrs = buildElAttrs(props, generatedClassNames, this.handleEl);
+ const children = props.children(this.InnerContent, props.renderProps, elAttrs);
+ if (props.elTag) {
+ return y(props.elTag, elAttrs, children);
+ }
+ else {
+ return children;
+ }
+ }
+ else {
+ return y((ContentInjector), Object.assign(Object.assign({}, props), { elRef: this.handleEl, elTag: props.elTag || 'div', elClasses: (props.elClasses || []).concat(generatedClassNames), renderId: this.context }));
+ }
+ }
+ componentDidMount() {
+ var _a, _b;
+ if (this.el) {
+ (_b = (_a = this.props).didMount) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign(Object.assign({}, this.props.renderProps), { el: this.el }));
+ }
+ else {
+ this.didMountMisfire = true;
+ }
+ }
+ componentWillUnmount() {
+ var _a, _b;
+ (_b = (_a = this.props).willUnmount) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign(Object.assign({}, this.props.renderProps), { el: this.el }));
+ }
+ }
+ ContentContainer.contextType = RenderId;
+ function InnerContentInjector(containerComponent, props) {
+ const parentProps = containerComponent.props;
+ return y((ContentInjector), Object.assign({ renderProps: parentProps.renderProps, generatorName: parentProps.generatorName, customGenerator: parentProps.customGenerator, defaultGenerator: parentProps.defaultGenerator, renderId: containerComponent.context }, props));
+ }
+ function generateClassNames(classNameGenerator, renderProps) {
+ const classNames = typeof classNameGenerator === 'function' ?
+ classNameGenerator(renderProps) :
+ classNameGenerator || [];
+ return typeof classNames === 'string' ? [classNames] : classNames;
+ }
+ class ViewContainer extends BaseComponent {
+ render() {
+ let { props, context } = this;
+ let { options } = context;
+ let renderProps = { view: context.viewApi };
+ return (y(ContentContainer, { elRef: props.elRef, elTag: props.elTag || 'div', elAttrs: props.elAttrs, elClasses: [
+ ...buildViewClassNames(props.viewSpec),
+ ...(props.elClasses || []),
+ ], elStyle: props.elStyle, renderProps: renderProps, classNameGenerator: options.viewClassNames, generatorName: undefined, didMount: options.viewDidMount, willUnmount: options.viewWillUnmount }, () => props.children));
+ }
+ }
+ function buildViewClassNames(viewSpec) {
+ return [
+ `fc-${viewSpec.type}-view`,
+ 'fc-view',
+ ];
+ }
+ function parseRange(input, dateEnv) {
+ let start = null;
+ let end = null;
+ if (input.start) {
+ start = dateEnv.createMarker(input.start);
+ }
+ if (input.end) {
+ end = dateEnv.createMarker(input.end);
+ }
+ if (!start && !end) {
+ return null;
+ }
+ if (start && end && end < start) {
+ return null;
+ }
+ return { start, end };
+ }
+ function invertRanges(ranges, constraintRange) {
+ let invertedRanges = [];
+ let { start } = constraintRange;
+ let i;
+ let dateRange;
+ ranges.sort(compareRanges);
+ for (i = 0; i < ranges.length; i += 1) {
+ dateRange = ranges[i];
+ if (dateRange.start > start) {
+ invertedRanges.push({ start, end: dateRange.start });
+ }
+ if (dateRange.end > start) {
+ start = dateRange.end;
+ }
+ }
+ if (start < constraintRange.end) {
+ invertedRanges.push({ start, end: constraintRange.end });
+ }
+ return invertedRanges;
+ }
+ function compareRanges(range0, range1) {
+ return range0.start.valueOf() - range1.start.valueOf();
+ }
+ function intersectRanges(range0, range1) {
+ let { start, end } = range0;
+ let newRange = null;
+ if (range1.start !== null) {
+ if (start === null) {
+ start = range1.start;
+ }
+ else {
+ start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
+ }
+ }
+ if (range1.end != null) {
+ if (end === null) {
+ end = range1.end;
+ }
+ else {
+ end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
+ }
+ }
+ if (start === null || end === null || start < end) {
+ newRange = { start, end };
+ }
+ return newRange;
+ }
+ function rangesEqual(range0, range1) {
+ return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
+ (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
+ }
+ function rangesIntersect(range0, range1) {
+ return (range0.end === null || range1.start === null || range0.end > range1.start) &&
+ (range0.start === null || range1.end === null || range0.start < range1.end);
+ }
+ function rangeContainsRange(outerRange, innerRange) {
+ return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
+ (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
+ }
+ function rangeContainsMarker(range, date) {
+ return (range.start === null || date >= range.start) &&
+ (range.end === null || date < range.end);
+ }
+ function constrainMarkerToRange(date, range) {
+ if (range.start != null && date < range.start) {
+ return range.start;
+ }
+ if (range.end != null && date >= range.end) {
+ return new Date(range.end.valueOf() - 1);
+ }
+ return date;
+ }
+ function computeAlignedDayRange(timedRange) {
+ let dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
+ let start = startOfDay(timedRange.start);
+ let end = addDays(start, dayCnt);
+ return { start, end };
+ }
+ function computeVisibleDayRange(timedRange, nextDayThreshold = createDuration(0)) {
+ let startDay = null;
+ let endDay = null;
+ if (timedRange.end) {
+ endDay = startOfDay(timedRange.end);
+ let endTimeMS = timedRange.end.valueOf() - endDay.valueOf();
+ if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
+ endDay = addDays(endDay, 1);
+ }
+ }
+ if (timedRange.start) {
+ startDay = startOfDay(timedRange.start);
+ if (endDay && endDay <= startDay) {
+ endDay = addDays(startDay, 1);
+ }
+ }
+ return { start: startDay, end: endDay };
+ }
+ function isMultiDayRange(range) {
+ let visibleRange = computeVisibleDayRange(range);
+ return diffDays(visibleRange.start, visibleRange.end) > 1;
+ }
+ function diffDates(date0, date1, dateEnv, largeUnit) {
+ if (largeUnit === 'year') {
+ return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
+ }
+ if (largeUnit === 'month') {
+ return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
+ }
+ return diffDayAndTime(date0, date1);
+ }
+ class DateProfileGenerator {
+ constructor(props) {
+ this.props = props;
+ this.initHiddenDays();
+ }
+ buildPrev(currentDateProfile, currentDate, forceToValid) {
+ let { dateEnv } = this.props;
+ let prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit),
+ currentDateProfile.dateIncrement);
+ return this.build(prevDate, -1, forceToValid);
+ }
+ buildNext(currentDateProfile, currentDate, forceToValid) {
+ let { dateEnv } = this.props;
+ let nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit),
+ currentDateProfile.dateIncrement);
+ return this.build(nextDate, 1, forceToValid);
+ }
+ build(currentDate, direction, forceToValid = true) {
+ let { props } = this;
+ let validRange;
+ let currentInfo;
+ let isRangeAllDay;
+ let renderRange;
+ let activeRange;
+ let isValid;
+ validRange = this.buildValidRange();
+ validRange = this.trimHiddenDays(validRange);
+ if (forceToValid) {
+ currentDate = constrainMarkerToRange(currentDate, validRange);
+ }
+ currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
+ isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
+ renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
+ renderRange = this.trimHiddenDays(renderRange);
+ activeRange = renderRange;
+ if (!props.showNonCurrentDates) {
+ activeRange = intersectRanges(activeRange, currentInfo.range);
+ }
+ activeRange = this.adjustActiveRange(activeRange);
+ activeRange = intersectRanges(activeRange, validRange);
+ isValid = rangesIntersect(currentInfo.range, validRange);
+ if (!rangeContainsMarker(renderRange, currentDate)) {
+ currentDate = renderRange.start;
+ }
+ return {
+ currentDate,
+ validRange,
+ currentRange: currentInfo.range,
+ currentRangeUnit: currentInfo.unit,
+ isRangeAllDay,
+ activeRange,
+ renderRange,
+ slotMinTime: props.slotMinTime,
+ slotMaxTime: props.slotMaxTime,
+ isValid,
+ dateIncrement: this.buildDateIncrement(currentInfo.duration),
+ };
+ }
+ buildValidRange() {
+ let input = this.props.validRangeInput;
+ let simpleInput = typeof input === 'function'
+ ? input.call(this.props.calendarApi, this.props.dateEnv.toDate(this.props.nowManager.getDateMarker()))
+ : input;
+ return this.refineRange(simpleInput) ||
+ { start: null, end: null };
+ }
+ buildCurrentRangeInfo(date, direction) {
+ let { props } = this;
+ let duration = null;
+ let unit = null;
+ let range = null;
+ let dayCount;
+ if (props.duration) {
+ duration = props.duration;
+ unit = props.durationUnit;
+ range = this.buildRangeFromDuration(date, direction, duration, unit);
+ }
+ else if ((dayCount = this.props.dayCount)) {
+ unit = 'day';
+ range = this.buildRangeFromDayCount(date, direction, dayCount);
+ }
+ else if ((range = this.buildCustomVisibleRange(date))) {
+ unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
+ }
+ else {
+ duration = this.getFallbackDuration();
+ unit = greatestDurationDenominator(duration).unit;
+ range = this.buildRangeFromDuration(date, direction, duration, unit);
+ }
+ return { duration, unit, range };
+ }
+ getFallbackDuration() {
+ return createDuration({ day: 1 });
+ }
+ adjustActiveRange(range) {
+ let { dateEnv, usesMinMaxTime, slotMinTime, slotMaxTime } = this.props;
+ let { start, end } = range;
+ if (usesMinMaxTime) {
+ if (asRoughDays(slotMinTime) < 0) {
+ start = startOfDay(start);
+ start = dateEnv.add(start, slotMinTime);
+ }
+ if (asRoughDays(slotMaxTime) > 1) {
+ end = startOfDay(end);
+ end = addDays(end, -1);
+ end = dateEnv.add(end, slotMaxTime);
+ }
+ }
+ return { start, end };
+ }
+ buildRangeFromDuration(date, direction, duration, unit) {
+ let { dateEnv, dateAlignment } = this.props;
+ let start;
+ let end;
+ let res;
+ if (!dateAlignment) {
+ let { dateIncrement } = this.props;
+ if (dateIncrement) {
+ if (asRoughMs(dateIncrement) < asRoughMs(duration)) {
+ dateAlignment = greatestDurationDenominator(dateIncrement).unit;
+ }
+ else {
+ dateAlignment = unit;
+ }
+ }
+ else {
+ dateAlignment = unit;
+ }
+ }
+ if (asRoughDays(duration) <= 1) {
+ if (this.isHiddenDay(start)) {
+ start = this.skipHiddenDays(start, direction);
+ start = startOfDay(start);
+ }
+ }
+ function computeRes() {
+ start = dateEnv.startOf(date, dateAlignment);
+ end = dateEnv.add(start, duration);
+ res = { start, end };
+ }
+ computeRes();
+ if (!this.trimHiddenDays(res)) {
+ date = this.skipHiddenDays(date, direction);
+ computeRes();
+ }
+ return res;
+ }
+ buildRangeFromDayCount(date, direction, dayCount) {
+ let { dateEnv, dateAlignment } = this.props;
+ let runningCount = 0;
+ let start = date;
+ let end;
+ if (dateAlignment) {
+ start = dateEnv.startOf(start, dateAlignment);
+ }
+ start = startOfDay(start);
+ start = this.skipHiddenDays(start, direction);
+ end = start;
+ do {
+ end = addDays(end, 1);
+ if (!this.isHiddenDay(end)) {
+ runningCount += 1;
+ }
+ } while (runningCount < dayCount);
+ return { start, end };
+ }
+ buildCustomVisibleRange(date) {
+ let { props } = this;
+ let input = props.visibleRangeInput;
+ let simpleInput = typeof input === 'function'
+ ? input.call(props.calendarApi, props.dateEnv.toDate(date))
+ : input;
+ let range = this.refineRange(simpleInput);
+ if (range && (range.start == null || range.end == null)) {
+ return null;
+ }
+ return range;
+ }
+ buildRenderRange(currentRange, currentRangeUnit, isRangeAllDay) {
+ return currentRange;
+ }
+ buildDateIncrement(fallback) {
+ let { dateIncrement } = this.props;
+ let customAlignment;
+ if (dateIncrement) {
+ return dateIncrement;
+ }
+ if ((customAlignment = this.props.dateAlignment)) {
+ return createDuration(1, customAlignment);
+ }
+ if (fallback) {
+ return fallback;
+ }
+ return createDuration({ days: 1 });
+ }
+ refineRange(rangeInput) {
+ if (rangeInput) {
+ let range = parseRange(rangeInput, this.props.dateEnv);
+ if (range) {
+ range = computeVisibleDayRange(range);
+ }
+ return range;
+ }
+ return null;
+ }
+ initHiddenDays() {
+ let hiddenDays = this.props.hiddenDays || [];
+ let isHiddenDayHash = [];
+ let dayCnt = 0;
+ let i;
+ if (this.props.weekends === false) {
+ hiddenDays.push(0, 6);
+ }
+ for (i = 0; i < 7; i += 1) {
+ if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
+ dayCnt += 1;
+ }
+ }
+ if (!dayCnt) {
+ throw new Error('invalid hiddenDays');
+ }
+ this.isHiddenDayHash = isHiddenDayHash;
+ }
+ trimHiddenDays(range) {
+ let { start, end } = range;
+ if (start) {
+ start = this.skipHiddenDays(start);
+ }
+ if (end) {
+ end = this.skipHiddenDays(end, -1, true);
+ }
+ if (start == null || end == null || start < end) {
+ return { start, end };
+ }
+ return null;
+ }
+ isHiddenDay(day) {
+ if (day instanceof Date) {
+ day = day.getUTCDay();
+ }
+ return this.isHiddenDayHash[day];
+ }
+ skipHiddenDays(date, inc = 1, isExclusive = false) {
+ while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
+ date = addDays(date, inc);
+ }
+ return date;
+ }
+ }
+ function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
+ return {
+ instanceId: guid(),
+ defId,
+ range,
+ forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
+ forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo,
+ };
+ }
+ function parseRecurring(refined, defaultAllDay, dateEnv, recurringTypes) {
+ for (let i = 0; i < recurringTypes.length; i += 1) {
+ let parsed = recurringTypes[i].parse(refined, dateEnv);
+ if (parsed) {
+ let { allDay } = refined;
+ if (allDay == null) {
+ allDay = defaultAllDay;
+ if (allDay == null) {
+ allDay = parsed.allDayGuess;
+ if (allDay == null) {
+ allDay = false;
+ }
+ }
+ }
+ return {
+ allDay,
+ duration: parsed.duration,
+ typeData: parsed.typeData,
+ typeId: i,
+ };
+ }
+ }
+ return null;
+ }
+ function expandRecurring(eventStore, framingRange, context) {
+ let { dateEnv, pluginHooks, options } = context;
+ let { defs, instances } = eventStore;
+ instances = filterHash(instances, (instance) => !defs[instance.defId].recurringDef);
+ for (let defId in defs) {
+ let def = defs[defId];
+ if (def.recurringDef) {
+ let { duration } = def.recurringDef;
+ if (!duration) {
+ duration = def.allDay ?
+ options.defaultAllDayEventDuration :
+ options.defaultTimedEventDuration;
+ }
+ let starts = expandRecurringRanges(def, duration, framingRange, dateEnv, pluginHooks.recurringTypes);
+ for (let start of starts) {
+ let instance = createEventInstance(defId, {
+ start,
+ end: dateEnv.add(start, duration),
+ });
+ instances[instance.instanceId] = instance;
+ }
+ }
+ }
+ return { defs, instances };
+ }
+ function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
+ let typeDef = recurringTypes[eventDef.recurringDef.typeId];
+ let markers = typeDef.expand(eventDef.recurringDef.typeData, {
+ start: dateEnv.subtract(framingRange.start, duration),
+ end: framingRange.end,
+ }, dateEnv);
+ if (eventDef.allDay) {
+ markers = markers.map(startOfDay);
+ }
+ return markers;
+ }
+ const EVENT_NON_DATE_REFINERS = {
+ id: String,
+ groupId: String,
+ title: String,
+ url: String,
+ interactive: Boolean,
+ };
+ const EVENT_DATE_REFINERS = {
+ start: identity,
+ end: identity,
+ date: identity,
+ allDay: Boolean,
+ };
+ const EVENT_REFINERS = Object.assign(Object.assign(Object.assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
+ function parseEvent(raw, eventSource, context, allowOpenRange, refiners = buildEventRefiners(context), defIdMap, instanceIdMap) {
+ let { refined, extra } = refineEventDef(raw, context, refiners);
+ let defaultAllDay = computeIsDefaultAllDay(eventSource, context);
+ let recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
+ if (recurringRes) {
+ let def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', recurringRes.allDay, Boolean(recurringRes.duration), context, defIdMap);
+ def.recurringDef = {
+ typeId: recurringRes.typeId,
+ typeData: recurringRes.typeData,
+ duration: recurringRes.duration,
+ };
+ return { def, instance: null };
+ }
+ let singleRes = parseSingle(refined, defaultAllDay, context, allowOpenRange);
+ if (singleRes) {
+ let def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', singleRes.allDay, singleRes.hasEnd, context, defIdMap);
+ let instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
+ if (instanceIdMap && def.publicId && instanceIdMap[def.publicId]) {
+ instance.instanceId = instanceIdMap[def.publicId];
+ }
+ return { def, instance };
+ }
+ return null;
+ }
+ function refineEventDef(raw, context, refiners = buildEventRefiners(context)) {
+ return refineProps(raw, refiners);
+ }
+ function buildEventRefiners(context) {
+ return Object.assign(Object.assign(Object.assign({}, EVENT_UI_REFINERS), EVENT_REFINERS), context.pluginHooks.eventRefiners);
+ }
+ function parseEventDef(refined, extra, sourceId, allDay, hasEnd, context, defIdMap) {
+ let def = {
+ title: refined.title || '',
+ groupId: refined.groupId || '',
+ publicId: refined.id || '',
+ url: refined.url || '',
+ recurringDef: null,
+ defId: ((defIdMap && refined.id) ? defIdMap[refined.id] : '') || guid(),
+ sourceId,
+ allDay,
+ hasEnd,
+ interactive: refined.interactive,
+ ui: createEventUi(refined, context),
+ extendedProps: Object.assign(Object.assign({}, (refined.extendedProps || {})), extra),
+ };
+ for (let memberAdder of context.pluginHooks.eventDefMemberAdders) {
+ Object.assign(def, memberAdder(refined));
+ }
+ Object.freeze(def.ui.classNames);
+ Object.freeze(def.extendedProps);
+ return def;
+ }
+ function parseSingle(refined, defaultAllDay, context, allowOpenRange) {
+ let { allDay } = refined;
+ let startMeta;
+ let startMarker = null;
+ let hasEnd = false;
+ let endMeta;
+ let endMarker = null;
+ let startInput = refined.start != null ? refined.start : refined.date;
+ startMeta = context.dateEnv.createMarkerMeta(startInput);
+ if (startMeta) {
+ startMarker = startMeta.marker;
+ }
+ else if (!allowOpenRange) {
+ return null;
+ }
+ if (refined.end != null) {
+ endMeta = context.dateEnv.createMarkerMeta(refined.end);
+ }
+ if (allDay == null) {
+ if (defaultAllDay != null) {
+ allDay = defaultAllDay;
+ }
+ else {
+ allDay = (!startMeta || startMeta.isTimeUnspecified) &&
+ (!endMeta || endMeta.isTimeUnspecified);
+ }
+ }
+ if (allDay && startMarker) {
+ startMarker = startOfDay(startMarker);
+ }
+ if (endMeta) {
+ endMarker = endMeta.marker;
+ if (allDay) {
+ endMarker = startOfDay(endMarker);
+ }
+ if (startMarker && endMarker <= startMarker) {
+ endMarker = null;
+ }
+ }
+ if (endMarker) {
+ hasEnd = true;
+ }
+ else if (!allowOpenRange) {
+ hasEnd = context.options.forceEventDuration || false;
+ endMarker = context.dateEnv.add(startMarker, allDay ?
+ context.options.defaultAllDayEventDuration :
+ context.options.defaultTimedEventDuration);
+ }
+ return {
+ allDay,
+ hasEnd,
+ range: { start: startMarker, end: endMarker },
+ forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
+ forcedEndTzo: endMeta ? endMeta.forcedTzo : null,
+ };
+ }
+ function computeIsDefaultAllDay(eventSource, context) {
+ let res = null;
+ if (eventSource) {
+ res = eventSource.defaultAllDay;
+ }
+ if (res == null) {
+ res = context.options.defaultAllDay;
+ }
+ return res;
+ }
+ function parseEvents(rawEvents, eventSource, context, allowOpenRange, defIdMap, instanceIdMap) {
+ let eventStore = createEmptyEventStore();
+ let eventRefiners = buildEventRefiners(context);
+ for (let rawEvent of rawEvents) {
+ let tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners, defIdMap, instanceIdMap);
+ if (tuple) {
+ eventTupleToStore(tuple, eventStore);
+ }
+ }
+ return eventStore;
+ }
+ function eventTupleToStore(tuple, eventStore = createEmptyEventStore()) {
+ eventStore.defs[tuple.def.defId] = tuple.def;
+ if (tuple.instance) {
+ eventStore.instances[tuple.instance.instanceId] = tuple.instance;
+ }
+ return eventStore;
+ }
+ function getRelevantEvents(eventStore, instanceId) {
+ let instance = eventStore.instances[instanceId];
+ if (instance) {
+ let def = eventStore.defs[instance.defId];
+ let newStore = filterEventStoreDefs(eventStore, (lookDef) => isEventDefsGrouped(def, lookDef));
+ newStore.defs[def.defId] = def;
+ newStore.instances[instance.instanceId] = instance;
+ return newStore;
+ }
+ return createEmptyEventStore();
+ }
+ function isEventDefsGrouped(def0, def1) {
+ return Boolean(def0.groupId && def0.groupId === def1.groupId);
+ }
+ function createEmptyEventStore() {
+ return { defs: {}, instances: {} };
+ }
+ function mergeEventStores(store0, store1) {
+ return {
+ defs: Object.assign(Object.assign({}, store0.defs), store1.defs),
+ instances: Object.assign(Object.assign({}, store0.instances), store1.instances),
+ };
+ }
+ function filterEventStoreDefs(eventStore, filterFunc) {
+ let defs = filterHash(eventStore.defs, filterFunc);
+ let instances = filterHash(eventStore.instances, (instance) => (defs[instance.defId]
+ ));
+ return { defs, instances };
+ }
+ function excludeSubEventStore(master, sub) {
+ let { defs, instances } = master;
+ let filteredDefs = {};
+ let filteredInstances = {};
+ for (let defId in defs) {
+ if (!sub.defs[defId]) {
+ filteredDefs[defId] = defs[defId];
+ }
+ }
+ for (let instanceId in instances) {
+ if (!sub.instances[instanceId] &&
+ filteredDefs[instances[instanceId].defId]
+ ) {
+ filteredInstances[instanceId] = instances[instanceId];
+ }
+ }
+ return {
+ defs: filteredDefs,
+ instances: filteredInstances,
+ };
+ }
+ function normalizeConstraint(input, context) {
+ if (Array.isArray(input)) {
+ return parseEvents(input, null, context, true);
+ }
+ if (typeof input === 'object' && input) {
+ return parseEvents([input], null, context, true);
+ }
+ if (input != null) {
+ return String(input);
+ }
+ return null;
+ }
+ function parseClassNames(raw) {
+ if (Array.isArray(raw)) {
+ return raw;
+ }
+ if (typeof raw === 'string') {
+ return raw.split(/\s+/);
+ }
+ return [];
+ }
+ const EVENT_UI_REFINERS = {
+ display: String,
+ editable: Boolean,
+ startEditable: Boolean,
+ durationEditable: Boolean,
+ constraint: identity,
+ overlap: identity,
+ allow: identity,
+ className: parseClassNames,
+ classNames: parseClassNames,
+ color: String,
+ backgroundColor: String,
+ borderColor: String,
+ textColor: String,
+ };
+ const EMPTY_EVENT_UI = {
+ display: null,
+ startEditable: null,
+ durationEditable: null,
+ constraints: [],
+ overlap: null,
+ allows: [],
+ backgroundColor: '',
+ borderColor: '',
+ textColor: '',
+ classNames: [],
+ };
+ function createEventUi(refined, context) {
+ let constraint = normalizeConstraint(refined.constraint, context);
+ return {
+ display: refined.display || null,
+ startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
+ durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
+ constraints: constraint != null ? [constraint] : [],
+ overlap: refined.overlap != null ? refined.overlap : null,
+ allows: refined.allow != null ? [refined.allow] : [],
+ backgroundColor: refined.backgroundColor || refined.color || '',
+ borderColor: refined.borderColor || refined.color || '',
+ textColor: refined.textColor || '',
+ classNames: (refined.className || []).concat(refined.classNames || []),
+ };
+ }
+ function combineEventUis(uis) {
+ return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
+ }
+ function combineTwoEventUis(item0, item1) {
+ return {
+ display: item1.display != null ? item1.display : item0.display,
+ startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
+ durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
+ constraints: item0.constraints.concat(item1.constraints),
+ overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
+ allows: item0.allows.concat(item1.allows),
+ backgroundColor: item1.backgroundColor || item0.backgroundColor,
+ borderColor: item1.borderColor || item0.borderColor,
+ textColor: item1.textColor || item0.textColor,
+ classNames: item0.classNames.concat(item1.classNames),
+ };
+ }
+ const EVENT_SOURCE_REFINERS = {
+ id: String,
+ defaultAllDay: Boolean,
+ url: String,
+ format: String,
+ events: identity,
+ eventDataTransform: identity,
+ success: identity,
+ failure: identity,
+ };
+ function parseEventSource(raw, context, refiners = buildEventSourceRefiners(context)) {
+ let rawObj;
+ if (typeof raw === 'string') {
+ rawObj = { url: raw };
+ }
+ else if (typeof raw === 'function' || Array.isArray(raw)) {
+ rawObj = { events: raw };
+ }
+ else if (typeof raw === 'object' && raw) {
+ rawObj = raw;
+ }
+ if (rawObj) {
+ let { refined, extra } = refineProps(rawObj, refiners);
+ let metaRes = buildEventSourceMeta(refined, context);
+ if (metaRes) {
+ return {
+ _raw: raw,
+ isFetching: false,
+ latestFetchId: '',
+ fetchRange: null,
+ defaultAllDay: refined.defaultAllDay,
+ eventDataTransform: refined.eventDataTransform,
+ success: refined.success,
+ failure: refined.failure,
+ publicId: refined.id || '',
+ sourceId: guid(),
+ sourceDefId: metaRes.sourceDefId,
+ meta: metaRes.meta,
+ ui: createEventUi(refined, context),
+ extendedProps: extra,
+ };
+ }
+ }
+ return null;
+ }
+ function buildEventSourceRefiners(context) {
+ return Object.assign(Object.assign(Object.assign({}, EVENT_UI_REFINERS), EVENT_SOURCE_REFINERS), context.pluginHooks.eventSourceRefiners);
+ }
+ function buildEventSourceMeta(raw, context) {
+ let defs = context.pluginHooks.eventSourceDefs;
+ for (let i = defs.length - 1; i >= 0; i -= 1) {
+ let def = defs[i];
+ let meta = def.parseMeta(raw);
+ if (meta) {
+ return { sourceDefId: i, meta };
+ }
+ }
+ return null;
+ }
+ function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
+ switch (action.type) {
+ case 'RECEIVE_EVENTS':
+ return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
+ case 'RESET_RAW_EVENTS':
+ return resetRawEvents(eventStore, eventSources[action.sourceId], action.rawEvents, dateProfile.activeRange, context);
+ case 'ADD_EVENTS':
+ return addEvent(eventStore, action.eventStore,
+ dateProfile ? dateProfile.activeRange : null, context);
+ case 'RESET_EVENTS':
+ return action.eventStore;
+ case 'MERGE_EVENTS':
+ return mergeEventStores(eventStore, action.eventStore);
+ case 'PREV':
+ case 'NEXT':
+ case 'CHANGE_DATE':
+ case 'CHANGE_VIEW_TYPE':
+ if (dateProfile) {
+ return expandRecurring(eventStore, dateProfile.activeRange, context);
+ }
+ return eventStore;
+ case 'REMOVE_EVENTS':
+ return excludeSubEventStore(eventStore, action.eventStore);
+ case 'REMOVE_EVENT_SOURCE':
+ return excludeEventsBySourceId(eventStore, action.sourceId);
+ case 'REMOVE_ALL_EVENT_SOURCES':
+ return filterEventStoreDefs(eventStore, (eventDef) => (!eventDef.sourceId
+ ));
+ case 'REMOVE_ALL_EVENTS':
+ return createEmptyEventStore();
+ default:
+ return eventStore;
+ }
+ }
+ function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
+ if (eventSource &&
+ fetchId === eventSource.latestFetchId
+ ) {
+ let subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
+ if (fetchRange) {
+ subset = expandRecurring(subset, fetchRange, context);
+ }
+ return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
+ }
+ return eventStore;
+ }
+ function resetRawEvents(existingEventStore, eventSource, rawEvents, activeRange, context) {
+ const { defIdMap, instanceIdMap } = buildPublicIdMaps(existingEventStore);
+ let newEventStore = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context, false, defIdMap, instanceIdMap);
+ return expandRecurring(newEventStore, activeRange, context);
+ }
+ function transformRawEvents(rawEvents, eventSource, context) {
+ let calEachTransform = context.options.eventDataTransform;
+ let sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
+ if (sourceEachTransform) {
+ rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
+ }
+ if (calEachTransform) {
+ rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
+ }
+ return rawEvents;
+ }
+ function transformEachRawEvent(rawEvents, func) {
+ let refinedEvents;
+ if (!func) {
+ refinedEvents = rawEvents;
+ }
+ else {
+ refinedEvents = [];
+ for (let rawEvent of rawEvents) {
+ let refinedEvent = func(rawEvent);
+ if (refinedEvent) {
+ refinedEvents.push(refinedEvent);
+ }
+ else if (refinedEvent == null) {
+ refinedEvents.push(rawEvent);
+ }
+ }
+ }
+ return refinedEvents;
+ }
+ function addEvent(eventStore, subset, expandRange, context) {
+ if (expandRange) {
+ subset = expandRecurring(subset, expandRange, context);
+ }
+ return mergeEventStores(eventStore, subset);
+ }
+ function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
+ let { defs } = eventStore;
+ let instances = mapHash(eventStore.instances, (instance) => {
+ let def = defs[instance.defId];
+ if (def.allDay) {
+ return instance;
+ }
+ return Object.assign(Object.assign({}, instance), { range: {
+ start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
+ end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo)),
+ }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
+ });
+ return { defs, instances };
+ }
+ function excludeEventsBySourceId(eventStore, sourceId) {
+ return filterEventStoreDefs(eventStore, (eventDef) => eventDef.sourceId !== sourceId);
+ }
+ function excludeInstances(eventStore, removals) {
+ return {
+ defs: eventStore.defs,
+ instances: filterHash(eventStore.instances, (instance) => !removals[instance.instanceId]),
+ };
+ }
+ function buildPublicIdMaps(eventStore) {
+ const { defs, instances } = eventStore;
+ const defIdMap = {};
+ const instanceIdMap = {};
+ for (let defId in defs) {
+ const def = defs[defId];
+ const { publicId } = def;
+ if (publicId) {
+ defIdMap[publicId] = defId;
+ }
+ }
+ for (let instanceId in instances) {
+ const instance = instances[instanceId];
+ const def = defs[instance.defId];
+ const { publicId } = def;
+ if (publicId) {
+ instanceIdMap[publicId] = instanceId;
+ }
+ }
+ return { defIdMap, instanceIdMap };
+ }
+ class Emitter {
+ constructor() {
+ this.handlers = {};
+ this.thisContext = null;
+ }
+ setThisContext(thisContext) {
+ this.thisContext = thisContext;
+ }
+ setOptions(options) {
+ this.options = options;
+ }
+ on(type, handler) {
+ addToHash(this.handlers, type, handler);
+ }
+ off(type, handler) {
+ removeFromHash(this.handlers, type, handler);
+ }
+ trigger(type, ...args) {
+ let attachedHandlers = this.handlers[type] || [];
+ let optionHandler = this.options && this.options[type];
+ let handlers = [].concat(optionHandler || [], attachedHandlers);
+ for (let handler of handlers) {
+ handler.apply(this.thisContext, args);
+ }
+ }
+ hasHandlers(type) {
+ return Boolean((this.handlers[type] && this.handlers[type].length) ||
+ (this.options && this.options[type]));
+ }
+ }
+ function addToHash(hash, type, handler) {
+ (hash[type] || (hash[type] = []))
+ .push(handler);
+ }
+ function removeFromHash(hash, type, handler) {
+ if (handler) {
+ if (hash[type]) {
+ hash[type] = hash[type].filter((func) => func !== handler);
+ }
+ }
+ else {
+ delete hash[type];
+ }
+ }
+ const DEF_DEFAULTS = {
+ startTime: '09:00',
+ endTime: '17:00',
+ daysOfWeek: [1, 2, 3, 4, 5],
+ display: 'inverse-background',
+ classNames: 'fc-non-business',
+ groupId: '_businessHours',
+ };
+ function parseBusinessHours(input, context) {
+ return parseEvents(refineInputs(input), null, context);
+ }
+ function refineInputs(input) {
+ let rawDefs;
+ if (input === true) {
+ rawDefs = [{}];
+ }
+ else if (Array.isArray(input)) {
+ rawDefs = input.filter((rawDef) => rawDef.daysOfWeek);
+ }
+ else if (typeof input === 'object' && input) {
+ rawDefs = [input];
+ }
+ else {
+ rawDefs = [];
+ }
+ rawDefs = rawDefs.map((rawDef) => (Object.assign(Object.assign({}, DEF_DEFAULTS), rawDef)));
+ return rawDefs;
+ }
+ function triggerDateSelect(selection, pev, context) {
+ context.emitter.trigger('select', Object.assign(Object.assign({}, buildDateSpanApiWithContext(selection, context)), { jsEvent: pev ? pev.origEvent : null, view: context.viewApi || context.calendarApi.view }));
+ }
+ function triggerDateUnselect(pev, context) {
+ context.emitter.trigger('unselect', {
+ jsEvent: pev ? pev.origEvent : null,
+ view: context.viewApi || context.calendarApi.view,
+ });
+ }
+ function buildDateSpanApiWithContext(dateSpan, context) {
+ let props = {};
+ for (let transform of context.pluginHooks.dateSpanTransforms) {
+ Object.assign(props, transform(dateSpan, context));
+ }
+ Object.assign(props, buildDateSpanApi(dateSpan, context.dateEnv));
+ return props;
+ }
+ function getDefaultEventEnd(allDay, marker, context) {
+ let { dateEnv, options } = context;
+ let end = marker;
+ if (allDay) {
+ end = startOfDay(end);
+ end = dateEnv.add(end, options.defaultAllDayEventDuration);
+ }
+ else {
+ end = dateEnv.add(end, options.defaultTimedEventDuration);
+ }
+ return end;
+ }
+ function applyMutationToEventStore(eventStore, eventConfigBase, mutation, context) {
+ let eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
+ let dest = createEmptyEventStore();
+ for (let defId in eventStore.defs) {
+ let def = eventStore.defs[defId];
+ dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, context);
+ }
+ for (let instanceId in eventStore.instances) {
+ let instance = eventStore.instances[instanceId];
+ let def = dest.defs[instance.defId];
+ dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, context);
+ }
+ return dest;
+ }
+ function applyMutationToEventDef(eventDef, eventConfig, mutation, context) {
+ let standardProps = mutation.standardProps || {};
+ if (standardProps.hasEnd == null &&
+ eventConfig.durationEditable &&
+ (mutation.startDelta || mutation.endDelta)) {
+ standardProps.hasEnd = true;
+ }
+ let copy = Object.assign(Object.assign(Object.assign({}, eventDef), standardProps), { ui: Object.assign(Object.assign({}, eventDef.ui), standardProps.ui) });
+ if (mutation.extendedProps) {
+ copy.extendedProps = Object.assign(Object.assign({}, copy.extendedProps), mutation.extendedProps);
+ }
+ for (let applier of context.pluginHooks.eventDefMutationAppliers) {
+ applier(copy, mutation, context);
+ }
+ if (!copy.hasEnd && context.options.forceEventDuration) {
+ copy.hasEnd = true;
+ }
+ return copy;
+ }
+ function applyMutationToEventInstance(eventInstance, eventDef,
+ eventConfig, mutation, context) {
+ let { dateEnv } = context;
+ let forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
+ let clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
+ let copy = Object.assign({}, eventInstance);
+ if (forceAllDay) {
+ copy.range = computeAlignedDayRange(copy.range);
+ }
+ if (mutation.datesDelta && eventConfig.startEditable) {
+ copy.range = {
+ start: dateEnv.add(copy.range.start, mutation.datesDelta),
+ end: dateEnv.add(copy.range.end, mutation.datesDelta),
+ };
+ }
+ if (mutation.startDelta && eventConfig.durationEditable) {
+ copy.range = {
+ start: dateEnv.add(copy.range.start, mutation.startDelta),
+ end: copy.range.end,
+ };
+ }
+ if (mutation.endDelta && eventConfig.durationEditable) {
+ copy.range = {
+ start: copy.range.start,
+ end: dateEnv.add(copy.range.end, mutation.endDelta),
+ };
+ }
+ if (clearEnd) {
+ copy.range = {
+ start: copy.range.start,
+ end: getDefaultEventEnd(eventDef.allDay, copy.range.start, context),
+ };
+ }
+ if (eventDef.allDay) {
+ copy.range = {
+ start: startOfDay(copy.range.start),
+ end: startOfDay(copy.range.end),
+ };
+ }
+ if (copy.range.end < copy.range.start) {
+ copy.range.end = getDefaultEventEnd(eventDef.allDay, copy.range.start, context);
+ }
+ return copy;
+ }
+ class EventSourceImpl {
+ constructor(context, internalEventSource) {
+ this.context = context;
+ this.internalEventSource = internalEventSource;
+ }
+ remove() {
+ this.context.dispatch({
+ type: 'REMOVE_EVENT_SOURCE',
+ sourceId: this.internalEventSource.sourceId,
+ });
+ }
+ refetch() {
+ this.context.dispatch({
+ type: 'FETCH_EVENT_SOURCES',
+ sourceIds: [this.internalEventSource.sourceId],
+ isRefetch: true,
+ });
+ }
+ get id() {
+ return this.internalEventSource.publicId;
+ }
+ get url() {
+ return this.internalEventSource.meta.url;
+ }
+ get format() {
+ return this.internalEventSource.meta.format;
+ }
+ }
+ class EventImpl {
+ constructor(context, def, instance) {
+ this._context = context;
+ this._def = def;
+ this._instance = instance || null;
+ }
+ setProp(name, val) {
+ if (name in EVENT_DATE_REFINERS) {
+ console.warn('Could not set date-related prop \'name\'. Use one of the date-related methods instead.');
+ }
+ else if (name === 'id') {
+ val = EVENT_NON_DATE_REFINERS[name](val);
+ this.mutate({
+ standardProps: { publicId: val },
+ });
+ }
+ else if (name in EVENT_NON_DATE_REFINERS) {
+ val = EVENT_NON_DATE_REFINERS[name](val);
+ this.mutate({
+ standardProps: { [name]: val },
+ });
+ }
+ else if (name in EVENT_UI_REFINERS) {
+ let ui = EVENT_UI_REFINERS[name](val);
+ if (name === 'color') {
+ ui = { backgroundColor: val, borderColor: val };
+ }
+ else if (name === 'editable') {
+ ui = { startEditable: val, durationEditable: val };
+ }
+ else {
+ ui = { [name]: val };
+ }
+ this.mutate({
+ standardProps: { ui },
+ });
+ }
+ else {
+ console.warn(`Could not set prop '${name}'. Use setExtendedProp instead.`);
+ }
+ }
+ setExtendedProp(name, val) {
+ this.mutate({
+ extendedProps: { [name]: val },
+ });
+ }
+ setStart(startInput, options = {}) {
+ let { dateEnv } = this._context;
+ let start = dateEnv.createMarker(startInput);
+ if (start && this._instance) {
+ let instanceRange = this._instance.range;
+ let startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
+ if (options.maintainDuration) {
+ this.mutate({ datesDelta: startDelta });
+ }
+ else {
+ this.mutate({ startDelta });
+ }
+ }
+ }
+ setEnd(endInput, options = {}) {
+ let { dateEnv } = this._context;
+ let end;
+ if (endInput != null) {
+ end = dateEnv.createMarker(endInput);
+ if (!end) {
+ return;
+ }
+ }
+ if (this._instance) {
+ if (end) {
+ let endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
+ this.mutate({ endDelta });
+ }
+ else {
+ this.mutate({ standardProps: { hasEnd: false } });
+ }
+ }
+ }
+ setDates(startInput, endInput, options = {}) {
+ let { dateEnv } = this._context;
+ let standardProps = { allDay: options.allDay };
+ let start = dateEnv.createMarker(startInput);
+ let end;
+ if (!start) {
+ return;
+ }
+ if (endInput != null) {
+ end = dateEnv.createMarker(endInput);
+ if (!end) {
+ return;
+ }
+ }
+ if (this._instance) {
+ let instanceRange = this._instance.range;
+ if (options.allDay === true) {
+ instanceRange = computeAlignedDayRange(instanceRange);
+ }
+ let startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
+ if (end) {
+ let endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
+ if (durationsEqual(startDelta, endDelta)) {
+ this.mutate({ datesDelta: startDelta, standardProps });
+ }
+ else {
+ this.mutate({ startDelta, endDelta, standardProps });
+ }
+ }
+ else {
+ standardProps.hasEnd = false;
+ this.mutate({ datesDelta: startDelta, standardProps });
+ }
+ }
+ }
+ moveStart(deltaInput) {
+ let delta = createDuration(deltaInput);
+ if (delta) {
+ this.mutate({ startDelta: delta });
+ }
+ }
+ moveEnd(deltaInput) {
+ let delta = createDuration(deltaInput);
+ if (delta) {
+ this.mutate({ endDelta: delta });
+ }
+ }
+ moveDates(deltaInput) {
+ let delta = createDuration(deltaInput);
+ if (delta) {
+ this.mutate({ datesDelta: delta });
+ }
+ }
+ setAllDay(allDay, options = {}) {
+ let standardProps = { allDay };
+ let { maintainDuration } = options;
+ if (maintainDuration == null) {
+ maintainDuration = this._context.options.allDayMaintainDuration;
+ }
+ if (this._def.allDay !== allDay) {
+ standardProps.hasEnd = maintainDuration;
+ }
+ this.mutate({ standardProps });
+ }
+ formatRange(formatInput) {
+ let { dateEnv } = this._context;
+ let instance = this._instance;
+ let formatter = createFormatter(formatInput);
+ if (this._def.hasEnd) {
+ return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
+ forcedStartTzo: instance.forcedStartTzo,
+ forcedEndTzo: instance.forcedEndTzo,
+ });
+ }
+ return dateEnv.format(instance.range.start, formatter, {
+ forcedTzo: instance.forcedStartTzo,
+ });
+ }
+ mutate(mutation) {
+ let instance = this._instance;
+ if (instance) {
+ let def = this._def;
+ let context = this._context;
+ let { eventStore } = context.getCurrentData();
+ let relevantEvents = getRelevantEvents(eventStore, instance.instanceId);
+ let eventConfigBase = {
+ '': {
+ display: '',
+ startEditable: true,
+ durationEditable: true,
+ constraints: [],
+ overlap: null,
+ allows: [],
+ backgroundColor: '',
+ borderColor: '',
+ textColor: '',
+ classNames: [],
+ },
+ };
+ relevantEvents = applyMutationToEventStore(relevantEvents, eventConfigBase, mutation, context);
+ let oldEvent = new EventImpl(context, def, instance);
+ this._def = relevantEvents.defs[def.defId];
+ this._instance = relevantEvents.instances[instance.instanceId];
+ context.dispatch({
+ type: 'MERGE_EVENTS',
+ eventStore: relevantEvents,
+ });
+ context.emitter.trigger('eventChange', {
+ oldEvent,
+ event: this,
+ relatedEvents: buildEventApis(relevantEvents, context, instance),
+ revert() {
+ context.dispatch({
+ type: 'RESET_EVENTS',
+ eventStore,
+ });
+ },
+ });
+ }
+ }
+ remove() {
+ let context = this._context;
+ let asStore = eventApiToStore(this);
+ context.dispatch({
+ type: 'REMOVE_EVENTS',
+ eventStore: asStore,
+ });
+ context.emitter.trigger('eventRemove', {
+ event: this,
+ relatedEvents: [],
+ revert() {
+ context.dispatch({
+ type: 'MERGE_EVENTS',
+ eventStore: asStore,
+ });
+ },
+ });
+ }
+ get source() {
+ let { sourceId } = this._def;
+ if (sourceId) {
+ return new EventSourceImpl(this._context, this._context.getCurrentData().eventSources[sourceId]);
+ }
+ return null;
+ }
+ get start() {
+ return this._instance ?
+ this._context.dateEnv.toDate(this._instance.range.start) :
+ null;
+ }
+ get end() {
+ return (this._instance && this._def.hasEnd) ?
+ this._context.dateEnv.toDate(this._instance.range.end) :
+ null;
+ }
+ get startStr() {
+ let instance = this._instance;
+ if (instance) {
+ return this._context.dateEnv.formatIso(instance.range.start, {
+ omitTime: this._def.allDay,
+ forcedTzo: instance.forcedStartTzo,
+ });
+ }
+ return '';
+ }
+ get endStr() {
+ let instance = this._instance;
+ if (instance && this._def.hasEnd) {
+ return this._context.dateEnv.formatIso(instance.range.end, {
+ omitTime: this._def.allDay,
+ forcedTzo: instance.forcedEndTzo,
+ });
+ }
+ return '';
+ }
+ get id() { return this._def.publicId; }
+ get groupId() { return this._def.groupId; }
+ get allDay() { return this._def.allDay; }
+ get title() { return this._def.title; }
+ get url() { return this._def.url; }
+ get display() { return this._def.ui.display || 'auto'; }
+ get startEditable() { return this._def.ui.startEditable; }
+ get durationEditable() { return this._def.ui.durationEditable; }
+ get constraint() { return this._def.ui.constraints[0] || null; }
+ get overlap() { return this._def.ui.overlap; }
+ get allow() { return this._def.ui.allows[0] || null; }
+ get backgroundColor() { return this._def.ui.backgroundColor; }
+ get borderColor() { return this._def.ui.borderColor; }
+ get textColor() { return this._def.ui.textColor; }
+ get classNames() { return this._def.ui.classNames; }
+ get extendedProps() { return this._def.extendedProps; }
+ toPlainObject(settings = {}) {
+ let def = this._def;
+ let { ui } = def;
+ let { startStr, endStr } = this;
+ let res = {
+ allDay: def.allDay,
+ };
+ if (def.title) {
+ res.title = def.title;
+ }
+ if (startStr) {
+ res.start = startStr;
+ }
+ if (endStr) {
+ res.end = endStr;
+ }
+ if (def.publicId) {
+ res.id = def.publicId;
+ }
+ if (def.groupId) {
+ res.groupId = def.groupId;
+ }
+ if (def.url) {
+ res.url = def.url;
+ }
+ if (ui.display && ui.display !== 'auto') {
+ res.display = ui.display;
+ }
+ if (settings.collapseColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
+ res.color = ui.backgroundColor;
+ }
+ else {
+ if (ui.backgroundColor) {
+ res.backgroundColor = ui.backgroundColor;
+ }
+ if (ui.borderColor) {
+ res.borderColor = ui.borderColor;
+ }
+ }
+ if (ui.textColor) {
+ res.textColor = ui.textColor;
+ }
+ if (ui.classNames.length) {
+ res.classNames = ui.classNames;
+ }
+ if (Object.keys(def.extendedProps).length) {
+ if (settings.collapseExtendedProps) {
+ Object.assign(res, def.extendedProps);
+ }
+ else {
+ res.extendedProps = def.extendedProps;
+ }
+ }
+ return res;
+ }
+ toJSON() {
+ return this.toPlainObject();
+ }
+ }
+ function eventApiToStore(eventApi) {
+ let def = eventApi._def;
+ let instance = eventApi._instance;
+ return {
+ defs: { [def.defId]: def },
+ instances: instance
+ ? { [instance.instanceId]: instance }
+ : {},
+ };
+ }
+ function buildEventApis(eventStore, context, excludeInstance) {
+ let { defs, instances } = eventStore;
+ let eventApis = [];
+ let excludeInstanceId = excludeInstance ? excludeInstance.instanceId : '';
+ for (let id in instances) {
+ let instance = instances[id];
+ let def = defs[instance.defId];
+ if (instance.instanceId !== excludeInstanceId) {
+ eventApis.push(new EventImpl(context, def, instance));
+ }
+ }
+ return eventApis;
+ }
+ function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
+ let inverseBgByGroupId = {};
+ let inverseBgByDefId = {};
+ let defByGroupId = {};
+ let bgRanges = [];
+ let fgRanges = [];
+ let eventUis = compileEventUis(eventStore.defs, eventUiBases);
+ for (let defId in eventStore.defs) {
+ let def = eventStore.defs[defId];
+ let ui = eventUis[def.defId];
+ if (ui.display === 'inverse-background') {
+ if (def.groupId) {
+ inverseBgByGroupId[def.groupId] = [];
+ if (!defByGroupId[def.groupId]) {
+ defByGroupId[def.groupId] = def;
+ }
+ }
+ else {
+ inverseBgByDefId[defId] = [];
+ }
+ }
+ }
+ for (let instanceId in eventStore.instances) {
+ let instance = eventStore.instances[instanceId];
+ let def = eventStore.defs[instance.defId];
+ let ui = eventUis[def.defId];
+ let origRange = instance.range;
+ let normalRange = (!def.allDay && nextDayThreshold) ?
+ computeVisibleDayRange(origRange, nextDayThreshold) :
+ origRange;
+ let slicedRange = intersectRanges(normalRange, framingRange);
+ if (slicedRange) {
+ if (ui.display === 'inverse-background') {
+ if (def.groupId) {
+ inverseBgByGroupId[def.groupId].push(slicedRange);
+ }
+ else {
+ inverseBgByDefId[instance.defId].push(slicedRange);
+ }
+ }
+ else if (ui.display !== 'none') {
+ (ui.display === 'background' ? bgRanges : fgRanges).push({
+ def,
+ ui,
+ instance,
+ range: slicedRange,
+ isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
+ isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf(),
+ });
+ }
+ }
+ }
+ for (let groupId in inverseBgByGroupId) {
+ let ranges = inverseBgByGroupId[groupId];
+ let invertedRanges = invertRanges(ranges, framingRange);
+ for (let invertedRange of invertedRanges) {
+ let def = defByGroupId[groupId];
+ let ui = eventUis[def.defId];
+ bgRanges.push({
+ def,
+ ui,
+ instance: null,
+ range: invertedRange,
+ isStart: false,
+ isEnd: false,
+ });
+ }
+ }
+ for (let defId in inverseBgByDefId) {
+ let ranges = inverseBgByDefId[defId];
+ let invertedRanges = invertRanges(ranges, framingRange);
+ for (let invertedRange of invertedRanges) {
+ bgRanges.push({
+ def: eventStore.defs[defId],
+ ui: eventUis[defId],
+ instance: null,
+ range: invertedRange,
+ isStart: false,
+ isEnd: false,
+ });
+ }
+ }
+ return { bg: bgRanges, fg: fgRanges };
+ }
+ function hasBgRendering(def) {
+ return def.ui.display === 'background' || def.ui.display === 'inverse-background';
+ }
+ function setElSeg(el, seg) {
+ el.fcSeg = seg;
+ }
+ function getElSeg(el) {
+ return el.fcSeg ||
+ el.parentNode.fcSeg ||
+ null;
+ }
+ function compileEventUis(eventDefs, eventUiBases) {
+ return mapHash(eventDefs, (eventDef) => compileEventUi(eventDef, eventUiBases));
+ }
+ function compileEventUi(eventDef, eventUiBases) {
+ let uis = [];
+ if (eventUiBases['']) {
+ uis.push(eventUiBases['']);
+ }
+ if (eventUiBases[eventDef.defId]) {
+ uis.push(eventUiBases[eventDef.defId]);
+ }
+ uis.push(eventDef.ui);
+ return combineEventUis(uis);
+ }
+ function sortEventSegs(segs, eventOrderSpecs) {
+ let objs = segs.map(buildSegCompareObj);
+ objs.sort((obj0, obj1) => compareByFieldSpecs(obj0, obj1, eventOrderSpecs));
+ return objs.map((c) => c._seg);
+ }
+ function buildSegCompareObj(seg) {
+ let { eventRange } = seg;
+ let eventDef = eventRange.def;
+ let range = eventRange.instance ? eventRange.instance.range : eventRange.range;
+ let start = range.start ? range.start.valueOf() : 0;
+ let end = range.end ? range.end.valueOf() : 0;
+ return Object.assign(Object.assign(Object.assign({}, eventDef.extendedProps), eventDef), { id: eventDef.publicId, start,
+ end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg });
+ }
+ function computeSegDraggable(seg, context) {
+ let { pluginHooks } = context;
+ let transformers = pluginHooks.isDraggableTransformers;
+ let { def, ui } = seg.eventRange;
+ let val = ui.startEditable;
+ for (let transformer of transformers) {
+ val = transformer(val, def, ui, context);
+ }
+ return val;
+ }
+ function computeSegStartResizable(seg, context) {
+ return seg.isStart && seg.eventRange.ui.durationEditable && context.options.eventResizableFromStart;
+ }
+ function computeSegEndResizable(seg, context) {
+ return seg.isEnd && seg.eventRange.ui.durationEditable;
+ }
+ function buildSegTimeText(seg, timeFormat, context, defaultDisplayEventTime,
+ defaultDisplayEventEnd,
+ startOverride, endOverride) {
+ let { dateEnv, options } = context;
+ let { displayEventTime, displayEventEnd } = options;
+ let eventDef = seg.eventRange.def;
+ let eventInstance = seg.eventRange.instance;
+ if (displayEventTime == null) {
+ displayEventTime = defaultDisplayEventTime !== false;
+ }
+ if (displayEventEnd == null) {
+ displayEventEnd = defaultDisplayEventEnd !== false;
+ }
+ let wholeEventStart = eventInstance.range.start;
+ let wholeEventEnd = eventInstance.range.end;
+ let segStart = startOverride || seg.start || seg.eventRange.range.start;
+ let segEnd = endOverride || seg.end || seg.eventRange.range.end;
+ let isStartDay = startOfDay(wholeEventStart).valueOf() === startOfDay(segStart).valueOf();
+ let isEndDay = startOfDay(addMs(wholeEventEnd, -1)).valueOf() === startOfDay(addMs(segEnd, -1)).valueOf();
+ if (displayEventTime && !eventDef.allDay && (isStartDay || isEndDay)) {
+ segStart = isStartDay ? wholeEventStart : segStart;
+ segEnd = isEndDay ? wholeEventEnd : segEnd;
+ if (displayEventEnd && eventDef.hasEnd) {
+ return dateEnv.formatRange(segStart, segEnd, timeFormat, {
+ forcedStartTzo: startOverride ? null : eventInstance.forcedStartTzo,
+ forcedEndTzo: endOverride ? null : eventInstance.forcedEndTzo,
+ });
+ }
+ return dateEnv.format(segStart, timeFormat, {
+ forcedTzo: startOverride ? null : eventInstance.forcedStartTzo,
+ });
+ }
+ return '';
+ }
+ function getSegMeta(seg, todayRange, nowDate) {
+ let segRange = seg.eventRange.range;
+ return {
+ isPast: segRange.end <= (nowDate || todayRange.start),
+ isFuture: segRange.start >= (nowDate || todayRange.end),
+ isToday: todayRange && rangeContainsMarker(todayRange, segRange.start),
+ };
+ }
+ function getEventClassNames(props) {
+ let classNames = ['fc-event'];
+ if (props.isMirror) {
+ classNames.push('fc-event-mirror');
+ }
+ if (props.isDraggable) {
+ classNames.push('fc-event-draggable');
+ }
+ if (props.isStartResizable || props.isEndResizable) {
+ classNames.push('fc-event-resizable');
+ }
+ if (props.isDragging) {
+ classNames.push('fc-event-dragging');
+ }
+ if (props.isResizing) {
+ classNames.push('fc-event-resizing');
+ }
+ if (props.isSelected) {
+ classNames.push('fc-event-selected');
+ }
+ if (props.isStart) {
+ classNames.push('fc-event-start');
+ }
+ if (props.isEnd) {
+ classNames.push('fc-event-end');
+ }
+ if (props.isPast) {
+ classNames.push('fc-event-past');
+ }
+ if (props.isToday) {
+ classNames.push('fc-event-today');
+ }
+ if (props.isFuture) {
+ classNames.push('fc-event-future');
+ }
+ return classNames;
+ }
+ function buildEventRangeKey(eventRange) {
+ return eventRange.instance
+ ? eventRange.instance.instanceId
+ : `${eventRange.def.defId}:${eventRange.range.start.toISOString()}`;
+ }
+ function getSegAnchorAttrs(seg, context) {
+ let { def, instance } = seg.eventRange;
+ let { url } = def;
+ if (url) {
+ return { href: url };
+ }
+ let { emitter, options } = context;
+ let { eventInteractive } = options;
+ if (eventInteractive == null) {
+ eventInteractive = def.interactive;
+ if (eventInteractive == null) {
+ eventInteractive = Boolean(emitter.hasHandlers('eventClick'));
+ }
+ }
+ if (eventInteractive) {
+ return createAriaKeyboardAttrs((ev) => {
+ emitter.trigger('eventClick', {
+ el: ev.target,
+ event: new EventImpl(context, def, instance),
+ jsEvent: ev,
+ view: context.viewApi,
+ });
+ });
+ }
+ return {};
+ }
+ const STANDARD_PROPS = {
+ start: identity,
+ end: identity,
+ allDay: Boolean,
+ };
+ function parseDateSpan(raw, dateEnv, defaultDuration) {
+ let span = parseOpenDateSpan(raw, dateEnv);
+ let { range } = span;
+ if (!range.start) {
+ return null;
+ }
+ if (!range.end) {
+ if (defaultDuration == null) {
+ return null;
+ }
+ range.end = dateEnv.add(range.start, defaultDuration);
+ }
+ return span;
+ }
+ function parseOpenDateSpan(raw, dateEnv) {
+ let { refined: standardProps, extra } = refineProps(raw, STANDARD_PROPS);
+ let startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
+ let endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
+ let { allDay } = standardProps;
+ if (allDay == null) {
+ allDay = (startMeta && startMeta.isTimeUnspecified) &&
+ (!endMeta || endMeta.isTimeUnspecified);
+ }
+ return Object.assign({ range: {
+ start: startMeta ? startMeta.marker : null,
+ end: endMeta ? endMeta.marker : null,
+ }, allDay }, extra);
+ }
+ function isDateSpansEqual(span0, span1) {
+ return rangesEqual(span0.range, span1.range) &&
+ span0.allDay === span1.allDay &&
+ isSpanPropsEqual(span0, span1);
+ }
+ function isSpanPropsEqual(span0, span1) {
+ for (let propName in span1) {
+ if (propName !== 'range' && propName !== 'allDay') {
+ if (span0[propName] !== span1[propName]) {
+ return false;
+ }
+ }
+ }
+ for (let propName in span0) {
+ if (!(propName in span1)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ function buildDateSpanApi(span, dateEnv) {
+ return Object.assign(Object.assign({}, buildRangeApi(span.range, dateEnv, span.allDay)), { allDay: span.allDay });
+ }
+ function buildRangeApiWithTimeZone(range, dateEnv, omitTime) {
+ return Object.assign(Object.assign({}, buildRangeApi(range, dateEnv, omitTime)), { timeZone: dateEnv.timeZone });
+ }
+ function buildRangeApi(range, dateEnv, omitTime) {
+ return {
+ start: dateEnv.toDate(range.start),
+ end: dateEnv.toDate(range.end),
+ startStr: dateEnv.formatIso(range.start, { omitTime }),
+ endStr: dateEnv.formatIso(range.end, { omitTime }),
+ };
+ }
+ function fabricateEventRange(dateSpan, eventUiBases, context) {
+ let res = refineEventDef({ editable: false }, context);
+ let def = parseEventDef(res.refined, res.extra, '',
+ dateSpan.allDay, true,
+ context);
+ return {
+ def,
+ ui: compileEventUi(def, eventUiBases),
+ instance: createEventInstance(def.defId, dateSpan.range),
+ range: dateSpan.range,
+ isStart: true,
+ isEnd: true,
+ };
+ }
+ function unpromisify(func, normalizedSuccessCallback, normalizedFailureCallback) {
+ let isResolved = false;
+ let wrappedSuccess = function (res) {
+ if (!isResolved) {
+ isResolved = true;
+ normalizedSuccessCallback(res);
+ }
+ };
+ let wrappedFailure = function (error) {
+ if (!isResolved) {
+ isResolved = true;
+ normalizedFailureCallback(error);
+ }
+ };
+ let res = func(wrappedSuccess, wrappedFailure);
+ if (res && typeof res.then === 'function') {
+ res.then(wrappedSuccess, wrappedFailure);
+ }
+ }
+ class JsonRequestError extends Error {
+ constructor(message, response) {
+ super(message);
+ this.response = response;
+ }
+ }
+ function requestJson(method, url, params) {
+ method = method.toUpperCase();
+ const fetchOptions = {
+ method,
+ };
+ if (method === 'GET') {
+ url += (url.indexOf('?') === -1 ? '?' : '&') +
+ new URLSearchParams(params);
+ }
+ else {
+ fetchOptions.body = new URLSearchParams(params);
+ fetchOptions.headers = {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ };
+ }
+ return fetch(url, fetchOptions).then((fetchRes) => {
+ if (fetchRes.ok) {
+ return fetchRes.json().then((parsedResponse) => {
+ return [parsedResponse, fetchRes];
+ }, () => {
+ throw new JsonRequestError('Failure parsing JSON', fetchRes);
+ });
+ }
+ else {
+ throw new JsonRequestError('Request failed', fetchRes);
+ }
+ });
+ }
+ let canVGrowWithinCell;
+ function getCanVGrowWithinCell() {
+ if (canVGrowWithinCell == null) {
+ canVGrowWithinCell = computeCanVGrowWithinCell();
+ }
+ return canVGrowWithinCell;
+ }
+ function computeCanVGrowWithinCell() {
+ if (typeof document === 'undefined') {
+ return true;
+ }
+ let el = document.createElement('div');
+ el.style.position = 'absolute';
+ el.style.top = '0px';
+ el.style.left = '0px';
+ el.innerHTML = '';
+ el.querySelector('table').style.height = '100px';
+ el.querySelector('div').style.height = '100%';
+ document.body.appendChild(el);
+ let div = el.querySelector('div');
+ let possible = div.offsetHeight > 0;
+ document.body.removeChild(el);
+ return possible;
+ }
+ class CalendarRoot extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.state = {
+ forPrint: false,
+ };
+ this.handleBeforePrint = () => {
+ flushSync(() => {
+ this.setState({ forPrint: true });
+ });
+ };
+ this.handleAfterPrint = () => {
+ flushSync(() => {
+ this.setState({ forPrint: false });
+ });
+ };
+ }
+ render() {
+ let { props } = this;
+ let { options } = props;
+ let { forPrint } = this.state;
+ let isHeightAuto = forPrint || options.height === 'auto' || options.contentHeight === 'auto';
+ let height = (!isHeightAuto && options.height != null) ? options.height : '';
+ let classNames = [
+ 'fc',
+ forPrint ? 'fc-media-print' : 'fc-media-screen',
+ `fc-direction-${options.direction}`,
+ props.theme.getClass('root'),
+ ];
+ if (!getCanVGrowWithinCell()) {
+ classNames.push('fc-liquid-hack');
+ }
+ return props.children(classNames, height, isHeightAuto, forPrint);
+ }
+ componentDidMount() {
+ let { emitter } = this.props;
+ emitter.on('_beforeprint', this.handleBeforePrint);
+ emitter.on('_afterprint', this.handleAfterPrint);
+ }
+ componentWillUnmount() {
+ let { emitter } = this.props;
+ emitter.off('_beforeprint', this.handleBeforePrint);
+ emitter.off('_afterprint', this.handleAfterPrint);
+ }
+ }
+ class Interaction {
+ constructor(settings) {
+ this.component = settings.component;
+ this.isHitComboAllowed = settings.isHitComboAllowed || null;
+ }
+ destroy() {
+ }
+ }
+ function parseInteractionSettings(component, input) {
+ return {
+ component,
+ el: input.el,
+ useEventCenter: input.useEventCenter != null ? input.useEventCenter : true,
+ isHitComboAllowed: input.isHitComboAllowed || null,
+ };
+ }
+ function interactionSettingsToStore(settings) {
+ return {
+ [settings.component.uid]: settings,
+ };
+ }
+ const interactionSettingsStore = {};
+ class NowTimer extends x$1 {
+ constructor(props, context) {
+ super(props, context);
+ this.handleRefresh = () => {
+ let timing = this.computeTiming();
+ if (timing.state.nowDate.valueOf() !== this.state.nowDate.valueOf()) {
+ this.setState(timing.state);
+ }
+ this.clearTimeout();
+ this.setTimeout(timing.waitMs);
+ };
+ this.handleVisibilityChange = () => {
+ if (!document.hidden) {
+ this.handleRefresh();
+ }
+ };
+ this.state = this.computeTiming().state;
+ }
+ render() {
+ let { props, state } = this;
+ return props.children(state.nowDate, state.todayRange);
+ }
+ componentDidMount() {
+ this.setTimeout();
+ this.context.nowManager.addResetListener(this.handleRefresh);
+ document.addEventListener('visibilitychange', this.handleVisibilityChange);
+ }
+ componentDidUpdate(prevProps) {
+ if (prevProps.unit !== this.props.unit) {
+ this.clearTimeout();
+ this.setTimeout();
+ }
+ }
+ componentWillUnmount() {
+ this.clearTimeout();
+ this.context.nowManager.removeResetListener(this.handleRefresh);
+ document.removeEventListener('visibilitychange', this.handleVisibilityChange);
+ }
+ computeTiming() {
+ let { props, context } = this;
+ let unroundedNow = context.nowManager.getDateMarker();
+ let { nowIndicatorSnap } = context.options;
+ if (nowIndicatorSnap === 'auto') {
+ nowIndicatorSnap =
+ /year|month|week|day/.test(props.unit) ||
+ (props.unitValue || 1) === 1;
+ }
+ let nowDate;
+ let waitMs;
+ if (nowIndicatorSnap) {
+ nowDate = context.dateEnv.startOf(unroundedNow, props.unit);
+ let nextUnitStart = context.dateEnv.add(nowDate, createDuration(1, props.unit));
+ waitMs = nextUnitStart.valueOf() - unroundedNow.valueOf();
+ }
+ else {
+ nowDate = unroundedNow;
+ waitMs = 1000 * 60;
+ }
+ waitMs = Math.min(1000 * 60 * 60 * 24, waitMs);
+ return {
+ state: { nowDate, todayRange: buildDayRange(nowDate) },
+ waitMs,
+ };
+ }
+ setTimeout(waitMs = this.computeTiming().waitMs) {
+ this.timeoutId = setTimeout(() => {
+ const timing = this.computeTiming();
+ this.setState(timing.state, () => {
+ this.setTimeout(timing.waitMs);
+ });
+ }, waitMs);
+ }
+ clearTimeout() {
+ if (this.timeoutId) {
+ clearTimeout(this.timeoutId);
+ }
+ }
+ }
+ NowTimer.contextType = ViewContextType;
+ function buildDayRange(date) {
+ let start = startOfDay(date);
+ let end = addDays(start, 1);
+ return { start, end };
+ }
+ class CalendarImpl {
+ getCurrentData() {
+ return this.currentDataManager.getCurrentData();
+ }
+ dispatch(action) {
+ this.currentDataManager.dispatch(action);
+ }
+ get view() { return this.getCurrentData().viewApi; }
+ batchRendering(callback) {
+ callback();
+ }
+ updateSize() {
+ this.trigger('_resize', true);
+ }
+ setOption(name, val) {
+ this.dispatch({
+ type: 'SET_OPTION',
+ optionName: name,
+ rawOptionValue: val,
+ });
+ }
+ getOption(name) {
+ return this.currentDataManager.currentCalendarOptionsInput[name];
+ }
+ getAvailableLocaleCodes() {
+ return Object.keys(this.getCurrentData().availableRawLocales);
+ }
+ on(handlerName, handler) {
+ let { currentDataManager } = this;
+ if (currentDataManager.currentCalendarOptionsRefiners[handlerName]) {
+ currentDataManager.emitter.on(handlerName, handler);
+ }
+ else {
+ console.warn(`Unknown listener name '${handlerName}'`);
+ }
+ }
+ off(handlerName, handler) {
+ this.currentDataManager.emitter.off(handlerName, handler);
+ }
+ trigger(handlerName, ...args) {
+ this.currentDataManager.emitter.trigger(handlerName, ...args);
+ }
+ changeView(viewType, dateOrRange) {
+ this.batchRendering(() => {
+ this.unselect();
+ if (dateOrRange) {
+ if (dateOrRange.start && dateOrRange.end) {
+ this.dispatch({
+ type: 'CHANGE_VIEW_TYPE',
+ viewType,
+ });
+ this.dispatch({
+ type: 'SET_OPTION',
+ optionName: 'visibleRange',
+ rawOptionValue: dateOrRange,
+ });
+ }
+ else {
+ let { dateEnv } = this.getCurrentData();
+ this.dispatch({
+ type: 'CHANGE_VIEW_TYPE',
+ viewType,
+ dateMarker: dateEnv.createMarker(dateOrRange),
+ });
+ }
+ }
+ else {
+ this.dispatch({
+ type: 'CHANGE_VIEW_TYPE',
+ viewType,
+ });
+ }
+ });
+ }
+ zoomTo(dateMarker, viewType) {
+ let state = this.getCurrentData();
+ let spec;
+ viewType = viewType || 'day';
+ spec = state.viewSpecs[viewType] || this.getUnitViewSpec(viewType);
+ this.unselect();
+ if (spec) {
+ this.dispatch({
+ type: 'CHANGE_VIEW_TYPE',
+ viewType: spec.type,
+ dateMarker,
+ });
+ }
+ else {
+ this.dispatch({
+ type: 'CHANGE_DATE',
+ dateMarker,
+ });
+ }
+ }
+ getUnitViewSpec(unit) {
+ let { viewSpecs, toolbarConfig } = this.getCurrentData();
+ let viewTypes = [].concat(toolbarConfig.header ? toolbarConfig.header.viewsWithButtons : [], toolbarConfig.footer ? toolbarConfig.footer.viewsWithButtons : []);
+ let i;
+ let spec;
+ for (let viewType in viewSpecs) {
+ viewTypes.push(viewType);
+ }
+ for (i = 0; i < viewTypes.length; i += 1) {
+ spec = viewSpecs[viewTypes[i]];
+ if (spec) {
+ if (spec.singleUnit === unit) {
+ return spec;
+ }
+ }
+ }
+ return null;
+ }
+ prev() {
+ this.unselect();
+ this.dispatch({ type: 'PREV' });
+ }
+ next() {
+ this.unselect();
+ this.dispatch({ type: 'NEXT' });
+ }
+ prevYear() {
+ let state = this.getCurrentData();
+ this.unselect();
+ this.dispatch({
+ type: 'CHANGE_DATE',
+ dateMarker: state.dateEnv.addYears(state.currentDate, -1),
+ });
+ }
+ nextYear() {
+ let state = this.getCurrentData();
+ this.unselect();
+ this.dispatch({
+ type: 'CHANGE_DATE',
+ dateMarker: state.dateEnv.addYears(state.currentDate, 1),
+ });
+ }
+ today() {
+ let state = this.getCurrentData();
+ this.unselect();
+ this.dispatch({
+ type: 'CHANGE_DATE',
+ dateMarker: state.nowManager.getDateMarker(),
+ });
+ }
+ gotoDate(zonedDateInput) {
+ let state = this.getCurrentData();
+ this.unselect();
+ this.dispatch({
+ type: 'CHANGE_DATE',
+ dateMarker: state.dateEnv.createMarker(zonedDateInput),
+ });
+ }
+ incrementDate(deltaInput) {
+ let state = this.getCurrentData();
+ let delta = createDuration(deltaInput);
+ if (delta) {
+ this.unselect();
+ this.dispatch({
+ type: 'CHANGE_DATE',
+ dateMarker: state.dateEnv.add(state.currentDate, delta),
+ });
+ }
+ }
+ getDate() {
+ let state = this.getCurrentData();
+ return state.dateEnv.toDate(state.currentDate);
+ }
+ formatDate(d, formatter) {
+ let { dateEnv } = this.getCurrentData();
+ return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
+ }
+ formatRange(d0, d1, settings) {
+ let { dateEnv } = this.getCurrentData();
+ return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings), settings);
+ }
+ formatIso(d, omitTime) {
+ let { dateEnv } = this.getCurrentData();
+ return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime });
+ }
+ select(dateOrObj, endDate) {
+ let selectionInput;
+ if (endDate == null) {
+ if (dateOrObj.start != null) {
+ selectionInput = dateOrObj;
+ }
+ else {
+ selectionInput = {
+ start: dateOrObj,
+ end: null,
+ };
+ }
+ }
+ else {
+ selectionInput = {
+ start: dateOrObj,
+ end: endDate,
+ };
+ }
+ let state = this.getCurrentData();
+ let selection = parseDateSpan(selectionInput, state.dateEnv, createDuration({ days: 1 }));
+ if (selection) {
+ this.dispatch({ type: 'SELECT_DATES', selection });
+ triggerDateSelect(selection, null, state);
+ }
+ }
+ unselect(pev) {
+ let state = this.getCurrentData();
+ if (state.dateSelection) {
+ this.dispatch({ type: 'UNSELECT_DATES' });
+ triggerDateUnselect(pev, state);
+ }
+ }
+ addEvent(eventInput, sourceInput) {
+ if (eventInput instanceof EventImpl) {
+ let def = eventInput._def;
+ let instance = eventInput._instance;
+ let currentData = this.getCurrentData();
+ if (!currentData.eventStore.defs[def.defId]) {
+ this.dispatch({
+ type: 'ADD_EVENTS',
+ eventStore: eventTupleToStore({ def, instance }),
+ });
+ this.triggerEventAdd(eventInput);
+ }
+ return eventInput;
+ }
+ let state = this.getCurrentData();
+ let eventSource;
+ if (sourceInput instanceof EventSourceImpl) {
+ eventSource = sourceInput.internalEventSource;
+ }
+ else if (typeof sourceInput === 'boolean') {
+ if (sourceInput) {
+ [eventSource] = hashValuesToArray(state.eventSources);
+ }
+ }
+ else if (sourceInput != null) {
+ let sourceApi = this.getEventSourceById(sourceInput);
+ if (!sourceApi) {
+ console.warn(`Could not find an event source with ID "${sourceInput}"`);
+ return null;
+ }
+ eventSource = sourceApi.internalEventSource;
+ }
+ let tuple = parseEvent(eventInput, eventSource, state, false);
+ if (tuple) {
+ let newEventApi = new EventImpl(state, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
+ this.dispatch({
+ type: 'ADD_EVENTS',
+ eventStore: eventTupleToStore(tuple),
+ });
+ this.triggerEventAdd(newEventApi);
+ return newEventApi;
+ }
+ return null;
+ }
+ triggerEventAdd(eventApi) {
+ let { emitter } = this.getCurrentData();
+ emitter.trigger('eventAdd', {
+ event: eventApi,
+ relatedEvents: [],
+ revert: () => {
+ this.dispatch({
+ type: 'REMOVE_EVENTS',
+ eventStore: eventApiToStore(eventApi),
+ });
+ },
+ });
+ }
+ getEventById(id) {
+ let state = this.getCurrentData();
+ let { defs, instances } = state.eventStore;
+ id = String(id);
+ for (let defId in defs) {
+ let def = defs[defId];
+ if (def.publicId === id) {
+ if (def.recurringDef) {
+ return new EventImpl(state, def, null);
+ }
+ for (let instanceId in instances) {
+ let instance = instances[instanceId];
+ if (instance.defId === def.defId) {
+ return new EventImpl(state, def, instance);
+ }
+ }
+ }
+ }
+ return null;
+ }
+ getEvents() {
+ let currentData = this.getCurrentData();
+ return buildEventApis(currentData.eventStore, currentData);
+ }
+ removeAllEvents() {
+ this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
+ }
+ getEventSources() {
+ let state = this.getCurrentData();
+ let sourceHash = state.eventSources;
+ let sourceApis = [];
+ for (let internalId in sourceHash) {
+ sourceApis.push(new EventSourceImpl(state, sourceHash[internalId]));
+ }
+ return sourceApis;
+ }
+ getEventSourceById(id) {
+ let state = this.getCurrentData();
+ let sourceHash = state.eventSources;
+ id = String(id);
+ for (let sourceId in sourceHash) {
+ if (sourceHash[sourceId].publicId === id) {
+ return new EventSourceImpl(state, sourceHash[sourceId]);
+ }
+ }
+ return null;
+ }
+ addEventSource(sourceInput) {
+ let state = this.getCurrentData();
+ if (sourceInput instanceof EventSourceImpl) {
+ if (!state.eventSources[sourceInput.internalEventSource.sourceId]) {
+ this.dispatch({
+ type: 'ADD_EVENT_SOURCES',
+ sources: [sourceInput.internalEventSource],
+ });
+ }
+ return sourceInput;
+ }
+ let eventSource = parseEventSource(sourceInput, state);
+ if (eventSource) {
+ this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
+ return new EventSourceImpl(state, eventSource);
+ }
+ return null;
+ }
+ removeAllEventSources() {
+ this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
+ }
+ refetchEvents() {
+ this.dispatch({ type: 'FETCH_EVENT_SOURCES', isRefetch: true });
+ }
+ scrollToTime(timeInput) {
+ let time = createDuration(timeInput);
+ if (time) {
+ this.trigger('_scrollRequest', { time });
+ }
+ }
+ }
+ function pointInsideRect(point, rect) {
+ return point.left >= rect.left &&
+ point.left < rect.right &&
+ point.top >= rect.top &&
+ point.top < rect.bottom;
+ }
+ function intersectRects(rect1, rect2) {
+ let res = {
+ left: Math.max(rect1.left, rect2.left),
+ right: Math.min(rect1.right, rect2.right),
+ top: Math.max(rect1.top, rect2.top),
+ bottom: Math.min(rect1.bottom, rect2.bottom),
+ };
+ if (res.left < res.right && res.top < res.bottom) {
+ return res;
+ }
+ return false;
+ }
+ function constrainPoint(point, rect) {
+ return {
+ left: Math.min(Math.max(point.left, rect.left), rect.right),
+ top: Math.min(Math.max(point.top, rect.top), rect.bottom),
+ };
+ }
+ function getRectCenter(rect) {
+ return {
+ left: (rect.left + rect.right) / 2,
+ top: (rect.top + rect.bottom) / 2,
+ };
+ }
+ function diffPoints(point1, point2) {
+ return {
+ left: point1.left - point2.left,
+ top: point1.top - point2.top,
+ };
+ }
+ const EMPTY_EVENT_STORE = createEmptyEventStore();
+ class Splitter {
+ constructor() {
+ this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
+ this.splitDateSelection = memoize(this._splitDateSpan);
+ this.splitEventStore = memoize(this._splitEventStore);
+ this.splitIndividualUi = memoize(this._splitIndividualUi);
+ this.splitEventDrag = memoize(this._splitInteraction);
+ this.splitEventResize = memoize(this._splitInteraction);
+ this.eventUiBuilders = {};
+ }
+ splitProps(props) {
+ let keyInfos = this.getKeyInfo(props);
+ let defKeys = this.getKeysForEventDefs(props.eventStore);
+ let dateSelections = this.splitDateSelection(props.dateSelection);
+ let individualUi = this.splitIndividualUi(props.eventUiBases, defKeys);
+ let eventStores = this.splitEventStore(props.eventStore, defKeys);
+ let eventDrags = this.splitEventDrag(props.eventDrag);
+ let eventResizes = this.splitEventResize(props.eventResize);
+ let splitProps = {};
+ this.eventUiBuilders = mapHash(keyInfos, (info, key) => this.eventUiBuilders[key] || memoize(buildEventUiForKey));
+ for (let key in keyInfos) {
+ let keyInfo = keyInfos[key];
+ let eventStore = eventStores[key] || EMPTY_EVENT_STORE;
+ let buildEventUi = this.eventUiBuilders[key];
+ splitProps[key] = {
+ businessHours: keyInfo.businessHours || props.businessHours,
+ dateSelection: dateSelections[key] || null,
+ eventStore,
+ eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
+ eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
+ eventDrag: eventDrags[key] || null,
+ eventResize: eventResizes[key] || null,
+ };
+ }
+ return splitProps;
+ }
+ _splitDateSpan(dateSpan) {
+ let dateSpans = {};
+ if (dateSpan) {
+ let keys = this.getKeysForDateSpan(dateSpan);
+ for (let key of keys) {
+ dateSpans[key] = dateSpan;
+ }
+ }
+ return dateSpans;
+ }
+ _getKeysForEventDefs(eventStore) {
+ return mapHash(eventStore.defs, (eventDef) => this.getKeysForEventDef(eventDef));
+ }
+ _splitEventStore(eventStore, defKeys) {
+ let { defs, instances } = eventStore;
+ let splitStores = {};
+ for (let defId in defs) {
+ for (let key of defKeys[defId]) {
+ if (!splitStores[key]) {
+ splitStores[key] = createEmptyEventStore();
+ }
+ splitStores[key].defs[defId] = defs[defId];
+ }
+ }
+ for (let instanceId in instances) {
+ let instance = instances[instanceId];
+ for (let key of defKeys[instance.defId]) {
+ if (splitStores[key]) {
+ splitStores[key].instances[instanceId] = instance;
+ }
+ }
+ }
+ return splitStores;
+ }
+ _splitIndividualUi(eventUiBases, defKeys) {
+ let splitHashes = {};
+ for (let defId in eventUiBases) {
+ if (defId) {
+ for (let key of defKeys[defId]) {
+ if (!splitHashes[key]) {
+ splitHashes[key] = {};
+ }
+ splitHashes[key][defId] = eventUiBases[defId];
+ }
+ }
+ }
+ return splitHashes;
+ }
+ _splitInteraction(interaction) {
+ let splitStates = {};
+ if (interaction) {
+ let affectedStores = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents));
+ let mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
+ let mutatedStores = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
+ let populate = (key) => {
+ if (!splitStates[key]) {
+ splitStates[key] = {
+ affectedEvents: affectedStores[key] || EMPTY_EVENT_STORE,
+ mutatedEvents: mutatedStores[key] || EMPTY_EVENT_STORE,
+ isEvent: interaction.isEvent,
+ };
+ }
+ };
+ for (let key in affectedStores) {
+ populate(key);
+ }
+ for (let key in mutatedStores) {
+ populate(key);
+ }
+ }
+ return splitStates;
+ }
+ }
+ function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
+ let baseParts = [];
+ if (allUi) {
+ baseParts.push(allUi);
+ }
+ if (eventUiForKey) {
+ baseParts.push(eventUiForKey);
+ }
+ let stuff = {
+ '': combineEventUis(baseParts),
+ };
+ if (individualUi) {
+ Object.assign(stuff, individualUi);
+ }
+ return stuff;
+ }
+ function getDateMeta(date, todayRange, nowDate, dateProfile) {
+ return {
+ dow: date.getUTCDay(),
+ isDisabled: Boolean(dateProfile && (!dateProfile.activeRange || !rangeContainsMarker(dateProfile.activeRange, date))),
+ isOther: Boolean(dateProfile && !rangeContainsMarker(dateProfile.currentRange, date)),
+ isToday: Boolean(todayRange && rangeContainsMarker(todayRange, date)),
+ isPast: Boolean(nowDate ? (date < nowDate) : todayRange ? (date < todayRange.start) : false),
+ isFuture: Boolean(nowDate ? (date > nowDate) : todayRange ? (date >= todayRange.end) : false),
+ };
+ }
+ function getDayClassNames(meta, theme) {
+ let classNames = [
+ 'fc-day',
+ `fc-day-${DAY_IDS[meta.dow]}`,
+ ];
+ if (meta.isDisabled) {
+ classNames.push('fc-day-disabled');
+ }
+ else {
+ if (meta.isToday) {
+ classNames.push('fc-day-today');
+ classNames.push(theme.getClass('today'));
+ }
+ if (meta.isPast) {
+ classNames.push('fc-day-past');
+ }
+ if (meta.isFuture) {
+ classNames.push('fc-day-future');
+ }
+ if (meta.isOther) {
+ classNames.push('fc-day-other');
+ }
+ }
+ return classNames;
+ }
+ const DAY_FORMAT = createFormatter({ year: 'numeric', month: 'long', day: 'numeric' });
+ const WEEK_FORMAT = createFormatter({ week: 'long' });
+ function buildNavLinkAttrs(context, dateMarker, viewType = 'day', isTabbable = true) {
+ const { dateEnv, options, calendarApi } = context;
+ let dateStr = dateEnv.format(dateMarker, viewType === 'week' ? WEEK_FORMAT : DAY_FORMAT);
+ if (options.navLinks) {
+ let zonedDate = dateEnv.toDate(dateMarker);
+ const handleInteraction = (ev) => {
+ let customAction = viewType === 'day' ? options.navLinkDayClick :
+ viewType === 'week' ? options.navLinkWeekClick : null;
+ if (typeof customAction === 'function') {
+ customAction.call(calendarApi, dateEnv.toDate(dateMarker), ev);
+ }
+ else {
+ if (typeof customAction === 'string') {
+ viewType = customAction;
+ }
+ calendarApi.zoomTo(dateMarker, viewType);
+ }
+ };
+ return Object.assign({ title: formatWithOrdinals(options.navLinkHint, [dateStr, zonedDate], dateStr), 'data-navlink': '' }, (isTabbable
+ ? createAriaClickAttrs(handleInteraction)
+ : { onClick: handleInteraction }));
+ }
+ return { 'aria-label': dateStr };
+ }
+ let _isRtlScrollbarOnLeft = null;
+ function getIsRtlScrollbarOnLeft() {
+ if (_isRtlScrollbarOnLeft === null) {
+ _isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
+ }
+ return _isRtlScrollbarOnLeft;
+ }
+ function computeIsRtlScrollbarOnLeft() {
+ let outerEl = document.createElement('div');
+ applyStyle(outerEl, {
+ position: 'absolute',
+ top: -1000,
+ left: 0,
+ border: 0,
+ padding: 0,
+ overflow: 'scroll',
+ direction: 'rtl',
+ });
+ outerEl.innerHTML = '
';
+ document.body.appendChild(outerEl);
+ let innerEl = outerEl.firstChild;
+ let res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
+ removeElement(outerEl);
+ return res;
+ }
+ let _scrollbarWidths;
+ function getScrollbarWidths() {
+ if (!_scrollbarWidths) {
+ _scrollbarWidths = computeScrollbarWidths();
+ }
+ return _scrollbarWidths;
+ }
+ function computeScrollbarWidths() {
+ let el = document.createElement('div');
+ el.style.overflow = 'scroll';
+ el.style.position = 'absolute';
+ el.style.top = '-9999px';
+ el.style.left = '-9999px';
+ document.body.appendChild(el);
+ let res = computeScrollbarWidthsForEl(el);
+ document.body.removeChild(el);
+ return res;
+ }
+ function computeScrollbarWidthsForEl(el) {
+ return {
+ x: el.offsetHeight - el.clientHeight,
+ y: el.offsetWidth - el.clientWidth,
+ };
+ }
+ function computeEdges(el, getPadding = false) {
+ let computedStyle = window.getComputedStyle(el);
+ let borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
+ let borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
+ let borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
+ let borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
+ let badScrollbarWidths = computeScrollbarWidthsForEl(el);
+ let scrollbarLeftRight = badScrollbarWidths.y - borderLeft - borderRight;
+ let scrollbarBottom = badScrollbarWidths.x - borderTop - borderBottom;
+ let res = {
+ borderLeft,
+ borderRight,
+ borderTop,
+ borderBottom,
+ scrollbarBottom,
+ scrollbarLeft: 0,
+ scrollbarRight: 0,
+ };
+ if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') {
+ res.scrollbarLeft = scrollbarLeftRight;
+ }
+ else {
+ res.scrollbarRight = scrollbarLeftRight;
+ }
+ if (getPadding) {
+ res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
+ res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
+ res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
+ res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
+ }
+ return res;
+ }
+ function computeInnerRect(el, goWithinPadding = false, doFromWindowViewport) {
+ let outerRect = doFromWindowViewport ? el.getBoundingClientRect() : computeRect(el);
+ let edges = computeEdges(el, goWithinPadding);
+ let res = {
+ left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
+ right: outerRect.right - edges.borderRight - edges.scrollbarRight,
+ top: outerRect.top + edges.borderTop,
+ bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom,
+ };
+ if (goWithinPadding) {
+ res.left += edges.paddingLeft;
+ res.right -= edges.paddingRight;
+ res.top += edges.paddingTop;
+ res.bottom -= edges.paddingBottom;
+ }
+ return res;
+ }
+ function computeRect(el) {
+ let rect = el.getBoundingClientRect();
+ return {
+ left: rect.left + window.scrollX,
+ top: rect.top + window.scrollY,
+ right: rect.right + window.scrollX,
+ bottom: rect.bottom + window.scrollY,
+ };
+ }
+ function computeClippedClientRect(el) {
+ let clippingParents = getClippingParents(el);
+ let rect = el.getBoundingClientRect();
+ for (let clippingParent of clippingParents) {
+ let intersection = intersectRects(rect, clippingParent.getBoundingClientRect());
+ if (intersection) {
+ rect = intersection;
+ }
+ else {
+ return null;
+ }
+ }
+ return rect;
+ }
+ function getClippingParents(el) {
+ let parents = [];
+ while (el instanceof HTMLElement) {
+ let computedStyle = window.getComputedStyle(el);
+ if (computedStyle.position === 'fixed') {
+ break;
+ }
+ if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
+ parents.push(el);
+ }
+ el = el.parentNode;
+ }
+ return parents;
+ }
+ class PositionCache {
+ constructor(originEl, els, isHorizontal, isVertical) {
+ this.els = els;
+ let originClientRect = this.originClientRect = originEl.getBoundingClientRect();
+ if (isHorizontal) {
+ this.buildElHorizontals(originClientRect.left);
+ }
+ if (isVertical) {
+ this.buildElVerticals(originClientRect.top);
+ }
+ }
+ buildElHorizontals(originClientLeft) {
+ let lefts = [];
+ let rights = [];
+ for (let el of this.els) {
+ let rect = el.getBoundingClientRect();
+ lefts.push(rect.left - originClientLeft);
+ rights.push(rect.right - originClientLeft);
+ }
+ this.lefts = lefts;
+ this.rights = rights;
+ }
+ buildElVerticals(originClientTop) {
+ let tops = [];
+ let bottoms = [];
+ for (let el of this.els) {
+ let rect = el.getBoundingClientRect();
+ tops.push(rect.top - originClientTop);
+ bottoms.push(rect.bottom - originClientTop);
+ }
+ this.tops = tops;
+ this.bottoms = bottoms;
+ }
+ leftToIndex(leftPosition) {
+ let { lefts, rights } = this;
+ let len = lefts.length;
+ let i;
+ for (i = 0; i < len; i += 1) {
+ if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
+ return i;
+ }
+ }
+ return undefined;
+ }
+ topToIndex(topPosition) {
+ let { tops, bottoms } = this;
+ let len = tops.length;
+ let i;
+ for (i = 0; i < len; i += 1) {
+ if (topPosition >= tops[i] && topPosition < bottoms[i]) {
+ return i;
+ }
+ }
+ return undefined;
+ }
+ getWidth(leftIndex) {
+ return this.rights[leftIndex] - this.lefts[leftIndex];
+ }
+ getHeight(topIndex) {
+ return this.bottoms[topIndex] - this.tops[topIndex];
+ }
+ similarTo(otherCache) {
+ return similarNumArrays(this.tops || [], otherCache.tops || []) &&
+ similarNumArrays(this.bottoms || [], otherCache.bottoms || []) &&
+ similarNumArrays(this.lefts || [], otherCache.lefts || []) &&
+ similarNumArrays(this.rights || [], otherCache.rights || []);
+ }
+ }
+ function similarNumArrays(a, b) {
+ const len = a.length;
+ if (len !== b.length) {
+ return false;
+ }
+ for (let i = 0; i < len; i++) {
+ if (Math.round(a[i]) !== Math.round(b[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ class ScrollController {
+ getMaxScrollTop() {
+ return this.getScrollHeight() - this.getClientHeight();
+ }
+ getMaxScrollLeft() {
+ return this.getScrollWidth() - this.getClientWidth();
+ }
+ canScrollVertically() {
+ return this.getMaxScrollTop() > 0;
+ }
+ canScrollHorizontally() {
+ return this.getMaxScrollLeft() > 0;
+ }
+ canScrollUp() {
+ return this.getScrollTop() > 0;
+ }
+ canScrollDown() {
+ return this.getScrollTop() < this.getMaxScrollTop();
+ }
+ canScrollLeft() {
+ return this.getScrollLeft() > 0;
+ }
+ canScrollRight() {
+ return this.getScrollLeft() < this.getMaxScrollLeft();
+ }
+ }
+ class ElementScrollController extends ScrollController {
+ constructor(el) {
+ super();
+ this.el = el;
+ }
+ getScrollTop() {
+ return this.el.scrollTop;
+ }
+ getScrollLeft() {
+ return this.el.scrollLeft;
+ }
+ setScrollTop(top) {
+ this.el.scrollTop = top;
+ }
+ setScrollLeft(left) {
+ this.el.scrollLeft = left;
+ }
+ getScrollWidth() {
+ return this.el.scrollWidth;
+ }
+ getScrollHeight() {
+ return this.el.scrollHeight;
+ }
+ getClientHeight() {
+ return this.el.clientHeight;
+ }
+ getClientWidth() {
+ return this.el.clientWidth;
+ }
+ }
+ class WindowScrollController extends ScrollController {
+ getScrollTop() {
+ return window.scrollY;
+ }
+ getScrollLeft() {
+ return window.scrollX;
+ }
+ setScrollTop(n) {
+ window.scroll(window.scrollX, n);
+ }
+ setScrollLeft(n) {
+ window.scroll(n, window.scrollY);
+ }
+ getScrollWidth() {
+ return document.documentElement.scrollWidth;
+ }
+ getScrollHeight() {
+ return document.documentElement.scrollHeight;
+ }
+ getClientHeight() {
+ return document.documentElement.clientHeight;
+ }
+ getClientWidth() {
+ return document.documentElement.clientWidth;
+ }
+ }
+ class DateComponent extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.uid = guid();
+ }
+ prepareHits() {
+ }
+ queryHit(positionLeft, positionTop, elWidth, elHeight) {
+ return null;
+ }
+ isValidSegDownEl(el) {
+ return !this.props.eventDrag &&
+ !this.props.eventResize &&
+ !elementClosest(el, '.fc-event-mirror');
+ }
+ isValidDateDownEl(el) {
+ return !elementClosest(el, '.fc-event:not(.fc-bg-event)') &&
+ !elementClosest(el, '.fc-more-link') &&
+ !elementClosest(el, 'a[data-navlink]') &&
+ !elementClosest(el, '.fc-popover');
+ }
+ }
+ class SegHierarchy {
+ constructor(getEntryThickness = (entry) => {
+ return entry.thickness || 1;
+ }) {
+ this.getEntryThickness = getEntryThickness;
+ this.strictOrder = false;
+ this.allowReslicing = false;
+ this.maxCoord = -1;
+ this.maxStackCnt = -1;
+ this.levelCoords = [];
+ this.entriesByLevel = [];
+ this.stackCnts = {};
+ }
+ addSegs(inputs) {
+ let hiddenEntries = [];
+ for (let input of inputs) {
+ this.insertEntry(input, hiddenEntries);
+ }
+ return hiddenEntries;
+ }
+ insertEntry(entry, hiddenEntries) {
+ let insertion = this.findInsertion(entry);
+ if (this.isInsertionValid(insertion, entry)) {
+ this.insertEntryAt(entry, insertion);
+ }
+ else {
+ this.handleInvalidInsertion(insertion, entry, hiddenEntries);
+ }
+ }
+ isInsertionValid(insertion, entry) {
+ return (this.maxCoord === -1 || insertion.levelCoord + this.getEntryThickness(entry) <= this.maxCoord) &&
+ (this.maxStackCnt === -1 || insertion.stackCnt < this.maxStackCnt);
+ }
+ handleInvalidInsertion(insertion, entry, hiddenEntries) {
+ if (this.allowReslicing && insertion.touchingEntry) {
+ const hiddenEntry = Object.assign(Object.assign({}, entry), { span: intersectSpans(entry.span, insertion.touchingEntry.span) });
+ hiddenEntries.push(hiddenEntry);
+ this.splitEntry(entry, insertion.touchingEntry, hiddenEntries);
+ }
+ else {
+ hiddenEntries.push(entry);
+ }
+ }
+ splitEntry(entry, barrier, hiddenEntries) {
+ let entrySpan = entry.span;
+ let barrierSpan = barrier.span;
+ if (entrySpan.start < barrierSpan.start) {
+ this.insertEntry({
+ index: entry.index,
+ thickness: entry.thickness,
+ span: { start: entrySpan.start, end: barrierSpan.start },
+ }, hiddenEntries);
+ }
+ if (entrySpan.end > barrierSpan.end) {
+ this.insertEntry({
+ index: entry.index,
+ thickness: entry.thickness,
+ span: { start: barrierSpan.end, end: entrySpan.end },
+ }, hiddenEntries);
+ }
+ }
+ insertEntryAt(entry, insertion) {
+ let { entriesByLevel, levelCoords } = this;
+ if (insertion.lateral === -1) {
+ insertAt(levelCoords, insertion.level, insertion.levelCoord);
+ insertAt(entriesByLevel, insertion.level, [entry]);
+ }
+ else {
+ insertAt(entriesByLevel[insertion.level], insertion.lateral, entry);
+ }
+ this.stackCnts[buildEntryKey(entry)] = insertion.stackCnt;
+ }
+ findInsertion(newEntry) {
+ let { levelCoords, entriesByLevel, strictOrder, stackCnts } = this;
+ let levelCnt = levelCoords.length;
+ let candidateCoord = 0;
+ let touchingLevel = -1;
+ let touchingLateral = -1;
+ let touchingEntry = null;
+ let stackCnt = 0;
+ for (let trackingLevel = 0; trackingLevel < levelCnt; trackingLevel += 1) {
+ const trackingCoord = levelCoords[trackingLevel];
+ if (!strictOrder && trackingCoord >= candidateCoord + this.getEntryThickness(newEntry)) {
+ break;
+ }
+ let trackingEntries = entriesByLevel[trackingLevel];
+ let trackingEntry;
+ let searchRes = binarySearch(trackingEntries, newEntry.span.start, getEntrySpanEnd);
+ let lateralIndex = searchRes[0] + searchRes[1];
+ while (
+ (trackingEntry = trackingEntries[lateralIndex]) &&
+ trackingEntry.span.start < newEntry.span.end
+ ) {
+ let trackingEntryBottom = trackingCoord + this.getEntryThickness(trackingEntry);
+ if (trackingEntryBottom > candidateCoord) {
+ candidateCoord = trackingEntryBottom;
+ touchingEntry = trackingEntry;
+ touchingLevel = trackingLevel;
+ touchingLateral = lateralIndex;
+ }
+ if (trackingEntryBottom === candidateCoord) {
+ stackCnt = Math.max(stackCnt, stackCnts[buildEntryKey(trackingEntry)] + 1);
+ }
+ lateralIndex += 1;
+ }
+ }
+ let destLevel = 0;
+ if (touchingEntry) {
+ destLevel = touchingLevel + 1;
+ while (destLevel < levelCnt && levelCoords[destLevel] < candidateCoord) {
+ destLevel += 1;
+ }
+ }
+ let destLateral = -1;
+ if (destLevel < levelCnt && levelCoords[destLevel] === candidateCoord) {
+ destLateral = binarySearch(entriesByLevel[destLevel], newEntry.span.end, getEntrySpanEnd)[0];
+ }
+ return {
+ touchingLevel,
+ touchingLateral,
+ touchingEntry,
+ stackCnt,
+ levelCoord: candidateCoord,
+ level: destLevel,
+ lateral: destLateral,
+ };
+ }
+ toRects() {
+ let { entriesByLevel, levelCoords } = this;
+ let levelCnt = entriesByLevel.length;
+ let rects = [];
+ for (let level = 0; level < levelCnt; level += 1) {
+ let entries = entriesByLevel[level];
+ let levelCoord = levelCoords[level];
+ for (let entry of entries) {
+ rects.push(Object.assign(Object.assign({}, entry), { thickness: this.getEntryThickness(entry), levelCoord }));
+ }
+ }
+ return rects;
+ }
+ }
+ function getEntrySpanEnd(entry) {
+ return entry.span.end;
+ }
+ function buildEntryKey(entry) {
+ return entry.index + ':' + entry.span.start;
+ }
+ function groupIntersectingEntries(entries) {
+ let merges = [];
+ for (let entry of entries) {
+ let filteredMerges = [];
+ let hungryMerge = {
+ span: entry.span,
+ entries: [entry],
+ };
+ for (let merge of merges) {
+ if (intersectSpans(merge.span, hungryMerge.span)) {
+ hungryMerge = {
+ entries: merge.entries.concat(hungryMerge.entries),
+ span: joinSpans(merge.span, hungryMerge.span),
+ };
+ }
+ else {
+ filteredMerges.push(merge);
+ }
+ }
+ filteredMerges.push(hungryMerge);
+ merges = filteredMerges;
+ }
+ return merges;
+ }
+ function joinSpans(span0, span1) {
+ return {
+ start: Math.min(span0.start, span1.start),
+ end: Math.max(span0.end, span1.end),
+ };
+ }
+ function intersectSpans(span0, span1) {
+ let start = Math.max(span0.start, span1.start);
+ let end = Math.min(span0.end, span1.end);
+ if (start < end) {
+ return { start, end };
+ }
+ return null;
+ }
+ function insertAt(arr, index, item) {
+ arr.splice(index, 0, item);
+ }
+ function binarySearch(a, searchVal, getItemVal) {
+ let startIndex = 0;
+ let endIndex = a.length;
+ if (!endIndex || searchVal < getItemVal(a[startIndex])) {
+ return [0, 0];
+ }
+ if (searchVal > getItemVal(a[endIndex - 1])) {
+ return [endIndex, 0];
+ }
+ while (startIndex < endIndex) {
+ let middleIndex = Math.floor(startIndex + (endIndex - startIndex) / 2);
+ let middleVal = getItemVal(a[middleIndex]);
+ if (searchVal < middleVal) {
+ endIndex = middleIndex;
+ }
+ else if (searchVal > middleVal) {
+ startIndex = middleIndex + 1;
+ }
+ else {
+ return [middleIndex, 1];
+ }
+ }
+ return [startIndex, 0];
+ }
+ class ElementDragging {
+ constructor(el, selector) {
+ this.emitter = new Emitter();
+ }
+ destroy() {
+ }
+ setMirrorIsVisible(bool) {
+ }
+ setMirrorNeedsRevert(bool) {
+ }
+ setAutoScrollEnabled(bool) {
+ }
+ }
+ const config = {};
+ function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
+ if (!datesRepDistinctDays || dayCnt > 10) {
+ return createFormatter({ weekday: 'short' });
+ }
+ if (dayCnt > 1) {
+ return createFormatter({ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true });
+ }
+ return createFormatter({ weekday: 'long' });
+ }
+ const CLASS_NAME = 'fc-col-header-cell';
+ function renderInner$1(renderProps) {
+ return renderProps.text;
+ }
+ class TableDateCell extends BaseComponent {
+ render() {
+ let { dateEnv, options, theme, viewApi } = this.context;
+ let { props } = this;
+ let { date, dateProfile } = props;
+ let dayMeta = getDateMeta(date, props.todayRange, null, dateProfile);
+ let classNames = [CLASS_NAME].concat(getDayClassNames(dayMeta, theme));
+ let text = dateEnv.format(date, props.dayHeaderFormat);
+ let navLinkAttrs = (!dayMeta.isDisabled && props.colCnt > 1)
+ ? buildNavLinkAttrs(this.context, date)
+ : {};
+ let publicDate = dateEnv.toDate(date);
+ if (dateEnv.namedTimeZoneImpl) {
+ publicDate = addMs(publicDate, 3600000);
+ }
+ let renderProps = Object.assign(Object.assign(Object.assign({ date: publicDate, view: viewApi }, props.extraRenderProps), { text }), dayMeta);
+ return (y(ContentContainer, { elTag: "th", elClasses: classNames, elAttrs: Object.assign({ role: 'columnheader', colSpan: props.colSpan, 'data-date': !dayMeta.isDisabled ? formatDayString(date) : undefined }, props.extraDataAttrs), renderProps: renderProps, generatorName: "dayHeaderContent", customGenerator: options.dayHeaderContent, defaultGenerator: renderInner$1, classNameGenerator: options.dayHeaderClassNames, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, (InnerContainer) => (y("div", { className: "fc-scrollgrid-sync-inner" }, !dayMeta.isDisabled && (y(InnerContainer, { elTag: "a", elAttrs: navLinkAttrs, elClasses: [
+ 'fc-col-header-cell-cushion',
+ props.isSticky && 'fc-sticky',
+ ] }))))));
+ }
+ }
+ const WEEKDAY_FORMAT = createFormatter({ weekday: 'long' });
+ class TableDowCell extends BaseComponent {
+ render() {
+ let { props } = this;
+ let { dateEnv, theme, viewApi, options } = this.context;
+ let date = addDays(new Date(259200000), props.dow);
+ let dateMeta = {
+ dow: props.dow,
+ isDisabled: false,
+ isFuture: false,
+ isPast: false,
+ isToday: false,
+ isOther: false,
+ };
+ let text = dateEnv.format(date, props.dayHeaderFormat);
+ let renderProps = Object.assign(Object.assign(Object.assign(Object.assign({
+ date }, dateMeta), { view: viewApi }), props.extraRenderProps), { text });
+ return (y(ContentContainer, { elTag: "th", elClasses: [
+ CLASS_NAME,
+ ...getDayClassNames(dateMeta, theme),
+ ...(props.extraClassNames || []),
+ ], elAttrs: Object.assign({ role: 'columnheader', colSpan: props.colSpan }, props.extraDataAttrs), renderProps: renderProps, generatorName: "dayHeaderContent", customGenerator: options.dayHeaderContent, defaultGenerator: renderInner$1, classNameGenerator: options.dayHeaderClassNames, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, (InnerContent) => (y("div", { className: "fc-scrollgrid-sync-inner" },
+ y(InnerContent, { elTag: "a", elClasses: [
+ 'fc-col-header-cell-cushion',
+ props.isSticky && 'fc-sticky',
+ ], elAttrs: {
+ 'aria-label': dateEnv.format(date, WEEKDAY_FORMAT),
+ } })))));
+ }
+ }
+ class DayHeader extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
+ }
+ render() {
+ let { context } = this;
+ let { dates, dateProfile, datesRepDistinctDays, renderIntro } = this.props;
+ let dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, datesRepDistinctDays, dates.length);
+ return (y(NowTimer, { unit: "day" }, (nowDate, todayRange) => (y("tr", { role: "row" },
+ renderIntro && renderIntro('day'),
+ dates.map((date) => (datesRepDistinctDays ? (y(TableDateCell, { key: date.toISOString(), date: date, dateProfile: dateProfile, todayRange: todayRange, colCnt: dates.length, dayHeaderFormat: dayHeaderFormat })) : (y(TableDowCell, { key: date.getUTCDay(), dow: date.getUTCDay(), dayHeaderFormat: dayHeaderFormat }))))))));
+ }
+ }
+ function createDayHeaderFormatter(explicitFormat, datesRepDistinctDays, dateCnt) {
+ return explicitFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dateCnt);
+ }
+ class DaySeriesModel {
+ constructor(range, dateProfileGenerator) {
+ let date = range.start;
+ let { end } = range;
+ let indices = [];
+ let dates = [];
+ let dayIndex = -1;
+ while (date < end) {
+ if (dateProfileGenerator.isHiddenDay(date)) {
+ indices.push(dayIndex + 0.5);
+ }
+ else {
+ dayIndex += 1;
+ indices.push(dayIndex);
+ dates.push(date);
+ }
+ date = addDays(date, 1);
+ }
+ this.dates = dates;
+ this.indices = indices;
+ this.cnt = dates.length;
+ }
+ sliceRange(range) {
+ let firstIndex = this.getDateDayIndex(range.start);
+ let lastIndex = this.getDateDayIndex(addDays(range.end, -1));
+ let clippedFirstIndex = Math.max(0, firstIndex);
+ let clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
+ clippedFirstIndex = Math.ceil(clippedFirstIndex);
+ clippedLastIndex = Math.floor(clippedLastIndex);
+ if (clippedFirstIndex <= clippedLastIndex) {
+ return {
+ firstIndex: clippedFirstIndex,
+ lastIndex: clippedLastIndex,
+ isStart: firstIndex === clippedFirstIndex,
+ isEnd: lastIndex === clippedLastIndex,
+ };
+ }
+ return null;
+ }
+ getDateDayIndex(date) {
+ let { indices } = this;
+ let dayOffset = Math.floor(diffDays(this.dates[0], date));
+ if (dayOffset < 0) {
+ return indices[0] - 1;
+ }
+ if (dayOffset >= indices.length) {
+ return indices[indices.length - 1] + 1;
+ }
+ return indices[dayOffset];
+ }
+ }
+ class DayTableModel {
+ constructor(daySeries, breakOnWeeks) {
+ let { dates } = daySeries;
+ let daysPerRow;
+ let firstDay;
+ let rowCnt;
+ if (breakOnWeeks) {
+ firstDay = dates[0].getUTCDay();
+ for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow += 1) {
+ if (dates[daysPerRow].getUTCDay() === firstDay) {
+ break;
+ }
+ }
+ rowCnt = Math.ceil(dates.length / daysPerRow);
+ }
+ else {
+ rowCnt = 1;
+ daysPerRow = dates.length;
+ }
+ this.rowCnt = rowCnt;
+ this.colCnt = daysPerRow;
+ this.daySeries = daySeries;
+ this.cells = this.buildCells();
+ this.headerDates = this.buildHeaderDates();
+ }
+ buildCells() {
+ let rows = [];
+ for (let row = 0; row < this.rowCnt; row += 1) {
+ let cells = [];
+ for (let col = 0; col < this.colCnt; col += 1) {
+ cells.push(this.buildCell(row, col));
+ }
+ rows.push(cells);
+ }
+ return rows;
+ }
+ buildCell(row, col) {
+ let date = this.daySeries.dates[row * this.colCnt + col];
+ return {
+ key: date.toISOString(),
+ date,
+ };
+ }
+ buildHeaderDates() {
+ let dates = [];
+ for (let col = 0; col < this.colCnt; col += 1) {
+ dates.push(this.cells[0][col].date);
+ }
+ return dates;
+ }
+ sliceRange(range) {
+ let { colCnt } = this;
+ let seriesSeg = this.daySeries.sliceRange(range);
+ let segs = [];
+ if (seriesSeg) {
+ let { firstIndex, lastIndex } = seriesSeg;
+ let index = firstIndex;
+ while (index <= lastIndex) {
+ let row = Math.floor(index / colCnt);
+ let nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
+ segs.push({
+ row,
+ firstCol: index % colCnt,
+ lastCol: (nextIndex - 1) % colCnt,
+ isStart: seriesSeg.isStart && index === firstIndex,
+ isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex,
+ });
+ index = nextIndex;
+ }
+ }
+ return segs;
+ }
+ }
+ class Slicer {
+ constructor() {
+ this.sliceBusinessHours = memoize(this._sliceBusinessHours);
+ this.sliceDateSelection = memoize(this._sliceDateSpan);
+ this.sliceEventStore = memoize(this._sliceEventStore);
+ this.sliceEventDrag = memoize(this._sliceInteraction);
+ this.sliceEventResize = memoize(this._sliceInteraction);
+ this.forceDayIfListItem = false;
+ }
+ sliceProps(props, dateProfile, nextDayThreshold, context, ...extraArgs) {
+ let { eventUiBases } = props;
+ let eventSegs = this.sliceEventStore(props.eventStore, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs);
+ return {
+ dateSelectionSegs: this.sliceDateSelection(props.dateSelection, dateProfile, nextDayThreshold, eventUiBases, context, ...extraArgs),
+ businessHourSegs: this.sliceBusinessHours(props.businessHours, dateProfile, nextDayThreshold, context, ...extraArgs),
+ fgEventSegs: eventSegs.fg,
+ bgEventSegs: eventSegs.bg,
+ eventDrag: this.sliceEventDrag(props.eventDrag, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs),
+ eventResize: this.sliceEventResize(props.eventResize, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs),
+ eventSelection: props.eventSelection,
+ };
+ }
+ sliceNowDate(
+ date, dateProfile, nextDayThreshold, context, ...extraArgs) {
+ return this._sliceDateSpan({ range: { start: date, end: addMs(date, 1) }, allDay: false },
+ dateProfile, nextDayThreshold, {}, context, ...extraArgs);
+ }
+ _sliceBusinessHours(businessHours, dateProfile, nextDayThreshold, context, ...extraArgs) {
+ if (!businessHours) {
+ return [];
+ }
+ return this._sliceEventStore(expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), context), {}, dateProfile, nextDayThreshold, ...extraArgs).bg;
+ }
+ _sliceEventStore(eventStore, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs) {
+ if (eventStore) {
+ let rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
+ return {
+ bg: this.sliceEventRanges(rangeRes.bg, extraArgs),
+ fg: this.sliceEventRanges(rangeRes.fg, extraArgs),
+ };
+ }
+ return { bg: [], fg: [] };
+ }
+ _sliceInteraction(interaction, eventUiBases, dateProfile, nextDayThreshold, ...extraArgs) {
+ if (!interaction) {
+ return null;
+ }
+ let rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
+ return {
+ segs: this.sliceEventRanges(rangeRes.fg, extraArgs),
+ affectedInstances: interaction.affectedEvents.instances,
+ isEvent: interaction.isEvent,
+ };
+ }
+ _sliceDateSpan(dateSpan, dateProfile, nextDayThreshold, eventUiBases, context, ...extraArgs) {
+ if (!dateSpan) {
+ return [];
+ }
+ let activeRange = computeActiveRange(dateProfile, Boolean(nextDayThreshold));
+ let activeDateSpanRange = intersectRanges(dateSpan.range, activeRange);
+ if (activeDateSpanRange) {
+ dateSpan = Object.assign(Object.assign({}, dateSpan), { range: activeDateSpanRange });
+ let eventRange = fabricateEventRange(dateSpan, eventUiBases, context);
+ let segs = this.sliceRange(dateSpan.range, ...extraArgs);
+ for (let seg of segs) {
+ seg.eventRange = eventRange;
+ }
+ return segs;
+ }
+ return [];
+ }
+ sliceEventRanges(eventRanges, extraArgs) {
+ let segs = [];
+ for (let eventRange of eventRanges) {
+ segs.push(...this.sliceEventRange(eventRange, extraArgs));
+ }
+ return segs;
+ }
+ sliceEventRange(eventRange, extraArgs) {
+ let dateRange = eventRange.range;
+ if (this.forceDayIfListItem && eventRange.ui.display === 'list-item') {
+ dateRange = {
+ start: dateRange.start,
+ end: addDays(dateRange.start, 1),
+ };
+ }
+ let segs = this.sliceRange(dateRange, ...extraArgs);
+ for (let seg of segs) {
+ seg.eventRange = eventRange;
+ seg.isStart = eventRange.isStart && seg.isStart;
+ seg.isEnd = eventRange.isEnd && seg.isEnd;
+ }
+ return segs;
+ }
+ }
+ function computeActiveRange(dateProfile, isComponentAllDay) {
+ let range = dateProfile.activeRange;
+ if (isComponentAllDay) {
+ return range;
+ }
+ return {
+ start: addMs(range.start, dateProfile.slotMinTime.milliseconds),
+ end: addMs(range.end, dateProfile.slotMaxTime.milliseconds - 864e5),
+ };
+ }
+ function isInteractionValid(interaction, dateProfile, context) {
+ let { instances } = interaction.mutatedEvents;
+ for (let instanceId in instances) {
+ if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
+ return false;
+ }
+ }
+ return isNewPropsValid({ eventDrag: interaction }, context);
+ }
+ function isDateSelectionValid(dateSelection, dateProfile, context) {
+ if (!rangeContainsRange(dateProfile.validRange, dateSelection.range)) {
+ return false;
+ }
+ return isNewPropsValid({ dateSelection }, context);
+ }
+ function isNewPropsValid(newProps, context) {
+ let calendarState = context.getCurrentData();
+ let props = Object.assign({ businessHours: calendarState.businessHours, dateSelection: '', eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
+ return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
+ }
+ function isPropsValid(state, context, dateSpanMeta = {}, filterConfig) {
+ if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
+ return false;
+ }
+ if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
+ return false;
+ }
+ return true;
+ }
+ function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
+ let currentState = context.getCurrentData();
+ let interaction = state.eventDrag;
+ let subjectEventStore = interaction.mutatedEvents;
+ let subjectDefs = subjectEventStore.defs;
+ let subjectInstances = subjectEventStore.instances;
+ let subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
+ state.eventUiBases :
+ { '': currentState.selectionConfig });
+ if (filterConfig) {
+ subjectConfigs = mapHash(subjectConfigs, filterConfig);
+ }
+ let otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances);
+ let otherDefs = otherEventStore.defs;
+ let otherInstances = otherEventStore.instances;
+ let otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
+ for (let subjectInstanceId in subjectInstances) {
+ let subjectInstance = subjectInstances[subjectInstanceId];
+ let subjectRange = subjectInstance.range;
+ let subjectConfig = subjectConfigs[subjectInstance.defId];
+ let subjectDef = subjectDefs[subjectInstance.defId];
+ if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
+ return false;
+ }
+ let { eventOverlap } = context.options;
+ let eventOverlapFunc = typeof eventOverlap === 'function' ? eventOverlap : null;
+ for (let otherInstanceId in otherInstances) {
+ let otherInstance = otherInstances[otherInstanceId];
+ if (rangesIntersect(subjectRange, otherInstance.range)) {
+ let otherOverlap = otherConfigs[otherInstance.defId].overlap;
+ if (otherOverlap === false && interaction.isEvent) {
+ return false;
+ }
+ if (subjectConfig.overlap === false) {
+ return false;
+ }
+ if (eventOverlapFunc && !eventOverlapFunc(new EventImpl(context, otherDefs[otherInstance.defId], otherInstance),
+ new EventImpl(context, subjectDef, subjectInstance))) {
+ return false;
+ }
+ }
+ }
+ let calendarEventStore = currentState.eventStore;
+ for (let subjectAllow of subjectConfig.allows) {
+ let subjectDateSpan = Object.assign(Object.assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
+ let origDef = calendarEventStore.defs[subjectDef.defId];
+ let origInstance = calendarEventStore.instances[subjectInstanceId];
+ let eventApi;
+ if (origDef) {
+ eventApi = new EventImpl(context, origDef, origInstance);
+ }
+ else {
+ eventApi = new EventImpl(context, subjectDef);
+ }
+ if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
+ let relevantEventStore = state.eventStore;
+ let relevantDefs = relevantEventStore.defs;
+ let relevantInstances = relevantEventStore.instances;
+ let selection = state.dateSelection;
+ let selectionRange = selection.range;
+ let { selectionConfig } = context.getCurrentData();
+ if (filterConfig) {
+ selectionConfig = filterConfig(selectionConfig);
+ }
+ if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
+ return false;
+ }
+ let { selectOverlap } = context.options;
+ let selectOverlapFunc = typeof selectOverlap === 'function' ? selectOverlap : null;
+ for (let relevantInstanceId in relevantInstances) {
+ let relevantInstance = relevantInstances[relevantInstanceId];
+ if (rangesIntersect(selectionRange, relevantInstance.range)) {
+ if (selectionConfig.overlap === false) {
+ return false;
+ }
+ if (selectOverlapFunc && !selectOverlapFunc(new EventImpl(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
+ return false;
+ }
+ }
+ }
+ for (let selectionAllow of selectionConfig.allows) {
+ let fullDateSpan = Object.assign(Object.assign({}, dateSpanMeta), selection);
+ if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
+ for (let constraint of constraints) {
+ if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ function constraintToRanges(constraint, subjectRange,
+ otherEventStore,
+ businessHoursUnexpanded,
+ context) {
+ if (constraint === 'businessHours') {
+ return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
+ }
+ if (typeof constraint === 'string') {
+ return eventStoreToRanges(filterEventStoreDefs(otherEventStore, (eventDef) => eventDef.groupId === constraint));
+ }
+ if (typeof constraint === 'object' && constraint) {
+ return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
+ }
+ return [];
+ }
+ function eventStoreToRanges(eventStore) {
+ let { instances } = eventStore;
+ let ranges = [];
+ for (let instanceId in instances) {
+ ranges.push(instances[instanceId].range);
+ }
+ return ranges;
+ }
+ function anyRangesContainRange(outerRanges, innerRange) {
+ for (let outerRange of outerRanges) {
+ if (rangeContainsRange(outerRange, innerRange)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ const VISIBLE_HIDDEN_RE = /^(visible|hidden)$/;
+ class Scroller extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.handleEl = (el) => {
+ this.el = el;
+ setRef(this.props.elRef, el);
+ };
+ }
+ render() {
+ let { props } = this;
+ let { liquid, liquidIsAbsolute } = props;
+ let isAbsolute = liquid && liquidIsAbsolute;
+ let className = ['fc-scroller'];
+ if (liquid) {
+ if (liquidIsAbsolute) {
+ className.push('fc-scroller-liquid-absolute');
+ }
+ else {
+ className.push('fc-scroller-liquid');
+ }
+ }
+ return (y("div", { ref: this.handleEl, className: className.join(' '), style: {
+ overflowX: props.overflowX,
+ overflowY: props.overflowY,
+ left: (isAbsolute && -(props.overcomeLeft || 0)) || '',
+ right: (isAbsolute && -(props.overcomeRight || 0)) || '',
+ bottom: (isAbsolute && -(props.overcomeBottom || 0)) || '',
+ marginLeft: (!isAbsolute && -(props.overcomeLeft || 0)) || '',
+ marginRight: (!isAbsolute && -(props.overcomeRight || 0)) || '',
+ marginBottom: (!isAbsolute && -(props.overcomeBottom || 0)) || '',
+ maxHeight: props.maxHeight || '',
+ } }, props.children));
+ }
+ needsXScrolling() {
+ if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
+ return false;
+ }
+ let { el } = this;
+ let realClientWidth = this.el.getBoundingClientRect().width - this.getYScrollbarWidth();
+ let { children } = el;
+ for (let i = 0; i < children.length; i += 1) {
+ let childEl = children[i];
+ if (childEl.getBoundingClientRect().width > realClientWidth) {
+ return true;
+ }
+ }
+ return false;
+ }
+ needsYScrolling() {
+ if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
+ return false;
+ }
+ let { el } = this;
+ let realClientHeight = this.el.getBoundingClientRect().height - this.getXScrollbarWidth();
+ let { children } = el;
+ for (let i = 0; i < children.length; i += 1) {
+ let childEl = children[i];
+ if (childEl.getBoundingClientRect().height > realClientHeight) {
+ return true;
+ }
+ }
+ return false;
+ }
+ getXScrollbarWidth() {
+ if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
+ return 0;
+ }
+ return this.el.offsetHeight - this.el.clientHeight;
+ }
+ getYScrollbarWidth() {
+ if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
+ return 0;
+ }
+ return this.el.offsetWidth - this.el.clientWidth;
+ }
+ }
+ class RefMap {
+ constructor(masterCallback) {
+ this.masterCallback = masterCallback;
+ this.currentMap = {};
+ this.depths = {};
+ this.callbackMap = {};
+ this.handleValue = (val, key) => {
+ let { depths, currentMap } = this;
+ let removed = false;
+ let added = false;
+ if (val !== null) {
+ removed = (key in currentMap);
+ currentMap[key] = val;
+ depths[key] = (depths[key] || 0) + 1;
+ added = true;
+ }
+ else {
+ depths[key] -= 1;
+ if (!depths[key]) {
+ delete currentMap[key];
+ delete this.callbackMap[key];
+ removed = true;
+ }
+ }
+ if (this.masterCallback) {
+ if (removed) {
+ this.masterCallback(null, String(key));
+ }
+ if (added) {
+ this.masterCallback(val, String(key));
+ }
+ }
+ };
+ }
+ createRef(key) {
+ let refCallback = this.callbackMap[key];
+ if (!refCallback) {
+ refCallback = this.callbackMap[key] = (val) => {
+ this.handleValue(val, String(key));
+ };
+ }
+ return refCallback;
+ }
+ collect(startIndex, endIndex, step) {
+ return collectFromHash(this.currentMap, startIndex, endIndex, step);
+ }
+ getAll() {
+ return hashValuesToArray(this.currentMap);
+ }
+ }
+ function computeShrinkWidth(chunkEls) {
+ let shrinkCells = findElements(chunkEls, '.fc-scrollgrid-shrink');
+ let largestWidth = 0;
+ for (let shrinkCell of shrinkCells) {
+ largestWidth = Math.max(largestWidth, computeSmallestCellWidth(shrinkCell));
+ }
+ return Math.ceil(largestWidth);
+ }
+ function getSectionHasLiquidHeight(props, sectionConfig) {
+ return props.liquid && sectionConfig.liquid;
+ }
+ function getAllowYScrolling(props, sectionConfig) {
+ return sectionConfig.maxHeight != null ||
+ getSectionHasLiquidHeight(props, sectionConfig);
+ }
+ function renderChunkContent(sectionConfig, chunkConfig, arg, isHeader) {
+ let { expandRows } = arg;
+ let content = typeof chunkConfig.content === 'function' ?
+ chunkConfig.content(arg) :
+ y('table', {
+ role: 'presentation',
+ className: [
+ chunkConfig.tableClassName,
+ sectionConfig.syncRowHeights ? 'fc-scrollgrid-sync-table' : '',
+ ].join(' '),
+ style: {
+ minWidth: arg.tableMinWidth,
+ width: arg.clientWidth,
+ height: expandRows ? arg.clientHeight : '',
+ },
+ }, arg.tableColGroupNode, y(isHeader ? 'thead' : 'tbody', {
+ role: 'presentation',
+ }, typeof chunkConfig.rowContent === 'function'
+ ? chunkConfig.rowContent(arg)
+ : chunkConfig.rowContent));
+ return content;
+ }
+ function isColPropsEqual(cols0, cols1) {
+ return isArraysEqual(cols0, cols1, isPropsEqual);
+ }
+ function renderMicroColGroup(cols, shrinkWidth) {
+ let colNodes = [];
+ for (let colProps of cols) {
+ let span = colProps.span || 1;
+ for (let i = 0; i < span; i += 1) {
+ colNodes.push(y("col", { style: {
+ width: colProps.width === 'shrink' ? sanitizeShrinkWidth(shrinkWidth) : (colProps.width || ''),
+ minWidth: colProps.minWidth || '',
+ } }));
+ }
+ }
+ return y('colgroup', {}, ...colNodes);
+ }
+ function sanitizeShrinkWidth(shrinkWidth) {
+ return shrinkWidth == null ? 4 : shrinkWidth;
+ }
+ function hasShrinkWidth(cols) {
+ for (let col of cols) {
+ if (col.width === 'shrink') {
+ return true;
+ }
+ }
+ return false;
+ }
+ function getScrollGridClassNames(liquid, context) {
+ let classNames = [
+ 'fc-scrollgrid',
+ context.theme.getClass('table'),
+ ];
+ if (liquid) {
+ classNames.push('fc-scrollgrid-liquid');
+ }
+ return classNames;
+ }
+ function getSectionClassNames(sectionConfig, wholeTableVGrow) {
+ let classNames = [
+ 'fc-scrollgrid-section',
+ `fc-scrollgrid-section-${sectionConfig.type}`,
+ sectionConfig.className,
+ ];
+ if (wholeTableVGrow && sectionConfig.liquid && sectionConfig.maxHeight == null) {
+ classNames.push('fc-scrollgrid-section-liquid');
+ }
+ if (sectionConfig.isSticky) {
+ classNames.push('fc-scrollgrid-section-sticky');
+ }
+ return classNames;
+ }
+ function renderScrollShim(arg) {
+ return (y("div", { className: "fc-scrollgrid-sticky-shim", style: {
+ width: arg.clientWidth,
+ minWidth: arg.tableMinWidth,
+ } }));
+ }
+ function getStickyHeaderDates(options) {
+ let { stickyHeaderDates } = options;
+ if (stickyHeaderDates == null || stickyHeaderDates === 'auto') {
+ stickyHeaderDates = options.height === 'auto' || options.viewHeight === 'auto';
+ }
+ return stickyHeaderDates;
+ }
+ function getStickyFooterScrollbar(options) {
+ let { stickyFooterScrollbar } = options;
+ if (stickyFooterScrollbar == null || stickyFooterScrollbar === 'auto') {
+ stickyFooterScrollbar = options.height === 'auto' || options.viewHeight === 'auto';
+ }
+ return stickyFooterScrollbar;
+ }
+ class SimpleScrollGrid extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.processCols = memoize((a) => a, isColPropsEqual);
+ this.renderMicroColGroup = memoize(renderMicroColGroup);
+ this.scrollerRefs = new RefMap();
+ this.scrollerElRefs = new RefMap(this._handleScrollerEl.bind(this));
+ this.state = {
+ shrinkWidth: null,
+ forceYScrollbars: false,
+ scrollerClientWidths: {},
+ scrollerClientHeights: {},
+ };
+ this.handleSizing = () => {
+ this.safeSetState(Object.assign({ shrinkWidth: this.computeShrinkWidth() }, this.computeScrollerDims()));
+ };
+ }
+ render() {
+ let { props, state, context } = this;
+ let sectionConfigs = props.sections || [];
+ let cols = this.processCols(props.cols);
+ let microColGroupNode = this.renderMicroColGroup(cols, state.shrinkWidth);
+ let classNames = getScrollGridClassNames(props.liquid, context);
+ if (props.collapsibleWidth) {
+ classNames.push('fc-scrollgrid-collapsible');
+ }
+ let configCnt = sectionConfigs.length;
+ let configI = 0;
+ let currentConfig;
+ let headSectionNodes = [];
+ let bodySectionNodes = [];
+ let footSectionNodes = [];
+ while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'header') {
+ headSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
+ configI += 1;
+ }
+ while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'body') {
+ bodySectionNodes.push(this.renderSection(currentConfig, microColGroupNode, false));
+ configI += 1;
+ }
+ while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'footer') {
+ footSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
+ configI += 1;
+ }
+ let isBuggy = !getCanVGrowWithinCell();
+ const roleAttrs = { role: 'rowgroup' };
+ return y('table', {
+ role: 'grid',
+ className: classNames.join(' '),
+ style: { height: props.height },
+ }, Boolean(!isBuggy && headSectionNodes.length) && y('thead', roleAttrs, ...headSectionNodes), Boolean(!isBuggy && bodySectionNodes.length) && y('tbody', roleAttrs, ...bodySectionNodes), Boolean(!isBuggy && footSectionNodes.length) && y('tfoot', roleAttrs, ...footSectionNodes), isBuggy && y('tbody', roleAttrs, ...headSectionNodes, ...bodySectionNodes, ...footSectionNodes));
+ }
+ renderSection(sectionConfig, microColGroupNode, isHeader) {
+ if ('outerContent' in sectionConfig) {
+ return (y(_, { key: sectionConfig.key }, sectionConfig.outerContent));
+ }
+ return (y("tr", { key: sectionConfig.key, role: "presentation", className: getSectionClassNames(sectionConfig, this.props.liquid).join(' ') }, this.renderChunkTd(sectionConfig, microColGroupNode, sectionConfig.chunk, isHeader)));
+ }
+ renderChunkTd(sectionConfig, microColGroupNode, chunkConfig, isHeader) {
+ if ('outerContent' in chunkConfig) {
+ return chunkConfig.outerContent;
+ }
+ let { props } = this;
+ let { forceYScrollbars, scrollerClientWidths, scrollerClientHeights } = this.state;
+ let needsYScrolling = getAllowYScrolling(props, sectionConfig);
+ let isLiquid = getSectionHasLiquidHeight(props, sectionConfig);
+ let overflowY = !props.liquid ? 'visible' :
+ forceYScrollbars ? 'scroll' :
+ !needsYScrolling ? 'hidden' :
+ 'auto';
+ let sectionKey = sectionConfig.key;
+ let content = renderChunkContent(sectionConfig, chunkConfig, {
+ tableColGroupNode: microColGroupNode,
+ tableMinWidth: '',
+ clientWidth: (!props.collapsibleWidth && scrollerClientWidths[sectionKey] !== undefined) ? scrollerClientWidths[sectionKey] : null,
+ clientHeight: scrollerClientHeights[sectionKey] !== undefined ? scrollerClientHeights[sectionKey] : null,
+ expandRows: sectionConfig.expandRows,
+ syncRowHeights: false,
+ rowSyncHeights: [],
+ reportRowHeightChange: () => { },
+ }, isHeader);
+ return y(isHeader ? 'th' : 'td', {
+ ref: chunkConfig.elRef,
+ role: 'presentation',
+ }, y("div", { className: `fc-scroller-harness${isLiquid ? ' fc-scroller-harness-liquid' : ''}` },
+ y(Scroller, { ref: this.scrollerRefs.createRef(sectionKey), elRef: this.scrollerElRefs.createRef(sectionKey), overflowY: overflowY, overflowX: !props.liquid ? 'visible' : 'hidden' , maxHeight: sectionConfig.maxHeight, liquid: isLiquid, liquidIsAbsolute
+ : true }, content)));
+ }
+ _handleScrollerEl(scrollerEl, key) {
+ let section = getSectionByKey(this.props.sections, key);
+ if (section) {
+ setRef(section.chunk.scrollerElRef, scrollerEl);
+ }
+ }
+ componentDidMount() {
+ this.handleSizing();
+ this.context.addResizeHandler(this.handleSizing);
+ }
+ componentDidUpdate() {
+ this.handleSizing();
+ }
+ componentWillUnmount() {
+ this.context.removeResizeHandler(this.handleSizing);
+ }
+ computeShrinkWidth() {
+ return hasShrinkWidth(this.props.cols)
+ ? computeShrinkWidth(this.scrollerElRefs.getAll())
+ : 0;
+ }
+ computeScrollerDims() {
+ let scrollbarWidth = getScrollbarWidths();
+ let { scrollerRefs, scrollerElRefs } = this;
+ let forceYScrollbars = false;
+ let scrollerClientWidths = {};
+ let scrollerClientHeights = {};
+ for (let sectionKey in scrollerRefs.currentMap) {
+ let scroller = scrollerRefs.currentMap[sectionKey];
+ if (scroller && scroller.needsYScrolling()) {
+ forceYScrollbars = true;
+ break;
+ }
+ }
+ for (let section of this.props.sections) {
+ let sectionKey = section.key;
+ let scrollerEl = scrollerElRefs.currentMap[sectionKey];
+ if (scrollerEl) {
+ let harnessEl = scrollerEl.parentNode;
+ scrollerClientWidths[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().width - (forceYScrollbars
+ ? scrollbarWidth.y
+ : 0));
+ scrollerClientHeights[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().height);
+ }
+ }
+ return { forceYScrollbars, scrollerClientWidths, scrollerClientHeights };
+ }
+ }
+ SimpleScrollGrid.addStateEquality({
+ scrollerClientWidths: isPropsEqual,
+ scrollerClientHeights: isPropsEqual,
+ });
+ function getSectionByKey(sections, key) {
+ for (let section of sections) {
+ if (section.key === key) {
+ return section;
+ }
+ }
+ return null;
+ }
+ class EventContainer extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.buildPublicEvent = memoize((context, eventDef, eventInstance) => new EventImpl(context, eventDef, eventInstance));
+ this.handleEl = (el) => {
+ this.el = el;
+ setRef(this.props.elRef, el);
+ if (el) {
+ setElSeg(el, this.props.seg);
+ }
+ };
+ }
+ render() {
+ const { props, context } = this;
+ const { options } = context;
+ const { seg } = props;
+ const { eventRange } = seg;
+ const { ui } = eventRange;
+ const renderProps = {
+ event: this.buildPublicEvent(context, eventRange.def, eventRange.instance),
+ view: context.viewApi,
+ timeText: props.timeText,
+ textColor: ui.textColor,
+ backgroundColor: ui.backgroundColor,
+ borderColor: ui.borderColor,
+ isDraggable: !props.disableDragging && computeSegDraggable(seg, context),
+ isStartResizable: !props.disableResizing && computeSegStartResizable(seg, context),
+ isEndResizable: !props.disableResizing && computeSegEndResizable(seg),
+ isMirror: Boolean(props.isDragging || props.isResizing || props.isDateSelecting),
+ isStart: Boolean(seg.isStart),
+ isEnd: Boolean(seg.isEnd),
+ isPast: Boolean(props.isPast),
+ isFuture: Boolean(props.isFuture),
+ isToday: Boolean(props.isToday),
+ isSelected: Boolean(props.isSelected),
+ isDragging: Boolean(props.isDragging),
+ isResizing: Boolean(props.isResizing),
+ };
+ return (y(ContentContainer, { elRef: this.handleEl, elTag: props.elTag, elAttrs: props.elAttrs, elClasses: [
+ ...getEventClassNames(renderProps),
+ ...seg.eventRange.ui.classNames,
+ ...(props.elClasses || []),
+ ], elStyle: props.elStyle, renderProps: renderProps, generatorName: "eventContent", customGenerator: options.eventContent, defaultGenerator: props.defaultGenerator, classNameGenerator: options.eventClassNames, didMount: options.eventDidMount, willUnmount: options.eventWillUnmount }, props.children));
+ }
+ componentDidUpdate(prevProps) {
+ if (this.el && this.props.seg !== prevProps.seg) {
+ setElSeg(this.el, this.props.seg);
+ }
+ }
+ }
+ class StandardEvent extends BaseComponent {
+ render() {
+ let { props, context } = this;
+ let { options } = context;
+ let { seg } = props;
+ let { ui } = seg.eventRange;
+ let timeFormat = options.eventTimeFormat || props.defaultTimeFormat;
+ let timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd);
+ return (y(EventContainer, Object.assign({}, props , { elTag: "a", elStyle: {
+ borderColor: ui.borderColor,
+ backgroundColor: ui.backgroundColor,
+ }, elAttrs: getSegAnchorAttrs(seg, context), defaultGenerator: renderInnerContent$1$1, timeText: timeText }), (InnerContent, eventContentArg) => (y(_, null,
+ y(InnerContent, { elTag: "div", elClasses: ['fc-event-main'], elStyle: { color: eventContentArg.textColor } }),
+ Boolean(eventContentArg.isStartResizable) && (y("div", { className: "fc-event-resizer fc-event-resizer-start" })),
+ Boolean(eventContentArg.isEndResizable) && (y("div", { className: "fc-event-resizer fc-event-resizer-end" }))))));
+ }
+ }
+ StandardEvent.addPropsEquality({
+ seg: isPropsEqual,
+ });
+ function renderInnerContent$1$1(innerProps) {
+ return (y("div", { className: "fc-event-main-frame" },
+ innerProps.timeText && (y("div", { className: "fc-event-time" }, innerProps.timeText)),
+ y("div", { className: "fc-event-title-container" },
+ y("div", { className: "fc-event-title fc-sticky" }, innerProps.event.title || y(_, null, "\u00A0")))));
+ }
+ const NowIndicatorContainer = (props) => (y(ViewContextType.Consumer, null, (context) => {
+ let { options } = context;
+ let renderProps = {
+ isAxis: props.isAxis,
+ date: context.dateEnv.toDate(props.date),
+ view: context.viewApi,
+ };
+ return (y(ContentContainer, { elRef: props.elRef, elTag: props.elTag || 'div', elAttrs: props.elAttrs, elClasses: props.elClasses, elStyle: props.elStyle, renderProps: renderProps, generatorName: "nowIndicatorContent", customGenerator: options.nowIndicatorContent, classNameGenerator: options.nowIndicatorClassNames, didMount: options.nowIndicatorDidMount, willUnmount: options.nowIndicatorWillUnmount }, props.children));
+ }));
+ const DAY_NUM_FORMAT = createFormatter({ day: 'numeric' });
+ class DayCellContainer extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.refineRenderProps = memoizeObjArg(refineRenderProps);
+ }
+ render() {
+ let { props, context } = this;
+ let { options } = context;
+ let renderProps = this.refineRenderProps({
+ date: props.date,
+ dateProfile: props.dateProfile,
+ todayRange: props.todayRange,
+ isMonthStart: props.isMonthStart || false,
+ showDayNumber: props.showDayNumber,
+ extraRenderProps: props.extraRenderProps,
+ viewApi: context.viewApi,
+ dateEnv: context.dateEnv,
+ monthStartFormat: options.monthStartFormat,
+ });
+ return (y(ContentContainer, { elRef: props.elRef, elTag: props.elTag, elAttrs: Object.assign(Object.assign({}, props.elAttrs), (renderProps.isDisabled ? {} : { 'data-date': formatDayString(props.date) })), elClasses: [
+ ...getDayClassNames(renderProps, context.theme),
+ ...(props.elClasses || []),
+ ], elStyle: props.elStyle, renderProps: renderProps, generatorName: "dayCellContent", customGenerator: options.dayCellContent, defaultGenerator: props.defaultGenerator, classNameGenerator:
+ renderProps.isDisabled ? undefined : options.dayCellClassNames, didMount: options.dayCellDidMount, willUnmount: options.dayCellWillUnmount }, props.children));
+ }
+ }
+ function hasCustomDayCellContent(options) {
+ return Boolean(options.dayCellContent || hasCustomRenderingHandler('dayCellContent', options));
+ }
+ function refineRenderProps(raw) {
+ let { date, dateEnv, dateProfile, isMonthStart } = raw;
+ let dayMeta = getDateMeta(date, raw.todayRange, null, dateProfile);
+ let dayNumberText = raw.showDayNumber ? (dateEnv.format(date, isMonthStart ? raw.monthStartFormat : DAY_NUM_FORMAT)) : '';
+ return Object.assign(Object.assign(Object.assign({ date: dateEnv.toDate(date), view: raw.viewApi }, dayMeta), { isMonthStart,
+ dayNumberText }), raw.extraRenderProps);
+ }
+ class BgEvent extends BaseComponent {
+ render() {
+ let { props } = this;
+ let { seg } = props;
+ return (y(EventContainer, { elTag: "div", elClasses: ['fc-bg-event'], elStyle: { backgroundColor: seg.eventRange.ui.backgroundColor }, defaultGenerator: renderInnerContent$3, seg: seg, timeText: "", isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday, disableDragging: true, disableResizing: true }));
+ }
+ }
+ function renderInnerContent$3(props) {
+ let { title } = props.event;
+ return title && (y("div", { className: "fc-event-title" }, props.event.title));
+ }
+ function renderFill(fillType) {
+ return (y("div", { className: `fc-${fillType}` }));
+ }
+ const WeekNumberContainer = (props) => (y(ViewContextType.Consumer, null, (context) => {
+ let { dateEnv, options } = context;
+ let { date } = props;
+ let format = options.weekNumberFormat || props.defaultFormat;
+ let num = dateEnv.computeWeekNumber(date);
+ let text = dateEnv.format(date, format);
+ let renderProps = { num, text, date };
+ return (y(ContentContainer
+ , { elRef: props.elRef, elTag: props.elTag, elAttrs: props.elAttrs, elClasses: props.elClasses, elStyle: props.elStyle, renderProps: renderProps, generatorName: "weekNumberContent", customGenerator: options.weekNumberContent, defaultGenerator: renderInner, classNameGenerator: options.weekNumberClassNames, didMount: options.weekNumberDidMount, willUnmount: options.weekNumberWillUnmount }, props.children));
+ }));
+ function renderInner(innerProps) {
+ return innerProps.text;
+ }
+ const PADDING_FROM_VIEWPORT = 10;
+ class Popover extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.state = {
+ titleId: getUniqueDomId(),
+ };
+ this.handleRootEl = (el) => {
+ this.rootEl = el;
+ if (this.props.elRef) {
+ setRef(this.props.elRef, el);
+ }
+ };
+ this.handleDocumentMouseDown = (ev) => {
+ const target = getEventTargetViaRoot(ev);
+ if (!this.rootEl.contains(target)) {
+ this.handleCloseClick();
+ }
+ };
+ this.handleDocumentKeyDown = (ev) => {
+ if (ev.key === 'Escape') {
+ this.handleCloseClick();
+ }
+ };
+ this.handleCloseClick = () => {
+ let { onClose } = this.props;
+ if (onClose) {
+ onClose();
+ }
+ };
+ }
+ render() {
+ let { theme, options } = this.context;
+ let { props, state } = this;
+ let classNames = [
+ 'fc-popover',
+ theme.getClass('popover'),
+ ].concat(props.extraClassNames || []);
+ return j(y("div", Object.assign({}, props.extraAttrs, { id: props.id, className: classNames.join(' '), "aria-labelledby": state.titleId, ref: this.handleRootEl }),
+ y("div", { className: 'fc-popover-header ' + theme.getClass('popoverHeader') },
+ y("span", { className: "fc-popover-title", id: state.titleId }, props.title),
+ y("span", { className: 'fc-popover-close ' + theme.getIconClass('close'), title: options.closeHint, onClick: this.handleCloseClick })),
+ y("div", { className: 'fc-popover-body ' + theme.getClass('popoverContent') }, props.children)), props.parentEl);
+ }
+ componentDidMount() {
+ document.addEventListener('mousedown', this.handleDocumentMouseDown);
+ document.addEventListener('keydown', this.handleDocumentKeyDown);
+ this.updateSize();
+ }
+ componentWillUnmount() {
+ document.removeEventListener('mousedown', this.handleDocumentMouseDown);
+ document.removeEventListener('keydown', this.handleDocumentKeyDown);
+ }
+ updateSize() {
+ let { isRtl } = this.context;
+ let { alignmentEl, alignGridTop } = this.props;
+ let { rootEl } = this;
+ let alignmentRect = computeClippedClientRect(alignmentEl);
+ if (alignmentRect) {
+ let popoverDims = rootEl.getBoundingClientRect();
+ let popoverTop = alignGridTop
+ ? elementClosest(alignmentEl, '.fc-scrollgrid').getBoundingClientRect().top
+ : alignmentRect.top;
+ let popoverLeft = isRtl ? alignmentRect.right - popoverDims.width : alignmentRect.left;
+ popoverTop = Math.max(popoverTop, PADDING_FROM_VIEWPORT);
+ popoverLeft = Math.min(popoverLeft, document.documentElement.clientWidth - PADDING_FROM_VIEWPORT - popoverDims.width);
+ popoverLeft = Math.max(popoverLeft, PADDING_FROM_VIEWPORT);
+ let origin = rootEl.offsetParent.getBoundingClientRect();
+ applyStyle(rootEl, {
+ top: popoverTop - origin.top,
+ left: popoverLeft - origin.left,
+ });
+ }
+ }
+ }
+ class MorePopover extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.handleRootEl = (rootEl) => {
+ this.rootEl = rootEl;
+ if (rootEl) {
+ this.context.registerInteractiveComponent(this, {
+ el: rootEl,
+ useEventCenter: false,
+ });
+ }
+ else {
+ this.context.unregisterInteractiveComponent(this);
+ }
+ };
+ }
+ render() {
+ let { options, dateEnv } = this.context;
+ let { props } = this;
+ let { startDate, todayRange, dateProfile } = props;
+ let title = dateEnv.format(startDate, options.dayPopoverFormat);
+ return (y(DayCellContainer, { elRef: this.handleRootEl, date: startDate, dateProfile: dateProfile, todayRange: todayRange }, (InnerContent, renderProps, elAttrs) => (y(Popover, { elRef: elAttrs.ref, id: props.id, title: title, extraClassNames: ['fc-more-popover'].concat(elAttrs.className || []), extraAttrs: elAttrs , parentEl: props.parentEl, alignmentEl: props.alignmentEl, alignGridTop: props.alignGridTop, onClose: props.onClose },
+ hasCustomDayCellContent(options) && (y(InnerContent, { elTag: "div", elClasses: ['fc-more-popover-misc'] })),
+ props.children))));
+ }
+ queryHit(positionLeft, positionTop, elWidth, elHeight) {
+ let { rootEl, props } = this;
+ if (positionLeft >= 0 && positionLeft < elWidth &&
+ positionTop >= 0 && positionTop < elHeight) {
+ return {
+ dateProfile: props.dateProfile,
+ dateSpan: Object.assign({ allDay: !props.forceTimed, range: {
+ start: props.startDate,
+ end: props.endDate,
+ } }, props.extraDateSpan),
+ dayEl: rootEl,
+ rect: {
+ left: 0,
+ top: 0,
+ right: elWidth,
+ bottom: elHeight,
+ },
+ layer: 1,
+ };
+ }
+ return null;
+ }
+ }
+ class MoreLinkContainer extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.state = {
+ isPopoverOpen: false,
+ popoverId: getUniqueDomId(),
+ };
+ this.handleLinkEl = (linkEl) => {
+ this.linkEl = linkEl;
+ if (this.props.elRef) {
+ setRef(this.props.elRef, linkEl);
+ }
+ };
+ this.handleClick = (ev) => {
+ let { props, context } = this;
+ let { moreLinkClick } = context.options;
+ let date = computeRange(props).start;
+ function buildPublicSeg(seg) {
+ let { def, instance, range } = seg.eventRange;
+ return {
+ event: new EventImpl(context, def, instance),
+ start: context.dateEnv.toDate(range.start),
+ end: context.dateEnv.toDate(range.end),
+ isStart: seg.isStart,
+ isEnd: seg.isEnd,
+ };
+ }
+ if (typeof moreLinkClick === 'function') {
+ moreLinkClick = moreLinkClick({
+ date,
+ allDay: Boolean(props.allDayDate),
+ allSegs: props.allSegs.map(buildPublicSeg),
+ hiddenSegs: props.hiddenSegs.map(buildPublicSeg),
+ jsEvent: ev,
+ view: context.viewApi,
+ });
+ }
+ if (!moreLinkClick || moreLinkClick === 'popover') {
+ this.setState({ isPopoverOpen: true });
+ }
+ else if (typeof moreLinkClick === 'string') {
+ context.calendarApi.zoomTo(date, moreLinkClick);
+ }
+ };
+ this.handlePopoverClose = () => {
+ this.setState({ isPopoverOpen: false });
+ };
+ }
+ render() {
+ let { props, state } = this;
+ return (y(ViewContextType.Consumer, null, (context) => {
+ let { viewApi, options, calendarApi } = context;
+ let { moreLinkText } = options;
+ let { moreCnt } = props;
+ let range = computeRange(props);
+ let text = typeof moreLinkText === 'function'
+ ? moreLinkText.call(calendarApi, moreCnt)
+ : `+${moreCnt} ${moreLinkText}`;
+ let hint = formatWithOrdinals(options.moreLinkHint, [moreCnt], text);
+ let renderProps = {
+ num: moreCnt,
+ shortText: `+${moreCnt}`,
+ text,
+ view: viewApi,
+ };
+ return (y(_, null,
+ Boolean(props.moreCnt) && (y(ContentContainer, { elTag: props.elTag || 'a', elRef: this.handleLinkEl, elClasses: [
+ ...(props.elClasses || []),
+ 'fc-more-link',
+ ], elStyle: props.elStyle, elAttrs: Object.assign(Object.assign(Object.assign({}, props.elAttrs), createAriaClickAttrs(this.handleClick)), { title: hint, 'aria-expanded': state.isPopoverOpen, 'aria-controls': state.isPopoverOpen ? state.popoverId : '' }), renderProps: renderProps, generatorName: "moreLinkContent", customGenerator: options.moreLinkContent, defaultGenerator: props.defaultGenerator || renderMoreLinkInner$1, classNameGenerator: options.moreLinkClassNames, didMount: options.moreLinkDidMount, willUnmount: options.moreLinkWillUnmount }, props.children)),
+ state.isPopoverOpen && (y(MorePopover, { id: state.popoverId, startDate: range.start, endDate: range.end, dateProfile: props.dateProfile, todayRange: props.todayRange, extraDateSpan: props.extraDateSpan, parentEl: this.parentEl, alignmentEl: props.alignmentElRef ?
+ props.alignmentElRef.current :
+ this.linkEl, alignGridTop: props.alignGridTop, forceTimed: props.forceTimed, onClose: this.handlePopoverClose }, props.popoverContent()))));
+ }));
+ }
+ componentDidMount() {
+ this.updateParentEl();
+ }
+ componentDidUpdate() {
+ this.updateParentEl();
+ }
+ updateParentEl() {
+ if (this.linkEl) {
+ this.parentEl = elementClosest(this.linkEl, '.fc-view-harness');
+ }
+ }
+ }
+ function renderMoreLinkInner$1(props) {
+ return props.text;
+ }
+ function computeRange(props) {
+ if (props.allDayDate) {
+ return {
+ start: props.allDayDate,
+ end: addDays(props.allDayDate, 1),
+ };
+ }
+ let { hiddenSegs } = props;
+ return {
+ start: computeEarliestSegStart(hiddenSegs),
+ end: computeLatestSegEnd(hiddenSegs),
+ };
+ }
+ function computeEarliestSegStart(segs) {
+ return segs.reduce(pickEarliestStart).eventRange.range.start;
+ }
+ function pickEarliestStart(seg0, seg1) {
+ return seg0.eventRange.range.start < seg1.eventRange.range.start ? seg0 : seg1;
+ }
+ function computeLatestSegEnd(segs) {
+ return segs.reduce(pickLatestEnd).eventRange.range.end;
+ }
+ function pickLatestEnd(seg0, seg1) {
+ return seg0.eventRange.range.end > seg1.eventRange.range.end ? seg0 : seg1;
+ }
+
+ const globalLocales = [];
+ const MINIMAL_RAW_EN_LOCALE = {
+ code: 'en',
+ week: {
+ dow: 0,
+ doy: 4,
+ },
+ direction: 'ltr',
+ buttonText: {
+ prev: 'prev',
+ next: 'next',
+ prevYear: 'prev year',
+ nextYear: 'next year',
+ year: 'year',
+ today: 'today',
+ month: 'month',
+ week: 'week',
+ day: 'day',
+ list: 'list',
+ },
+ weekText: 'W',
+ weekTextLong: 'Week',
+ closeHint: 'Close',
+ timeHint: 'Time',
+ eventHint: 'Event',
+ allDayText: 'all-day',
+ moreLinkText: 'more',
+ noEventsText: 'No events to display',
+ };
+ const RAW_EN_LOCALE = Object.assign(Object.assign({}, MINIMAL_RAW_EN_LOCALE), {
+ buttonHints: {
+ prev: 'Previous $0',
+ next: 'Next $0',
+ today(buttonText, unit) {
+ return (unit === 'day')
+ ? 'Today'
+ : `This ${buttonText}`;
+ },
+ }, viewHint: '$0 view', navLinkHint: 'Go to $0', moreLinkHint(eventCnt) {
+ return `Show ${eventCnt} more event${eventCnt === 1 ? '' : 's'}`;
+ } });
+ function organizeRawLocales(explicitRawLocales) {
+ let defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
+ let allRawLocales = globalLocales.concat(explicitRawLocales);
+ let rawLocaleMap = {
+ en: RAW_EN_LOCALE,
+ };
+ for (let rawLocale of allRawLocales) {
+ rawLocaleMap[rawLocale.code] = rawLocale;
+ }
+ return {
+ map: rawLocaleMap,
+ defaultCode,
+ };
+ }
+ function buildLocale(inputSingular, available) {
+ if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
+ return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
+ }
+ return queryLocale(inputSingular, available);
+ }
+ function queryLocale(codeArg, available) {
+ let codes = [].concat(codeArg || []);
+ let raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
+ return parseLocale(codeArg, codes, raw);
+ }
+ function queryRawLocale(codes, available) {
+ for (let i = 0; i < codes.length; i += 1) {
+ let parts = codes[i].toLocaleLowerCase().split('-');
+ for (let j = parts.length; j > 0; j -= 1) {
+ let simpleId = parts.slice(0, j).join('-');
+ if (available[simpleId]) {
+ return available[simpleId];
+ }
+ }
+ }
+ return null;
+ }
+ function parseLocale(codeArg, codes, raw) {
+ let merged = mergeProps([MINIMAL_RAW_EN_LOCALE, raw], ['buttonText']);
+ delete merged.code;
+ let { week } = merged;
+ delete merged.week;
+ return {
+ codeArg,
+ codes,
+ week,
+ simpleNumberFormat: new Intl.NumberFormat(codeArg),
+ options: merged,
+ };
+ }
+ function createPlugin(input) {
+ return {
+ id: guid(),
+ name: input.name,
+ premiumReleaseDate: input.premiumReleaseDate ? new Date(input.premiumReleaseDate) : undefined,
+ deps: input.deps || [],
+ reducers: input.reducers || [],
+ isLoadingFuncs: input.isLoadingFuncs || [],
+ contextInit: [].concat(input.contextInit || []),
+ eventRefiners: input.eventRefiners || {},
+ eventDefMemberAdders: input.eventDefMemberAdders || [],
+ eventSourceRefiners: input.eventSourceRefiners || {},
+ isDraggableTransformers: input.isDraggableTransformers || [],
+ eventDragMutationMassagers: input.eventDragMutationMassagers || [],
+ eventDefMutationAppliers: input.eventDefMutationAppliers || [],
+ dateSelectionTransformers: input.dateSelectionTransformers || [],
+ datePointTransforms: input.datePointTransforms || [],
+ dateSpanTransforms: input.dateSpanTransforms || [],
+ views: input.views || {},
+ viewPropsTransformers: input.viewPropsTransformers || [],
+ isPropsValid: input.isPropsValid || null,
+ externalDefTransforms: input.externalDefTransforms || [],
+ viewContainerAppends: input.viewContainerAppends || [],
+ eventDropTransformers: input.eventDropTransformers || [],
+ componentInteractions: input.componentInteractions || [],
+ calendarInteractions: input.calendarInteractions || [],
+ themeClasses: input.themeClasses || {},
+ eventSourceDefs: input.eventSourceDefs || [],
+ cmdFormatter: input.cmdFormatter,
+ recurringTypes: input.recurringTypes || [],
+ namedTimeZonedImpl: input.namedTimeZonedImpl,
+ initialView: input.initialView || '',
+ elementDraggingImpl: input.elementDraggingImpl,
+ optionChangeHandlers: input.optionChangeHandlers || {},
+ scrollGridImpl: input.scrollGridImpl || null,
+ listenerRefiners: input.listenerRefiners || {},
+ optionRefiners: input.optionRefiners || {},
+ propSetHandlers: input.propSetHandlers || {},
+ };
+ }
+ function buildPluginHooks(pluginDefs, globalDefs) {
+ let currentPluginIds = {};
+ let hooks = {
+ premiumReleaseDate: undefined,
+ reducers: [],
+ isLoadingFuncs: [],
+ contextInit: [],
+ eventRefiners: {},
+ eventDefMemberAdders: [],
+ eventSourceRefiners: {},
+ isDraggableTransformers: [],
+ eventDragMutationMassagers: [],
+ eventDefMutationAppliers: [],
+ dateSelectionTransformers: [],
+ datePointTransforms: [],
+ dateSpanTransforms: [],
+ views: {},
+ viewPropsTransformers: [],
+ isPropsValid: null,
+ externalDefTransforms: [],
+ viewContainerAppends: [],
+ eventDropTransformers: [],
+ componentInteractions: [],
+ calendarInteractions: [],
+ themeClasses: {},
+ eventSourceDefs: [],
+ cmdFormatter: null,
+ recurringTypes: [],
+ namedTimeZonedImpl: null,
+ initialView: '',
+ elementDraggingImpl: null,
+ optionChangeHandlers: {},
+ scrollGridImpl: null,
+ listenerRefiners: {},
+ optionRefiners: {},
+ propSetHandlers: {},
+ };
+ function addDefs(defs) {
+ for (let def of defs) {
+ const pluginName = def.name;
+ const currentId = currentPluginIds[pluginName];
+ if (currentId === undefined) {
+ currentPluginIds[pluginName] = def.id;
+ addDefs(def.deps);
+ hooks = combineHooks(hooks, def);
+ }
+ else if (currentId !== def.id) {
+ console.warn(`Duplicate plugin '${pluginName}'`);
+ }
+ }
+ }
+ if (pluginDefs) {
+ addDefs(pluginDefs);
+ }
+ addDefs(globalDefs);
+ return hooks;
+ }
+ function buildBuildPluginHooks() {
+ let currentOverrideDefs = [];
+ let currentGlobalDefs = [];
+ let currentHooks;
+ return (overrideDefs, globalDefs) => {
+ if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
+ currentHooks = buildPluginHooks(overrideDefs, globalDefs);
+ }
+ currentOverrideDefs = overrideDefs;
+ currentGlobalDefs = globalDefs;
+ return currentHooks;
+ };
+ }
+ function combineHooks(hooks0, hooks1) {
+ return {
+ premiumReleaseDate: compareOptionalDates(hooks0.premiumReleaseDate, hooks1.premiumReleaseDate),
+ reducers: hooks0.reducers.concat(hooks1.reducers),
+ isLoadingFuncs: hooks0.isLoadingFuncs.concat(hooks1.isLoadingFuncs),
+ contextInit: hooks0.contextInit.concat(hooks1.contextInit),
+ eventRefiners: Object.assign(Object.assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
+ eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
+ eventSourceRefiners: Object.assign(Object.assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
+ isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
+ eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
+ eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
+ dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
+ datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
+ dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
+ views: Object.assign(Object.assign({}, hooks0.views), hooks1.views),
+ viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
+ isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
+ externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
+ viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
+ eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
+ calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
+ componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
+ themeClasses: Object.assign(Object.assign({}, hooks0.themeClasses), hooks1.themeClasses),
+ eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
+ cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
+ recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
+ namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
+ initialView: hooks0.initialView || hooks1.initialView,
+ elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
+ optionChangeHandlers: Object.assign(Object.assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
+ scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
+ listenerRefiners: Object.assign(Object.assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
+ optionRefiners: Object.assign(Object.assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
+ propSetHandlers: Object.assign(Object.assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers),
+ };
+ }
+ function compareOptionalDates(date0, date1) {
+ if (date0 === undefined) {
+ return date1;
+ }
+ if (date1 === undefined) {
+ return date0;
+ }
+ return new Date(Math.max(date0.valueOf(), date1.valueOf()));
+ }
+ class StandardTheme extends Theme {
+ }
+ StandardTheme.prototype.classes = {
+ root: 'fc-theme-standard',
+ tableCellShaded: 'fc-cell-shaded',
+ buttonGroup: 'fc-button-group',
+ button: 'fc-button fc-button-primary',
+ buttonActive: 'fc-button-active',
+ };
+ StandardTheme.prototype.baseIconClass = 'fc-icon';
+ StandardTheme.prototype.iconClasses = {
+ close: 'fc-icon-x',
+ prev: 'fc-icon-chevron-left',
+ next: 'fc-icon-chevron-right',
+ prevYear: 'fc-icon-chevrons-left',
+ nextYear: 'fc-icon-chevrons-right',
+ };
+ StandardTheme.prototype.rtlIconClasses = {
+ prev: 'fc-icon-chevron-right',
+ next: 'fc-icon-chevron-left',
+ prevYear: 'fc-icon-chevrons-right',
+ nextYear: 'fc-icon-chevrons-left',
+ };
+ StandardTheme.prototype.iconOverrideOption = 'buttonIcons';
+ StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
+ StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
+ function compileViewDefs(defaultConfigs, overrideConfigs) {
+ let hash = {};
+ let viewType;
+ for (viewType in defaultConfigs) {
+ ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
+ }
+ for (viewType in overrideConfigs) {
+ ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
+ }
+ return hash;
+ }
+ function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
+ if (hash[viewType]) {
+ return hash[viewType];
+ }
+ let viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
+ if (viewDef) {
+ hash[viewType] = viewDef;
+ }
+ return viewDef;
+ }
+ function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
+ let defaultConfig = defaultConfigs[viewType];
+ let overrideConfig = overrideConfigs[viewType];
+ let queryProp = (name) => ((defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
+ ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null));
+ let theComponent = queryProp('component');
+ let superType = queryProp('superType');
+ let superDef = null;
+ if (superType) {
+ if (superType === viewType) {
+ throw new Error('Can\'t have a custom view type that references itself');
+ }
+ superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
+ }
+ if (!theComponent && superDef) {
+ theComponent = superDef.component;
+ }
+ if (!theComponent) {
+ return null;
+ }
+ return {
+ type: viewType,
+ component: theComponent,
+ defaults: Object.assign(Object.assign({}, (superDef ? superDef.defaults : {})), (defaultConfig ? defaultConfig.rawOptions : {})),
+ overrides: Object.assign(Object.assign({}, (superDef ? superDef.overrides : {})), (overrideConfig ? overrideConfig.rawOptions : {})),
+ };
+ }
+ function parseViewConfigs(inputs) {
+ return mapHash(inputs, parseViewConfig);
+ }
+ function parseViewConfig(input) {
+ let rawOptions = typeof input === 'function' ?
+ { component: input } :
+ input;
+ let { component } = rawOptions;
+ if (rawOptions.content) {
+ component = createViewHookComponent(rawOptions);
+ }
+ else if (component && !(component.prototype instanceof BaseComponent)) {
+ component = createViewHookComponent(Object.assign(Object.assign({}, rawOptions), { content: component }));
+ }
+ return {
+ superType: rawOptions.type,
+ component: component,
+ rawOptions,
+ };
+ }
+ function createViewHookComponent(options) {
+ return (viewProps) => (y(ViewContextType.Consumer, null, (context) => (y(ContentContainer, { elTag: "div", elClasses: buildViewClassNames(context.viewSpec), renderProps: Object.assign(Object.assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold }), generatorName: undefined, customGenerator: options.content, classNameGenerator: options.classNames, didMount: options.didMount, willUnmount: options.willUnmount }))));
+ }
+ function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
+ let defaultConfigs = parseViewConfigs(defaultInputs);
+ let overrideConfigs = parseViewConfigs(optionOverrides.views);
+ let viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
+ return mapHash(viewDefs, (viewDef) => buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults));
+ }
+ function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
+ let durationInput = viewDef.overrides.duration ||
+ viewDef.defaults.duration ||
+ dynamicOptionOverrides.duration ||
+ optionOverrides.duration;
+ let duration = null;
+ let durationUnit = '';
+ let singleUnit = '';
+ let singleUnitOverrides = {};
+ if (durationInput) {
+ duration = createDurationCached(durationInput);
+ if (duration) {
+ let denom = greatestDurationDenominator(duration);
+ durationUnit = denom.unit;
+ if (denom.value === 1) {
+ singleUnit = durationUnit;
+ singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
+ }
+ }
+ }
+ let queryButtonText = (optionsSubset) => {
+ let buttonTextMap = optionsSubset.buttonText || {};
+ let buttonTextKey = viewDef.defaults.buttonTextKey;
+ if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
+ return buttonTextMap[buttonTextKey];
+ }
+ if (buttonTextMap[viewDef.type] != null) {
+ return buttonTextMap[viewDef.type];
+ }
+ if (buttonTextMap[singleUnit] != null) {
+ return buttonTextMap[singleUnit];
+ }
+ return null;
+ };
+ let queryButtonTitle = (optionsSubset) => {
+ let buttonHints = optionsSubset.buttonHints || {};
+ let buttonKey = viewDef.defaults.buttonTextKey;
+ if (buttonKey != null && buttonHints[buttonKey] != null) {
+ return buttonHints[buttonKey];
+ }
+ if (buttonHints[viewDef.type] != null) {
+ return buttonHints[viewDef.type];
+ }
+ if (buttonHints[singleUnit] != null) {
+ return buttonHints[singleUnit];
+ }
+ return null;
+ };
+ return {
+ type: viewDef.type,
+ component: viewDef.component,
+ duration,
+ durationUnit,
+ singleUnit,
+ optionDefaults: viewDef.defaults,
+ optionOverrides: Object.assign(Object.assign({}, singleUnitOverrides), viewDef.overrides),
+ buttonTextOverride: queryButtonText(dynamicOptionOverrides) ||
+ queryButtonText(optionOverrides) ||
+ viewDef.overrides.buttonText,
+ buttonTextDefault: queryButtonText(localeDefaults) ||
+ viewDef.defaults.buttonText ||
+ queryButtonText(BASE_OPTION_DEFAULTS) ||
+ viewDef.type,
+ buttonTitleOverride: queryButtonTitle(dynamicOptionOverrides) ||
+ queryButtonTitle(optionOverrides) ||
+ viewDef.overrides.buttonHint,
+ buttonTitleDefault: queryButtonTitle(localeDefaults) ||
+ viewDef.defaults.buttonHint ||
+ queryButtonTitle(BASE_OPTION_DEFAULTS),
+ };
+ }
+ let durationInputMap = {};
+ function createDurationCached(durationInput) {
+ let json = JSON.stringify(durationInput);
+ let res = durationInputMap[json];
+ if (res === undefined) {
+ res = createDuration(durationInput);
+ durationInputMap[json] = res;
+ }
+ return res;
+ }
+ function reduceViewType(viewType, action) {
+ switch (action.type) {
+ case 'CHANGE_VIEW_TYPE':
+ viewType = action.viewType;
+ }
+ return viewType;
+ }
+ function reduceCurrentDate(currentDate, action) {
+ switch (action.type) {
+ case 'CHANGE_DATE':
+ return action.dateMarker;
+ default:
+ return currentDate;
+ }
+ }
+ function getInitialDate(options, dateEnv, nowManager) {
+ let initialDateInput = options.initialDate;
+ if (initialDateInput != null) {
+ return dateEnv.createMarker(initialDateInput);
+ }
+ return nowManager.getDateMarker();
+ }
+ function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
+ switch (action.type) {
+ case 'SET_OPTION':
+ return Object.assign(Object.assign({}, dynamicOptionOverrides), { [action.optionName]: action.rawOptionValue });
+ default:
+ return dynamicOptionOverrides;
+ }
+ }
+ function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
+ let dp;
+ switch (action.type) {
+ case 'CHANGE_VIEW_TYPE':
+ return dateProfileGenerator.build(action.dateMarker || currentDate);
+ case 'CHANGE_DATE':
+ return dateProfileGenerator.build(action.dateMarker);
+ case 'PREV':
+ dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
+ if (dp.isValid) {
+ return dp;
+ }
+ break;
+ case 'NEXT':
+ dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
+ if (dp.isValid) {
+ return dp;
+ }
+ break;
+ }
+ return currentDateProfile;
+ }
+ function initEventSources(calendarOptions, dateProfile, context) {
+ let activeRange = dateProfile ? dateProfile.activeRange : null;
+ return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
+ }
+ function reduceEventSources(eventSources, action, dateProfile, context) {
+ let activeRange = dateProfile ? dateProfile.activeRange : null;
+ switch (action.type) {
+ case 'ADD_EVENT_SOURCES':
+ return addSources(eventSources, action.sources, activeRange, context);
+ case 'REMOVE_EVENT_SOURCE':
+ return removeSource(eventSources, action.sourceId);
+ case 'PREV':
+ case 'NEXT':
+ case 'CHANGE_DATE':
+ case 'CHANGE_VIEW_TYPE':
+ if (dateProfile) {
+ return fetchDirtySources(eventSources, activeRange, context);
+ }
+ return eventSources;
+ case 'FETCH_EVENT_SOURCES':
+ return fetchSourcesByIds(eventSources, action.sourceIds ?
+ arrayToHash(action.sourceIds) :
+ excludeStaticSources(eventSources, context), activeRange, action.isRefetch || false, context);
+ case 'RECEIVE_EVENTS':
+ case 'RECEIVE_EVENT_ERROR':
+ return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
+ case 'REMOVE_ALL_EVENT_SOURCES':
+ return {};
+ default:
+ return eventSources;
+ }
+ }
+ function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
+ let activeRange = dateProfile ? dateProfile.activeRange : null;
+ return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, true, context);
+ }
+ function computeEventSourcesLoading(eventSources) {
+ for (let sourceId in eventSources) {
+ if (eventSources[sourceId].isFetching) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function addSources(eventSourceHash, sources, fetchRange, context) {
+ let hash = {};
+ for (let source of sources) {
+ hash[source.sourceId] = source;
+ }
+ if (fetchRange) {
+ hash = fetchDirtySources(hash, fetchRange, context);
+ }
+ return Object.assign(Object.assign({}, eventSourceHash), hash);
+ }
+ function removeSource(eventSourceHash, sourceId) {
+ return filterHash(eventSourceHash, (eventSource) => eventSource.sourceId !== sourceId);
+ }
+ function fetchDirtySources(sourceHash, fetchRange, context) {
+ return fetchSourcesByIds(sourceHash, filterHash(sourceHash, (eventSource) => isSourceDirty(eventSource, fetchRange, context)), fetchRange, false, context);
+ }
+ function isSourceDirty(eventSource, fetchRange, context) {
+ if (!doesSourceNeedRange(eventSource, context)) {
+ return !eventSource.latestFetchId;
+ }
+ return !context.options.lazyFetching ||
+ !eventSource.fetchRange ||
+ eventSource.isFetching ||
+ fetchRange.start < eventSource.fetchRange.start ||
+ fetchRange.end > eventSource.fetchRange.end;
+ }
+ function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, isRefetch, context) {
+ let nextSources = {};
+ for (let sourceId in prevSources) {
+ let source = prevSources[sourceId];
+ if (sourceIdHash[sourceId]) {
+ nextSources[sourceId] = fetchSource(source, fetchRange, isRefetch, context);
+ }
+ else {
+ nextSources[sourceId] = source;
+ }
+ }
+ return nextSources;
+ }
+ function fetchSource(eventSource, fetchRange, isRefetch, context) {
+ let { options, calendarApi } = context;
+ let sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
+ let fetchId = guid();
+ sourceDef.fetch({
+ eventSource,
+ range: fetchRange,
+ isRefetch,
+ context,
+ }, (res) => {
+ let { rawEvents } = res;
+ if (options.eventSourceSuccess) {
+ rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.response) || rawEvents;
+ }
+ if (eventSource.success) {
+ rawEvents = eventSource.success.call(calendarApi, rawEvents, res.response) || rawEvents;
+ }
+ context.dispatch({
+ type: 'RECEIVE_EVENTS',
+ sourceId: eventSource.sourceId,
+ fetchId,
+ fetchRange,
+ rawEvents,
+ });
+ }, (error) => {
+ let errorHandled = false;
+ if (options.eventSourceFailure) {
+ options.eventSourceFailure.call(calendarApi, error);
+ errorHandled = true;
+ }
+ if (eventSource.failure) {
+ eventSource.failure(error);
+ errorHandled = true;
+ }
+ if (!errorHandled) {
+ console.warn(error.message, error);
+ }
+ context.dispatch({
+ type: 'RECEIVE_EVENT_ERROR',
+ sourceId: eventSource.sourceId,
+ fetchId,
+ fetchRange,
+ error,
+ });
+ });
+ return Object.assign(Object.assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
+ }
+ function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
+ let eventSource = sourceHash[sourceId];
+ if (eventSource &&
+ fetchId === eventSource.latestFetchId) {
+ return Object.assign(Object.assign({}, sourceHash), { [sourceId]: Object.assign(Object.assign({}, eventSource), { isFetching: false, fetchRange }) });
+ }
+ return sourceHash;
+ }
+ function excludeStaticSources(eventSources, context) {
+ return filterHash(eventSources, (eventSource) => doesSourceNeedRange(eventSource, context));
+ }
+ function parseInitialSources(rawOptions, context) {
+ let refiners = buildEventSourceRefiners(context);
+ let rawSources = [].concat(rawOptions.eventSources || []);
+ let sources = [];
+ if (rawOptions.initialEvents) {
+ rawSources.unshift(rawOptions.initialEvents);
+ }
+ if (rawOptions.events) {
+ rawSources.unshift(rawOptions.events);
+ }
+ for (let rawSource of rawSources) {
+ let source = parseEventSource(rawSource, context, refiners);
+ if (source) {
+ sources.push(source);
+ }
+ }
+ return sources;
+ }
+ function doesSourceNeedRange(eventSource, context) {
+ let defs = context.pluginHooks.eventSourceDefs;
+ return !defs[eventSource.sourceDefId].ignoreRange;
+ }
+ function reduceDateSelection(currentSelection, action) {
+ switch (action.type) {
+ case 'UNSELECT_DATES':
+ return null;
+ case 'SELECT_DATES':
+ return action.selection;
+ default:
+ return currentSelection;
+ }
+ }
+ function reduceSelectedEvent(currentInstanceId, action) {
+ switch (action.type) {
+ case 'UNSELECT_EVENT':
+ return '';
+ case 'SELECT_EVENT':
+ return action.eventInstanceId;
+ default:
+ return currentInstanceId;
+ }
+ }
+ function reduceEventDrag(currentDrag, action) {
+ let newDrag;
+ switch (action.type) {
+ case 'UNSET_EVENT_DRAG':
+ return null;
+ case 'SET_EVENT_DRAG':
+ newDrag = action.state;
+ return {
+ affectedEvents: newDrag.affectedEvents,
+ mutatedEvents: newDrag.mutatedEvents,
+ isEvent: newDrag.isEvent,
+ };
+ default:
+ return currentDrag;
+ }
+ }
+ function reduceEventResize(currentResize, action) {
+ let newResize;
+ switch (action.type) {
+ case 'UNSET_EVENT_RESIZE':
+ return null;
+ case 'SET_EVENT_RESIZE':
+ newResize = action.state;
+ return {
+ affectedEvents: newResize.affectedEvents,
+ mutatedEvents: newResize.mutatedEvents,
+ isEvent: newResize.isEvent,
+ };
+ default:
+ return currentResize;
+ }
+ }
+ function parseToolbars(calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
+ let header = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
+ let footer = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
+ return { header, footer };
+ }
+ function parseToolbar(sectionStrHash, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
+ let sectionWidgets = {};
+ let viewsWithButtons = [];
+ let hasTitle = false;
+ for (let sectionName in sectionStrHash) {
+ let sectionStr = sectionStrHash[sectionName];
+ let sectionRes = parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi);
+ sectionWidgets[sectionName] = sectionRes.widgets;
+ viewsWithButtons.push(...sectionRes.viewsWithButtons);
+ hasTitle = hasTitle || sectionRes.hasTitle;
+ }
+ return { sectionWidgets, viewsWithButtons, hasTitle };
+ }
+ function parseSection(sectionStr, calendarOptions,
+ calendarOptionOverrides,
+ theme, viewSpecs, calendarApi) {
+ let isRtl = calendarOptions.direction === 'rtl';
+ let calendarCustomButtons = calendarOptions.customButtons || {};
+ let calendarButtonTextOverrides = calendarOptionOverrides.buttonText || {};
+ let calendarButtonText = calendarOptions.buttonText || {};
+ let calendarButtonHintOverrides = calendarOptionOverrides.buttonHints || {};
+ let calendarButtonHints = calendarOptions.buttonHints || {};
+ let sectionSubstrs = sectionStr ? sectionStr.split(' ') : [];
+ let viewsWithButtons = [];
+ let hasTitle = false;
+ let widgets = sectionSubstrs.map((buttonGroupStr) => (buttonGroupStr.split(',').map((buttonName) => {
+ if (buttonName === 'title') {
+ hasTitle = true;
+ return { buttonName };
+ }
+ let customButtonProps;
+ let viewSpec;
+ let buttonClick;
+ let buttonIcon;
+ let buttonText;
+ let buttonHint;
+ if ((customButtonProps = calendarCustomButtons[buttonName])) {
+ buttonClick = (ev) => {
+ if (customButtonProps.click) {
+ customButtonProps.click.call(ev.target, ev, ev.target);
+ }
+ };
+ (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
+ (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
+ (buttonText = customButtonProps.text);
+ buttonHint = customButtonProps.hint || customButtonProps.text;
+ }
+ else if ((viewSpec = viewSpecs[buttonName])) {
+ viewsWithButtons.push(buttonName);
+ buttonClick = () => {
+ calendarApi.changeView(buttonName);
+ };
+ (buttonText = viewSpec.buttonTextOverride) ||
+ (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
+ (buttonText = viewSpec.buttonTextDefault);
+ let textFallback = viewSpec.buttonTextOverride ||
+ viewSpec.buttonTextDefault;
+ buttonHint = formatWithOrdinals(viewSpec.buttonTitleOverride ||
+ viewSpec.buttonTitleDefault ||
+ calendarOptions.viewHint, [textFallback, buttonName],
+ textFallback);
+ }
+ else if (calendarApi[buttonName]) {
+ buttonClick = () => {
+ calendarApi[buttonName]();
+ };
+ (buttonText = calendarButtonTextOverrides[buttonName]) ||
+ (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
+ (buttonText = calendarButtonText[buttonName]);
+ if (buttonName === 'prevYear' || buttonName === 'nextYear') {
+ let prevOrNext = buttonName === 'prevYear' ? 'prev' : 'next';
+ buttonHint = formatWithOrdinals(calendarButtonHintOverrides[prevOrNext] ||
+ calendarButtonHints[prevOrNext], [
+ calendarButtonText.year || 'year',
+ 'year',
+ ], calendarButtonText[buttonName]);
+ }
+ else {
+ buttonHint = (navUnit) => formatWithOrdinals(calendarButtonHintOverrides[buttonName] ||
+ calendarButtonHints[buttonName], [
+ calendarButtonText[navUnit] || navUnit,
+ navUnit,
+ ], calendarButtonText[buttonName]);
+ }
+ }
+ return { buttonName, buttonClick, buttonIcon, buttonText, buttonHint };
+ })));
+ return { widgets, viewsWithButtons, hasTitle };
+ }
+ class ViewImpl {
+ constructor(type, getCurrentData, dateEnv) {
+ this.type = type;
+ this.getCurrentData = getCurrentData;
+ this.dateEnv = dateEnv;
+ }
+ get calendar() {
+ return this.getCurrentData().calendarApi;
+ }
+ get title() {
+ return this.getCurrentData().viewTitle;
+ }
+ get activeStart() {
+ return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
+ }
+ get activeEnd() {
+ return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
+ }
+ get currentStart() {
+ return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
+ }
+ get currentEnd() {
+ return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
+ }
+ getOption(name) {
+ return this.getCurrentData().options[name];
+ }
+ }
+ let eventSourceDef$2 = {
+ ignoreRange: true,
+ parseMeta(refined) {
+ if (Array.isArray(refined.events)) {
+ return refined.events;
+ }
+ return null;
+ },
+ fetch(arg, successCallback) {
+ successCallback({
+ rawEvents: arg.eventSource.meta,
+ });
+ },
+ };
+ const arrayEventSourcePlugin = createPlugin({
+ name: 'array-event-source',
+ eventSourceDefs: [eventSourceDef$2],
+ });
+ let eventSourceDef$1 = {
+ parseMeta(refined) {
+ if (typeof refined.events === 'function') {
+ return refined.events;
+ }
+ return null;
+ },
+ fetch(arg, successCallback, errorCallback) {
+ const { dateEnv } = arg.context;
+ const func = arg.eventSource.meta;
+ unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), (rawEvents) => successCallback({ rawEvents }), errorCallback);
+ },
+ };
+ const funcEventSourcePlugin = createPlugin({
+ name: 'func-event-source',
+ eventSourceDefs: [eventSourceDef$1],
+ });
+ const JSON_FEED_EVENT_SOURCE_REFINERS = {
+ method: String,
+ extraParams: identity,
+ startParam: String,
+ endParam: String,
+ timeZoneParam: String,
+ };
+ let eventSourceDef = {
+ parseMeta(refined) {
+ if (refined.url && (refined.format === 'json' || !refined.format)) {
+ return {
+ url: refined.url,
+ format: 'json',
+ method: (refined.method || 'GET').toUpperCase(),
+ extraParams: refined.extraParams,
+ startParam: refined.startParam,
+ endParam: refined.endParam,
+ timeZoneParam: refined.timeZoneParam,
+ };
+ }
+ return null;
+ },
+ fetch(arg, successCallback, errorCallback) {
+ const { meta } = arg.eventSource;
+ const requestParams = buildRequestParams(meta, arg.range, arg.context);
+ requestJson(meta.method, meta.url, requestParams).then(([rawEvents, response]) => {
+ successCallback({ rawEvents, response });
+ }, errorCallback);
+ },
+ };
+ const jsonFeedEventSourcePlugin = createPlugin({
+ name: 'json-event-source',
+ eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
+ eventSourceDefs: [eventSourceDef],
+ });
+ function buildRequestParams(meta, range, context) {
+ let { dateEnv, options } = context;
+ let startParam;
+ let endParam;
+ let timeZoneParam;
+ let customRequestParams;
+ let params = {};
+ startParam = meta.startParam;
+ if (startParam == null) {
+ startParam = options.startParam;
+ }
+ endParam = meta.endParam;
+ if (endParam == null) {
+ endParam = options.endParam;
+ }
+ timeZoneParam = meta.timeZoneParam;
+ if (timeZoneParam == null) {
+ timeZoneParam = options.timeZoneParam;
+ }
+ if (typeof meta.extraParams === 'function') {
+ customRequestParams = meta.extraParams();
+ }
+ else {
+ customRequestParams = meta.extraParams || {};
+ }
+ Object.assign(params, customRequestParams);
+ params[startParam] = dateEnv.formatIso(range.start);
+ params[endParam] = dateEnv.formatIso(range.end);
+ if (dateEnv.timeZone !== 'local') {
+ params[timeZoneParam] = dateEnv.timeZone;
+ }
+ return params;
+ }
+ const SIMPLE_RECURRING_REFINERS = {
+ daysOfWeek: identity,
+ startTime: createDuration,
+ endTime: createDuration,
+ duration: createDuration,
+ startRecur: identity,
+ endRecur: identity,
+ };
+ let recurring = {
+ parse(refined, dateEnv) {
+ if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
+ let recurringData = {
+ daysOfWeek: refined.daysOfWeek || null,
+ startTime: refined.startTime || null,
+ endTime: refined.endTime || null,
+ startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
+ endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null,
+ dateEnv,
+ };
+ let duration;
+ if (refined.duration) {
+ duration = refined.duration;
+ }
+ if (!duration && refined.startTime && refined.endTime) {
+ duration = subtractDurations(refined.endTime, refined.startTime);
+ }
+ return {
+ allDayGuess: Boolean(!refined.startTime && !refined.endTime),
+ duration,
+ typeData: recurringData,
+ };
+ }
+ return null;
+ },
+ expand(typeData, framingRange, dateEnv) {
+ let clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
+ if (clippedFramingRange) {
+ return expandRanges(typeData.daysOfWeek, typeData.startTime, typeData.dateEnv, dateEnv, clippedFramingRange);
+ }
+ return [];
+ },
+ };
+ const simpleRecurringEventsPlugin = createPlugin({
+ name: 'simple-recurring-event',
+ recurringTypes: [recurring],
+ eventRefiners: SIMPLE_RECURRING_REFINERS,
+ });
+ function expandRanges(daysOfWeek, startTime, eventDateEnv, calendarDateEnv, framingRange) {
+ let dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
+ let dayMarker = startOfDay(framingRange.start);
+ let endMarker = framingRange.end;
+ let instanceStarts = [];
+ if (startTime) {
+ if (startTime.milliseconds < 0) {
+ endMarker = addDays(endMarker, 1);
+ }
+ else if (startTime.milliseconds >= 1000 * 60 * 60 * 24) {
+ dayMarker = addDays(dayMarker, -1);
+ }
+ }
+ while (dayMarker < endMarker) {
+ let instanceStart;
+ if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
+ if (startTime) {
+ instanceStart = calendarDateEnv.add(dayMarker, startTime);
+ }
+ else {
+ instanceStart = dayMarker;
+ }
+ instanceStarts.push(calendarDateEnv.createMarker(eventDateEnv.toDate(instanceStart)));
+ }
+ dayMarker = addDays(dayMarker, 1);
+ }
+ return instanceStarts;
+ }
+ const changeHandlerPlugin = createPlugin({
+ name: 'change-handler',
+ optionChangeHandlers: {
+ events(events, context) {
+ handleEventSources([events], context);
+ },
+ eventSources: handleEventSources,
+ },
+ });
+ function handleEventSources(inputs, context) {
+ let unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
+ if (unfoundSources.length === 1 &&
+ inputs.length === 1 &&
+ Array.isArray(unfoundSources[0]._raw) &&
+ Array.isArray(inputs[0])) {
+ context.dispatch({
+ type: 'RESET_RAW_EVENTS',
+ sourceId: unfoundSources[0].sourceId,
+ rawEvents: inputs[0],
+ });
+ return;
+ }
+ let newInputs = [];
+ for (let input of inputs) {
+ let inputFound = false;
+ for (let i = 0; i < unfoundSources.length; i += 1) {
+ if (unfoundSources[i]._raw === input) {
+ unfoundSources.splice(i, 1);
+ inputFound = true;
+ break;
+ }
+ }
+ if (!inputFound) {
+ newInputs.push(input);
+ }
+ }
+ for (let unfoundSource of unfoundSources) {
+ context.dispatch({
+ type: 'REMOVE_EVENT_SOURCE',
+ sourceId: unfoundSource.sourceId,
+ });
+ }
+ for (let newInput of newInputs) {
+ context.calendarApi.addEventSource(newInput);
+ }
+ }
+ function handleDateProfile(dateProfile, context) {
+ context.emitter.trigger('datesSet', Object.assign(Object.assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
+ }
+ function handleEventStore(eventStore, context) {
+ let { emitter } = context;
+ if (emitter.hasHandlers('eventsSet')) {
+ emitter.trigger('eventsSet', buildEventApis(eventStore, context));
+ }
+ }
+ const globalPlugins = [
+ arrayEventSourcePlugin,
+ funcEventSourcePlugin,
+ jsonFeedEventSourcePlugin,
+ simpleRecurringEventsPlugin,
+ changeHandlerPlugin,
+ createPlugin({
+ name: 'misc',
+ isLoadingFuncs: [
+ (state) => computeEventSourcesLoading(state.eventSources),
+ ],
+ propSetHandlers: {
+ dateProfile: handleDateProfile,
+ eventStore: handleEventStore,
+ },
+ }),
+ ];
+ class TaskRunner {
+ constructor(runTaskOption, drainedOption) {
+ this.runTaskOption = runTaskOption;
+ this.drainedOption = drainedOption;
+ this.queue = [];
+ this.delayedRunner = new DelayedRunner(this.drain.bind(this));
+ }
+ request(task, delay) {
+ this.queue.push(task);
+ this.delayedRunner.request(delay);
+ }
+ pause(scope) {
+ this.delayedRunner.pause(scope);
+ }
+ resume(scope, force) {
+ this.delayedRunner.resume(scope, force);
+ }
+ drain() {
+ let { queue } = this;
+ while (queue.length) {
+ let completedTasks = [];
+ let task;
+ while ((task = queue.shift())) {
+ this.runTask(task);
+ completedTasks.push(task);
+ }
+ this.drained(completedTasks);
+ }
+ }
+ runTask(task) {
+ if (this.runTaskOption) {
+ this.runTaskOption(task);
+ }
+ }
+ drained(completedTasks) {
+ if (this.drainedOption) {
+ this.drainedOption(completedTasks);
+ }
+ }
+ }
+ function buildTitle(dateProfile, viewOptions, dateEnv) {
+ let range;
+ if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
+ range = dateProfile.currentRange;
+ }
+ else {
+ range = dateProfile.activeRange;
+ }
+ return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile)), {
+ isEndExclusive: dateProfile.isRangeAllDay,
+ defaultSeparator: viewOptions.titleRangeSeparator,
+ });
+ }
+ function buildTitleFormat(dateProfile) {
+ let { currentRangeUnit } = dateProfile;
+ if (currentRangeUnit === 'year') {
+ return { year: 'numeric' };
+ }
+ if (currentRangeUnit === 'month') {
+ return { year: 'numeric', month: 'long' };
+ }
+ let days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
+ if (days !== null && days > 1) {
+ return { year: 'numeric', month: 'short', day: 'numeric' };
+ }
+ return { year: 'numeric', month: 'long', day: 'numeric' };
+ }
+ class CalendarNowManager {
+ constructor() {
+ this.resetListeners = new Set();
+ }
+ handleInput(dateEnv,
+ nowInput) {
+ const oldDateEnv = this.dateEnv;
+ if (dateEnv !== oldDateEnv) {
+ if (typeof nowInput === 'function') {
+ this.nowFn = nowInput;
+ }
+ else if (!oldDateEnv) {
+ this.nowAnchorDate = dateEnv.toDate(nowInput
+ ? dateEnv.createMarker(nowInput)
+ : dateEnv.createNowMarker());
+ this.nowAnchorQueried = Date.now();
+ }
+ this.dateEnv = dateEnv;
+ if (oldDateEnv) {
+ for (const resetListener of this.resetListeners.values()) {
+ resetListener();
+ }
+ }
+ }
+ }
+ getDateMarker() {
+ return this.nowAnchorDate
+ ? this.dateEnv.timestampToMarker(this.nowAnchorDate.valueOf() +
+ (Date.now() - this.nowAnchorQueried))
+ : this.dateEnv.createMarker(this.nowFn());
+ }
+ addResetListener(handler) {
+ this.resetListeners.add(handler);
+ }
+ removeResetListener(handler) {
+ this.resetListeners.delete(handler);
+ }
+ }
+ class CalendarDataManager {
+ constructor(props) {
+ this.computeCurrentViewData = memoize(this._computeCurrentViewData);
+ this.organizeRawLocales = memoize(organizeRawLocales);
+ this.buildLocale = memoize(buildLocale);
+ this.buildPluginHooks = buildBuildPluginHooks();
+ this.buildDateEnv = memoize(buildDateEnv$1);
+ this.buildTheme = memoize(buildTheme);
+ this.parseToolbars = memoize(parseToolbars);
+ this.buildViewSpecs = memoize(buildViewSpecs);
+ this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
+ this.buildViewApi = memoize(buildViewApi);
+ this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
+ this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqual);
+ this.buildEventUiBases = memoize(buildEventUiBases);
+ this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
+ this.buildTitle = memoize(buildTitle);
+ this.nowManager = new CalendarNowManager();
+ this.emitter = new Emitter();
+ this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
+ this.currentCalendarOptionsInput = {};
+ this.currentCalendarOptionsRefined = {};
+ this.currentViewOptionsInput = {};
+ this.currentViewOptionsRefined = {};
+ this.currentCalendarOptionsRefiners = {};
+ this.optionsForRefining = [];
+ this.optionsForHandling = [];
+ this.getCurrentData = () => this.data;
+ this.dispatch = (action) => {
+ this.actionRunner.request(action);
+ };
+ this.props = props;
+ this.actionRunner.pause();
+ this.nowManager = new CalendarNowManager();
+ let dynamicOptionOverrides = {};
+ let optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
+ let currentViewType = optionsData.calendarOptions.initialView || optionsData.pluginHooks.initialView;
+ let currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
+ props.calendarApi.currentDataManager = this;
+ this.emitter.setThisContext(props.calendarApi);
+ this.emitter.setOptions(currentViewData.options);
+ let calendarContext = {
+ nowManager: this.nowManager,
+ dateEnv: optionsData.dateEnv,
+ options: optionsData.calendarOptions,
+ pluginHooks: optionsData.pluginHooks,
+ calendarApi: props.calendarApi,
+ dispatch: this.dispatch,
+ emitter: this.emitter,
+ getCurrentData: this.getCurrentData,
+ };
+ let currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv, this.nowManager);
+ let dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
+ if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
+ currentDate = dateProfile.currentRange.start;
+ }
+ for (let callback of optionsData.pluginHooks.contextInit) {
+ callback(calendarContext);
+ }
+ let eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
+ let initialState = {
+ dynamicOptionOverrides,
+ currentViewType,
+ currentDate,
+ dateProfile,
+ businessHours: this.parseContextBusinessHours(calendarContext),
+ eventSources,
+ eventUiBases: {},
+ eventStore: createEmptyEventStore(),
+ renderableEventStore: createEmptyEventStore(),
+ dateSelection: null,
+ eventSelection: '',
+ eventDrag: null,
+ eventResize: null,
+ selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig,
+ };
+ let contextAndState = Object.assign(Object.assign({}, calendarContext), initialState);
+ for (let reducer of optionsData.pluginHooks.reducers) {
+ Object.assign(initialState, reducer(null, null, contextAndState));
+ }
+ if (computeIsLoading(initialState, calendarContext)) {
+ this.emitter.trigger('loading', true);
+ }
+ this.state = initialState;
+ this.updateData();
+ this.actionRunner.resume();
+ }
+ resetOptions(optionOverrides, changedOptionNames) {
+ let { props } = this;
+ if (changedOptionNames === undefined) {
+ props.optionOverrides = optionOverrides;
+ }
+ else {
+ props.optionOverrides = Object.assign(Object.assign({}, (props.optionOverrides || {})), optionOverrides);
+ this.optionsForRefining.push(...changedOptionNames);
+ }
+ if (changedOptionNames === undefined || changedOptionNames.length) {
+ this.actionRunner.request({
+ type: 'NOTHING',
+ });
+ }
+ }
+ _handleAction(action) {
+ let { props, state, emitter } = this;
+ let dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
+ let optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
+ let currentViewType = reduceViewType(state.currentViewType, action);
+ let currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
+ props.calendarApi.currentDataManager = this;
+ emitter.setThisContext(props.calendarApi);
+ emitter.setOptions(currentViewData.options);
+ let calendarContext = {
+ nowManager: this.nowManager,
+ dateEnv: optionsData.dateEnv,
+ options: optionsData.calendarOptions,
+ pluginHooks: optionsData.pluginHooks,
+ calendarApi: props.calendarApi,
+ dispatch: this.dispatch,
+ emitter,
+ getCurrentData: this.getCurrentData,
+ };
+ let { currentDate, dateProfile } = state;
+ if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) {
+ dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
+ }
+ currentDate = reduceCurrentDate(currentDate, action);
+ dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
+ if (action.type === 'PREV' ||
+ action.type === 'NEXT' ||
+ !rangeContainsMarker(dateProfile.currentRange, currentDate)) {
+ currentDate = dateProfile.currentRange.start;
+ }
+ let eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
+ let eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
+ let isEventsLoading = computeEventSourcesLoading(eventSources);
+ let renderableEventStore = (isEventsLoading && !currentViewData.options.progressiveEventRendering) ?
+ (state.renderableEventStore || eventStore) :
+ eventStore;
+ let { eventUiSingleBase, selectionConfig } = this.buildViewUiProps(calendarContext);
+ let eventUiBySource = this.buildEventUiBySource(eventSources);
+ let eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
+ let newState = {
+ dynamicOptionOverrides,
+ currentViewType,
+ currentDate,
+ dateProfile,
+ eventSources,
+ eventStore,
+ renderableEventStore,
+ selectionConfig,
+ eventUiBases,
+ businessHours: this.parseContextBusinessHours(calendarContext),
+ dateSelection: reduceDateSelection(state.dateSelection, action),
+ eventSelection: reduceSelectedEvent(state.eventSelection, action),
+ eventDrag: reduceEventDrag(state.eventDrag, action),
+ eventResize: reduceEventResize(state.eventResize, action),
+ };
+ let contextAndState = Object.assign(Object.assign({}, calendarContext), newState);
+ for (let reducer of optionsData.pluginHooks.reducers) {
+ Object.assign(newState, reducer(state, action, contextAndState));
+ }
+ let wasLoading = computeIsLoading(state, calendarContext);
+ let isLoading = computeIsLoading(newState, calendarContext);
+ if (!wasLoading && isLoading) {
+ emitter.trigger('loading', true);
+ }
+ else if (wasLoading && !isLoading) {
+ emitter.trigger('loading', false);
+ }
+ this.state = newState;
+ if (props.onAction) {
+ props.onAction(action);
+ }
+ }
+ updateData() {
+ let { props, state } = this;
+ let oldData = this.data;
+ let optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
+ let currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
+ let data = this.data = Object.assign(Object.assign(Object.assign({ nowManager: this.nowManager, viewTitle: this.buildTitle(state.dateProfile, currentViewData.options, optionsData.dateEnv), calendarApi: props.calendarApi, dispatch: this.dispatch, emitter: this.emitter, getCurrentData: this.getCurrentData }, optionsData), currentViewData), state);
+ let changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
+ let oldCalendarOptions = oldData && oldData.calendarOptions;
+ let newCalendarOptions = optionsData.calendarOptions;
+ if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
+ if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
+ state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
+ state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
+ state.renderableEventStore = data.renderableEventStore = rezoneEventStoreDates(data.renderableEventStore, oldData.dateEnv, data.dateEnv);
+ }
+ for (let optionName in changeHandlers) {
+ if (this.optionsForHandling.indexOf(optionName) !== -1 ||
+ oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
+ changeHandlers[optionName](newCalendarOptions[optionName], data);
+ }
+ }
+ }
+ this.optionsForHandling = [];
+ if (props.onData) {
+ props.onData(data);
+ }
+ }
+ computeOptionsData(optionOverrides, dynamicOptionOverrides, calendarApi) {
+ if (!this.optionsForRefining.length &&
+ optionOverrides === this.stableOptionOverrides &&
+ dynamicOptionOverrides === this.stableDynamicOptionOverrides) {
+ return this.stableCalendarOptionsData;
+ }
+ let { refinedOptions, pluginHooks, localeDefaults, availableLocaleData, extra, } = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides);
+ warnUnknownOptions(extra);
+ let dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
+ let viewSpecs = this.buildViewSpecs(pluginHooks.views, this.stableOptionOverrides, this.stableDynamicOptionOverrides, localeDefaults);
+ let theme = this.buildTheme(refinedOptions, pluginHooks);
+ let toolbarConfig = this.parseToolbars(refinedOptions, this.stableOptionOverrides, theme, viewSpecs, calendarApi);
+ return this.stableCalendarOptionsData = {
+ calendarOptions: refinedOptions,
+ pluginHooks,
+ dateEnv,
+ viewSpecs,
+ theme,
+ toolbarConfig,
+ localeDefaults,
+ availableRawLocales: availableLocaleData.map,
+ };
+ }
+ processRawCalendarOptions(optionOverrides, dynamicOptionOverrides) {
+ let { locales, locale } = mergeRawOptions([
+ BASE_OPTION_DEFAULTS,
+ optionOverrides,
+ dynamicOptionOverrides,
+ ]);
+ let availableLocaleData = this.organizeRawLocales(locales);
+ let availableRawLocales = availableLocaleData.map;
+ let localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
+ let pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
+ let refiners = this.currentCalendarOptionsRefiners = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
+ let extra = {};
+ let raw = mergeRawOptions([
+ BASE_OPTION_DEFAULTS,
+ localeDefaults,
+ optionOverrides,
+ dynamicOptionOverrides,
+ ]);
+ let refined = {};
+ let currentRaw = this.currentCalendarOptionsInput;
+ let currentRefined = this.currentCalendarOptionsRefined;
+ let anyChanges = false;
+ for (let optionName in raw) {
+ if (this.optionsForRefining.indexOf(optionName) === -1 && (raw[optionName] === currentRaw[optionName] || (COMPLEX_OPTION_COMPARATORS[optionName] &&
+ (optionName in currentRaw) &&
+ COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName])))) {
+ refined[optionName] = currentRefined[optionName];
+ }
+ else if (refiners[optionName]) {
+ refined[optionName] = refiners[optionName](raw[optionName]);
+ anyChanges = true;
+ }
+ else {
+ extra[optionName] = currentRaw[optionName];
+ }
+ }
+ if (anyChanges) {
+ this.currentCalendarOptionsInput = raw;
+ this.currentCalendarOptionsRefined = refined;
+ this.stableOptionOverrides = optionOverrides;
+ this.stableDynamicOptionOverrides = dynamicOptionOverrides;
+ }
+ this.optionsForHandling.push(...this.optionsForRefining);
+ this.optionsForRefining = [];
+ return {
+ rawOptions: this.currentCalendarOptionsInput,
+ refinedOptions: this.currentCalendarOptionsRefined,
+ pluginHooks,
+ availableLocaleData,
+ localeDefaults,
+ extra,
+ };
+ }
+ _computeCurrentViewData(viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
+ let viewSpec = optionsData.viewSpecs[viewType];
+ if (!viewSpec) {
+ throw new Error(`viewType "${viewType}" is not available. Please make sure you've loaded all neccessary plugins`);
+ }
+ let { refinedOptions, extra } = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides);
+ warnUnknownOptions(extra);
+ this.nowManager.handleInput(optionsData.dateEnv, refinedOptions.now);
+ let dateProfileGenerator = this.buildDateProfileGenerator({
+ dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
+ nowManager: this.nowManager,
+ duration: viewSpec.duration,
+ durationUnit: viewSpec.durationUnit,
+ usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
+ dateEnv: optionsData.dateEnv,
+ calendarApi: this.props.calendarApi,
+ slotMinTime: refinedOptions.slotMinTime,
+ slotMaxTime: refinedOptions.slotMaxTime,
+ showNonCurrentDates: refinedOptions.showNonCurrentDates,
+ dayCount: refinedOptions.dayCount,
+ dateAlignment: refinedOptions.dateAlignment,
+ dateIncrement: refinedOptions.dateIncrement,
+ hiddenDays: refinedOptions.hiddenDays,
+ weekends: refinedOptions.weekends,
+ validRangeInput: refinedOptions.validRange,
+ visibleRangeInput: refinedOptions.visibleRange,
+ fixedWeekCount: refinedOptions.fixedWeekCount,
+ });
+ let viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
+ return { viewSpec, options: refinedOptions, dateProfileGenerator, viewApi };
+ }
+ processRawViewOptions(viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
+ let raw = mergeRawOptions([
+ BASE_OPTION_DEFAULTS,
+ viewSpec.optionDefaults,
+ localeDefaults,
+ optionOverrides,
+ viewSpec.optionOverrides,
+ dynamicOptionOverrides,
+ ]);
+ let refiners = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), VIEW_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
+ let refined = {};
+ let currentRaw = this.currentViewOptionsInput;
+ let currentRefined = this.currentViewOptionsRefined;
+ let anyChanges = false;
+ let extra = {};
+ for (let optionName in raw) {
+ if (raw[optionName] === currentRaw[optionName] ||
+ (COMPLEX_OPTION_COMPARATORS[optionName] &&
+ COMPLEX_OPTION_COMPARATORS[optionName](raw[optionName], currentRaw[optionName]))) {
+ refined[optionName] = currentRefined[optionName];
+ }
+ else {
+ if (raw[optionName] === this.currentCalendarOptionsInput[optionName] ||
+ (COMPLEX_OPTION_COMPARATORS[optionName] &&
+ COMPLEX_OPTION_COMPARATORS[optionName](raw[optionName], this.currentCalendarOptionsInput[optionName]))) {
+ if (optionName in this.currentCalendarOptionsRefined) {
+ refined[optionName] = this.currentCalendarOptionsRefined[optionName];
+ }
+ }
+ else if (refiners[optionName]) {
+ refined[optionName] = refiners[optionName](raw[optionName]);
+ }
+ else {
+ extra[optionName] = raw[optionName];
+ }
+ anyChanges = true;
+ }
+ }
+ if (anyChanges) {
+ this.currentViewOptionsInput = raw;
+ this.currentViewOptionsRefined = refined;
+ }
+ return {
+ rawOptions: this.currentViewOptionsInput,
+ refinedOptions: this.currentViewOptionsRefined,
+ extra,
+ };
+ }
+ }
+ function buildDateEnv$1(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, pluginHooks, availableLocaleData, defaultSeparator) {
+ let locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
+ return new DateEnv({
+ calendarSystem: 'gregory',
+ timeZone,
+ namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
+ locale,
+ weekNumberCalculation,
+ firstDay,
+ weekText,
+ cmdFormatter: pluginHooks.cmdFormatter,
+ defaultSeparator,
+ });
+ }
+ function buildTheme(options, pluginHooks) {
+ let ThemeClass = pluginHooks.themeClasses[options.themeSystem] || StandardTheme;
+ return new ThemeClass(options);
+ }
+ function buildDateProfileGenerator(props) {
+ let DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
+ return new DateProfileGeneratorClass(props);
+ }
+ function buildViewApi(type, getCurrentData, dateEnv) {
+ return new ViewImpl(type, getCurrentData, dateEnv);
+ }
+ function buildEventUiBySource(eventSources) {
+ return mapHash(eventSources, (eventSource) => eventSource.ui);
+ }
+ function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
+ let eventUiBases = { '': eventUiSingleBase };
+ for (let defId in eventDefs) {
+ let def = eventDefs[defId];
+ if (def.sourceId && eventUiBySource[def.sourceId]) {
+ eventUiBases[defId] = eventUiBySource[def.sourceId];
+ }
+ }
+ return eventUiBases;
+ }
+ function buildViewUiProps(calendarContext) {
+ let { options } = calendarContext;
+ return {
+ eventUiSingleBase: createEventUi({
+ display: options.eventDisplay,
+ editable: options.editable,
+ startEditable: options.eventStartEditable,
+ durationEditable: options.eventDurationEditable,
+ constraint: options.eventConstraint,
+ overlap: typeof options.eventOverlap === 'boolean' ? options.eventOverlap : undefined,
+ allow: options.eventAllow,
+ backgroundColor: options.eventBackgroundColor,
+ borderColor: options.eventBorderColor,
+ textColor: options.eventTextColor,
+ color: options.eventColor,
+ }, calendarContext),
+ selectionConfig: createEventUi({
+ constraint: options.selectConstraint,
+ overlap: typeof options.selectOverlap === 'boolean' ? options.selectOverlap : undefined,
+ allow: options.selectAllow,
+ }, calendarContext),
+ };
+ }
+ function computeIsLoading(state, context) {
+ for (let isLoadingFunc of context.pluginHooks.isLoadingFuncs) {
+ if (isLoadingFunc(state)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ function parseContextBusinessHours(calendarContext) {
+ return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
+ }
+ function warnUnknownOptions(options, viewName) {
+ for (let optionName in options) {
+ console.warn(`Unknown option '${optionName}'` +
+ (viewName ? ` for view '${viewName}'` : ''));
+ }
+ }
+ class ToolbarSection extends BaseComponent {
+ render() {
+ let children = this.props.widgetGroups.map((widgetGroup) => this.renderWidgetGroup(widgetGroup));
+ return y('div', { className: 'fc-toolbar-chunk' }, ...children);
+ }
+ renderWidgetGroup(widgetGroup) {
+ let { props } = this;
+ let { theme } = this.context;
+ let children = [];
+ let isOnlyButtons = true;
+ for (let widget of widgetGroup) {
+ let { buttonName, buttonClick, buttonText, buttonIcon, buttonHint } = widget;
+ if (buttonName === 'title') {
+ isOnlyButtons = false;
+ children.push(y("h2", { className: "fc-toolbar-title", id: props.titleId }, props.title));
+ }
+ else {
+ let isPressed = buttonName === props.activeButton;
+ let isDisabled = (!props.isTodayEnabled && buttonName === 'today') ||
+ (!props.isPrevEnabled && buttonName === 'prev') ||
+ (!props.isNextEnabled && buttonName === 'next');
+ let buttonClasses = [`fc-${buttonName}-button`, theme.getClass('button')];
+ if (isPressed) {
+ buttonClasses.push(theme.getClass('buttonActive'));
+ }
+ children.push(y("button", { type: "button", title: typeof buttonHint === 'function' ? buttonHint(props.navUnit) : buttonHint, disabled: isDisabled, "aria-pressed": isPressed, className: buttonClasses.join(' '), onClick: buttonClick }, buttonText || (buttonIcon ? y("span", { className: buttonIcon, role: "img" }) : '')));
+ }
+ }
+ if (children.length > 1) {
+ let groupClassName = (isOnlyButtons && theme.getClass('buttonGroup')) || '';
+ return y('div', { className: groupClassName }, ...children);
+ }
+ return children[0];
+ }
+ }
+ class Toolbar extends BaseComponent {
+ render() {
+ let { model, extraClassName } = this.props;
+ let forceLtr = false;
+ let startContent;
+ let endContent;
+ let sectionWidgets = model.sectionWidgets;
+ let centerContent = sectionWidgets.center;
+ if (sectionWidgets.left) {
+ forceLtr = true;
+ startContent = sectionWidgets.left;
+ }
+ else {
+ startContent = sectionWidgets.start;
+ }
+ if (sectionWidgets.right) {
+ forceLtr = true;
+ endContent = sectionWidgets.right;
+ }
+ else {
+ endContent = sectionWidgets.end;
+ }
+ let classNames = [
+ extraClassName || '',
+ 'fc-toolbar',
+ forceLtr ? 'fc-toolbar-ltr' : '',
+ ];
+ return (y("div", { className: classNames.join(' ') },
+ this.renderSection('start', startContent || []),
+ this.renderSection('center', centerContent || []),
+ this.renderSection('end', endContent || [])));
+ }
+ renderSection(key, widgetGroups) {
+ let { props } = this;
+ return (y(ToolbarSection, { key: key, widgetGroups: widgetGroups, title: props.title, navUnit: props.navUnit, activeButton: props.activeButton, isTodayEnabled: props.isTodayEnabled, isPrevEnabled: props.isPrevEnabled, isNextEnabled: props.isNextEnabled, titleId: props.titleId }));
+ }
+ }
+ class ViewHarness extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.state = {
+ availableWidth: null,
+ };
+ this.handleEl = (el) => {
+ this.el = el;
+ setRef(this.props.elRef, el);
+ this.updateAvailableWidth();
+ };
+ this.handleResize = () => {
+ this.updateAvailableWidth();
+ };
+ }
+ render() {
+ let { props, state } = this;
+ let { aspectRatio } = props;
+ let classNames = [
+ 'fc-view-harness',
+ (aspectRatio || props.liquid || props.height)
+ ? 'fc-view-harness-active'
+ : 'fc-view-harness-passive',
+ ];
+ let height = '';
+ let paddingBottom = '';
+ if (aspectRatio) {
+ if (state.availableWidth !== null) {
+ height = state.availableWidth / aspectRatio;
+ }
+ else {
+ paddingBottom = `${(1 / aspectRatio) * 100}%`;
+ }
+ }
+ else {
+ height = props.height || '';
+ }
+ return (y("div", { "aria-labelledby": props.labeledById, ref: this.handleEl, className: classNames.join(' '), style: { height, paddingBottom } }, props.children));
+ }
+ componentDidMount() {
+ this.context.addResizeHandler(this.handleResize);
+ }
+ componentWillUnmount() {
+ this.context.removeResizeHandler(this.handleResize);
+ }
+ updateAvailableWidth() {
+ if (this.el &&
+ this.props.aspectRatio
+ ) {
+ this.setState({ availableWidth: this.el.offsetWidth });
+ }
+ }
+ }
+ class EventClicking extends Interaction {
+ constructor(settings) {
+ super(settings);
+ this.handleSegClick = (ev, segEl) => {
+ let { component } = this;
+ let { context } = component;
+ let seg = getElSeg(segEl);
+ if (seg &&
+ component.isValidSegDownEl(ev.target)) {
+ let hasUrlContainer = elementClosest(ev.target, '.fc-event-forced-url');
+ let url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
+ context.emitter.trigger('eventClick', {
+ el: segEl,
+ event: new EventImpl(component.context, seg.eventRange.def, seg.eventRange.instance),
+ jsEvent: ev,
+ view: context.viewApi,
+ });
+ if (url && !ev.defaultPrevented) {
+ window.location.href = url;
+ }
+ }
+ };
+ this.destroy = listenBySelector(settings.el, 'click', '.fc-event',
+ this.handleSegClick);
+ }
+ }
+ class EventHovering extends Interaction {
+ constructor(settings) {
+ super(settings);
+ this.handleEventElRemove = (el) => {
+ if (el === this.currentSegEl) {
+ this.handleSegLeave(null, this.currentSegEl);
+ }
+ };
+ this.handleSegEnter = (ev, segEl) => {
+ if (getElSeg(segEl)) {
+ this.currentSegEl = segEl;
+ this.triggerEvent('eventMouseEnter', ev, segEl);
+ }
+ };
+ this.handleSegLeave = (ev, segEl) => {
+ if (this.currentSegEl) {
+ this.currentSegEl = null;
+ this.triggerEvent('eventMouseLeave', ev, segEl);
+ }
+ };
+ this.removeHoverListeners = listenToHoverBySelector(settings.el, '.fc-event',
+ this.handleSegEnter, this.handleSegLeave);
+ }
+ destroy() {
+ this.removeHoverListeners();
+ }
+ triggerEvent(publicEvName, ev, segEl) {
+ let { component } = this;
+ let { context } = component;
+ let seg = getElSeg(segEl);
+ if (!ev || component.isValidSegDownEl(ev.target)) {
+ context.emitter.trigger(publicEvName, {
+ el: segEl,
+ event: new EventImpl(context, seg.eventRange.def, seg.eventRange.instance),
+ jsEvent: ev,
+ view: context.viewApi,
+ });
+ }
+ }
+ }
+ class CalendarContent extends PureComponent {
+ constructor() {
+ super(...arguments);
+ this.buildViewContext = memoize(buildViewContext);
+ this.buildViewPropTransformers = memoize(buildViewPropTransformers);
+ this.buildToolbarProps = memoize(buildToolbarProps);
+ this.headerRef = d();
+ this.footerRef = d();
+ this.interactionsStore = {};
+ this.state = {
+ viewLabelId: getUniqueDomId(),
+ };
+ this.registerInteractiveComponent = (component, settingsInput) => {
+ let settings = parseInteractionSettings(component, settingsInput);
+ let DEFAULT_INTERACTIONS = [
+ EventClicking,
+ EventHovering,
+ ];
+ let interactionClasses = DEFAULT_INTERACTIONS.concat(this.props.pluginHooks.componentInteractions);
+ let interactions = interactionClasses.map((TheInteractionClass) => new TheInteractionClass(settings));
+ this.interactionsStore[component.uid] = interactions;
+ interactionSettingsStore[component.uid] = settings;
+ };
+ this.unregisterInteractiveComponent = (component) => {
+ let listeners = this.interactionsStore[component.uid];
+ if (listeners) {
+ for (let listener of listeners) {
+ listener.destroy();
+ }
+ delete this.interactionsStore[component.uid];
+ }
+ delete interactionSettingsStore[component.uid];
+ };
+ this.resizeRunner = new DelayedRunner(() => {
+ this.props.emitter.trigger('_resize', true);
+ this.props.emitter.trigger('windowResize', { view: this.props.viewApi });
+ });
+ this.handleWindowResize = (ev) => {
+ let { options } = this.props;
+ if (options.handleWindowResize &&
+ ev.target === window
+ ) {
+ this.resizeRunner.request(options.windowResizeDelay);
+ }
+ };
+ }
+ render() {
+ let { props } = this;
+ let { toolbarConfig, options } = props;
+ let viewVGrow = false;
+ let viewHeight = '';
+ let viewAspectRatio;
+ if (props.isHeightAuto || props.forPrint) {
+ viewHeight = '';
+ }
+ else if (options.height != null) {
+ viewVGrow = true;
+ }
+ else if (options.contentHeight != null) {
+ viewHeight = options.contentHeight;
+ }
+ else {
+ viewAspectRatio = Math.max(options.aspectRatio, 0.5);
+ }
+ let viewContext = this.buildViewContext(props.viewSpec, props.viewApi, props.options, props.dateProfileGenerator, props.dateEnv, props.nowManager, props.theme, props.pluginHooks, props.dispatch, props.getCurrentData, props.emitter, props.calendarApi, this.registerInteractiveComponent, this.unregisterInteractiveComponent);
+ let viewLabelId = (toolbarConfig.header && toolbarConfig.header.hasTitle)
+ ? this.state.viewLabelId
+ : undefined;
+ return (y(ViewContextType.Provider, { value: viewContext },
+ y(NowTimer, { unit: "day" }, (nowDate) => {
+ let toolbarProps = this.buildToolbarProps(props.viewSpec, props.dateProfile, props.dateProfileGenerator, props.currentDate, nowDate, props.viewTitle);
+ return (y(_, null,
+ toolbarConfig.header && (y(Toolbar, Object.assign({ ref: this.headerRef, extraClassName: "fc-header-toolbar", model: toolbarConfig.header, titleId: viewLabelId }, toolbarProps))),
+ y(ViewHarness, { liquid: viewVGrow, height: viewHeight, aspectRatio: viewAspectRatio, labeledById: viewLabelId },
+ this.renderView(props),
+ this.buildAppendContent()),
+ toolbarConfig.footer && (y(Toolbar, Object.assign({ ref: this.footerRef, extraClassName: "fc-footer-toolbar", model: toolbarConfig.footer, titleId: "" }, toolbarProps)))));
+ })));
+ }
+ componentDidMount() {
+ let { props } = this;
+ this.calendarInteractions = props.pluginHooks.calendarInteractions
+ .map((CalendarInteractionClass) => new CalendarInteractionClass(props));
+ window.addEventListener('resize', this.handleWindowResize);
+ let { propSetHandlers } = props.pluginHooks;
+ for (let propName in propSetHandlers) {
+ propSetHandlers[propName](props[propName], props);
+ }
+ }
+ componentDidUpdate(prevProps) {
+ let { props } = this;
+ let { propSetHandlers } = props.pluginHooks;
+ for (let propName in propSetHandlers) {
+ if (props[propName] !== prevProps[propName]) {
+ propSetHandlers[propName](props[propName], props);
+ }
+ }
+ }
+ componentWillUnmount() {
+ window.removeEventListener('resize', this.handleWindowResize);
+ this.resizeRunner.clear();
+ for (let interaction of this.calendarInteractions) {
+ interaction.destroy();
+ }
+ this.props.emitter.trigger('_unmount');
+ }
+ buildAppendContent() {
+ let { props } = this;
+ let children = props.pluginHooks.viewContainerAppends.map((buildAppendContent) => buildAppendContent(props));
+ return y(_, {}, ...children);
+ }
+ renderView(props) {
+ let { pluginHooks } = props;
+ let { viewSpec } = props;
+ let viewProps = {
+ dateProfile: props.dateProfile,
+ businessHours: props.businessHours,
+ eventStore: props.renderableEventStore,
+ eventUiBases: props.eventUiBases,
+ dateSelection: props.dateSelection,
+ eventSelection: props.eventSelection,
+ eventDrag: props.eventDrag,
+ eventResize: props.eventResize,
+ isHeightAuto: props.isHeightAuto,
+ forPrint: props.forPrint,
+ };
+ let transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
+ for (let transformer of transformers) {
+ Object.assign(viewProps, transformer.transform(viewProps, props));
+ }
+ let ViewComponent = viewSpec.component;
+ return (y(ViewComponent, Object.assign({}, viewProps)));
+ }
+ }
+ function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
+ let todayInfo = dateProfileGenerator.build(now, undefined, false);
+ let prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
+ let nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
+ return {
+ title,
+ activeButton: viewSpec.type,
+ navUnit: viewSpec.singleUnit,
+ isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
+ isPrevEnabled: prevInfo.isValid,
+ isNextEnabled: nextInfo.isValid,
+ };
+ }
+ function buildViewPropTransformers(theClasses) {
+ return theClasses.map((TheClass) => new TheClass());
+ }
+ class Calendar extends CalendarImpl {
+ constructor(el, optionOverrides = {}) {
+ super();
+ this.isRendering = false;
+ this.isRendered = false;
+ this.currentClassNames = [];
+ this.customContentRenderId = 0;
+ this.handleAction = (action) => {
+ switch (action.type) {
+ case 'SET_EVENT_DRAG':
+ case 'SET_EVENT_RESIZE':
+ this.renderRunner.tryDrain();
+ }
+ };
+ this.handleData = (data) => {
+ this.currentData = data;
+ this.renderRunner.request(data.calendarOptions.rerenderDelay);
+ };
+ this.handleRenderRequest = () => {
+ if (this.isRendering) {
+ this.isRendered = true;
+ let { currentData } = this;
+ flushSync(() => {
+ D$1(y(CalendarRoot, { options: currentData.calendarOptions, theme: currentData.theme, emitter: currentData.emitter }, (classNames, height, isHeightAuto, forPrint) => {
+ this.setClassNames(classNames);
+ this.setHeight(height);
+ return (y(RenderId.Provider, { value: this.customContentRenderId },
+ y(CalendarContent, Object.assign({ isHeightAuto: isHeightAuto, forPrint: forPrint }, currentData))));
+ }), this.el);
+ });
+ }
+ else if (this.isRendered) {
+ this.isRendered = false;
+ D$1(null, this.el);
+ this.setClassNames([]);
+ this.setHeight('');
+ }
+ };
+ ensureElHasStyles(el);
+ this.el = el;
+ this.renderRunner = new DelayedRunner(this.handleRenderRequest);
+ new CalendarDataManager({
+ optionOverrides,
+ calendarApi: this,
+ onAction: this.handleAction,
+ onData: this.handleData,
+ });
+ }
+ render() {
+ let wasRendering = this.isRendering;
+ if (!wasRendering) {
+ this.isRendering = true;
+ }
+ else {
+ this.customContentRenderId += 1;
+ }
+ this.renderRunner.request();
+ if (wasRendering) {
+ this.updateSize();
+ }
+ }
+ destroy() {
+ if (this.isRendering) {
+ this.isRendering = false;
+ this.renderRunner.request();
+ }
+ }
+ updateSize() {
+ flushSync(() => {
+ super.updateSize();
+ });
+ }
+ batchRendering(func) {
+ this.renderRunner.pause('batchRendering');
+ func();
+ this.renderRunner.resume('batchRendering');
+ }
+ pauseRendering() {
+ this.renderRunner.pause('pauseRendering');
+ }
+ resumeRendering() {
+ this.renderRunner.resume('pauseRendering', true);
+ }
+ resetOptions(optionOverrides, changedOptionNames) {
+ this.currentDataManager.resetOptions(optionOverrides, changedOptionNames);
+ }
+ setClassNames(classNames) {
+ if (!isArraysEqual(classNames, this.currentClassNames)) {
+ let { classList } = this.el;
+ for (let className of this.currentClassNames) {
+ classList.remove(className);
+ }
+ for (let className of classNames) {
+ classList.add(className);
+ }
+ this.currentClassNames = classNames;
+ }
+ }
+ setHeight(height) {
+ applyStyleProp(this.el, 'height', height);
+ }
+ }
+
+ class TableView extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.headerElRef = d();
+ }
+ renderSimpleLayout(headerRowContent, bodyContent) {
+ let { props, context } = this;
+ let sections = [];
+ let stickyHeaderDates = getStickyHeaderDates(context.options);
+ if (headerRowContent) {
+ sections.push({
+ type: 'header',
+ key: 'header',
+ isSticky: stickyHeaderDates,
+ chunk: {
+ elRef: this.headerElRef,
+ tableClassName: 'fc-col-header',
+ rowContent: headerRowContent,
+ },
+ });
+ }
+ sections.push({
+ type: 'body',
+ key: 'body',
+ liquid: true,
+ chunk: { content: bodyContent },
+ });
+ return (y(ViewContainer, { elClasses: ['fc-daygrid'], viewSpec: context.viewSpec },
+ y(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [] , sections: sections })));
+ }
+ renderHScrollLayout(headerRowContent, bodyContent, colCnt, dayMinWidth) {
+ let ScrollGrid = this.context.pluginHooks.scrollGridImpl;
+ if (!ScrollGrid) {
+ throw new Error('No ScrollGrid implementation');
+ }
+ let { props, context } = this;
+ let stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
+ let stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
+ let sections = [];
+ if (headerRowContent) {
+ sections.push({
+ type: 'header',
+ key: 'header',
+ isSticky: stickyHeaderDates,
+ chunks: [{
+ key: 'main',
+ elRef: this.headerElRef,
+ tableClassName: 'fc-col-header',
+ rowContent: headerRowContent,
+ }],
+ });
+ }
+ sections.push({
+ type: 'body',
+ key: 'body',
+ liquid: true,
+ chunks: [{
+ key: 'main',
+ content: bodyContent,
+ }],
+ });
+ if (stickyFooterScrollbar) {
+ sections.push({
+ type: 'footer',
+ key: 'footer',
+ isSticky: true,
+ chunks: [{
+ key: 'main',
+ content: renderScrollShim,
+ }],
+ });
+ }
+ return (y(ViewContainer, { elClasses: ['fc-daygrid'], viewSpec: context.viewSpec },
+ y(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, forPrint: props.forPrint, collapsibleWidth: props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections })));
+ }
+ }
+ function splitSegsByRow(segs, rowCnt) {
+ let byRow = [];
+ for (let i = 0; i < rowCnt; i += 1) {
+ byRow[i] = [];
+ }
+ for (let seg of segs) {
+ byRow[seg.row].push(seg);
+ }
+ return byRow;
+ }
+ function splitSegsByFirstCol(segs, colCnt) {
+ let byCol = [];
+ for (let i = 0; i < colCnt; i += 1) {
+ byCol[i] = [];
+ }
+ for (let seg of segs) {
+ byCol[seg.firstCol].push(seg);
+ }
+ return byCol;
+ }
+ function splitInteractionByRow(ui, rowCnt) {
+ let byRow = [];
+ if (!ui) {
+ for (let i = 0; i < rowCnt; i += 1) {
+ byRow[i] = null;
+ }
+ }
+ else {
+ for (let i = 0; i < rowCnt; i += 1) {
+ byRow[i] = {
+ affectedInstances: ui.affectedInstances,
+ isEvent: ui.isEvent,
+ segs: [],
+ };
+ }
+ for (let seg of ui.segs) {
+ byRow[seg.row].segs.push(seg);
+ }
+ }
+ return byRow;
+ }
+ const DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
+ hour: 'numeric',
+ minute: '2-digit',
+ omitZeroMinute: true,
+ meridiem: 'narrow',
+ });
+ function hasListItemDisplay(seg) {
+ let { display } = seg.eventRange.ui;
+ return display === 'list-item' || (display === 'auto' &&
+ !seg.eventRange.def.allDay &&
+ seg.firstCol === seg.lastCol &&
+ seg.isStart &&
+ seg.isEnd
+ );
+ }
+ class TableBlockEvent extends BaseComponent {
+ render() {
+ let { props } = this;
+ return (y(StandardEvent, Object.assign({}, props, { elClasses: ['fc-daygrid-event', 'fc-daygrid-block-event', 'fc-h-event'], defaultTimeFormat: DEFAULT_TABLE_EVENT_TIME_FORMAT, defaultDisplayEventEnd: props.defaultDisplayEventEnd, disableResizing: !props.seg.eventRange.def.allDay })));
+ }
+ }
+ class TableListItemEvent extends BaseComponent {
+ render() {
+ let { props, context } = this;
+ let { options } = context;
+ let { seg } = props;
+ let timeFormat = options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
+ let timeText = buildSegTimeText(seg, timeFormat, context, true, props.defaultDisplayEventEnd);
+ return (y(EventContainer, Object.assign({}, props, { elTag: "a", elClasses: ['fc-daygrid-event', 'fc-daygrid-dot-event'], elAttrs: getSegAnchorAttrs(props.seg, context), defaultGenerator: renderInnerContent$2, timeText: timeText, isResizing: false, isDateSelecting: false })));
+ }
+ }
+ function renderInnerContent$2(renderProps) {
+ return (y(_, null,
+ y("div", { className: "fc-daygrid-event-dot", style: { borderColor: renderProps.borderColor || renderProps.backgroundColor } }),
+ renderProps.timeText && (y("div", { className: "fc-event-time" }, renderProps.timeText)),
+ y("div", { className: "fc-event-title" }, renderProps.event.title || y(_, null, "\u00A0"))));
+ }
+ class TableCellMoreLink extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.compileSegs = memoize(compileSegs);
+ }
+ render() {
+ let { props } = this;
+ let { allSegs, invisibleSegs } = this.compileSegs(props.singlePlacements);
+ return (y(MoreLinkContainer, { elClasses: ['fc-daygrid-more-link'], dateProfile: props.dateProfile, todayRange: props.todayRange, allDayDate: props.allDayDate, moreCnt: props.moreCnt, allSegs: allSegs, hiddenSegs: invisibleSegs, alignmentElRef: props.alignmentElRef, alignGridTop: props.alignGridTop, extraDateSpan: props.extraDateSpan, popoverContent: () => {
+ let isForcedInvisible = (props.eventDrag ? props.eventDrag.affectedInstances : null) ||
+ (props.eventResize ? props.eventResize.affectedInstances : null) ||
+ {};
+ return (y(_, null, allSegs.map((seg) => {
+ let instanceId = seg.eventRange.instance.instanceId;
+ return (y("div", { className: "fc-daygrid-event-harness", key: instanceId, style: {
+ visibility: isForcedInvisible[instanceId] ? 'hidden' : '',
+ } }, hasListItemDisplay(seg) ? (y(TableListItemEvent, Object.assign({ seg: seg, isDragging: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange)))) : (y(TableBlockEvent, Object.assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange))))));
+ })));
+ } }));
+ }
+ }
+ function compileSegs(singlePlacements) {
+ let allSegs = [];
+ let invisibleSegs = [];
+ for (let placement of singlePlacements) {
+ allSegs.push(placement.seg);
+ if (!placement.isVisible) {
+ invisibleSegs.push(placement.seg);
+ }
+ }
+ return { allSegs, invisibleSegs };
+ }
+ const DEFAULT_WEEK_NUM_FORMAT$1 = createFormatter({ week: 'narrow' });
+ class TableCell extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.rootElRef = d();
+ this.state = {
+ dayNumberId: getUniqueDomId(),
+ };
+ this.handleRootEl = (el) => {
+ setRef(this.rootElRef, el);
+ setRef(this.props.elRef, el);
+ };
+ }
+ render() {
+ let { context, props, state, rootElRef } = this;
+ let { options, dateEnv } = context;
+ let { date, dateProfile } = props;
+ const isMonthStart = props.showDayNumber &&
+ shouldDisplayMonthStart(date, dateProfile.currentRange, dateEnv);
+ return (y(DayCellContainer, { elTag: "td", elRef: this.handleRootEl, elClasses: [
+ 'fc-daygrid-day',
+ ...(props.extraClassNames || []),
+ ], elAttrs: Object.assign(Object.assign(Object.assign({}, props.extraDataAttrs), (props.showDayNumber ? { 'aria-labelledby': state.dayNumberId } : {})), { role: 'gridcell' }), defaultGenerator: renderTopInner, date: date, dateProfile: dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, isMonthStart: isMonthStart, extraRenderProps: props.extraRenderProps }, (InnerContent, renderProps) => (y("div", { ref: props.innerElRef, className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", style: { minHeight: props.minHeight } },
+ props.showWeekNumber && (y(WeekNumberContainer, { elTag: "a", elClasses: ['fc-daygrid-week-number'], elAttrs: buildNavLinkAttrs(context, date, 'week'), date: date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT$1 })),
+ !renderProps.isDisabled &&
+ (props.showDayNumber || hasCustomDayCellContent(options) || props.forceDayTop) ? (y("div", { className: "fc-daygrid-day-top" },
+ y(InnerContent, { elTag: "a", elClasses: [
+ 'fc-daygrid-day-number',
+ isMonthStart && 'fc-daygrid-month-start',
+ ], elAttrs: Object.assign(Object.assign({}, buildNavLinkAttrs(context, date)), { id: state.dayNumberId }) }))) : props.showDayNumber ? (
+ y("div", { className: "fc-daygrid-day-top", style: { visibility: 'hidden' } },
+ y("a", { className: "fc-daygrid-day-number" }, "\u00A0"))) : undefined,
+ y("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef },
+ props.fgContent,
+ y("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } },
+ y(TableCellMoreLink, { allDayDate: date, singlePlacements: props.singlePlacements, moreCnt: props.moreCnt, alignmentElRef: rootElRef, alignGridTop: !props.showDayNumber, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange }))),
+ y("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))));
+ }
+ }
+ function renderTopInner(props) {
+ return props.dayNumberText || y(_, null, "\u00A0");
+ }
+ function shouldDisplayMonthStart(date, currentRange, dateEnv) {
+ const { start: currentStart, end: currentEnd } = currentRange;
+ const currentEndIncl = addMs(currentEnd, -1);
+ const currentFirstYear = dateEnv.getYear(currentStart);
+ const currentFirstMonth = dateEnv.getMonth(currentStart);
+ const currentLastYear = dateEnv.getYear(currentEndIncl);
+ const currentLastMonth = dateEnv.getMonth(currentEndIncl);
+ return !(currentFirstYear === currentLastYear && currentFirstMonth === currentLastMonth) &&
+ Boolean(
+ date.valueOf() === currentStart.valueOf() ||
+ (dateEnv.getDay(date) === 1 && date.valueOf() < currentEnd.valueOf()));
+ }
+ function generateSegKey(seg) {
+ return seg.eventRange.instance.instanceId + ':' + seg.firstCol;
+ }
+ function generateSegUid(seg) {
+ return generateSegKey(seg) + ':' + seg.lastCol;
+ }
+ function computeFgSegPlacement(segs,
+ dayMaxEvents, dayMaxEventRows, strictOrder, segHeights, maxContentHeight, cells) {
+ let hierarchy = new DayGridSegHierarchy((segEntry) => {
+ let segUid = segs[segEntry.index].eventRange.instance.instanceId +
+ ':' + segEntry.span.start +
+ ':' + (segEntry.span.end - 1);
+ return segHeights[segUid] || 1;
+ });
+ hierarchy.allowReslicing = true;
+ hierarchy.strictOrder = strictOrder;
+ if (dayMaxEvents === true || dayMaxEventRows === true) {
+ hierarchy.maxCoord = maxContentHeight;
+ hierarchy.hiddenConsumes = true;
+ }
+ else if (typeof dayMaxEvents === 'number') {
+ hierarchy.maxStackCnt = dayMaxEvents;
+ }
+ else if (typeof dayMaxEventRows === 'number') {
+ hierarchy.maxStackCnt = dayMaxEventRows;
+ hierarchy.hiddenConsumes = true;
+ }
+ let segInputs = [];
+ let unknownHeightSegs = [];
+ for (let i = 0; i < segs.length; i += 1) {
+ let seg = segs[i];
+ let segUid = generateSegUid(seg);
+ let eventHeight = segHeights[segUid];
+ if (eventHeight != null) {
+ segInputs.push({
+ index: i,
+ span: {
+ start: seg.firstCol,
+ end: seg.lastCol + 1,
+ },
+ });
+ }
+ else {
+ unknownHeightSegs.push(seg);
+ }
+ }
+ let hiddenEntries = hierarchy.addSegs(segInputs);
+ let segRects = hierarchy.toRects();
+ let { singleColPlacements, multiColPlacements, leftoverMargins } = placeRects(segRects, segs, cells);
+ let moreCnts = [];
+ let moreMarginTops = [];
+ for (let seg of unknownHeightSegs) {
+ multiColPlacements[seg.firstCol].push({
+ seg,
+ isVisible: false,
+ isAbsolute: true,
+ absoluteTop: 0,
+ marginTop: 0,
+ });
+ for (let col = seg.firstCol; col <= seg.lastCol; col += 1) {
+ singleColPlacements[col].push({
+ seg: resliceSeg(seg, col, col + 1, cells),
+ isVisible: false,
+ isAbsolute: false,
+ absoluteTop: 0,
+ marginTop: 0,
+ });
+ }
+ }
+ for (let col = 0; col < cells.length; col += 1) {
+ moreCnts.push(0);
+ }
+ for (let hiddenEntry of hiddenEntries) {
+ let seg = segs[hiddenEntry.index];
+ let hiddenSpan = hiddenEntry.span;
+ multiColPlacements[hiddenSpan.start].push({
+ seg: resliceSeg(seg, hiddenSpan.start, hiddenSpan.end, cells),
+ isVisible: false,
+ isAbsolute: true,
+ absoluteTop: 0,
+ marginTop: 0,
+ });
+ for (let col = hiddenSpan.start; col < hiddenSpan.end; col += 1) {
+ moreCnts[col] += 1;
+ singleColPlacements[col].push({
+ seg: resliceSeg(seg, col, col + 1, cells),
+ isVisible: false,
+ isAbsolute: false,
+ absoluteTop: 0,
+ marginTop: 0,
+ });
+ }
+ }
+ for (let col = 0; col < cells.length; col += 1) {
+ moreMarginTops.push(leftoverMargins[col]);
+ }
+ return { singleColPlacements, multiColPlacements, moreCnts, moreMarginTops };
+ }
+ function placeRects(allRects, segs, cells) {
+ let rectsByEachCol = groupRectsByEachCol(allRects, cells.length);
+ let singleColPlacements = [];
+ let multiColPlacements = [];
+ let leftoverMargins = [];
+ for (let col = 0; col < cells.length; col += 1) {
+ let rects = rectsByEachCol[col];
+ let singlePlacements = [];
+ let currentHeight = 0;
+ let currentMarginTop = 0;
+ for (let rect of rects) {
+ let seg = segs[rect.index];
+ singlePlacements.push({
+ seg: resliceSeg(seg, col, col + 1, cells),
+ isVisible: true,
+ isAbsolute: false,
+ absoluteTop: rect.levelCoord,
+ marginTop: rect.levelCoord - currentHeight,
+ });
+ currentHeight = rect.levelCoord + rect.thickness;
+ }
+ let multiPlacements = [];
+ currentHeight = 0;
+ currentMarginTop = 0;
+ for (let rect of rects) {
+ let seg = segs[rect.index];
+ let isAbsolute = rect.span.end - rect.span.start > 1;
+ let isFirstCol = rect.span.start === col;
+ currentMarginTop += rect.levelCoord - currentHeight;
+ currentHeight = rect.levelCoord + rect.thickness;
+ if (isAbsolute) {
+ currentMarginTop += rect.thickness;
+ if (isFirstCol) {
+ multiPlacements.push({
+ seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
+ isVisible: true,
+ isAbsolute: true,
+ absoluteTop: rect.levelCoord,
+ marginTop: 0,
+ });
+ }
+ }
+ else if (isFirstCol) {
+ multiPlacements.push({
+ seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
+ isVisible: true,
+ isAbsolute: false,
+ absoluteTop: rect.levelCoord,
+ marginTop: currentMarginTop,
+ });
+ currentMarginTop = 0;
+ }
+ }
+ singleColPlacements.push(singlePlacements);
+ multiColPlacements.push(multiPlacements);
+ leftoverMargins.push(currentMarginTop);
+ }
+ return { singleColPlacements, multiColPlacements, leftoverMargins };
+ }
+ function groupRectsByEachCol(rects, colCnt) {
+ let rectsByEachCol = [];
+ for (let col = 0; col < colCnt; col += 1) {
+ rectsByEachCol.push([]);
+ }
+ for (let rect of rects) {
+ for (let col = rect.span.start; col < rect.span.end; col += 1) {
+ rectsByEachCol[col].push(rect);
+ }
+ }
+ return rectsByEachCol;
+ }
+ function resliceSeg(seg, spanStart, spanEnd, cells) {
+ if (seg.firstCol === spanStart && seg.lastCol === spanEnd - 1) {
+ return seg;
+ }
+ let eventRange = seg.eventRange;
+ let origRange = eventRange.range;
+ let slicedRange = intersectRanges(origRange, {
+ start: cells[spanStart].date,
+ end: addDays(cells[spanEnd - 1].date, 1),
+ });
+ return Object.assign(Object.assign({}, seg), { firstCol: spanStart, lastCol: spanEnd - 1, eventRange: {
+ def: eventRange.def,
+ ui: Object.assign(Object.assign({}, eventRange.ui), { durationEditable: false }),
+ instance: eventRange.instance,
+ range: slicedRange,
+ }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() });
+ }
+ class DayGridSegHierarchy extends SegHierarchy {
+ constructor() {
+ super(...arguments);
+ this.hiddenConsumes = false;
+ this.forceHidden = {};
+ }
+ addSegs(segInputs) {
+ const hiddenSegs = super.addSegs(segInputs);
+ const { entriesByLevel } = this;
+ const excludeHidden = (entry) => !this.forceHidden[buildEntryKey(entry)];
+ for (let level = 0; level < entriesByLevel.length; level += 1) {
+ entriesByLevel[level] = entriesByLevel[level].filter(excludeHidden);
+ }
+ return hiddenSegs;
+ }
+ handleInvalidInsertion(insertion, entry, hiddenEntries) {
+ const { entriesByLevel, forceHidden } = this;
+ const { touchingEntry, touchingLevel, touchingLateral } = insertion;
+ if (this.hiddenConsumes && touchingEntry) {
+ const touchingEntryId = buildEntryKey(touchingEntry);
+ if (!forceHidden[touchingEntryId]) {
+ if (this.allowReslicing) {
+ const hiddenEntry = Object.assign(Object.assign({}, touchingEntry), { span: intersectSpans(touchingEntry.span, entry.span) });
+ const hiddenEntryId = buildEntryKey(hiddenEntry);
+ forceHidden[hiddenEntryId] = true;
+ entriesByLevel[touchingLevel][touchingLateral] = hiddenEntry;
+ hiddenEntries.push(hiddenEntry);
+ this.splitEntry(touchingEntry, entry, hiddenEntries);
+ }
+ else {
+ forceHidden[touchingEntryId] = true;
+ hiddenEntries.push(touchingEntry);
+ }
+ }
+ }
+ super.handleInvalidInsertion(insertion, entry, hiddenEntries);
+ }
+ }
+ class TableRow extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.cellElRefs = new RefMap();
+ this.frameElRefs = new RefMap();
+ this.fgElRefs = new RefMap();
+ this.segHarnessRefs = new RefMap();
+ this.rootElRef = d();
+ this.state = {
+ framePositions: null,
+ maxContentHeight: null,
+ segHeights: {},
+ };
+ this.handleResize = (isForced) => {
+ if (isForced) {
+ this.updateSizing(true);
+ }
+ };
+ }
+ render() {
+ let { props, state, context } = this;
+ let { options } = context;
+ let colCnt = props.cells.length;
+ let businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
+ let bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
+ let highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
+ let mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
+ let { singleColPlacements, multiColPlacements, moreCnts, moreMarginTops } = computeFgSegPlacement(sortEventSegs(props.fgEventSegs, options.eventOrder), props.dayMaxEvents, props.dayMaxEventRows, options.eventOrderStrict, state.segHeights, state.maxContentHeight, props.cells);
+ let isForcedInvisible =
+ (props.eventDrag && props.eventDrag.affectedInstances) ||
+ (props.eventResize && props.eventResize.affectedInstances) ||
+ {};
+ return (y("tr", { ref: this.rootElRef, role: "row" },
+ props.renderIntro && props.renderIntro(),
+ props.cells.map((cell, col) => {
+ let normalFgNodes = this.renderFgSegs(col, props.forPrint ? singleColPlacements[col] : multiColPlacements[col], props.todayRange, isForcedInvisible);
+ let mirrorFgNodes = this.renderFgSegs(col, buildMirrorPlacements(mirrorSegsByCol[col], multiColPlacements), props.todayRange, {}, Boolean(props.eventDrag), Boolean(props.eventResize), false);
+ return (y(TableCell, { key: cell.key, elRef: this.cellElRefs.createRef(cell.key), innerElRef: this.frameElRefs.createRef(cell.key) , dateProfile: props.dateProfile, date: cell.date, showDayNumber: props.showDayNumbers, showWeekNumber: props.showWeekNumbers && col === 0, forceDayTop: props.showWeekNumbers , todayRange: props.todayRange, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, extraRenderProps: cell.extraRenderProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, moreCnt: moreCnts[col], moreMarginTop: moreMarginTops[col], singlePlacements: singleColPlacements[col], fgContentElRef: this.fgElRefs.createRef(cell.key), fgContent: (
+ y(_, null,
+ y(_, null, normalFgNodes),
+ y(_, null, mirrorFgNodes))), bgContent: (
+ y(_, null,
+ this.renderFillSegs(highlightSegsByCol[col], 'highlight'),
+ this.renderFillSegs(businessHoursByCol[col], 'non-business'),
+ this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))), minHeight: props.cellMinHeight }));
+ })));
+ }
+ componentDidMount() {
+ this.updateSizing(true);
+ this.context.addResizeHandler(this.handleResize);
+ }
+ componentDidUpdate(prevProps, prevState) {
+ let currentProps = this.props;
+ this.updateSizing(!isPropsEqual(prevProps, currentProps));
+ }
+ componentWillUnmount() {
+ this.context.removeResizeHandler(this.handleResize);
+ }
+ getHighlightSegs() {
+ let { props } = this;
+ if (props.eventDrag && props.eventDrag.segs.length) {
+ return props.eventDrag.segs;
+ }
+ if (props.eventResize && props.eventResize.segs.length) {
+ return props.eventResize.segs;
+ }
+ return props.dateSelectionSegs;
+ }
+ getMirrorSegs() {
+ let { props } = this;
+ if (props.eventResize && props.eventResize.segs.length) {
+ return props.eventResize.segs;
+ }
+ return [];
+ }
+ renderFgSegs(col, segPlacements, todayRange, isForcedInvisible, isDragging, isResizing, isDateSelecting) {
+ let { context } = this;
+ let { eventSelection } = this.props;
+ let { framePositions } = this.state;
+ let defaultDisplayEventEnd = this.props.cells.length === 1;
+ let isMirror = isDragging || isResizing || isDateSelecting;
+ let nodes = [];
+ if (framePositions) {
+ for (let placement of segPlacements) {
+ let { seg } = placement;
+ let { instanceId } = seg.eventRange.instance;
+ let isVisible = placement.isVisible && !isForcedInvisible[instanceId];
+ let isAbsolute = placement.isAbsolute;
+ let left = '';
+ let right = '';
+ if (isAbsolute) {
+ if (context.isRtl) {
+ right = 0;
+ left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
+ }
+ else {
+ left = 0;
+ right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
+ }
+ }
+ nodes.push(y("div", { className: 'fc-daygrid-event-harness' + (isAbsolute ? ' fc-daygrid-event-harness-abs' : ''), key: generateSegKey(seg), ref: isMirror ? null : this.segHarnessRefs.createRef(generateSegUid(seg)), style: {
+ visibility: isVisible ? '' : 'hidden',
+ marginTop: isAbsolute ? '' : placement.marginTop,
+ top: isAbsolute ? placement.absoluteTop : '',
+ left,
+ right,
+ } }, hasListItemDisplay(seg) ? (y(TableListItemEvent, Object.assign({ seg: seg, isDragging: isDragging, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange)))) : (y(TableBlockEvent, Object.assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange))))));
+ }
+ }
+ return nodes;
+ }
+ renderFillSegs(segs, fillType) {
+ let { isRtl } = this.context;
+ let { todayRange } = this.props;
+ let { framePositions } = this.state;
+ let nodes = [];
+ if (framePositions) {
+ for (let seg of segs) {
+ let leftRightCss = isRtl ? {
+ right: 0,
+ left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol],
+ } : {
+ left: 0,
+ right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol],
+ };
+ nodes.push(y("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-daygrid-bg-harness", style: leftRightCss }, fillType === 'bg-event' ?
+ y(BgEvent, Object.assign({ seg: seg }, getSegMeta(seg, todayRange))) :
+ renderFill(fillType)));
+ }
+ }
+ return y(_, {}, ...nodes);
+ }
+ updateSizing(isExternalSizingChange) {
+ let { props, state, frameElRefs } = this;
+ if (!props.forPrint &&
+ props.clientWidth !== null
+ ) {
+ if (isExternalSizingChange) {
+ let frameEls = props.cells.map((cell) => frameElRefs.currentMap[cell.key]);
+ if (frameEls.length) {
+ let originEl = this.rootElRef.current;
+ let newPositionCache = new PositionCache(originEl, frameEls, true,
+ false);
+ if (!state.framePositions || !state.framePositions.similarTo(newPositionCache)) {
+ this.setState({
+ framePositions: new PositionCache(originEl, frameEls, true,
+ false),
+ });
+ }
+ }
+ }
+ const oldSegHeights = this.state.segHeights;
+ const newSegHeights = this.querySegHeights();
+ const limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
+ this.safeSetState({
+ segHeights: Object.assign(Object.assign({}, oldSegHeights), newSegHeights),
+ maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null,
+ });
+ }
+ }
+ querySegHeights() {
+ let segElMap = this.segHarnessRefs.currentMap;
+ let segHeights = {};
+ for (let segUid in segElMap) {
+ let height = Math.round(segElMap[segUid].getBoundingClientRect().height);
+ segHeights[segUid] = Math.max(segHeights[segUid] || 0, height);
+ }
+ return segHeights;
+ }
+ computeMaxContentHeight() {
+ let firstKey = this.props.cells[0].key;
+ let cellEl = this.cellElRefs.currentMap[firstKey];
+ let fcContainerEl = this.fgElRefs.currentMap[firstKey];
+ return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
+ }
+ getCellEls() {
+ let elMap = this.cellElRefs.currentMap;
+ return this.props.cells.map((cell) => elMap[cell.key]);
+ }
+ }
+ TableRow.addStateEquality({
+ segHeights: isPropsEqual,
+ });
+ function buildMirrorPlacements(mirrorSegs, colPlacements) {
+ if (!mirrorSegs.length) {
+ return [];
+ }
+ let topsByInstanceId = buildAbsoluteTopHash(colPlacements);
+ return mirrorSegs.map((seg) => ({
+ seg,
+ isVisible: true,
+ isAbsolute: true,
+ absoluteTop: topsByInstanceId[seg.eventRange.instance.instanceId],
+ marginTop: 0,
+ }));
+ }
+ function buildAbsoluteTopHash(colPlacements) {
+ let topsByInstanceId = {};
+ for (let placements of colPlacements) {
+ for (let placement of placements) {
+ topsByInstanceId[placement.seg.eventRange.instance.instanceId] = placement.absoluteTop;
+ }
+ }
+ return topsByInstanceId;
+ }
+ class TableRows extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.splitBusinessHourSegs = memoize(splitSegsByRow);
+ this.splitBgEventSegs = memoize(splitAllDaySegsByRow);
+ this.splitFgEventSegs = memoize(splitSegsByRow);
+ this.splitDateSelectionSegs = memoize(splitSegsByRow);
+ this.splitEventDrag = memoize(splitInteractionByRow);
+ this.splitEventResize = memoize(splitInteractionByRow);
+ this.rowRefs = new RefMap();
+ }
+ render() {
+ let { props, context } = this;
+ let rowCnt = props.cells.length;
+ let businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
+ let bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
+ let fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
+ let dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
+ let eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
+ let eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
+ let cellMinHeight = (rowCnt >= 7 && props.clientWidth) ?
+ props.clientWidth / context.options.aspectRatio / 6 :
+ null;
+ return (y(NowTimer, { unit: "day" }, (nowDate, todayRange) => (y(_, null, props.cells.map((cells, row) => (y(TableRow, { ref: this.rowRefs.createRef(row), key: cells.length
+ ? cells[0].date.toISOString()
+ : row
+ , showDayNumbers: rowCnt > 1, showWeekNumbers: props.showWeekNumbers, todayRange: todayRange, dateProfile: props.dateProfile, cells: cells, renderIntro: props.renderRowIntro, businessHourSegs: businessHourSegsByRow[row], eventSelection: props.eventSelection, bgEventSegs: bgEventSegsByRow[row], fgEventSegs: fgEventSegsByRow[row], dateSelectionSegs: dateSelectionSegsByRow[row], eventDrag: eventDragByRow[row], eventResize: eventResizeByRow[row], dayMaxEvents: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, clientWidth: props.clientWidth, clientHeight: props.clientHeight, cellMinHeight: cellMinHeight, forPrint: props.forPrint })))))));
+ }
+ componentDidMount() {
+ this.registerInteractiveComponent();
+ }
+ componentDidUpdate() {
+ this.registerInteractiveComponent();
+ }
+ registerInteractiveComponent() {
+ if (!this.rootEl) {
+ const firstCellEl = this.rowRefs.currentMap[0].getCellEls()[0];
+ const rootEl = firstCellEl ? firstCellEl.closest('.fc-daygrid-body') : null;
+ if (rootEl) {
+ this.rootEl = rootEl;
+ this.context.registerInteractiveComponent(this, {
+ el: rootEl,
+ isHitComboAllowed: this.props.isHitComboAllowed,
+ });
+ }
+ }
+ }
+ componentWillUnmount() {
+ if (this.rootEl) {
+ this.context.unregisterInteractiveComponent(this);
+ this.rootEl = null;
+ }
+ }
+ prepareHits() {
+ this.rowPositions = new PositionCache(this.rootEl, this.rowRefs.collect().map((rowObj) => rowObj.getCellEls()[0]),
+ false, true);
+ this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(),
+ true,
+ false);
+ }
+ queryHit(positionLeft, positionTop) {
+ let { colPositions, rowPositions } = this;
+ let col = colPositions.leftToIndex(positionLeft);
+ let row = rowPositions.topToIndex(positionTop);
+ if (row != null && col != null) {
+ let cell = this.props.cells[row][col];
+ return {
+ dateProfile: this.props.dateProfile,
+ dateSpan: Object.assign({ range: this.getCellRange(row, col), allDay: true }, cell.extraDateSpan),
+ dayEl: this.getCellEl(row, col),
+ rect: {
+ left: colPositions.lefts[col],
+ right: colPositions.rights[col],
+ top: rowPositions.tops[row],
+ bottom: rowPositions.bottoms[row],
+ },
+ layer: 0,
+ };
+ }
+ return null;
+ }
+ getCellEl(row, col) {
+ return this.rowRefs.currentMap[row].getCellEls()[col];
+ }
+ getCellRange(row, col) {
+ let start = this.props.cells[row][col].date;
+ let end = addDays(start, 1);
+ return { start, end };
+ }
+ }
+ function splitAllDaySegsByRow(segs, rowCnt) {
+ return splitSegsByRow(segs.filter(isSegAllDay), rowCnt);
+ }
+ function isSegAllDay(seg) {
+ return seg.eventRange.def.allDay;
+ }
+ class Table extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.elRef = d();
+ this.needsScrollReset = false;
+ }
+ render() {
+ let { props } = this;
+ let { dayMaxEventRows, dayMaxEvents, expandRows } = props;
+ let limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
+ if (limitViaBalanced && !expandRows) {
+ limitViaBalanced = false;
+ dayMaxEventRows = null;
+ dayMaxEvents = null;
+ }
+ let classNames = [
+ 'fc-daygrid-body',
+ limitViaBalanced ? 'fc-daygrid-body-balanced' : 'fc-daygrid-body-unbalanced',
+ expandRows ? '' : 'fc-daygrid-body-natural',
+ ];
+ return (y("div", { ref: this.elRef, className: classNames.join(' '), style: {
+ width: props.clientWidth,
+ minWidth: props.tableMinWidth,
+ } },
+ y("table", { role: "presentation", className: "fc-scrollgrid-sync-table", style: {
+ width: props.clientWidth,
+ minWidth: props.tableMinWidth,
+ height: expandRows ? props.clientHeight : '',
+ } },
+ props.colGroupNode,
+ y("tbody", { role: "presentation" },
+ y(TableRows, { dateProfile: props.dateProfile, cells: props.cells, renderRowIntro: props.renderRowIntro, showWeekNumbers: props.showWeekNumbers, clientWidth: props.clientWidth, clientHeight: props.clientHeight, businessHourSegs: props.businessHourSegs, bgEventSegs: props.bgEventSegs, fgEventSegs: props.fgEventSegs, dateSelectionSegs: props.dateSelectionSegs, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows, forPrint: props.forPrint, isHitComboAllowed: props.isHitComboAllowed })))));
+ }
+ componentDidMount() {
+ this.requestScrollReset();
+ }
+ componentDidUpdate(prevProps) {
+ if (prevProps.dateProfile !== this.props.dateProfile) {
+ this.requestScrollReset();
+ }
+ else {
+ this.flushScrollReset();
+ }
+ }
+ requestScrollReset() {
+ this.needsScrollReset = true;
+ this.flushScrollReset();
+ }
+ flushScrollReset() {
+ if (this.needsScrollReset &&
+ this.props.clientWidth
+ ) {
+ const subjectEl = getScrollSubjectEl(this.elRef.current, this.props.dateProfile);
+ if (subjectEl) {
+ const originEl = subjectEl.closest('.fc-daygrid-body');
+ const scrollEl = originEl.closest('.fc-scroller');
+ const scrollTop = subjectEl.getBoundingClientRect().top -
+ originEl.getBoundingClientRect().top;
+ scrollEl.scrollTop = scrollTop ? (scrollTop + 1) : 0;
+ }
+ this.needsScrollReset = false;
+ }
+ }
+ }
+ function getScrollSubjectEl(containerEl, dateProfile) {
+ let el;
+ if (dateProfile.currentRangeUnit.match(/year|month/)) {
+ el = containerEl.querySelector(`[data-date="${formatIsoMonthStr(dateProfile.currentDate)}-01"]`);
+ }
+ if (!el) {
+ el = containerEl.querySelector(`[data-date="${formatDayString(dateProfile.currentDate)}"]`);
+ }
+ return el;
+ }
+ class DayTableSlicer extends Slicer {
+ constructor() {
+ super(...arguments);
+ this.forceDayIfListItem = true;
+ }
+ sliceRange(dateRange, dayTableModel) {
+ return dayTableModel.sliceRange(dateRange);
+ }
+ }
+ class DayTable extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.slicer = new DayTableSlicer();
+ this.tableRef = d();
+ }
+ render() {
+ let { props, context } = this;
+ return (y(Table, Object.assign({ ref: this.tableRef }, this.slicer.sliceProps(props, props.dateProfile, props.nextDayThreshold, context, props.dayTableModel), { dateProfile: props.dateProfile, cells: props.dayTableModel.cells, colGroupNode: props.colGroupNode, tableMinWidth: props.tableMinWidth, renderRowIntro: props.renderRowIntro, dayMaxEvents: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, showWeekNumbers: props.showWeekNumbers, expandRows: props.expandRows, headerAlignElRef: props.headerAlignElRef, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })));
+ }
+ }
+ class DayTableView extends TableView {
+ constructor() {
+ super(...arguments);
+ this.buildDayTableModel = memoize(buildDayTableModel);
+ this.headerRef = d();
+ this.tableRef = d();
+ }
+ render() {
+ let { options, dateProfileGenerator } = this.context;
+ let { props } = this;
+ let dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
+ let headerContent = options.dayHeaders && (y(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 }));
+ let bodyContent = (contentArg) => (y(DayTable, { ref: this.tableRef, dateProfile: props.dateProfile, dayTableModel: dayTableModel, businessHours: props.businessHours, dateSelection: props.dateSelection, eventStore: props.eventStore, eventUiBases: props.eventUiBases, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, nextDayThreshold: options.nextDayThreshold, colGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, dayMaxEvents: options.dayMaxEvents, dayMaxEventRows: options.dayMaxEventRows, showWeekNumbers: options.weekNumbers, expandRows: !props.isHeightAuto, headerAlignElRef: this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint }));
+ return options.dayMinWidth
+ ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth)
+ : this.renderSimpleLayout(headerContent, bodyContent);
+ }
+ }
+ function buildDayTableModel(dateProfile, dateProfileGenerator) {
+ let daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
+ return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
+ }
+ class TableDateProfileGenerator extends DateProfileGenerator {
+ buildRenderRange(currentRange, currentRangeUnit, isRangeAllDay) {
+ let renderRange = super.buildRenderRange(currentRange, currentRangeUnit, isRangeAllDay);
+ let { props } = this;
+ return buildDayTableRenderRange({
+ currentRange: renderRange,
+ snapToWeek: /^(year|month)$/.test(currentRangeUnit),
+ fixedWeekCount: props.fixedWeekCount,
+ dateEnv: props.dateEnv,
+ });
+ }
+ }
+ function buildDayTableRenderRange(props) {
+ let { dateEnv, currentRange } = props;
+ let { start, end } = currentRange;
+ let endOfWeek;
+ if (props.snapToWeek) {
+ start = dateEnv.startOfWeek(start);
+ endOfWeek = dateEnv.startOfWeek(end);
+ if (endOfWeek.valueOf() !== end.valueOf()) {
+ end = addWeeks(endOfWeek, 1);
+ }
+ }
+ if (props.fixedWeekCount) {
+ let lastMonthRenderStart = dateEnv.startOfWeek(dateEnv.startOfMonth(addDays(currentRange.end, -1)));
+ let rowCnt = Math.ceil(
+ diffWeeks(lastMonthRenderStart, end));
+ end = addWeeks(end, 6 - rowCnt);
+ }
+ return { start, end };
+ }
+ var css_248z$3 = ":root{--fc-daygrid-event-dot-width:8px}.fc-daygrid-day-events:after,.fc-daygrid-day-events:before,.fc-daygrid-day-frame:after,.fc-daygrid-day-frame:before,.fc-daygrid-event-harness:after,.fc-daygrid-event-harness:before{clear:both;content:\"\";display:table}.fc .fc-daygrid-body{position:relative;z-index:1}.fc .fc-daygrid-day.fc-day-today{background-color:var(--fc-today-bg-color)}.fc .fc-daygrid-day-frame{min-height:100%;position:relative}.fc .fc-daygrid-day-top{display:flex;flex-direction:row-reverse}.fc .fc-day-other .fc-daygrid-day-top{opacity:.3}.fc .fc-daygrid-day-number{padding:4px;position:relative;z-index:4}.fc .fc-daygrid-month-start{font-size:1.1em;font-weight:700}.fc .fc-daygrid-day-events{margin-top:1px}.fc .fc-daygrid-body-balanced .fc-daygrid-day-events{left:0;position:absolute;right:0}.fc .fc-daygrid-body-unbalanced .fc-daygrid-day-events{min-height:2em;position:relative}.fc .fc-daygrid-body-natural .fc-daygrid-day-events{margin-bottom:1em}.fc .fc-daygrid-event-harness{position:relative}.fc .fc-daygrid-event-harness-abs{left:0;position:absolute;right:0;top:0}.fc .fc-daygrid-bg-harness{bottom:0;position:absolute;top:0}.fc .fc-daygrid-day-bg .fc-non-business{z-index:1}.fc .fc-daygrid-day-bg .fc-bg-event{z-index:2}.fc .fc-daygrid-day-bg .fc-highlight{z-index:3}.fc .fc-daygrid-event{margin-top:1px;z-index:6}.fc .fc-daygrid-event.fc-event-mirror{z-index:7}.fc .fc-daygrid-day-bottom{font-size:.85em;margin:0 2px}.fc .fc-daygrid-day-bottom:after,.fc .fc-daygrid-day-bottom:before{clear:both;content:\"\";display:table}.fc .fc-daygrid-more-link{border-radius:3px;cursor:pointer;line-height:1;margin-top:1px;max-width:100%;overflow:hidden;padding:2px;position:relative;white-space:nowrap;z-index:4}.fc .fc-daygrid-more-link:hover{background-color:rgba(0,0,0,.1)}.fc .fc-daygrid-week-number{background-color:var(--fc-neutral-bg-color);color:var(--fc-neutral-text-color);min-width:1.5em;padding:2px;position:absolute;text-align:center;top:0;z-index:5}.fc .fc-more-popover .fc-popover-body{min-width:220px;padding:10px}.fc-direction-ltr .fc-daygrid-event.fc-event-start,.fc-direction-rtl .fc-daygrid-event.fc-event-end{margin-left:2px}.fc-direction-ltr .fc-daygrid-event.fc-event-end,.fc-direction-rtl .fc-daygrid-event.fc-event-start{margin-right:2px}.fc-direction-ltr .fc-daygrid-more-link{float:left}.fc-direction-ltr .fc-daygrid-week-number{border-radius:0 0 3px 0;left:0}.fc-direction-rtl .fc-daygrid-more-link{float:right}.fc-direction-rtl .fc-daygrid-week-number{border-radius:0 0 0 3px;right:0}.fc-liquid-hack .fc-daygrid-day-frame{position:static}.fc-daygrid-event{border-radius:3px;font-size:var(--fc-small-font-size);position:relative;white-space:nowrap}.fc-daygrid-block-event .fc-event-time{font-weight:700}.fc-daygrid-block-event .fc-event-time,.fc-daygrid-block-event .fc-event-title{padding:1px}.fc-daygrid-dot-event{align-items:center;display:flex;padding:2px 0}.fc-daygrid-dot-event .fc-event-title{flex-grow:1;flex-shrink:1;font-weight:700;min-width:0;overflow:hidden}.fc-daygrid-dot-event.fc-event-mirror,.fc-daygrid-dot-event:hover{background:rgba(0,0,0,.1)}.fc-daygrid-dot-event.fc-event-selected:before{bottom:-10px;top:-10px}.fc-daygrid-event-dot{border:calc(var(--fc-daygrid-event-dot-width)/2) solid var(--fc-event-border-color);border-radius:calc(var(--fc-daygrid-event-dot-width)/2);box-sizing:content-box;height:0;margin:0 4px;width:0}.fc-direction-ltr .fc-daygrid-event .fc-event-time{margin-right:3px}.fc-direction-rtl .fc-daygrid-event .fc-event-time{margin-left:3px}";
+ injectStyles(css_248z$3);
+
+ var index$4 = createPlugin({
+ name: '@fullcalendar/daygrid',
+ initialView: 'dayGridMonth',
+ views: {
+ dayGrid: {
+ component: DayTableView,
+ dateProfileGeneratorClass: TableDateProfileGenerator,
+ },
+ dayGridDay: {
+ type: 'dayGrid',
+ duration: { days: 1 },
+ },
+ dayGridWeek: {
+ type: 'dayGrid',
+ duration: { weeks: 1 },
+ },
+ dayGridMonth: {
+ type: 'dayGrid',
+ duration: { months: 1 },
+ fixedWeekCount: true,
+ },
+ dayGridYear: {
+ type: 'dayGrid',
+ duration: { years: 1 },
+ },
+ },
+ });
-});
+ class AllDaySplitter extends Splitter {
+ getKeyInfo() {
+ return {
+ allDay: {},
+ timed: {},
+ };
+ }
+ getKeysForDateSpan(dateSpan) {
+ if (dateSpan.allDay) {
+ return ['allDay'];
+ }
+ return ['timed'];
+ }
+ getKeysForEventDef(eventDef) {
+ if (!eventDef.allDay) {
+ return ['timed'];
+ }
+ if (hasBgRendering(eventDef)) {
+ return ['timed', 'allDay'];
+ }
+ return ['allDay'];
+ }
+ }
+ const DEFAULT_SLAT_LABEL_FORMAT = createFormatter({
+ hour: 'numeric',
+ minute: '2-digit',
+ omitZeroMinute: true,
+ meridiem: 'short',
+ });
+ function TimeColsAxisCell(props) {
+ let classNames = [
+ 'fc-timegrid-slot',
+ 'fc-timegrid-slot-label',
+ props.isLabeled ? 'fc-scrollgrid-shrink' : 'fc-timegrid-slot-minor',
+ ];
+ return (y(ViewContextType.Consumer, null, (context) => {
+ if (!props.isLabeled) {
+ return (y("td", { className: classNames.join(' '), "data-time": props.isoTimeStr }));
+ }
+ let { dateEnv, options, viewApi } = context;
+ let labelFormat =
+ options.slotLabelFormat == null ? DEFAULT_SLAT_LABEL_FORMAT :
+ Array.isArray(options.slotLabelFormat) ? createFormatter(options.slotLabelFormat[0]) :
+ createFormatter(options.slotLabelFormat);
+ let renderProps = {
+ level: 0,
+ time: props.time,
+ date: dateEnv.toDate(props.date),
+ view: viewApi,
+ text: dateEnv.format(props.date, labelFormat),
+ };
+ return (y(ContentContainer, { elTag: "td", elClasses: classNames, elAttrs: {
+ 'data-time': props.isoTimeStr,
+ }, renderProps: renderProps, generatorName: "slotLabelContent", customGenerator: options.slotLabelContent, defaultGenerator: renderInnerContent$1, classNameGenerator: options.slotLabelClassNames, didMount: options.slotLabelDidMount, willUnmount: options.slotLabelWillUnmount }, (InnerContent) => (y("div", { className: "fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame" },
+ y(InnerContent, { elTag: "div", elClasses: [
+ 'fc-timegrid-slot-label-cushion',
+ 'fc-scrollgrid-shrink-cushion',
+ ] })))));
+ }));
+ }
+ function renderInnerContent$1(props) {
+ return props.text;
+ }
+ class TimeBodyAxis extends BaseComponent {
+ render() {
+ return this.props.slatMetas.map((slatMeta) => (y("tr", { key: slatMeta.key },
+ y(TimeColsAxisCell, Object.assign({}, slatMeta)))));
+ }
+ }
+ const DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'short' });
+ const AUTO_ALL_DAY_MAX_EVENT_ROWS = 5;
+ class TimeColsView extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.allDaySplitter = new AllDaySplitter();
+ this.headerElRef = d();
+ this.rootElRef = d();
+ this.scrollerElRef = d();
+ this.state = {
+ slatCoords: null,
+ };
+ this.handleScrollTopRequest = (scrollTop) => {
+ let scrollerEl = this.scrollerElRef.current;
+ if (scrollerEl) {
+ scrollerEl.scrollTop = scrollTop;
+ }
+ };
+ this.renderHeadAxis = (rowKey, frameHeight = '') => {
+ let { options } = this.context;
+ let { dateProfile } = this.props;
+ let range = dateProfile.renderRange;
+ let dayCnt = diffDays(range.start, range.end);
+ let navLinkAttrs = (dayCnt === 1)
+ ? buildNavLinkAttrs(this.context, range.start, 'week')
+ : {};
+ if (options.weekNumbers && rowKey === 'day') {
+ return (y(WeekNumberContainer, { elTag: "th", elClasses: [
+ 'fc-timegrid-axis',
+ 'fc-scrollgrid-shrink',
+ ], elAttrs: {
+ 'aria-hidden': true,
+ }, date: range.start, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, (InnerContent) => (y("div", { className: [
+ 'fc-timegrid-axis-frame',
+ 'fc-scrollgrid-shrink-frame',
+ 'fc-timegrid-axis-frame-liquid',
+ ].join(' '), style: { height: frameHeight } },
+ y(InnerContent, { elTag: "a", elClasses: [
+ 'fc-timegrid-axis-cushion',
+ 'fc-scrollgrid-shrink-cushion',
+ 'fc-scrollgrid-sync-inner',
+ ], elAttrs: navLinkAttrs })))));
+ }
+ return (y("th", { "aria-hidden": true, className: "fc-timegrid-axis" },
+ y("div", { className: "fc-timegrid-axis-frame", style: { height: frameHeight } })));
+ };
+ this.renderTableRowAxis = (rowHeight) => {
+ let { options, viewApi } = this.context;
+ let renderProps = {
+ text: options.allDayText,
+ view: viewApi,
+ };
+ return (
+ y(ContentContainer, { elTag: "td", elClasses: [
+ 'fc-timegrid-axis',
+ 'fc-scrollgrid-shrink',
+ ], elAttrs: {
+ 'aria-hidden': true,
+ }, renderProps: renderProps, generatorName: "allDayContent", customGenerator: options.allDayContent, defaultGenerator: renderAllDayInner$1, classNameGenerator: options.allDayClassNames, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, (InnerContent) => (y("div", { className: [
+ 'fc-timegrid-axis-frame',
+ 'fc-scrollgrid-shrink-frame',
+ rowHeight == null ? ' fc-timegrid-axis-frame-liquid' : '',
+ ].join(' '), style: { height: rowHeight } },
+ y(InnerContent, { elTag: "span", elClasses: [
+ 'fc-timegrid-axis-cushion',
+ 'fc-scrollgrid-shrink-cushion',
+ 'fc-scrollgrid-sync-inner',
+ ] })))));
+ };
+ this.handleSlatCoords = (slatCoords) => {
+ this.setState({ slatCoords });
+ };
+ }
+ renderSimpleLayout(headerRowContent, allDayContent, timeContent) {
+ let { context, props } = this;
+ let sections = [];
+ let stickyHeaderDates = getStickyHeaderDates(context.options);
+ if (headerRowContent) {
+ sections.push({
+ type: 'header',
+ key: 'header',
+ isSticky: stickyHeaderDates,
+ chunk: {
+ elRef: this.headerElRef,
+ tableClassName: 'fc-col-header',
+ rowContent: headerRowContent,
+ },
+ });
+ }
+ if (allDayContent) {
+ sections.push({
+ type: 'body',
+ key: 'all-day',
+ chunk: { content: allDayContent },
+ });
+ sections.push({
+ type: 'body',
+ key: 'all-day-divider',
+ outerContent: (
+ y("tr", { role: "presentation", className: "fc-scrollgrid-section" },
+ y("td", { className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
+ });
+ }
+ sections.push({
+ type: 'body',
+ key: 'body',
+ liquid: true,
+ expandRows: Boolean(context.options.expandRows),
+ chunk: {
+ scrollerElRef: this.scrollerElRef,
+ content: timeContent,
+ },
+ });
+ return (y(ViewContainer, { elRef: this.rootElRef, elClasses: ['fc-timegrid'], viewSpec: context.viewSpec },
+ y(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [{ width: 'shrink' }], sections: sections })));
+ }
+ renderHScrollLayout(headerRowContent, allDayContent, timeContent, colCnt, dayMinWidth, slatMetas, slatCoords) {
+ let ScrollGrid = this.context.pluginHooks.scrollGridImpl;
+ if (!ScrollGrid) {
+ throw new Error('No ScrollGrid implementation');
+ }
+ let { context, props } = this;
+ let stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
+ let stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
+ let sections = [];
+ if (headerRowContent) {
+ sections.push({
+ type: 'header',
+ key: 'header',
+ isSticky: stickyHeaderDates,
+ syncRowHeights: true,
+ chunks: [
+ {
+ key: 'axis',
+ rowContent: (arg) => (y("tr", { role: "presentation" }, this.renderHeadAxis('day', arg.rowSyncHeights[0]))),
+ },
+ {
+ key: 'cols',
+ elRef: this.headerElRef,
+ tableClassName: 'fc-col-header',
+ rowContent: headerRowContent,
+ },
+ ],
+ });
+ }
+ if (allDayContent) {
+ sections.push({
+ type: 'body',
+ key: 'all-day',
+ syncRowHeights: true,
+ chunks: [
+ {
+ key: 'axis',
+ rowContent: (contentArg) => (y("tr", { role: "presentation" }, this.renderTableRowAxis(contentArg.rowSyncHeights[0]))),
+ },
+ {
+ key: 'cols',
+ content: allDayContent,
+ },
+ ],
+ });
+ sections.push({
+ key: 'all-day-divider',
+ type: 'body',
+ outerContent: (
+ y("tr", { role: "presentation", className: "fc-scrollgrid-section" },
+ y("td", { colSpan: 2, className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
+ });
+ }
+ let isNowIndicator = context.options.nowIndicator;
+ sections.push({
+ type: 'body',
+ key: 'body',
+ liquid: true,
+ expandRows: Boolean(context.options.expandRows),
+ chunks: [
+ {
+ key: 'axis',
+ content: (arg) => (
+ y("div", { className: "fc-timegrid-axis-chunk" },
+ y("table", { "aria-hidden": true, style: { height: arg.expandRows ? arg.clientHeight : '' } },
+ arg.tableColGroupNode,
+ y("tbody", null,
+ y(TimeBodyAxis, { slatMetas: slatMetas }))),
+ y("div", { className: "fc-timegrid-now-indicator-container" },
+ y(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' }, (nowDate) => {
+ let nowIndicatorTop = isNowIndicator &&
+ slatCoords &&
+ slatCoords.safeComputeTop(nowDate);
+ if (typeof nowIndicatorTop === 'number') {
+ return (y(NowIndicatorContainer, { elClasses: ['fc-timegrid-now-indicator-arrow'], elStyle: { top: nowIndicatorTop }, isAxis: true, date: nowDate }));
+ }
+ return null;
+ })))),
+ },
+ {
+ key: 'cols',
+ scrollerElRef: this.scrollerElRef,
+ content: timeContent,
+ },
+ ],
+ });
+ if (stickyFooterScrollbar) {
+ sections.push({
+ key: 'footer',
+ type: 'footer',
+ isSticky: true,
+ chunks: [
+ {
+ key: 'axis',
+ content: renderScrollShim,
+ },
+ {
+ key: 'cols',
+ content: renderScrollShim,
+ },
+ ],
+ });
+ }
+ return (y(ViewContainer, { elRef: this.rootElRef, elClasses: ['fc-timegrid'], viewSpec: context.viewSpec },
+ y(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, forPrint: props.forPrint, collapsibleWidth: false, colGroups: [
+ { width: 'shrink', cols: [{ width: 'shrink' }] },
+ { cols: [{ span: colCnt, minWidth: dayMinWidth }] },
+ ], sections: sections })));
+ }
+ getAllDayMaxEventProps() {
+ let { dayMaxEvents, dayMaxEventRows } = this.context.options;
+ if (dayMaxEvents === true || dayMaxEventRows === true) {
+ dayMaxEvents = undefined;
+ dayMaxEventRows = AUTO_ALL_DAY_MAX_EVENT_ROWS;
+ }
+ return { dayMaxEvents, dayMaxEventRows };
+ }
+ }
+ function renderAllDayInner$1(renderProps) {
+ return renderProps.text;
+ }
+ class TimeColsSlatsCoords {
+ constructor(positions, dateProfile, slotDuration) {
+ this.positions = positions;
+ this.dateProfile = dateProfile;
+ this.slotDuration = slotDuration;
+ }
+ safeComputeTop(date) {
+ let { dateProfile } = this;
+ if (rangeContainsMarker(dateProfile.currentRange, date)) {
+ let startOfDayDate = startOfDay(date);
+ let timeMs = date.valueOf() - startOfDayDate.valueOf();
+ if (timeMs >= asRoughMs(dateProfile.slotMinTime) &&
+ timeMs < asRoughMs(dateProfile.slotMaxTime)) {
+ return this.computeTimeTop(createDuration(timeMs));
+ }
+ }
+ return null;
+ }
+ computeDateTop(when, startOfDayDate) {
+ if (!startOfDayDate) {
+ startOfDayDate = startOfDay(when);
+ }
+ return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()));
+ }
+ computeTimeTop(duration) {
+ let { positions, dateProfile } = this;
+ let len = positions.els.length;
+ let slatCoverage = (duration.milliseconds - asRoughMs(dateProfile.slotMinTime)) / asRoughMs(this.slotDuration);
+ let slatIndex;
+ let slatRemainder;
+ slatCoverage = Math.max(0, slatCoverage);
+ slatCoverage = Math.min(len, slatCoverage);
+ slatIndex = Math.floor(slatCoverage);
+ slatIndex = Math.min(slatIndex, len - 1);
+ slatRemainder = slatCoverage - slatIndex;
+ return positions.tops[slatIndex] +
+ positions.getHeight(slatIndex) * slatRemainder;
+ }
+ }
+ class TimeColsSlatsBody extends BaseComponent {
+ render() {
+ let { props, context } = this;
+ let { options } = context;
+ let { slatElRefs } = props;
+ return (y("tbody", null, props.slatMetas.map((slatMeta, i) => {
+ let renderProps = {
+ time: slatMeta.time,
+ date: context.dateEnv.toDate(slatMeta.date),
+ view: context.viewApi,
+ };
+ return (y("tr", { key: slatMeta.key, ref: slatElRefs.createRef(slatMeta.key) },
+ props.axis && (y(TimeColsAxisCell, Object.assign({}, slatMeta))),
+ y(ContentContainer, { elTag: "td", elClasses: [
+ 'fc-timegrid-slot',
+ 'fc-timegrid-slot-lane',
+ !slatMeta.isLabeled && 'fc-timegrid-slot-minor',
+ ], elAttrs: {
+ 'data-time': slatMeta.isoTimeStr,
+ }, renderProps: renderProps, generatorName: "slotLaneContent", customGenerator: options.slotLaneContent, classNameGenerator: options.slotLaneClassNames, didMount: options.slotLaneDidMount, willUnmount: options.slotLaneWillUnmount })));
+ })));
+ }
+ }
+ class TimeColsSlats extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.rootElRef = d();
+ this.slatElRefs = new RefMap();
+ }
+ render() {
+ let { props, context } = this;
+ return (y("div", { ref: this.rootElRef, className: "fc-timegrid-slots" },
+ y("table", { "aria-hidden": true, className: context.theme.getClass('table'), style: {
+ minWidth: props.tableMinWidth,
+ width: props.clientWidth,
+ height: props.minHeight,
+ } },
+ props.tableColGroupNode ,
+ y(TimeColsSlatsBody, { slatElRefs: this.slatElRefs, axis: props.axis, slatMetas: props.slatMetas }))));
+ }
+ componentDidMount() {
+ this.updateSizing();
+ }
+ componentDidUpdate() {
+ this.updateSizing();
+ }
+ componentWillUnmount() {
+ if (this.props.onCoords) {
+ this.props.onCoords(null);
+ }
+ }
+ updateSizing() {
+ let { context, props } = this;
+ if (props.onCoords &&
+ props.clientWidth !== null
+ ) {
+ let rootEl = this.rootElRef.current;
+ if (rootEl.offsetHeight) {
+ props.onCoords(new TimeColsSlatsCoords(new PositionCache(this.rootElRef.current, collectSlatEls(this.slatElRefs.currentMap, props.slatMetas), false, true), this.props.dateProfile, context.options.slotDuration));
+ }
+ }
+ }
+ }
+ function collectSlatEls(elMap, slatMetas) {
+ return slatMetas.map((slatMeta) => elMap[slatMeta.key]);
+ }
+ function splitSegsByCol(segs, colCnt) {
+ let segsByCol = [];
+ let i;
+ for (i = 0; i < colCnt; i += 1) {
+ segsByCol.push([]);
+ }
+ if (segs) {
+ for (i = 0; i < segs.length; i += 1) {
+ segsByCol[segs[i].col].push(segs[i]);
+ }
+ }
+ return segsByCol;
+ }
+ function splitInteractionByCol(ui, colCnt) {
+ let byRow = [];
+ if (!ui) {
+ for (let i = 0; i < colCnt; i += 1) {
+ byRow[i] = null;
+ }
+ }
+ else {
+ for (let i = 0; i < colCnt; i += 1) {
+ byRow[i] = {
+ affectedInstances: ui.affectedInstances,
+ isEvent: ui.isEvent,
+ segs: [],
+ };
+ }
+ for (let seg of ui.segs) {
+ byRow[seg.col].segs.push(seg);
+ }
+ }
+ return byRow;
+ }
+ class TimeColMoreLink extends BaseComponent {
+ render() {
+ let { props } = this;
+ return (y(MoreLinkContainer, { elClasses: ['fc-timegrid-more-link'], elStyle: {
+ top: props.top,
+ bottom: props.bottom,
+ }, allDayDate: null, moreCnt: props.hiddenSegs.length, allSegs: props.hiddenSegs, hiddenSegs: props.hiddenSegs, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, todayRange: props.todayRange, popoverContent: () => renderPlainFgSegs(props.hiddenSegs, props), defaultGenerator: renderMoreLinkInner, forceTimed: true }, (InnerContent) => (y(InnerContent, { elTag: "div", elClasses: ['fc-timegrid-more-link-inner', 'fc-sticky'] }))));
+ }
+ }
+ function renderMoreLinkInner(props) {
+ return props.shortText;
+ }
+ function buildPositioning(segInputs, strictOrder, maxStackCnt) {
+ let hierarchy = new SegHierarchy();
+ if (strictOrder != null) {
+ hierarchy.strictOrder = strictOrder;
+ }
+ if (maxStackCnt != null) {
+ hierarchy.maxStackCnt = maxStackCnt;
+ }
+ let hiddenEntries = hierarchy.addSegs(segInputs);
+ let hiddenGroups = groupIntersectingEntries(hiddenEntries);
+ let web = buildWeb(hierarchy);
+ web = stretchWeb(web, 1);
+ let segRects = webToRects(web);
+ return { segRects, hiddenGroups };
+ }
+ function buildWeb(hierarchy) {
+ const { entriesByLevel } = hierarchy;
+ const buildNode = cacheable((level, lateral) => level + ':' + lateral, (level, lateral) => {
+ let siblingRange = findNextLevelSegs(hierarchy, level, lateral);
+ let nextLevelRes = buildNodes(siblingRange, buildNode);
+ let entry = entriesByLevel[level][lateral];
+ return [
+ Object.assign(Object.assign({}, entry), { nextLevelNodes: nextLevelRes[0] }),
+ entry.thickness + nextLevelRes[1],
+ ];
+ });
+ return buildNodes(entriesByLevel.length
+ ? { level: 0, lateralStart: 0, lateralEnd: entriesByLevel[0].length }
+ : null, buildNode)[0];
+ }
+ function buildNodes(siblingRange, buildNode) {
+ if (!siblingRange) {
+ return [[], 0];
+ }
+ let { level, lateralStart, lateralEnd } = siblingRange;
+ let lateral = lateralStart;
+ let pairs = [];
+ while (lateral < lateralEnd) {
+ pairs.push(buildNode(level, lateral));
+ lateral += 1;
+ }
+ pairs.sort(cmpDescPressures);
+ return [
+ pairs.map(extractNode),
+ pairs[0][1],
+ ];
+ }
+ function cmpDescPressures(a, b) {
+ return b[1] - a[1];
+ }
+ function extractNode(a) {
+ return a[0];
+ }
+ function findNextLevelSegs(hierarchy, subjectLevel, subjectLateral) {
+ let { levelCoords, entriesByLevel } = hierarchy;
+ let subjectEntry = entriesByLevel[subjectLevel][subjectLateral];
+ let afterSubject = levelCoords[subjectLevel] + subjectEntry.thickness;
+ let levelCnt = levelCoords.length;
+ let level = subjectLevel;
+ for (; level < levelCnt && levelCoords[level] < afterSubject; level += 1)
+ ;
+ for (; level < levelCnt; level += 1) {
+ let entries = entriesByLevel[level];
+ let entry;
+ let searchIndex = binarySearch(entries, subjectEntry.span.start, getEntrySpanEnd);
+ let lateralStart = searchIndex[0] + searchIndex[1];
+ let lateralEnd = lateralStart;
+ while (
+ (entry = entries[lateralEnd]) &&
+ entry.span.start < subjectEntry.span.end) {
+ lateralEnd += 1;
+ }
+ if (lateralStart < lateralEnd) {
+ return { level, lateralStart, lateralEnd };
+ }
+ }
+ return null;
+ }
+ function stretchWeb(topLevelNodes, totalThickness) {
+ const stretchNode = cacheable((node, startCoord, prevThickness) => buildEntryKey(node), (node, startCoord, prevThickness) => {
+ let { nextLevelNodes, thickness } = node;
+ let allThickness = thickness + prevThickness;
+ let thicknessFraction = thickness / allThickness;
+ let endCoord;
+ let newChildren = [];
+ if (!nextLevelNodes.length) {
+ endCoord = totalThickness;
+ }
+ else {
+ for (let childNode of nextLevelNodes) {
+ if (endCoord === undefined) {
+ let res = stretchNode(childNode, startCoord, allThickness);
+ endCoord = res[0];
+ newChildren.push(res[1]);
+ }
+ else {
+ let res = stretchNode(childNode, endCoord, 0);
+ newChildren.push(res[1]);
+ }
+ }
+ }
+ let newThickness = (endCoord - startCoord) * thicknessFraction;
+ return [endCoord - newThickness, Object.assign(Object.assign({}, node), { thickness: newThickness, nextLevelNodes: newChildren })];
+ });
+ return topLevelNodes.map((node) => stretchNode(node, 0, 0)[1]);
+ }
+ function webToRects(topLevelNodes) {
+ let rects = [];
+ const processNode = cacheable((node, levelCoord, stackDepth) => buildEntryKey(node), (node, levelCoord, stackDepth) => {
+ let rect = Object.assign(Object.assign({}, node), { levelCoord,
+ stackDepth, stackForward: 0 });
+ rects.push(rect);
+ return (rect.stackForward = processNodes(node.nextLevelNodes, levelCoord + node.thickness, stackDepth + 1) + 1);
+ });
+ function processNodes(nodes, levelCoord, stackDepth) {
+ let stackForward = 0;
+ for (let node of nodes) {
+ stackForward = Math.max(processNode(node, levelCoord, stackDepth), stackForward);
+ }
+ return stackForward;
+ }
+ processNodes(topLevelNodes, 0, 0);
+ return rects;
+ }
+ function cacheable(keyFunc, workFunc) {
+ const cache = {};
+ return (...args) => {
+ let key = keyFunc(...args);
+ return (key in cache)
+ ? cache[key]
+ : (cache[key] = workFunc(...args));
+ };
+ }
+ function computeSegVCoords(segs, colDate, slatCoords = null, eventMinHeight = 0) {
+ let vcoords = [];
+ if (slatCoords) {
+ for (let i = 0; i < segs.length; i += 1) {
+ let seg = segs[i];
+ let spanStart = slatCoords.computeDateTop(seg.start, colDate);
+ let spanEnd = Math.max(spanStart + (eventMinHeight || 0),
+ slatCoords.computeDateTop(seg.end, colDate));
+ vcoords.push({
+ start: Math.round(spanStart),
+ end: Math.round(spanEnd),
+ });
+ }
+ }
+ return vcoords;
+ }
+ function computeFgSegPlacements(segs, segVCoords,
+ eventOrderStrict, eventMaxStack) {
+ let segInputs = [];
+ let dumbSegs = [];
+ for (let i = 0; i < segs.length; i += 1) {
+ let vcoords = segVCoords[i];
+ if (vcoords) {
+ segInputs.push({
+ index: i,
+ thickness: 1,
+ span: vcoords,
+ });
+ }
+ else {
+ dumbSegs.push(segs[i]);
+ }
+ }
+ let { segRects, hiddenGroups } = buildPositioning(segInputs, eventOrderStrict, eventMaxStack);
+ let segPlacements = [];
+ for (let segRect of segRects) {
+ segPlacements.push({
+ seg: segs[segRect.index],
+ rect: segRect,
+ });
+ }
+ for (let dumbSeg of dumbSegs) {
+ segPlacements.push({ seg: dumbSeg, rect: null });
+ }
+ return { segPlacements, hiddenGroups };
+ }
+ const DEFAULT_TIME_FORMAT$1 = createFormatter({
+ hour: 'numeric',
+ minute: '2-digit',
+ meridiem: false,
+ });
+ class TimeColEvent extends BaseComponent {
+ render() {
+ return (y(StandardEvent, Object.assign({}, this.props, { elClasses: [
+ 'fc-timegrid-event',
+ 'fc-v-event',
+ this.props.isShort && 'fc-timegrid-event-short',
+ ], defaultTimeFormat: DEFAULT_TIME_FORMAT$1 })));
+ }
+ }
+ class TimeCol extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.sortEventSegs = memoize(sortEventSegs);
+ }
+ render() {
+ let { props, context } = this;
+ let { options } = context;
+ let isSelectMirror = options.selectMirror;
+ let mirrorSegs =
+ (props.eventDrag && props.eventDrag.segs) ||
+ (props.eventResize && props.eventResize.segs) ||
+ (isSelectMirror && props.dateSelectionSegs) ||
+ [];
+ let interactionAffectedInstances =
+ (props.eventDrag && props.eventDrag.affectedInstances) ||
+ (props.eventResize && props.eventResize.affectedInstances) ||
+ {};
+ let sortedFgSegs = this.sortEventSegs(props.fgEventSegs, options.eventOrder);
+ return (y(DayCellContainer, { elTag: "td", elRef: props.elRef, elClasses: [
+ 'fc-timegrid-col',
+ ...(props.extraClassNames || []),
+ ], elAttrs: Object.assign({ role: 'gridcell' }, props.extraDataAttrs), date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraRenderProps: props.extraRenderProps }, (InnerContent) => (y("div", { className: "fc-timegrid-col-frame" },
+ y("div", { className: "fc-timegrid-col-bg" },
+ this.renderFillSegs(props.businessHourSegs, 'non-business'),
+ this.renderFillSegs(props.bgEventSegs, 'bg-event'),
+ this.renderFillSegs(props.dateSelectionSegs, 'highlight')),
+ y("div", { className: "fc-timegrid-col-events" }, this.renderFgSegs(sortedFgSegs, interactionAffectedInstances, false, false, false)),
+ y("div", { className: "fc-timegrid-col-events" }, this.renderFgSegs(mirrorSegs, {}, Boolean(props.eventDrag), Boolean(props.eventResize), Boolean(isSelectMirror), 'mirror')),
+ y("div", { className: "fc-timegrid-now-indicator-container" }, this.renderNowIndicator(props.nowIndicatorSegs)),
+ hasCustomDayCellContent(options) && (y(InnerContent, { elTag: "div", elClasses: ['fc-timegrid-col-misc'] }))))));
+ }
+ renderFgSegs(sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting, forcedKey) {
+ let { props } = this;
+ if (props.forPrint) {
+ return renderPlainFgSegs(sortedFgSegs, props);
+ }
+ return this.renderPositionedFgSegs(sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting, forcedKey);
+ }
+ renderPositionedFgSegs(segs,
+ segIsInvisible, isDragging, isResizing, isDateSelecting, forcedKey) {
+ let { eventMaxStack, eventShortHeight, eventOrderStrict, eventMinHeight } = this.context.options;
+ let { date, slatCoords, eventSelection, todayRange, nowDate } = this.props;
+ let isMirror = isDragging || isResizing || isDateSelecting;
+ let segVCoords = computeSegVCoords(segs, date, slatCoords, eventMinHeight);
+ let { segPlacements, hiddenGroups } = computeFgSegPlacements(segs, segVCoords, eventOrderStrict, eventMaxStack);
+ return (y(_, null,
+ this.renderHiddenGroups(hiddenGroups, segs),
+ segPlacements.map((segPlacement) => {
+ let { seg, rect } = segPlacement;
+ let instanceId = seg.eventRange.instance.instanceId;
+ let isVisible = isMirror || Boolean(!segIsInvisible[instanceId] && rect);
+ let vStyle = computeSegVStyle(rect && rect.span);
+ let hStyle = (!isMirror && rect) ? this.computeSegHStyle(rect) : { left: 0, right: 0 };
+ let isInset = Boolean(rect) && rect.stackForward > 0;
+ let isShort = Boolean(rect) && (rect.span.end - rect.span.start) < eventShortHeight;
+ return (y("div", { className: 'fc-timegrid-event-harness' +
+ (isInset ? ' fc-timegrid-event-harness-inset' : ''), key: forcedKey || instanceId, style: Object.assign(Object.assign({ visibility: isVisible ? '' : 'hidden' }, vStyle), hStyle) },
+ y(TimeColEvent, Object.assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, isShort: isShort }, getSegMeta(seg, todayRange, nowDate)))));
+ })));
+ }
+ renderHiddenGroups(hiddenGroups, segs) {
+ let { extraDateSpan, dateProfile, todayRange, nowDate, eventSelection, eventDrag, eventResize } = this.props;
+ return (y(_, null, hiddenGroups.map((hiddenGroup) => {
+ let positionCss = computeSegVStyle(hiddenGroup.span);
+ let hiddenSegs = compileSegsFromEntries(hiddenGroup.entries, segs);
+ return (y(TimeColMoreLink, { key: buildIsoString(computeEarliestSegStart(hiddenSegs)), hiddenSegs: hiddenSegs, top: positionCss.top, bottom: positionCss.bottom, extraDateSpan: extraDateSpan, dateProfile: dateProfile, todayRange: todayRange, nowDate: nowDate, eventSelection: eventSelection, eventDrag: eventDrag, eventResize: eventResize }));
+ })));
+ }
+ renderFillSegs(segs, fillType) {
+ let { props, context } = this;
+ let segVCoords = computeSegVCoords(segs, props.date, props.slatCoords, context.options.eventMinHeight);
+ let children = segVCoords.map((vcoords, i) => {
+ let seg = segs[i];
+ return (y("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-timegrid-bg-harness", style: computeSegVStyle(vcoords) }, fillType === 'bg-event' ?
+ y(BgEvent, Object.assign({ seg: seg }, getSegMeta(seg, props.todayRange, props.nowDate))) :
+ renderFill(fillType)));
+ });
+ return y(_, null, children);
+ }
+ renderNowIndicator(segs) {
+ let { slatCoords, date } = this.props;
+ if (!slatCoords) {
+ return null;
+ }
+ return segs.map((seg, i) => (y(NowIndicatorContainer
+ , {
+ key: i, elClasses: ['fc-timegrid-now-indicator-line'], elStyle: {
+ top: slatCoords.computeDateTop(seg.start, date),
+ }, isAxis: false, date: date })));
+ }
+ computeSegHStyle(segHCoords) {
+ let { isRtl, options } = this.context;
+ let shouldOverlap = options.slotEventOverlap;
+ let nearCoord = segHCoords.levelCoord;
+ let farCoord = segHCoords.levelCoord + segHCoords.thickness;
+ let left;
+ let right;
+ if (shouldOverlap) {
+ farCoord = Math.min(1, nearCoord + (farCoord - nearCoord) * 2);
+ }
+ if (isRtl) {
+ left = 1 - farCoord;
+ right = nearCoord;
+ }
+ else {
+ left = nearCoord;
+ right = 1 - farCoord;
+ }
+ let props = {
+ zIndex: segHCoords.stackDepth + 1,
+ left: left * 100 + '%',
+ right: right * 100 + '%',
+ };
+ if (shouldOverlap && !segHCoords.stackForward) {
+ props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2;
+ }
+ return props;
+ }
+ }
+ function renderPlainFgSegs(sortedFgSegs, { todayRange, nowDate, eventSelection, eventDrag, eventResize }) {
+ let hiddenInstances = (eventDrag ? eventDrag.affectedInstances : null) ||
+ (eventResize ? eventResize.affectedInstances : null) ||
+ {};
+ return (y(_, null, sortedFgSegs.map((seg) => {
+ let instanceId = seg.eventRange.instance.instanceId;
+ return (y("div", { key: instanceId, style: { visibility: hiddenInstances[instanceId] ? 'hidden' : '' } },
+ y(TimeColEvent, Object.assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === eventSelection, isShort: false }, getSegMeta(seg, todayRange, nowDate)))));
+ })));
+ }
+ function computeSegVStyle(segVCoords) {
+ if (!segVCoords) {
+ return { top: '', bottom: '' };
+ }
+ return {
+ top: segVCoords.start,
+ bottom: -segVCoords.end,
+ };
+ }
+ function compileSegsFromEntries(segEntries, allSegs) {
+ return segEntries.map((segEntry) => allSegs[segEntry.index]);
+ }
+ class TimeColsContent extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.splitFgEventSegs = memoize(splitSegsByCol);
+ this.splitBgEventSegs = memoize(splitSegsByCol);
+ this.splitBusinessHourSegs = memoize(splitSegsByCol);
+ this.splitNowIndicatorSegs = memoize(splitSegsByCol);
+ this.splitDateSelectionSegs = memoize(splitSegsByCol);
+ this.splitEventDrag = memoize(splitInteractionByCol);
+ this.splitEventResize = memoize(splitInteractionByCol);
+ this.rootElRef = d();
+ this.cellElRefs = new RefMap();
+ }
+ render() {
+ let { props, context } = this;
+ let nowIndicatorTop = context.options.nowIndicator &&
+ props.slatCoords &&
+ props.slatCoords.safeComputeTop(props.nowDate);
+ let colCnt = props.cells.length;
+ let fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, colCnt);
+ let bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, colCnt);
+ let businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, colCnt);
+ let nowIndicatorSegsByRow = this.splitNowIndicatorSegs(props.nowIndicatorSegs, colCnt);
+ let dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, colCnt);
+ let eventDragByRow = this.splitEventDrag(props.eventDrag, colCnt);
+ let eventResizeByRow = this.splitEventResize(props.eventResize, colCnt);
+ return (y("div", { className: "fc-timegrid-cols", ref: this.rootElRef },
+ y("table", { role: "presentation", style: {
+ minWidth: props.tableMinWidth,
+ width: props.clientWidth,
+ } },
+ props.tableColGroupNode,
+ y("tbody", { role: "presentation" },
+ y("tr", { role: "row" },
+ props.axis && (y("td", { "aria-hidden": true, className: "fc-timegrid-col fc-timegrid-axis" },
+ y("div", { className: "fc-timegrid-col-frame" },
+ y("div", { className: "fc-timegrid-now-indicator-container" }, typeof nowIndicatorTop === 'number' && (y(NowIndicatorContainer, { elClasses: ['fc-timegrid-now-indicator-arrow'], elStyle: { top: nowIndicatorTop }, isAxis: true, date: props.nowDate })))))),
+ props.cells.map((cell, i) => (y(TimeCol, { key: cell.key, elRef: this.cellElRefs.createRef(cell.key), dateProfile: props.dateProfile, date: cell.date, nowDate: props.nowDate, todayRange: props.todayRange, extraRenderProps: cell.extraRenderProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, fgEventSegs: fgEventSegsByRow[i], bgEventSegs: bgEventSegsByRow[i], businessHourSegs: businessHourSegsByRow[i], nowIndicatorSegs: nowIndicatorSegsByRow[i], dateSelectionSegs: dateSelectionSegsByRow[i], eventDrag: eventDragByRow[i], eventResize: eventResizeByRow[i], slatCoords: props.slatCoords, eventSelection: props.eventSelection, forPrint: props.forPrint }))))))));
+ }
+ componentDidMount() {
+ this.updateCoords();
+ }
+ componentDidUpdate() {
+ this.updateCoords();
+ }
+ updateCoords() {
+ let { props } = this;
+ if (props.onColCoords &&
+ props.clientWidth !== null
+ ) {
+ props.onColCoords(new PositionCache(this.rootElRef.current, collectCellEls(this.cellElRefs.currentMap, props.cells), true,
+ false));
+ }
+ }
+ }
+ function collectCellEls(elMap, cells) {
+ return cells.map((cell) => elMap[cell.key]);
+ }
+ class TimeCols extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.processSlotOptions = memoize(processSlotOptions);
+ this.state = {
+ slatCoords: null,
+ };
+ this.handleRootEl = (el) => {
+ if (el) {
+ this.context.registerInteractiveComponent(this, {
+ el,
+ isHitComboAllowed: this.props.isHitComboAllowed,
+ });
+ }
+ else {
+ this.context.unregisterInteractiveComponent(this);
+ }
+ };
+ this.handleScrollRequest = (request) => {
+ let { onScrollTopRequest } = this.props;
+ let { slatCoords } = this.state;
+ if (onScrollTopRequest && slatCoords) {
+ if (request.time) {
+ let top = slatCoords.computeTimeTop(request.time);
+ top = Math.ceil(top);
+ if (top) {
+ top += 1;
+ }
+ onScrollTopRequest(top);
+ }
+ return true;
+ }
+ return false;
+ };
+ this.handleColCoords = (colCoords) => {
+ this.colCoords = colCoords;
+ };
+ this.handleSlatCoords = (slatCoords) => {
+ this.setState({ slatCoords });
+ if (this.props.onSlatCoords) {
+ this.props.onSlatCoords(slatCoords);
+ }
+ };
+ }
+ render() {
+ let { props, state } = this;
+ return (y("div", { className: "fc-timegrid-body", ref: this.handleRootEl, style: {
+ width: props.clientWidth,
+ minWidth: props.tableMinWidth,
+ } },
+ y(TimeColsSlats, { axis: props.axis, dateProfile: props.dateProfile, slatMetas: props.slatMetas, clientWidth: props.clientWidth, minHeight: props.expandRows ? props.clientHeight : '', tableMinWidth: props.tableMinWidth, tableColGroupNode: props.axis ? props.tableColGroupNode : null , onCoords: this.handleSlatCoords }),
+ y(TimeColsContent, { cells: props.cells, axis: props.axis, dateProfile: props.dateProfile, businessHourSegs: props.businessHourSegs, bgEventSegs: props.bgEventSegs, fgEventSegs: props.fgEventSegs, dateSelectionSegs: props.dateSelectionSegs, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange, nowDate: props.nowDate, nowIndicatorSegs: props.nowIndicatorSegs, clientWidth: props.clientWidth, tableMinWidth: props.tableMinWidth, tableColGroupNode: props.tableColGroupNode, slatCoords: state.slatCoords, onColCoords: this.handleColCoords, forPrint: props.forPrint })));
+ }
+ componentDidMount() {
+ this.scrollResponder = this.context.createScrollResponder(this.handleScrollRequest);
+ }
+ componentDidUpdate(prevProps) {
+ this.scrollResponder.update(prevProps.dateProfile !== this.props.dateProfile);
+ }
+ componentWillUnmount() {
+ this.scrollResponder.detach();
+ }
+ queryHit(positionLeft, positionTop) {
+ let { dateEnv, options } = this.context;
+ let { colCoords } = this;
+ let { dateProfile } = this.props;
+ let { slatCoords } = this.state;
+ let { snapDuration, snapsPerSlot } = this.processSlotOptions(this.props.slotDuration, options.snapDuration);
+ let colIndex = colCoords.leftToIndex(positionLeft);
+ let slatIndex = slatCoords.positions.topToIndex(positionTop);
+ if (colIndex != null && slatIndex != null) {
+ let cell = this.props.cells[colIndex];
+ let slatTop = slatCoords.positions.tops[slatIndex];
+ let slatHeight = slatCoords.positions.getHeight(slatIndex);
+ let partial = (positionTop - slatTop) / slatHeight;
+ let localSnapIndex = Math.floor(partial * snapsPerSlot);
+ let snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
+ let dayDate = this.props.cells[colIndex].date;
+ let time = addDurations(dateProfile.slotMinTime, multiplyDuration(snapDuration, snapIndex));
+ let start = dateEnv.add(dayDate, time);
+ let end = dateEnv.add(start, snapDuration);
+ return {
+ dateProfile,
+ dateSpan: Object.assign({ range: { start, end }, allDay: false }, cell.extraDateSpan),
+ dayEl: colCoords.els[colIndex],
+ rect: {
+ left: colCoords.lefts[colIndex],
+ right: colCoords.rights[colIndex],
+ top: slatTop,
+ bottom: slatTop + slatHeight,
+ },
+ layer: 0,
+ };
+ }
+ return null;
+ }
+ }
+ function processSlotOptions(slotDuration, snapDurationOverride) {
+ let snapDuration = snapDurationOverride || slotDuration;
+ let snapsPerSlot = wholeDivideDurations(slotDuration, snapDuration);
+ if (snapsPerSlot === null) {
+ snapDuration = slotDuration;
+ snapsPerSlot = 1;
+ }
+ return { snapDuration, snapsPerSlot };
+ }
+ class DayTimeColsSlicer extends Slicer {
+ sliceRange(range, dayRanges) {
+ let segs = [];
+ for (let col = 0; col < dayRanges.length; col += 1) {
+ let segRange = intersectRanges(range, dayRanges[col]);
+ if (segRange) {
+ segs.push({
+ start: segRange.start,
+ end: segRange.end,
+ isStart: segRange.start.valueOf() === range.start.valueOf(),
+ isEnd: segRange.end.valueOf() === range.end.valueOf(),
+ col,
+ });
+ }
+ }
+ return segs;
+ }
+ }
+ class DayTimeCols extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.buildDayRanges = memoize(buildDayRanges);
+ this.slicer = new DayTimeColsSlicer();
+ this.timeColsRef = d();
+ }
+ render() {
+ let { props, context } = this;
+ let { dateProfile, dayTableModel } = props;
+ let { nowIndicator, nextDayThreshold } = context.options;
+ let dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
+ return (y(NowTimer, { unit: nowIndicator ? 'minute' : 'day' }, (nowDate, todayRange) => (y(TimeCols, Object.assign({ ref: this.timeColsRef }, this.slicer.sliceProps(props, dateProfile, null, context, dayRanges), { forPrint: props.forPrint, axis: props.axis, dateProfile: dateProfile, slatMetas: props.slatMetas, slotDuration: props.slotDuration, cells: dayTableModel.cells[0], tableColGroupNode: props.tableColGroupNode, tableMinWidth: props.tableMinWidth, clientWidth: props.clientWidth, clientHeight: props.clientHeight, expandRows: props.expandRows, nowDate: nowDate, nowIndicatorSegs: nowIndicator && this.slicer.sliceNowDate(nowDate, dateProfile, nextDayThreshold, context, dayRanges), todayRange: todayRange, onScrollTopRequest: props.onScrollTopRequest, onSlatCoords: props.onSlatCoords })))));
+ }
+ }
+ function buildDayRanges(dayTableModel, dateProfile, dateEnv) {
+ let ranges = [];
+ for (let date of dayTableModel.headerDates) {
+ ranges.push({
+ start: dateEnv.add(date, dateProfile.slotMinTime),
+ end: dateEnv.add(date, dateProfile.slotMaxTime),
+ });
+ }
+ return ranges;
+ }
+ const STOCK_SUB_DURATIONS = [
+ { hours: 1 },
+ { minutes: 30 },
+ { minutes: 15 },
+ { seconds: 30 },
+ { seconds: 15 },
+ ];
+ function buildSlatMetas(slotMinTime, slotMaxTime, explicitLabelInterval, slotDuration, dateEnv) {
+ let dayStart = new Date(0);
+ let slatTime = slotMinTime;
+ let slatIterator = createDuration(0);
+ let labelInterval = explicitLabelInterval || computeLabelInterval(slotDuration);
+ let metas = [];
+ while (asRoughMs(slatTime) < asRoughMs(slotMaxTime)) {
+ let date = dateEnv.add(dayStart, slatTime);
+ let isLabeled = wholeDivideDurations(slatIterator, labelInterval) !== null;
+ metas.push({
+ date,
+ time: slatTime,
+ key: date.toISOString(),
+ isoTimeStr: formatIsoTimeString(date),
+ isLabeled,
+ });
+ slatTime = addDurations(slatTime, slotDuration);
+ slatIterator = addDurations(slatIterator, slotDuration);
+ }
+ return metas;
+ }
+ function computeLabelInterval(slotDuration) {
+ let i;
+ let labelInterval;
+ let slotsPerLabel;
+ for (i = STOCK_SUB_DURATIONS.length - 1; i >= 0; i -= 1) {
+ labelInterval = createDuration(STOCK_SUB_DURATIONS[i]);
+ slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration);
+ if (slotsPerLabel !== null && slotsPerLabel > 1) {
+ return labelInterval;
+ }
+ }
+ return slotDuration;
+ }
+ class DayTimeColsView extends TimeColsView {
+ constructor() {
+ super(...arguments);
+ this.buildTimeColsModel = memoize(buildTimeColsModel);
+ this.buildSlatMetas = memoize(buildSlatMetas);
+ }
+ render() {
+ let { options, dateEnv, dateProfileGenerator } = this.context;
+ let { props } = this;
+ let { dateProfile } = props;
+ let dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator);
+ let splitProps = this.allDaySplitter.splitProps(props);
+ let slatMetas = this.buildSlatMetas(dateProfile.slotMinTime, dateProfile.slotMaxTime, options.slotLabelInterval, options.slotDuration, dateEnv);
+ let { dayMinWidth } = options;
+ let hasAttachedAxis = !dayMinWidth;
+ let hasDetachedAxis = dayMinWidth;
+ let headerContent = options.dayHeaders && (y(DayHeader, { dates: dayTableModel.headerDates, dateProfile: dateProfile, datesRepDistinctDays: true, renderIntro: hasAttachedAxis ? this.renderHeadAxis : null }));
+ let allDayContent = (options.allDaySlot !== false) && ((contentArg) => (y(DayTable, Object.assign({}, splitProps.allDay, { dateProfile: dateProfile, dayTableModel: dayTableModel, nextDayThreshold: options.nextDayThreshold, tableMinWidth: contentArg.tableMinWidth, colGroupNode: contentArg.tableColGroupNode, renderRowIntro: hasAttachedAxis ? this.renderTableRowAxis : null, showWeekNumbers: false, expandRows: false, headerAlignElRef: this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint }, this.getAllDayMaxEventProps()))));
+ let timeGridContent = (contentArg) => (y(DayTimeCols, Object.assign({}, splitProps.timed, { dayTableModel: dayTableModel, dateProfile: dateProfile, axis: hasAttachedAxis, slotDuration: options.slotDuration, slatMetas: slatMetas, forPrint: props.forPrint, tableColGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, onSlatCoords: this.handleSlatCoords, expandRows: contentArg.expandRows, onScrollTopRequest: this.handleScrollTopRequest })));
+ return hasDetachedAxis
+ ? this.renderHScrollLayout(headerContent, allDayContent, timeGridContent, dayTableModel.colCnt, dayMinWidth, slatMetas, this.state.slatCoords)
+ : this.renderSimpleLayout(headerContent, allDayContent, timeGridContent);
+ }
+ }
+ function buildTimeColsModel(dateProfile, dateProfileGenerator) {
+ let daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
+ return new DayTableModel(daySeries, false);
+ }
+ var css_248z$2 = ".fc-v-event{background-color:var(--fc-event-bg-color);border:1px solid var(--fc-event-border-color);display:block}.fc-v-event .fc-event-main{color:var(--fc-event-text-color);height:100%}.fc-v-event .fc-event-main-frame{display:flex;flex-direction:column;height:100%}.fc-v-event .fc-event-time{flex-grow:0;flex-shrink:0;max-height:100%;overflow:hidden}.fc-v-event .fc-event-title-container{flex-grow:1;flex-shrink:1;min-height:0}.fc-v-event .fc-event-title{bottom:0;max-height:100%;overflow:hidden;top:0}.fc-v-event:not(.fc-event-start){border-top-left-radius:0;border-top-right-radius:0;border-top-width:0}.fc-v-event:not(.fc-event-end){border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-width:0}.fc-v-event.fc-event-selected:before{left:-10px;right:-10px}.fc-v-event .fc-event-resizer-start{cursor:n-resize}.fc-v-event .fc-event-resizer-end{cursor:s-resize}.fc-v-event:not(.fc-event-selected) .fc-event-resizer{height:var(--fc-event-resizer-thickness);left:0;right:0}.fc-v-event:not(.fc-event-selected) .fc-event-resizer-start{top:calc(var(--fc-event-resizer-thickness)/-2)}.fc-v-event:not(.fc-event-selected) .fc-event-resizer-end{bottom:calc(var(--fc-event-resizer-thickness)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer{left:50%;margin-left:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer-start{top:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc-v-event.fc-event-selected .fc-event-resizer-end{bottom:calc(var(--fc-event-resizer-dot-total-width)/-2)}.fc .fc-timegrid .fc-daygrid-body{z-index:2}.fc .fc-timegrid-divider{padding:0 0 2px}.fc .fc-timegrid-body{min-height:100%;position:relative;z-index:1}.fc .fc-timegrid-axis-chunk{position:relative}.fc .fc-timegrid-axis-chunk>table,.fc .fc-timegrid-slots{position:relative;z-index:1}.fc .fc-timegrid-slot{border-bottom:0;height:1.5em}.fc .fc-timegrid-slot:empty:before{content:\"\\00a0\"}.fc .fc-timegrid-slot-minor{border-top-style:dotted}.fc .fc-timegrid-slot-label-cushion{display:inline-block;white-space:nowrap}.fc .fc-timegrid-slot-label{vertical-align:middle}.fc .fc-timegrid-axis-cushion,.fc .fc-timegrid-slot-label-cushion{padding:0 4px}.fc .fc-timegrid-axis-frame-liquid{height:100%}.fc .fc-timegrid-axis-frame{align-items:center;display:flex;justify-content:flex-end;overflow:hidden}.fc .fc-timegrid-axis-cushion{flex-shrink:0;max-width:60px}.fc-direction-ltr .fc-timegrid-slot-label-frame{text-align:right}.fc-direction-rtl .fc-timegrid-slot-label-frame{text-align:left}.fc-liquid-hack .fc-timegrid-axis-frame-liquid{bottom:0;height:auto;left:0;position:absolute;right:0;top:0}.fc .fc-timegrid-col.fc-day-today{background-color:var(--fc-today-bg-color)}.fc .fc-timegrid-col-frame{min-height:100%;position:relative}.fc-media-screen.fc-liquid-hack .fc-timegrid-col-frame{bottom:0;height:auto;left:0;position:absolute;right:0;top:0}.fc-media-screen .fc-timegrid-cols{bottom:0;left:0;position:absolute;right:0;top:0}.fc-media-screen .fc-timegrid-cols>table{height:100%}.fc-media-screen .fc-timegrid-col-bg,.fc-media-screen .fc-timegrid-col-events,.fc-media-screen .fc-timegrid-now-indicator-container{left:0;position:absolute;right:0;top:0}.fc .fc-timegrid-col-bg{z-index:2}.fc .fc-timegrid-col-bg .fc-non-business{z-index:1}.fc .fc-timegrid-col-bg .fc-bg-event{z-index:2}.fc .fc-timegrid-col-bg .fc-highlight{z-index:3}.fc .fc-timegrid-bg-harness{left:0;position:absolute;right:0}.fc .fc-timegrid-col-events{z-index:3}.fc .fc-timegrid-now-indicator-container{bottom:0;overflow:hidden}.fc-direction-ltr .fc-timegrid-col-events{margin:0 2.5% 0 2px}.fc-direction-rtl .fc-timegrid-col-events{margin:0 2px 0 2.5%}.fc-timegrid-event-harness{position:absolute}.fc-timegrid-event-harness>.fc-timegrid-event{bottom:0;left:0;position:absolute;right:0;top:0}.fc-timegrid-event-harness-inset .fc-timegrid-event,.fc-timegrid-event.fc-event-mirror,.fc-timegrid-more-link{box-shadow:0 0 0 1px var(--fc-page-bg-color)}.fc-timegrid-event,.fc-timegrid-more-link{border-radius:3px;font-size:var(--fc-small-font-size)}.fc-timegrid-event{margin-bottom:1px}.fc-timegrid-event .fc-event-main{padding:1px 1px 0}.fc-timegrid-event .fc-event-time{font-size:var(--fc-small-font-size);margin-bottom:1px;white-space:nowrap}.fc-timegrid-event-short .fc-event-main-frame{flex-direction:row;overflow:hidden}.fc-timegrid-event-short .fc-event-time:after{content:\"\\00a0-\\00a0\"}.fc-timegrid-event-short .fc-event-title{font-size:var(--fc-small-font-size)}.fc-timegrid-more-link{background:var(--fc-more-link-bg-color);color:var(--fc-more-link-text-color);cursor:pointer;margin-bottom:1px;position:absolute;z-index:9999}.fc-timegrid-more-link-inner{padding:3px 2px;top:0}.fc-direction-ltr .fc-timegrid-more-link{right:0}.fc-direction-rtl .fc-timegrid-more-link{left:0}.fc .fc-timegrid-now-indicator-arrow,.fc .fc-timegrid-now-indicator-line{pointer-events:none}.fc .fc-timegrid-now-indicator-line{border-color:var(--fc-now-indicator-color);border-style:solid;border-width:1px 0 0;left:0;position:absolute;right:0;z-index:4}.fc .fc-timegrid-now-indicator-arrow{border-color:var(--fc-now-indicator-color);border-style:solid;margin-top:-5px;position:absolute;z-index:4}.fc-direction-ltr .fc-timegrid-now-indicator-arrow{border-bottom-color:transparent;border-top-color:transparent;border-width:5px 0 5px 6px;left:0}.fc-direction-rtl .fc-timegrid-now-indicator-arrow{border-bottom-color:transparent;border-top-color:transparent;border-width:5px 6px 5px 0;right:0}";
+ injectStyles(css_248z$2);
+
+ const OPTION_REFINERS$2 = {
+ allDaySlot: Boolean,
+ };
+ var index$3 = createPlugin({
+ name: '@fullcalendar/timegrid',
+ initialView: 'timeGridWeek',
+ optionRefiners: OPTION_REFINERS$2,
+ views: {
+ timeGrid: {
+ component: DayTimeColsView,
+ usesMinMaxTime: true,
+ allDaySlot: true,
+ slotDuration: '00:30:00',
+ slotEventOverlap: true,
+ },
+ timeGridDay: {
+ type: 'timeGrid',
+ duration: { days: 1 },
+ },
+ timeGridWeek: {
+ type: 'timeGrid',
+ duration: { weeks: 1 },
+ },
+ },
+ });
-;;
+ class ListViewHeaderRow extends BaseComponent {
+ constructor() {
+ super(...arguments);
+ this.state = {
+ textId: getUniqueDomId(),
+ };
+ }
+ render() {
+ let { theme, dateEnv, options, viewApi } = this.context;
+ let { cellId, dayDate, todayRange } = this.props;
+ let { textId } = this.state;
+ let dayMeta = getDateMeta(dayDate, todayRange);
+ let text = options.listDayFormat ? dateEnv.format(dayDate, options.listDayFormat) : '';
+ let sideText = options.listDaySideFormat ? dateEnv.format(dayDate, options.listDaySideFormat) : '';
+ let renderProps = Object.assign({ date: dateEnv.toDate(dayDate), view: viewApi, textId,
+ text,
+ sideText, navLinkAttrs: buildNavLinkAttrs(this.context, dayDate), sideNavLinkAttrs: buildNavLinkAttrs(this.context, dayDate, 'day', false) }, dayMeta);
+ return (y(ContentContainer, { elTag: "tr", elClasses: [
+ 'fc-list-day',
+ ...getDayClassNames(dayMeta, theme),
+ ], elAttrs: {
+ 'data-date': formatDayString(dayDate),
+ }, renderProps: renderProps, generatorName: "dayHeaderContent", customGenerator: options.dayHeaderContent, defaultGenerator: renderInnerContent, classNameGenerator: options.dayHeaderClassNames, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, (InnerContent) => (
+ y("th", { scope: "colgroup", colSpan: 3, id: cellId, "aria-labelledby": textId },
+ y(InnerContent, { elTag: "div", elClasses: [
+ 'fc-list-day-cushion',
+ theme.getClass('tableCellShaded'),
+ ] })))));
+ }
+ }
+ function renderInnerContent(props) {
+ return (y(_, null,
+ props.text && (y("a", Object.assign({ id: props.textId, className: "fc-list-day-text" }, props.navLinkAttrs), props.text)),
+ props.sideText && ( y("a", Object.assign({ "aria-hidden": true, className: "fc-list-day-side-text" }, props.sideNavLinkAttrs), props.sideText))));
+ }
+ const DEFAULT_TIME_FORMAT = createFormatter({
+ hour: 'numeric',
+ minute: '2-digit',
+ meridiem: 'short',
+ });
+ class ListViewEventRow extends BaseComponent {
+ render() {
+ let { props, context } = this;
+ let { options } = context;
+ let { seg, timeHeaderId, eventHeaderId, dateHeaderId } = props;
+ let timeFormat = options.eventTimeFormat || DEFAULT_TIME_FORMAT;
+ return (y(EventContainer, Object.assign({}, props, { elTag: "tr", elClasses: [
+ 'fc-list-event',
+ seg.eventRange.def.url && 'fc-event-forced-url',
+ ], defaultGenerator: () => renderEventInnerContent(seg, context) , seg: seg, timeText: "", disableDragging: true, disableResizing: true }), (InnerContent, eventContentArg) => (y(_, null,
+ buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId),
+ y("td", { "aria-hidden": true, className: "fc-list-event-graphic" },
+ y("span", { className: "fc-list-event-dot", style: {
+ borderColor: eventContentArg.borderColor || eventContentArg.backgroundColor,
+ } })),
+ y(InnerContent, { elTag: "td", elClasses: ['fc-list-event-title'], elAttrs: { headers: `${eventHeaderId} ${dateHeaderId}` } })))));
+ }
+ }
+ function renderEventInnerContent(seg, context) {
+ let interactiveAttrs = getSegAnchorAttrs(seg, context);
+ return (y("a", Object.assign({}, interactiveAttrs), seg.eventRange.def.title));
+ }
+ function buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId) {
+ let { options } = context;
+ if (options.displayEventTime !== false) {
+ let eventDef = seg.eventRange.def;
+ let eventInstance = seg.eventRange.instance;
+ let doAllDay = false;
+ let timeText;
+ if (eventDef.allDay) {
+ doAllDay = true;
+ }
+ else if (isMultiDayRange(seg.eventRange.range)) {
+ if (seg.isStart) {
+ timeText = buildSegTimeText(seg, timeFormat, context, null, null, eventInstance.range.start, seg.end);
+ }
+ else if (seg.isEnd) {
+ timeText = buildSegTimeText(seg, timeFormat, context, null, null, seg.start, eventInstance.range.end);
+ }
+ else {
+ doAllDay = true;
+ }
+ }
+ else {
+ timeText = buildSegTimeText(seg, timeFormat, context);
+ }
+ if (doAllDay) {
+ let renderProps = {
+ text: context.options.allDayText,
+ view: context.viewApi,
+ };
+ return (y(ContentContainer, { elTag: "td", elClasses: ['fc-list-event-time'], elAttrs: {
+ headers: `${timeHeaderId} ${dateHeaderId}`,
+ }, renderProps: renderProps, generatorName: "allDayContent", customGenerator: options.allDayContent, defaultGenerator: renderAllDayInner, classNameGenerator: options.allDayClassNames, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }));
+ }
+ return (y("td", { className: "fc-list-event-time" }, timeText));
+ }
+ return null;
+ }
+ function renderAllDayInner(renderProps) {
+ return renderProps.text;
+ }
+ class ListView extends DateComponent {
+ constructor() {
+ super(...arguments);
+ this.computeDateVars = memoize(computeDateVars);
+ this.eventStoreToSegs = memoize(this._eventStoreToSegs);
+ this.state = {
+ timeHeaderId: getUniqueDomId(),
+ eventHeaderId: getUniqueDomId(),
+ dateHeaderIdRoot: getUniqueDomId(),
+ };
+ this.setRootEl = (rootEl) => {
+ if (rootEl) {
+ this.context.registerInteractiveComponent(this, {
+ el: rootEl,
+ });
+ }
+ else {
+ this.context.unregisterInteractiveComponent(this);
+ }
+ };
+ }
+ render() {
+ let { props, context } = this;
+ let { dayDates, dayRanges } = this.computeDateVars(props.dateProfile);
+ let eventSegs = this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges);
+ return (y(ViewContainer, { elRef: this.setRootEl, elClasses: [
+ 'fc-list',
+ context.theme.getClass('table'),
+ context.options.stickyHeaderDates !== false ?
+ 'fc-list-sticky' :
+ '',
+ ], viewSpec: context.viewSpec },
+ y(Scroller, { liquid: !props.isHeightAuto, overflowX: props.isHeightAuto ? 'visible' : 'hidden', overflowY: props.isHeightAuto ? 'visible' : 'auto' }, eventSegs.length > 0 ?
+ this.renderSegList(eventSegs, dayDates) :
+ this.renderEmptyMessage())));
+ }
+ renderEmptyMessage() {
+ let { options, viewApi } = this.context;
+ let renderProps = {
+ text: options.noEventsText,
+ view: viewApi,
+ };
+ return (y(ContentContainer, { elTag: "div", elClasses: ['fc-list-empty'], renderProps: renderProps, generatorName: "noEventsContent", customGenerator: options.noEventsContent, defaultGenerator: renderNoEventsInner, classNameGenerator: options.noEventsClassNames, didMount: options.noEventsDidMount, willUnmount: options.noEventsWillUnmount }, (InnerContent) => (y(InnerContent, { elTag: "div", elClasses: ['fc-list-empty-cushion'] }))));
+ }
+ renderSegList(allSegs, dayDates) {
+ let { theme, options } = this.context;
+ let { timeHeaderId, eventHeaderId, dateHeaderIdRoot } = this.state;
+ let segsByDay = groupSegsByDay(allSegs);
+ return (y(NowTimer, { unit: "day" }, (nowDate, todayRange) => {
+ let innerNodes = [];
+ for (let dayIndex = 0; dayIndex < segsByDay.length; dayIndex += 1) {
+ let daySegs = segsByDay[dayIndex];
+ if (daySegs) {
+ let dayStr = formatDayString(dayDates[dayIndex]);
+ let dateHeaderId = dateHeaderIdRoot + '-' + dayStr;
+ innerNodes.push(y(ListViewHeaderRow, { key: dayStr, cellId: dateHeaderId, dayDate: dayDates[dayIndex], todayRange: todayRange }));
+ daySegs = sortEventSegs(daySegs, options.eventOrder);
+ for (let seg of daySegs) {
+ innerNodes.push(y(ListViewEventRow, Object.assign({ key: dayStr + ':' + seg.eventRange.instance.instanceId , seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, timeHeaderId: timeHeaderId, eventHeaderId: eventHeaderId, dateHeaderId: dateHeaderId }, getSegMeta(seg, todayRange, nowDate))));
+ }
+ }
+ }
+ return (y("table", { className: 'fc-list-table ' + theme.getClass('table') },
+ y("thead", null,
+ y("tr", null,
+ y("th", { scope: "col", id: timeHeaderId }, options.timeHint),
+ y("th", { scope: "col", "aria-hidden": true }),
+ y("th", { scope: "col", id: eventHeaderId }, options.eventHint))),
+ y("tbody", null, innerNodes)));
+ }));
+ }
+ _eventStoreToSegs(eventStore, eventUiBases, dayRanges) {
+ return this.eventRangesToSegs(sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.options.nextDayThreshold).fg, dayRanges);
+ }
+ eventRangesToSegs(eventRanges, dayRanges) {
+ let segs = [];
+ for (let eventRange of eventRanges) {
+ segs.push(...this.eventRangeToSegs(eventRange, dayRanges));
+ }
+ return segs;
+ }
+ eventRangeToSegs(eventRange, dayRanges) {
+ let { dateEnv } = this.context;
+ let { nextDayThreshold } = this.context.options;
+ let range = eventRange.range;
+ let allDay = eventRange.def.allDay;
+ let dayIndex;
+ let segRange;
+ let seg;
+ let segs = [];
+ for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex += 1) {
+ segRange = intersectRanges(range, dayRanges[dayIndex]);
+ if (segRange) {
+ seg = {
+ component: this,
+ eventRange,
+ start: segRange.start,
+ end: segRange.end,
+ isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
+ isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
+ dayIndex,
+ };
+ segs.push(seg);
+ if (!seg.isEnd && !allDay &&
+ dayIndex + 1 < dayRanges.length &&
+ range.end <
+ dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
+ seg.end = range.end;
+ seg.isEnd = true;
+ break;
+ }
+ }
+ }
+ return segs;
+ }
+ }
+ function renderNoEventsInner(renderProps) {
+ return renderProps.text;
+ }
+ function computeDateVars(dateProfile) {
+ let dayStart = startOfDay(dateProfile.renderRange.start);
+ let viewEnd = dateProfile.renderRange.end;
+ let dayDates = [];
+ let dayRanges = [];
+ while (dayStart < viewEnd) {
+ dayDates.push(dayStart);
+ dayRanges.push({
+ start: dayStart,
+ end: addDays(dayStart, 1),
+ });
+ dayStart = addDays(dayStart, 1);
+ }
+ return { dayDates, dayRanges };
+ }
+ function groupSegsByDay(segs) {
+ let segsByDay = [];
+ let i;
+ let seg;
+ for (i = 0; i < segs.length; i += 1) {
+ seg = segs[i];
+ (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
+ .push(seg);
+ }
+ return segsByDay;
+ }
+ var css_248z$1 = ":root{--fc-list-event-dot-width:10px;--fc-list-event-hover-bg-color:#f5f5f5}.fc-theme-standard .fc-list{border:1px solid var(--fc-border-color)}.fc .fc-list-empty{align-items:center;background-color:var(--fc-neutral-bg-color);display:flex;height:100%;justify-content:center}.fc .fc-list-empty-cushion{margin:5em 0}.fc .fc-list-table{border-style:hidden;width:100%}.fc .fc-list-table tr>*{border-left:0;border-right:0}.fc .fc-list-sticky .fc-list-day>*{background:var(--fc-page-bg-color);position:sticky;top:0}.fc .fc-list-table thead{left:-10000px;position:absolute}.fc .fc-list-table tbody>tr:first-child th{border-top:0}.fc .fc-list-table th{padding:0}.fc .fc-list-day-cushion,.fc .fc-list-table td{padding:8px 14px}.fc .fc-list-day-cushion:after{clear:both;content:\"\";display:table}.fc-theme-standard .fc-list-day-cushion{background-color:var(--fc-neutral-bg-color)}.fc-direction-ltr .fc-list-day-text,.fc-direction-rtl .fc-list-day-side-text{float:left}.fc-direction-ltr .fc-list-day-side-text,.fc-direction-rtl .fc-list-day-text{float:right}.fc-direction-ltr .fc-list-table .fc-list-event-graphic{padding-right:0}.fc-direction-rtl .fc-list-table .fc-list-event-graphic{padding-left:0}.fc .fc-list-event.fc-event-forced-url{cursor:pointer}.fc .fc-list-event:hover td{background-color:var(--fc-list-event-hover-bg-color)}.fc .fc-list-event-graphic,.fc .fc-list-event-time{white-space:nowrap;width:1px}.fc .fc-list-event-dot{border:calc(var(--fc-list-event-dot-width)/2) solid var(--fc-event-border-color);border-radius:calc(var(--fc-list-event-dot-width)/2);box-sizing:content-box;display:inline-block;height:0;width:0}.fc .fc-list-event-title a{color:inherit;text-decoration:none}.fc .fc-list-event.fc-event-forced-url:hover a{text-decoration:underline}";
+ injectStyles(css_248z$1);
+
+ const OPTION_REFINERS$1 = {
+ listDayFormat: createFalsableFormatter,
+ listDaySideFormat: createFalsableFormatter,
+ noEventsClassNames: identity,
+ noEventsContent: identity,
+ noEventsDidMount: identity,
+ noEventsWillUnmount: identity,
+ };
+ function createFalsableFormatter(input) {
+ return input === false ? null : createFormatter(input);
+ }
+ var index$2 = createPlugin({
+ name: '@fullcalendar/list',
+ optionRefiners: OPTION_REFINERS$1,
+ views: {
+ list: {
+ component: ListView,
+ buttonTextKey: 'list',
+ listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' },
+ },
+ listDay: {
+ type: 'list',
+ duration: { days: 1 },
+ listDayFormat: { weekday: 'long' },
+ },
+ listWeek: {
+ type: 'list',
+ duration: { weeks: 1 },
+ listDayFormat: { weekday: 'long' },
+ listDaySideFormat: { month: 'long', day: 'numeric', year: 'numeric' },
+ },
+ listMonth: {
+ type: 'list',
+ duration: { month: 1 },
+ listDaySideFormat: { weekday: 'long' },
+ },
+ listYear: {
+ type: 'list',
+ duration: { year: 1 },
+ listDaySideFormat: { weekday: 'long' },
+ },
+ },
+ });
-fcViews.list = {
- 'class': ListView,
- buttonTextKey: 'list', // what to lookup in locale files
- defaults: {
- buttonText: 'list', // text to display for English
- listDayFormat: 'LL', // like "January 1, 2016"
- noEventsMessage: 'No events to display'
- }
-};
+ config.touchMouseIgnoreWait = 500;
+ let ignoreMouseDepth = 0;
+ let listenerCnt = 0;
+ let isWindowTouchMoveCancelled = false;
+ class PointerDragging {
+ constructor(containerEl) {
+ this.subjectEl = null;
+ this.selector = '';
+ this.handleSelector = '';
+ this.shouldIgnoreMove = false;
+ this.shouldWatchScroll = true;
+ this.isDragging = false;
+ this.isTouchDragging = false;
+ this.wasTouchScroll = false;
+ this.handleMouseDown = (ev) => {
+ if (!this.shouldIgnoreMouse() &&
+ isPrimaryMouseButton(ev) &&
+ this.tryStart(ev)) {
+ let pev = this.createEventFromMouse(ev, true);
+ this.emitter.trigger('pointerdown', pev);
+ this.initScrollWatch(pev);
+ if (!this.shouldIgnoreMove) {
+ document.addEventListener('mousemove', this.handleMouseMove);
+ }
+ document.addEventListener('mouseup', this.handleMouseUp);
+ }
+ };
+ this.handleMouseMove = (ev) => {
+ let pev = this.createEventFromMouse(ev);
+ this.recordCoords(pev);
+ this.emitter.trigger('pointermove', pev);
+ };
+ this.handleMouseUp = (ev) => {
+ document.removeEventListener('mousemove', this.handleMouseMove);
+ document.removeEventListener('mouseup', this.handleMouseUp);
+ this.emitter.trigger('pointerup', this.createEventFromMouse(ev));
+ this.cleanup();
+ };
+ this.handleTouchStart = (ev) => {
+ if (this.tryStart(ev)) {
+ this.isTouchDragging = true;
+ let pev = this.createEventFromTouch(ev, true);
+ this.emitter.trigger('pointerdown', pev);
+ this.initScrollWatch(pev);
+ let targetEl = ev.target;
+ if (!this.shouldIgnoreMove) {
+ targetEl.addEventListener('touchmove', this.handleTouchMove);
+ }
+ targetEl.addEventListener('touchend', this.handleTouchEnd);
+ targetEl.addEventListener('touchcancel', this.handleTouchEnd);
+ window.addEventListener('scroll', this.handleTouchScroll, true);
+ }
+ };
+ this.handleTouchMove = (ev) => {
+ let pev = this.createEventFromTouch(ev);
+ this.recordCoords(pev);
+ this.emitter.trigger('pointermove', pev);
+ };
+ this.handleTouchEnd = (ev) => {
+ if (this.isDragging) {
+ let targetEl = ev.target;
+ targetEl.removeEventListener('touchmove', this.handleTouchMove);
+ targetEl.removeEventListener('touchend', this.handleTouchEnd);
+ targetEl.removeEventListener('touchcancel', this.handleTouchEnd);
+ window.removeEventListener('scroll', this.handleTouchScroll, true);
+ this.emitter.trigger('pointerup', this.createEventFromTouch(ev));
+ this.cleanup();
+ this.isTouchDragging = false;
+ startIgnoringMouse();
+ }
+ };
+ this.handleTouchScroll = () => {
+ this.wasTouchScroll = true;
+ };
+ this.handleScroll = (ev) => {
+ if (!this.shouldIgnoreMove) {
+ let pageX = (window.scrollX - this.prevScrollX) + this.prevPageX;
+ let pageY = (window.scrollY - this.prevScrollY) + this.prevPageY;
+ this.emitter.trigger('pointermove', {
+ origEvent: ev,
+ isTouch: this.isTouchDragging,
+ subjectEl: this.subjectEl,
+ pageX,
+ pageY,
+ deltaX: pageX - this.origPageX,
+ deltaY: pageY - this.origPageY,
+ });
+ }
+ };
+ this.containerEl = containerEl;
+ this.emitter = new Emitter();
+ containerEl.addEventListener('mousedown', this.handleMouseDown);
+ containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
+ listenerCreated();
+ }
+ destroy() {
+ this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
+ this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
+ listenerDestroyed();
+ }
+ tryStart(ev) {
+ let subjectEl = this.querySubjectEl(ev);
+ let downEl = ev.target;
+ if (subjectEl &&
+ (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
+ this.subjectEl = subjectEl;
+ this.isDragging = true;
+ this.wasTouchScroll = false;
+ return true;
+ }
+ return false;
+ }
+ cleanup() {
+ isWindowTouchMoveCancelled = false;
+ this.isDragging = false;
+ this.subjectEl = null;
+ this.destroyScrollWatch();
+ }
+ querySubjectEl(ev) {
+ if (this.selector) {
+ return elementClosest(ev.target, this.selector);
+ }
+ return this.containerEl;
+ }
+ shouldIgnoreMouse() {
+ return ignoreMouseDepth || this.isTouchDragging;
+ }
+ cancelTouchScroll() {
+ if (this.isDragging) {
+ isWindowTouchMoveCancelled = true;
+ }
+ }
+ initScrollWatch(ev) {
+ if (this.shouldWatchScroll) {
+ this.recordCoords(ev);
+ window.addEventListener('scroll', this.handleScroll, true);
+ }
+ }
+ recordCoords(ev) {
+ if (this.shouldWatchScroll) {
+ this.prevPageX = ev.pageX;
+ this.prevPageY = ev.pageY;
+ this.prevScrollX = window.scrollX;
+ this.prevScrollY = window.scrollY;
+ }
+ }
+ destroyScrollWatch() {
+ if (this.shouldWatchScroll) {
+ window.removeEventListener('scroll', this.handleScroll, true);
+ }
+ }
+ createEventFromMouse(ev, isFirst) {
+ let deltaX = 0;
+ let deltaY = 0;
+ if (isFirst) {
+ this.origPageX = ev.pageX;
+ this.origPageY = ev.pageY;
+ }
+ else {
+ deltaX = ev.pageX - this.origPageX;
+ deltaY = ev.pageY - this.origPageY;
+ }
+ return {
+ origEvent: ev,
+ isTouch: false,
+ subjectEl: this.subjectEl,
+ pageX: ev.pageX,
+ pageY: ev.pageY,
+ deltaX,
+ deltaY,
+ };
+ }
+ createEventFromTouch(ev, isFirst) {
+ let touches = ev.touches;
+ let pageX;
+ let pageY;
+ let deltaX = 0;
+ let deltaY = 0;
+ if (touches && touches.length) {
+ pageX = touches[0].pageX;
+ pageY = touches[0].pageY;
+ }
+ else {
+ pageX = ev.pageX;
+ pageY = ev.pageY;
+ }
+ if (isFirst) {
+ this.origPageX = pageX;
+ this.origPageY = pageY;
+ }
+ else {
+ deltaX = pageX - this.origPageX;
+ deltaY = pageY - this.origPageY;
+ }
+ return {
+ origEvent: ev,
+ isTouch: true,
+ subjectEl: this.subjectEl,
+ pageX,
+ pageY,
+ deltaX,
+ deltaY,
+ };
+ }
+ }
+ function isPrimaryMouseButton(ev) {
+ return ev.button === 0 && !ev.ctrlKey;
+ }
+ function startIgnoringMouse() {
+ ignoreMouseDepth += 1;
+ setTimeout(() => {
+ ignoreMouseDepth -= 1;
+ }, config.touchMouseIgnoreWait);
+ }
+ function listenerCreated() {
+ listenerCnt += 1;
+ if (listenerCnt === 1) {
+ window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
+ }
+ }
+ function listenerDestroyed() {
+ listenerCnt -= 1;
+ if (!listenerCnt) {
+ window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
+ }
+ }
+ function onWindowTouchMove(ev) {
+ if (isWindowTouchMoveCancelled) {
+ ev.preventDefault();
+ }
+ }
+ class ElementMirror {
+ constructor() {
+ this.isVisible = false;
+ this.sourceEl = null;
+ this.mirrorEl = null;
+ this.sourceElRect = null;
+ this.parentNode = document.body;
+ this.zIndex = 9999;
+ this.revertDuration = 0;
+ }
+ start(sourceEl, pageX, pageY) {
+ this.sourceEl = sourceEl;
+ this.sourceElRect = this.sourceEl.getBoundingClientRect();
+ this.origScreenX = pageX - window.scrollX;
+ this.origScreenY = pageY - window.scrollY;
+ this.deltaX = 0;
+ this.deltaY = 0;
+ this.updateElPosition();
+ }
+ handleMove(pageX, pageY) {
+ this.deltaX = (pageX - window.scrollX) - this.origScreenX;
+ this.deltaY = (pageY - window.scrollY) - this.origScreenY;
+ this.updateElPosition();
+ }
+ setIsVisible(bool) {
+ if (bool) {
+ if (!this.isVisible) {
+ if (this.mirrorEl) {
+ this.mirrorEl.style.display = '';
+ }
+ this.isVisible = bool;
+ this.updateElPosition();
+ }
+ }
+ else if (this.isVisible) {
+ if (this.mirrorEl) {
+ this.mirrorEl.style.display = 'none';
+ }
+ this.isVisible = bool;
+ }
+ }
+ stop(needsRevertAnimation, callback) {
+ let done = () => {
+ this.cleanup();
+ callback();
+ };
+ if (needsRevertAnimation &&
+ this.mirrorEl &&
+ this.isVisible &&
+ this.revertDuration &&
+ (this.deltaX || this.deltaY)
+ ) {
+ this.doRevertAnimation(done, this.revertDuration);
+ }
+ else {
+ setTimeout(done, 0);
+ }
+ }
+ doRevertAnimation(callback, revertDuration) {
+ let mirrorEl = this.mirrorEl;
+ let finalSourceElRect = this.sourceEl.getBoundingClientRect();
+ mirrorEl.style.transition =
+ 'top ' + revertDuration + 'ms,' +
+ 'left ' + revertDuration + 'ms';
+ applyStyle(mirrorEl, {
+ left: finalSourceElRect.left,
+ top: finalSourceElRect.top,
+ });
+ whenTransitionDone(mirrorEl, () => {
+ mirrorEl.style.transition = '';
+ callback();
+ });
+ }
+ cleanup() {
+ if (this.mirrorEl) {
+ removeElement(this.mirrorEl);
+ this.mirrorEl = null;
+ }
+ this.sourceEl = null;
+ }
+ updateElPosition() {
+ if (this.sourceEl && this.isVisible) {
+ applyStyle(this.getMirrorEl(), {
+ left: this.sourceElRect.left + this.deltaX,
+ top: this.sourceElRect.top + this.deltaY,
+ });
+ }
+ }
+ getMirrorEl() {
+ let sourceElRect = this.sourceElRect;
+ let mirrorEl = this.mirrorEl;
+ if (!mirrorEl) {
+ mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true);
+ mirrorEl.style.userSelect = 'none';
+ mirrorEl.style.webkitUserSelect = 'none';
+ mirrorEl.style.pointerEvents = 'none';
+ mirrorEl.classList.add('fc-event-dragging');
+ applyStyle(mirrorEl, {
+ position: 'fixed',
+ zIndex: this.zIndex,
+ visibility: '',
+ boxSizing: 'border-box',
+ width: sourceElRect.right - sourceElRect.left,
+ height: sourceElRect.bottom - sourceElRect.top,
+ right: 'auto',
+ bottom: 'auto',
+ margin: 0,
+ });
+ this.parentNode.appendChild(mirrorEl);
+ }
+ return mirrorEl;
+ }
+ }
+ class ScrollGeomCache extends ScrollController {
+ constructor(scrollController, doesListening) {
+ super();
+ this.handleScroll = () => {
+ this.scrollTop = this.scrollController.getScrollTop();
+ this.scrollLeft = this.scrollController.getScrollLeft();
+ this.handleScrollChange();
+ };
+ this.scrollController = scrollController;
+ this.doesListening = doesListening;
+ this.scrollTop = this.origScrollTop = scrollController.getScrollTop();
+ this.scrollLeft = this.origScrollLeft = scrollController.getScrollLeft();
+ this.scrollWidth = scrollController.getScrollWidth();
+ this.scrollHeight = scrollController.getScrollHeight();
+ this.clientWidth = scrollController.getClientWidth();
+ this.clientHeight = scrollController.getClientHeight();
+ this.clientRect = this.computeClientRect();
+ if (this.doesListening) {
+ this.getEventTarget().addEventListener('scroll', this.handleScroll);
+ }
+ }
+ destroy() {
+ if (this.doesListening) {
+ this.getEventTarget().removeEventListener('scroll', this.handleScroll);
+ }
+ }
+ getScrollTop() {
+ return this.scrollTop;
+ }
+ getScrollLeft() {
+ return this.scrollLeft;
+ }
+ setScrollTop(top) {
+ this.scrollController.setScrollTop(top);
+ if (!this.doesListening) {
+ this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
+ this.handleScrollChange();
+ }
+ }
+ setScrollLeft(top) {
+ this.scrollController.setScrollLeft(top);
+ if (!this.doesListening) {
+ this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
+ this.handleScrollChange();
+ }
+ }
+ getClientWidth() {
+ return this.clientWidth;
+ }
+ getClientHeight() {
+ return this.clientHeight;
+ }
+ getScrollWidth() {
+ return this.scrollWidth;
+ }
+ getScrollHeight() {
+ return this.scrollHeight;
+ }
+ handleScrollChange() {
+ }
+ }
+ class ElementScrollGeomCache extends ScrollGeomCache {
+ constructor(el, doesListening) {
+ super(new ElementScrollController(el), doesListening);
+ }
+ getEventTarget() {
+ return this.scrollController.el;
+ }
+ computeClientRect() {
+ return computeInnerRect(this.scrollController.el);
+ }
+ }
+ class WindowScrollGeomCache extends ScrollGeomCache {
+ constructor(doesListening) {
+ super(new WindowScrollController(), doesListening);
+ }
+ getEventTarget() {
+ return window;
+ }
+ computeClientRect() {
+ return {
+ left: this.scrollLeft,
+ right: this.scrollLeft + this.clientWidth,
+ top: this.scrollTop,
+ bottom: this.scrollTop + this.clientHeight,
+ };
+ }
+ handleScrollChange() {
+ this.clientRect = this.computeClientRect();
+ }
+ }
+ const getTime = typeof performance === 'function' ? performance.now : Date.now;
+ class AutoScroller {
+ constructor() {
+ this.isEnabled = true;
+ this.scrollQuery = [window, '.fc-scroller'];
+ this.edgeThreshold = 50;
+ this.maxVelocity = 300;
+ this.pointerScreenX = null;
+ this.pointerScreenY = null;
+ this.isAnimating = false;
+ this.scrollCaches = null;
+ this.everMovedUp = false;
+ this.everMovedDown = false;
+ this.everMovedLeft = false;
+ this.everMovedRight = false;
+ this.animate = () => {
+ if (this.isAnimating) {
+ let edge = this.computeBestEdge(this.pointerScreenX + window.scrollX, this.pointerScreenY + window.scrollY);
+ if (edge) {
+ let now = getTime();
+ this.handleSide(edge, (now - this.msSinceRequest) / 1000);
+ this.requestAnimation(now);
+ }
+ else {
+ this.isAnimating = false;
+ }
+ }
+ };
+ }
+ start(pageX, pageY, scrollStartEl) {
+ if (this.isEnabled) {
+ this.scrollCaches = this.buildCaches(scrollStartEl);
+ this.pointerScreenX = null;
+ this.pointerScreenY = null;
+ this.everMovedUp = false;
+ this.everMovedDown = false;
+ this.everMovedLeft = false;
+ this.everMovedRight = false;
+ this.handleMove(pageX, pageY);
+ }
+ }
+ handleMove(pageX, pageY) {
+ if (this.isEnabled) {
+ let pointerScreenX = pageX - window.scrollX;
+ let pointerScreenY = pageY - window.scrollY;
+ let yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
+ let xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
+ if (yDelta < 0) {
+ this.everMovedUp = true;
+ }
+ else if (yDelta > 0) {
+ this.everMovedDown = true;
+ }
+ if (xDelta < 0) {
+ this.everMovedLeft = true;
+ }
+ else if (xDelta > 0) {
+ this.everMovedRight = true;
+ }
+ this.pointerScreenX = pointerScreenX;
+ this.pointerScreenY = pointerScreenY;
+ if (!this.isAnimating) {
+ this.isAnimating = true;
+ this.requestAnimation(getTime());
+ }
+ }
+ }
+ stop() {
+ if (this.isEnabled) {
+ this.isAnimating = false;
+ for (let scrollCache of this.scrollCaches) {
+ scrollCache.destroy();
+ }
+ this.scrollCaches = null;
+ }
+ }
+ requestAnimation(now) {
+ this.msSinceRequest = now;
+ requestAnimationFrame(this.animate);
+ }
+ handleSide(edge, seconds) {
+ let { scrollCache } = edge;
+ let { edgeThreshold } = this;
+ let invDistance = edgeThreshold - edge.distance;
+ let velocity =
+ ((invDistance * invDistance) / (edgeThreshold * edgeThreshold)) *
+ this.maxVelocity * seconds;
+ let sign = 1;
+ switch (edge.name) {
+ case 'left':
+ sign = -1;
+ case 'right':
+ scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
+ break;
+ case 'top':
+ sign = -1;
+ case 'bottom':
+ scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
+ break;
+ }
+ }
+ computeBestEdge(left, top) {
+ let { edgeThreshold } = this;
+ let bestSide = null;
+ let scrollCaches = this.scrollCaches || [];
+ for (let scrollCache of scrollCaches) {
+ let rect = scrollCache.clientRect;
+ let leftDist = left - rect.left;
+ let rightDist = rect.right - left;
+ let topDist = top - rect.top;
+ let bottomDist = rect.bottom - top;
+ if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
+ if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
+ (!bestSide || bestSide.distance > topDist)) {
+ bestSide = { scrollCache, name: 'top', distance: topDist };
+ }
+ if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
+ (!bestSide || bestSide.distance > bottomDist)) {
+ bestSide = { scrollCache, name: 'bottom', distance: bottomDist };
+ }
+ if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
+ (!bestSide || bestSide.distance > leftDist)) {
+ bestSide = { scrollCache, name: 'left', distance: leftDist };
+ }
+ if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
+ (!bestSide || bestSide.distance > rightDist)) {
+ bestSide = { scrollCache, name: 'right', distance: rightDist };
+ }
+ }
+ }
+ return bestSide;
+ }
+ buildCaches(scrollStartEl) {
+ return this.queryScrollEls(scrollStartEl).map((el) => {
+ if (el === window) {
+ return new WindowScrollGeomCache(false);
+ }
+ return new ElementScrollGeomCache(el, false);
+ });
+ }
+ queryScrollEls(scrollStartEl) {
+ let els = [];
+ for (let query of this.scrollQuery) {
+ if (typeof query === 'object') {
+ els.push(query);
+ }
+ else {
+ els.push(...Array.prototype.slice.call(scrollStartEl.getRootNode().querySelectorAll(query)));
+ }
+ }
+ return els;
+ }
+ }
+ class FeaturefulElementDragging extends ElementDragging {
+ constructor(containerEl, selector) {
+ super(containerEl);
+ this.containerEl = containerEl;
+ this.delay = null;
+ this.minDistance = 0;
+ this.touchScrollAllowed = true;
+ this.mirrorNeedsRevert = false;
+ this.isInteracting = false;
+ this.isDragging = false;
+ this.isDelayEnded = false;
+ this.isDistanceSurpassed = false;
+ this.delayTimeoutId = null;
+ this.onPointerDown = (ev) => {
+ if (!this.isDragging) {
+ this.isInteracting = true;
+ this.isDelayEnded = false;
+ this.isDistanceSurpassed = false;
+ preventSelection(document.body);
+ preventContextMenu(document.body);
+ if (!ev.isTouch) {
+ ev.origEvent.preventDefault();
+ }
+ this.emitter.trigger('pointerdown', ev);
+ if (this.isInteracting &&
+ !this.pointer.shouldIgnoreMove) {
+ this.mirror.setIsVisible(false);
+ this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY);
+ this.startDelay(ev);
+ if (!this.minDistance) {
+ this.handleDistanceSurpassed(ev);
+ }
+ }
+ }
+ };
+ this.onPointerMove = (ev) => {
+ if (this.isInteracting) {
+ this.emitter.trigger('pointermove', ev);
+ if (!this.isDistanceSurpassed) {
+ let minDistance = this.minDistance;
+ let distanceSq;
+ let { deltaX, deltaY } = ev;
+ distanceSq = deltaX * deltaX + deltaY * deltaY;
+ if (distanceSq >= minDistance * minDistance) {
+ this.handleDistanceSurpassed(ev);
+ }
+ }
+ if (this.isDragging) {
+ if (ev.origEvent.type !== 'scroll') {
+ this.mirror.handleMove(ev.pageX, ev.pageY);
+ this.autoScroller.handleMove(ev.pageX, ev.pageY);
+ }
+ this.emitter.trigger('dragmove', ev);
+ }
+ }
+ };
+ this.onPointerUp = (ev) => {
+ if (this.isInteracting) {
+ this.isInteracting = false;
+ allowSelection(document.body);
+ allowContextMenu(document.body);
+ this.emitter.trigger('pointerup', ev);
+ if (this.isDragging) {
+ this.autoScroller.stop();
+ this.tryStopDrag(ev);
+ }
+ if (this.delayTimeoutId) {
+ clearTimeout(this.delayTimeoutId);
+ this.delayTimeoutId = null;
+ }
+ }
+ };
+ let pointer = this.pointer = new PointerDragging(containerEl);
+ pointer.emitter.on('pointerdown', this.onPointerDown);
+ pointer.emitter.on('pointermove', this.onPointerMove);
+ pointer.emitter.on('pointerup', this.onPointerUp);
+ if (selector) {
+ pointer.selector = selector;
+ }
+ this.mirror = new ElementMirror();
+ this.autoScroller = new AutoScroller();
+ }
+ destroy() {
+ this.pointer.destroy();
+ this.onPointerUp({});
+ }
+ startDelay(ev) {
+ if (typeof this.delay === 'number') {
+ this.delayTimeoutId = setTimeout(() => {
+ this.delayTimeoutId = null;
+ this.handleDelayEnd(ev);
+ }, this.delay);
+ }
+ else {
+ this.handleDelayEnd(ev);
+ }
+ }
+ handleDelayEnd(ev) {
+ this.isDelayEnded = true;
+ this.tryStartDrag(ev);
+ }
+ handleDistanceSurpassed(ev) {
+ this.isDistanceSurpassed = true;
+ this.tryStartDrag(ev);
+ }
+ tryStartDrag(ev) {
+ if (this.isDelayEnded && this.isDistanceSurpassed) {
+ if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
+ this.isDragging = true;
+ this.mirrorNeedsRevert = false;
+ this.autoScroller.start(ev.pageX, ev.pageY, this.containerEl);
+ this.emitter.trigger('dragstart', ev);
+ if (this.touchScrollAllowed === false) {
+ this.pointer.cancelTouchScroll();
+ }
+ }
+ }
+ }
+ tryStopDrag(ev) {
+ this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
+ }
+ stopDrag(ev) {
+ this.isDragging = false;
+ this.emitter.trigger('dragend', ev);
+ }
+ setIgnoreMove(bool) {
+ this.pointer.shouldIgnoreMove = bool;
+ }
+ setMirrorIsVisible(bool) {
+ this.mirror.setIsVisible(bool);
+ }
+ setMirrorNeedsRevert(bool) {
+ this.mirrorNeedsRevert = bool;
+ }
+ setAutoScrollEnabled(bool) {
+ this.autoScroller.isEnabled = bool;
+ }
+ }
+ class OffsetTracker {
+ constructor(el) {
+ this.el = el;
+ this.origRect = computeRect(el);
+ this.scrollCaches = getClippingParents(el).map((scrollEl) => new ElementScrollGeomCache(scrollEl, true));
+ }
+ destroy() {
+ for (let scrollCache of this.scrollCaches) {
+ scrollCache.destroy();
+ }
+ }
+ computeLeft() {
+ let left = this.origRect.left;
+ for (let scrollCache of this.scrollCaches) {
+ left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
+ }
+ return left;
+ }
+ computeTop() {
+ let top = this.origRect.top;
+ for (let scrollCache of this.scrollCaches) {
+ top += scrollCache.origScrollTop - scrollCache.getScrollTop();
+ }
+ return top;
+ }
+ isWithinClipping(pageX, pageY) {
+ let point = { left: pageX, top: pageY };
+ for (let scrollCache of this.scrollCaches) {
+ if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
+ !pointInsideRect(point, scrollCache.clientRect)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ function isIgnoredClipping(node) {
+ let tagName = node.tagName;
+ return tagName === 'HTML' || tagName === 'BODY';
+ }
+ class HitDragging {
+ constructor(dragging, droppableStore) {
+ this.useSubjectCenter = false;
+ this.requireInitial = true;
+ this.disablePointCheck = false;
+ this.initialHit = null;
+ this.movingHit = null;
+ this.finalHit = null;
+ this.handlePointerDown = (ev) => {
+ let { dragging } = this;
+ this.initialHit = null;
+ this.movingHit = null;
+ this.finalHit = null;
+ this.prepareHits();
+ this.processFirstCoord(ev);
+ if (this.initialHit || !this.requireInitial) {
+ dragging.setIgnoreMove(false);
+ this.emitter.trigger('pointerdown', ev);
+ }
+ else {
+ dragging.setIgnoreMove(true);
+ }
+ };
+ this.handleDragStart = (ev) => {
+ this.emitter.trigger('dragstart', ev);
+ this.handleMove(ev, true);
+ };
+ this.handleDragMove = (ev) => {
+ this.emitter.trigger('dragmove', ev);
+ this.handleMove(ev);
+ };
+ this.handlePointerUp = (ev) => {
+ this.releaseHits();
+ this.emitter.trigger('pointerup', ev);
+ };
+ this.handleDragEnd = (ev) => {
+ if (this.movingHit) {
+ this.emitter.trigger('hitupdate', null, true, ev);
+ }
+ this.finalHit = this.movingHit;
+ this.movingHit = null;
+ this.emitter.trigger('dragend', ev);
+ };
+ this.droppableStore = droppableStore;
+ dragging.emitter.on('pointerdown', this.handlePointerDown);
+ dragging.emitter.on('dragstart', this.handleDragStart);
+ dragging.emitter.on('dragmove', this.handleDragMove);
+ dragging.emitter.on('pointerup', this.handlePointerUp);
+ dragging.emitter.on('dragend', this.handleDragEnd);
+ this.dragging = dragging;
+ this.emitter = new Emitter();
+ }
+ processFirstCoord(ev) {
+ let origPoint = { left: ev.pageX, top: ev.pageY };
+ let adjustedPoint = origPoint;
+ let subjectEl = ev.subjectEl;
+ let subjectRect;
+ if (subjectEl instanceof HTMLElement) {
+ subjectRect = computeRect(subjectEl);
+ adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
+ }
+ let initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
+ if (initialHit) {
+ if (this.useSubjectCenter && subjectRect) {
+ let slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
+ if (slicedSubjectRect) {
+ adjustedPoint = getRectCenter(slicedSubjectRect);
+ }
+ }
+ this.coordAdjust = diffPoints(adjustedPoint, origPoint);
+ }
+ else {
+ this.coordAdjust = { left: 0, top: 0 };
+ }
+ }
+ handleMove(ev, forceHandle) {
+ let hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
+ if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
+ this.movingHit = hit;
+ this.emitter.trigger('hitupdate', hit, false, ev);
+ }
+ }
+ prepareHits() {
+ this.offsetTrackers = mapHash(this.droppableStore, (interactionSettings) => {
+ interactionSettings.component.prepareHits();
+ return new OffsetTracker(interactionSettings.el);
+ });
+ }
+ releaseHits() {
+ let { offsetTrackers } = this;
+ for (let id in offsetTrackers) {
+ offsetTrackers[id].destroy();
+ }
+ this.offsetTrackers = {};
+ }
+ queryHitForOffset(offsetLeft, offsetTop) {
+ let { droppableStore, offsetTrackers } = this;
+ let bestHit = null;
+ for (let id in droppableStore) {
+ let component = droppableStore[id].component;
+ let offsetTracker = offsetTrackers[id];
+ if (offsetTracker &&
+ offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
+ let originLeft = offsetTracker.computeLeft();
+ let originTop = offsetTracker.computeTop();
+ let positionLeft = offsetLeft - originLeft;
+ let positionTop = offsetTop - originTop;
+ let { origRect } = offsetTracker;
+ let width = origRect.right - origRect.left;
+ let height = origRect.bottom - origRect.top;
+ if (
+ positionLeft >= 0 && positionLeft < width &&
+ positionTop >= 0 && positionTop < height) {
+ let hit = component.queryHit(positionLeft, positionTop, width, height);
+ if (hit && (
+ rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
+ (this.disablePointCheck ||
+ offsetTracker.el.contains(offsetTracker.el.getRootNode().elementFromPoint(
+ positionLeft + originLeft - window.scrollX, positionTop + originTop - window.scrollY))) &&
+ (!bestHit || hit.layer > bestHit.layer)) {
+ hit.componentId = id;
+ hit.context = component.context;
+ hit.rect.left += originLeft;
+ hit.rect.right += originLeft;
+ hit.rect.top += originTop;
+ hit.rect.bottom += originTop;
+ bestHit = hit;
+ }
+ }
+ }
+ }
+ return bestHit;
+ }
+ }
+ function isHitsEqual(hit0, hit1) {
+ if (!hit0 && !hit1) {
+ return true;
+ }
+ if (Boolean(hit0) !== Boolean(hit1)) {
+ return false;
+ }
+ return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
+ }
+ function buildDatePointApiWithContext(dateSpan, context) {
+ let props = {};
+ for (let transform of context.pluginHooks.datePointTransforms) {
+ Object.assign(props, transform(dateSpan, context));
+ }
+ Object.assign(props, buildDatePointApi(dateSpan, context.dateEnv));
+ return props;
+ }
+ function buildDatePointApi(span, dateEnv) {
+ return {
+ date: dateEnv.toDate(span.range.start),
+ dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
+ allDay: span.allDay,
+ };
+ }
+ class DateClicking extends Interaction {
+ constructor(settings) {
+ super(settings);
+ this.handlePointerDown = (pev) => {
+ let { dragging } = this;
+ let downEl = pev.origEvent.target;
+ dragging.setIgnoreMove(!this.component.isValidDateDownEl(downEl));
+ };
+ this.handleDragEnd = (ev) => {
+ let { component } = this;
+ let { pointer } = this.dragging;
+ if (!pointer.wasTouchScroll) {
+ let { initialHit, finalHit } = this.hitDragging;
+ if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
+ let { context } = component;
+ let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
+ context.emitter.trigger('dateClick', arg);
+ }
+ }
+ };
+ this.dragging = new FeaturefulElementDragging(settings.el);
+ this.dragging.autoScroller.isEnabled = false;
+ let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsToStore(settings));
+ hitDragging.emitter.on('pointerdown', this.handlePointerDown);
+ hitDragging.emitter.on('dragend', this.handleDragEnd);
+ }
+ destroy() {
+ this.dragging.destroy();
+ }
+ }
+ class DateSelecting extends Interaction {
+ constructor(settings) {
+ super(settings);
+ this.dragSelection = null;
+ this.handlePointerDown = (ev) => {
+ let { component, dragging } = this;
+ let { options } = component.context;
+ let canSelect = options.selectable &&
+ component.isValidDateDownEl(ev.origEvent.target);
+ dragging.setIgnoreMove(!canSelect);
+ dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
+ };
+ this.handleDragStart = (ev) => {
+ this.component.context.calendarApi.unselect(ev);
+ };
+ this.handleHitUpdate = (hit, isFinal) => {
+ let { context } = this.component;
+ let dragSelection = null;
+ let isInvalid = false;
+ if (hit) {
+ let initialHit = this.hitDragging.initialHit;
+ let disallowed = hit.componentId === initialHit.componentId
+ && this.isHitComboAllowed
+ && !this.isHitComboAllowed(initialHit, hit);
+ if (!disallowed) {
+ dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
+ }
+ if (!dragSelection || !isDateSelectionValid(dragSelection, hit.dateProfile, context)) {
+ isInvalid = true;
+ dragSelection = null;
+ }
+ }
+ if (dragSelection) {
+ context.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
+ }
+ else if (!isFinal) {
+ context.dispatch({ type: 'UNSELECT_DATES' });
+ }
+ if (!isInvalid) {
+ enableCursor();
+ }
+ else {
+ disableCursor();
+ }
+ if (!isFinal) {
+ this.dragSelection = dragSelection;
+ }
+ };
+ this.handlePointerUp = (pev) => {
+ if (this.dragSelection) {
+ triggerDateSelect(this.dragSelection, pev, this.component.context);
+ this.dragSelection = null;
+ }
+ };
+ let { component } = settings;
+ let { options } = component.context;
+ let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
+ dragging.touchScrollAllowed = false;
+ dragging.minDistance = options.selectMinDistance || 0;
+ dragging.autoScroller.isEnabled = options.dragScroll;
+ let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsToStore(settings));
+ hitDragging.emitter.on('pointerdown', this.handlePointerDown);
+ hitDragging.emitter.on('dragstart', this.handleDragStart);
+ hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
+ hitDragging.emitter.on('pointerup', this.handlePointerUp);
+ }
+ destroy() {
+ this.dragging.destroy();
+ }
+ }
+ function getComponentTouchDelay$1(component) {
+ let { options } = component.context;
+ let delay = options.selectLongPressDelay;
+ if (delay == null) {
+ delay = options.longPressDelay;
+ }
+ return delay;
+ }
+ function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
+ let dateSpan0 = hit0.dateSpan;
+ let dateSpan1 = hit1.dateSpan;
+ let ms = [
+ dateSpan0.range.start,
+ dateSpan0.range.end,
+ dateSpan1.range.start,
+ dateSpan1.range.end,
+ ];
+ ms.sort(compareNumbers);
+ let props = {};
+ for (let transformer of dateSelectionTransformers) {
+ let res = transformer(hit0, hit1);
+ if (res === false) {
+ return null;
+ }
+ if (res) {
+ Object.assign(props, res);
+ }
+ }
+ props.range = { start: ms[0], end: ms[3] };
+ props.allDay = dateSpan0.allDay;
+ return props;
+ }
+ class EventDragging extends Interaction {
+ constructor(settings) {
+ super(settings);
+ this.subjectEl = null;
+ this.subjectSeg = null;
+ this.isDragging = false;
+ this.eventRange = null;
+ this.relevantEvents = null;
+ this.receivingContext = null;
+ this.validMutation = null;
+ this.mutatedRelevantEvents = null;
+ this.handlePointerDown = (ev) => {
+ let origTarget = ev.origEvent.target;
+ let { component, dragging } = this;
+ let { mirror } = dragging;
+ let { options } = component.context;
+ let initialContext = component.context;
+ this.subjectEl = ev.subjectEl;
+ let subjectSeg = this.subjectSeg = getElSeg(ev.subjectEl);
+ let eventRange = this.eventRange = subjectSeg.eventRange;
+ let eventInstanceId = eventRange.instance.instanceId;
+ this.relevantEvents = getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
+ dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
+ dragging.delay =
+ (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
+ getComponentTouchDelay(component) :
+ null;
+ if (options.fixedMirrorParent) {
+ mirror.parentNode = options.fixedMirrorParent;
+ }
+ else {
+ mirror.parentNode = elementClosest(origTarget, '.fc');
+ }
+ mirror.revertDuration = options.dragRevertDuration;
+ let isValid = component.isValidSegDownEl(origTarget) &&
+ !elementClosest(origTarget, '.fc-event-resizer');
+ dragging.setIgnoreMove(!isValid);
+ this.isDragging = isValid &&
+ ev.subjectEl.classList.contains('fc-event-draggable');
+ };
+ this.handleDragStart = (ev) => {
+ let initialContext = this.component.context;
+ let eventRange = this.eventRange;
+ let eventInstanceId = eventRange.instance.instanceId;
+ if (ev.isTouch) {
+ if (eventInstanceId !== this.component.props.eventSelection) {
+ initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId });
+ }
+ }
+ else {
+ initialContext.dispatch({ type: 'UNSELECT_EVENT' });
+ }
+ if (this.isDragging) {
+ initialContext.calendarApi.unselect(ev);
+ initialContext.emitter.trigger('eventDragStart', {
+ el: this.subjectEl,
+ event: new EventImpl(initialContext, eventRange.def, eventRange.instance),
+ jsEvent: ev.origEvent,
+ view: initialContext.viewApi,
+ });
+ }
+ };
+ this.handleHitUpdate = (hit, isFinal) => {
+ if (!this.isDragging) {
+ return;
+ }
+ let relevantEvents = this.relevantEvents;
+ let initialHit = this.hitDragging.initialHit;
+ let initialContext = this.component.context;
+ let receivingContext = null;
+ let mutation = null;
+ let mutatedRelevantEvents = null;
+ let isInvalid = false;
+ let interaction = {
+ affectedEvents: relevantEvents,
+ mutatedEvents: createEmptyEventStore(),
+ isEvent: true,
+ };
+ if (hit) {
+ receivingContext = hit.context;
+ let receivingOptions = receivingContext.options;
+ if (initialContext === receivingContext ||
+ (receivingOptions.editable && receivingOptions.droppable)) {
+ mutation = computeEventMutation(initialHit, hit, this.eventRange.instance.range.start, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
+ if (mutation) {
+ mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
+ interaction.mutatedEvents = mutatedRelevantEvents;
+ if (!isInteractionValid(interaction, hit.dateProfile, receivingContext)) {
+ isInvalid = true;
+ mutation = null;
+ mutatedRelevantEvents = null;
+ interaction.mutatedEvents = createEmptyEventStore();
+ }
+ }
+ }
+ else {
+ receivingContext = null;
+ }
+ }
+ this.displayDrag(receivingContext, interaction);
+ if (!isInvalid) {
+ enableCursor();
+ }
+ else {
+ disableCursor();
+ }
+ if (!isFinal) {
+ if (initialContext === receivingContext &&
+ isHitsEqual(initialHit, hit)) {
+ mutation = null;
+ }
+ this.dragging.setMirrorNeedsRevert(!mutation);
+ this.dragging.setMirrorIsVisible(!hit || !this.subjectEl.getRootNode().querySelector('.fc-event-mirror'));
+ this.receivingContext = receivingContext;
+ this.validMutation = mutation;
+ this.mutatedRelevantEvents = mutatedRelevantEvents;
+ }
+ };
+ this.handlePointerUp = () => {
+ if (!this.isDragging) {
+ this.cleanup();
+ }
+ };
+ this.handleDragEnd = (ev) => {
+ if (this.isDragging) {
+ let initialContext = this.component.context;
+ let initialView = initialContext.viewApi;
+ let { receivingContext, validMutation } = this;
+ let eventDef = this.eventRange.def;
+ let eventInstance = this.eventRange.instance;
+ let eventApi = new EventImpl(initialContext, eventDef, eventInstance);
+ let relevantEvents = this.relevantEvents;
+ let mutatedRelevantEvents = this.mutatedRelevantEvents;
+ let { finalHit } = this.hitDragging;
+ this.clearDrag();
+ initialContext.emitter.trigger('eventDragStop', {
+ el: this.subjectEl,
+ event: eventApi,
+ jsEvent: ev.origEvent,
+ view: initialView,
+ });
+ if (validMutation) {
+ if (receivingContext === initialContext) {
+ let updatedEventApi = new EventImpl(initialContext, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
+ initialContext.dispatch({
+ type: 'MERGE_EVENTS',
+ eventStore: mutatedRelevantEvents,
+ });
+ let eventChangeArg = {
+ oldEvent: eventApi,
+ event: updatedEventApi,
+ relatedEvents: buildEventApis(mutatedRelevantEvents, initialContext, eventInstance),
+ revert() {
+ initialContext.dispatch({
+ type: 'MERGE_EVENTS',
+ eventStore: relevantEvents,
+ });
+ },
+ };
+ let transformed = {};
+ for (let transformer of initialContext.getCurrentData().pluginHooks.eventDropTransformers) {
+ Object.assign(transformed, transformer(validMutation, initialContext));
+ }
+ initialContext.emitter.trigger('eventDrop', Object.assign(Object.assign(Object.assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
+ initialContext.emitter.trigger('eventChange', eventChangeArg);
+ }
+ else if (receivingContext) {
+ let eventRemoveArg = {
+ event: eventApi,
+ relatedEvents: buildEventApis(relevantEvents, initialContext, eventInstance),
+ revert() {
+ initialContext.dispatch({
+ type: 'MERGE_EVENTS',
+ eventStore: relevantEvents,
+ });
+ },
+ };
+ initialContext.emitter.trigger('eventLeave', Object.assign(Object.assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
+ initialContext.dispatch({
+ type: 'REMOVE_EVENTS',
+ eventStore: relevantEvents,
+ });
+ initialContext.emitter.trigger('eventRemove', eventRemoveArg);
+ let addedEventDef = mutatedRelevantEvents.defs[eventDef.defId];
+ let addedEventInstance = mutatedRelevantEvents.instances[eventInstance.instanceId];
+ let addedEventApi = new EventImpl(receivingContext, addedEventDef, addedEventInstance);
+ receivingContext.dispatch({
+ type: 'MERGE_EVENTS',
+ eventStore: mutatedRelevantEvents,
+ });
+ let eventAddArg = {
+ event: addedEventApi,
+ relatedEvents: buildEventApis(mutatedRelevantEvents, receivingContext, addedEventInstance),
+ revert() {
+ receivingContext.dispatch({
+ type: 'REMOVE_EVENTS',
+ eventStore: mutatedRelevantEvents,
+ });
+ },
+ };
+ receivingContext.emitter.trigger('eventAdd', eventAddArg);
+ if (ev.isTouch) {
+ receivingContext.dispatch({
+ type: 'SELECT_EVENT',
+ eventInstanceId: eventInstance.instanceId,
+ });
+ }
+ receivingContext.emitter.trigger('drop', Object.assign(Object.assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
+ receivingContext.emitter.trigger('eventReceive', Object.assign(Object.assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.context.viewApi }));
+ }
+ }
+ else {
+ initialContext.emitter.trigger('_noEventDrop');
+ }
+ }
+ this.cleanup();
+ };
+ let { component } = this;
+ let { options } = component.context;
+ let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
+ dragging.pointer.selector = EventDragging.SELECTOR;
+ dragging.touchScrollAllowed = false;
+ dragging.autoScroller.isEnabled = options.dragScroll;
+ let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsStore);
+ hitDragging.useSubjectCenter = settings.useEventCenter;
+ hitDragging.emitter.on('pointerdown', this.handlePointerDown);
+ hitDragging.emitter.on('dragstart', this.handleDragStart);
+ hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
+ hitDragging.emitter.on('pointerup', this.handlePointerUp);
+ hitDragging.emitter.on('dragend', this.handleDragEnd);
+ }
+ destroy() {
+ this.dragging.destroy();
+ }
+ displayDrag(nextContext, state) {
+ let initialContext = this.component.context;
+ let prevContext = this.receivingContext;
+ if (prevContext && prevContext !== nextContext) {
+ if (prevContext === initialContext) {
+ prevContext.dispatch({
+ type: 'SET_EVENT_DRAG',
+ state: {
+ affectedEvents: state.affectedEvents,
+ mutatedEvents: createEmptyEventStore(),
+ isEvent: true,
+ },
+ });
+ }
+ else {
+ prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
+ }
+ }
+ if (nextContext) {
+ nextContext.dispatch({ type: 'SET_EVENT_DRAG', state });
+ }
+ }
+ clearDrag() {
+ let initialCalendar = this.component.context;
+ let { receivingContext } = this;
+ if (receivingContext) {
+ receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
+ }
+ if (initialCalendar !== receivingContext) {
+ initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
+ }
+ }
+ cleanup() {
+ this.subjectSeg = null;
+ this.isDragging = false;
+ this.eventRange = null;
+ this.relevantEvents = null;
+ this.receivingContext = null;
+ this.validMutation = null;
+ this.mutatedRelevantEvents = null;
+ }
+ }
+ EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
+ function computeEventMutation(hit0, hit1, eventInstanceStart, massagers) {
+ let dateSpan0 = hit0.dateSpan;
+ let dateSpan1 = hit1.dateSpan;
+ let date0 = dateSpan0.range.start;
+ let date1 = dateSpan1.range.start;
+ let standardProps = {};
+ if (dateSpan0.allDay !== dateSpan1.allDay) {
+ standardProps.allDay = dateSpan1.allDay;
+ standardProps.hasEnd = hit1.context.options.allDayMaintainDuration;
+ if (dateSpan1.allDay) {
+ date0 = startOfDay(eventInstanceStart);
+ }
+ else {
+ date0 = eventInstanceStart;
+ }
+ }
+ let delta = diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
+ hit0.largeUnit :
+ null);
+ if (delta.milliseconds) {
+ standardProps.allDay = false;
+ }
+ let mutation = {
+ datesDelta: delta,
+ standardProps,
+ };
+ for (let massager of massagers) {
+ massager(mutation, hit0, hit1);
+ }
+ return mutation;
+ }
+ function getComponentTouchDelay(component) {
+ let { options } = component.context;
+ let delay = options.eventLongPressDelay;
+ if (delay == null) {
+ delay = options.longPressDelay;
+ }
+ return delay;
+ }
+ class EventResizing extends Interaction {
+ constructor(settings) {
+ super(settings);
+ this.draggingSegEl = null;
+ this.draggingSeg = null;
+ this.eventRange = null;
+ this.relevantEvents = null;
+ this.validMutation = null;
+ this.mutatedRelevantEvents = null;
+ this.handlePointerDown = (ev) => {
+ let { component } = this;
+ let segEl = this.querySegEl(ev);
+ let seg = getElSeg(segEl);
+ let eventRange = this.eventRange = seg.eventRange;
+ this.dragging.minDistance = component.context.options.eventDragMinDistance;
+ this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(ev.origEvent.target) ||
+ (ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId));
+ };
+ this.handleDragStart = (ev) => {
+ let { context } = this.component;
+ let eventRange = this.eventRange;
+ this.relevantEvents = getRelevantEvents(context.getCurrentData().eventStore, this.eventRange.instance.instanceId);
+ let segEl = this.querySegEl(ev);
+ this.draggingSegEl = segEl;
+ this.draggingSeg = getElSeg(segEl);
+ context.calendarApi.unselect();
+ context.emitter.trigger('eventResizeStart', {
+ el: segEl,
+ event: new EventImpl(context, eventRange.def, eventRange.instance),
+ jsEvent: ev.origEvent,
+ view: context.viewApi,
+ });
+ };
+ this.handleHitUpdate = (hit, isFinal, ev) => {
+ let { context } = this.component;
+ let relevantEvents = this.relevantEvents;
+ let initialHit = this.hitDragging.initialHit;
+ let eventInstance = this.eventRange.instance;
+ let mutation = null;
+ let mutatedRelevantEvents = null;
+ let isInvalid = false;
+ let interaction = {
+ affectedEvents: relevantEvents,
+ mutatedEvents: createEmptyEventStore(),
+ isEvent: true,
+ };
+ if (hit) {
+ let disallowed = hit.componentId === initialHit.componentId
+ && this.isHitComboAllowed
+ && !this.isHitComboAllowed(initialHit, hit);
+ if (!disallowed) {
+ mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range);
+ }
+ }
+ if (mutation) {
+ mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
+ interaction.mutatedEvents = mutatedRelevantEvents;
+ if (!isInteractionValid(interaction, hit.dateProfile, context)) {
+ isInvalid = true;
+ mutation = null;
+ mutatedRelevantEvents = null;
+ interaction.mutatedEvents = null;
+ }
+ }
+ if (mutatedRelevantEvents) {
+ context.dispatch({
+ type: 'SET_EVENT_RESIZE',
+ state: interaction,
+ });
+ }
+ else {
+ context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
+ }
+ if (!isInvalid) {
+ enableCursor();
+ }
+ else {
+ disableCursor();
+ }
+ if (!isFinal) {
+ if (mutation && isHitsEqual(initialHit, hit)) {
+ mutation = null;
+ }
+ this.validMutation = mutation;
+ this.mutatedRelevantEvents = mutatedRelevantEvents;
+ }
+ };
+ this.handleDragEnd = (ev) => {
+ let { context } = this.component;
+ let eventDef = this.eventRange.def;
+ let eventInstance = this.eventRange.instance;
+ let eventApi = new EventImpl(context, eventDef, eventInstance);
+ let relevantEvents = this.relevantEvents;
+ let mutatedRelevantEvents = this.mutatedRelevantEvents;
+ context.emitter.trigger('eventResizeStop', {
+ el: this.draggingSegEl,
+ event: eventApi,
+ jsEvent: ev.origEvent,
+ view: context.viewApi,
+ });
+ if (this.validMutation) {
+ let updatedEventApi = new EventImpl(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
+ context.dispatch({
+ type: 'MERGE_EVENTS',
+ eventStore: mutatedRelevantEvents,
+ });
+ let eventChangeArg = {
+ oldEvent: eventApi,
+ event: updatedEventApi,
+ relatedEvents: buildEventApis(mutatedRelevantEvents, context, eventInstance),
+ revert() {
+ context.dispatch({
+ type: 'MERGE_EVENTS',
+ eventStore: relevantEvents,
+ });
+ },
+ };
+ context.emitter.trigger('eventResize', Object.assign(Object.assign({}, eventChangeArg), { el: this.draggingSegEl, startDelta: this.validMutation.startDelta || createDuration(0), endDelta: this.validMutation.endDelta || createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
+ context.emitter.trigger('eventChange', eventChangeArg);
+ }
+ else {
+ context.emitter.trigger('_noEventResize');
+ }
+ this.draggingSeg = null;
+ this.relevantEvents = null;
+ this.validMutation = null;
+ };
+ let { component } = settings;
+ let dragging = this.dragging = new FeaturefulElementDragging(settings.el);
+ dragging.pointer.selector = '.fc-event-resizer';
+ dragging.touchScrollAllowed = false;
+ dragging.autoScroller.isEnabled = component.context.options.dragScroll;
+ let hitDragging = this.hitDragging = new HitDragging(this.dragging, interactionSettingsToStore(settings));
+ hitDragging.emitter.on('pointerdown', this.handlePointerDown);
+ hitDragging.emitter.on('dragstart', this.handleDragStart);
+ hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
+ hitDragging.emitter.on('dragend', this.handleDragEnd);
+ }
+ destroy() {
+ this.dragging.destroy();
+ }
+ querySegEl(ev) {
+ return elementClosest(ev.subjectEl, '.fc-event');
+ }
+ }
+ function computeMutation(hit0, hit1, isFromStart, instanceRange) {
+ let dateEnv = hit0.context.dateEnv;
+ let date0 = hit0.dateSpan.range.start;
+ let date1 = hit1.dateSpan.range.start;
+ let delta = diffDates(date0, date1, dateEnv, hit0.largeUnit);
+ if (isFromStart) {
+ if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
+ return { startDelta: delta };
+ }
+ }
+ else if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
+ return { endDelta: delta };
+ }
+ return null;
+ }
+ class UnselectAuto {
+ constructor(context) {
+ this.context = context;
+ this.isRecentPointerDateSelect = false;
+ this.matchesCancel = false;
+ this.matchesEvent = false;
+ this.onSelect = (selectInfo) => {
+ if (selectInfo.jsEvent) {
+ this.isRecentPointerDateSelect = true;
+ }
+ };
+ this.onDocumentPointerDown = (pev) => {
+ let unselectCancel = this.context.options.unselectCancel;
+ let downEl = getEventTargetViaRoot(pev.origEvent);
+ this.matchesCancel = !!elementClosest(downEl, unselectCancel);
+ this.matchesEvent = !!elementClosest(downEl, EventDragging.SELECTOR);
+ };
+ this.onDocumentPointerUp = (pev) => {
+ let { context } = this;
+ let { documentPointer } = this;
+ let calendarState = context.getCurrentData();
+ if (!documentPointer.wasTouchScroll) {
+ if (calendarState.dateSelection &&
+ !this.isRecentPointerDateSelect
+ ) {
+ let unselectAuto = context.options.unselectAuto;
+ if (unselectAuto && (!unselectAuto || !this.matchesCancel)) {
+ context.calendarApi.unselect(pev);
+ }
+ }
+ if (calendarState.eventSelection &&
+ !this.matchesEvent
+ ) {
+ context.dispatch({ type: 'UNSELECT_EVENT' });
+ }
+ }
+ this.isRecentPointerDateSelect = false;
+ };
+ let documentPointer = this.documentPointer = new PointerDragging(document);
+ documentPointer.shouldIgnoreMove = true;
+ documentPointer.shouldWatchScroll = false;
+ documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
+ documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
+ context.emitter.on('select', this.onSelect);
+ }
+ destroy() {
+ this.context.emitter.off('select', this.onSelect);
+ this.documentPointer.destroy();
+ }
+ }
+ const OPTION_REFINERS = {
+ fixedMirrorParent: identity,
+ };
+ const LISTENER_REFINERS = {
+ dateClick: identity,
+ eventDragStart: identity,
+ eventDragStop: identity,
+ eventDrop: identity,
+ eventResizeStart: identity,
+ eventResizeStop: identity,
+ eventResize: identity,
+ drop: identity,
+ eventReceive: identity,
+ eventLeave: identity,
+ };
+ config.dataAttrPrefix = '';
+ class InferredElementDragging extends ElementDragging {
+ constructor(containerEl) {
+ super(containerEl);
+ this.shouldIgnoreMove = false;
+ this.mirrorSelector = '';
+ this.currentMirrorEl = null;
+ this.handlePointerDown = (ev) => {
+ this.emitter.trigger('pointerdown', ev);
+ if (!this.shouldIgnoreMove) {
+ this.emitter.trigger('dragstart', ev);
+ }
+ };
+ this.handlePointerMove = (ev) => {
+ if (!this.shouldIgnoreMove) {
+ this.emitter.trigger('dragmove', ev);
+ }
+ };
+ this.handlePointerUp = (ev) => {
+ this.emitter.trigger('pointerup', ev);
+ if (!this.shouldIgnoreMove) {
+ this.emitter.trigger('dragend', ev);
+ }
+ };
+ let pointer = this.pointer = new PointerDragging(containerEl);
+ pointer.emitter.on('pointerdown', this.handlePointerDown);
+ pointer.emitter.on('pointermove', this.handlePointerMove);
+ pointer.emitter.on('pointerup', this.handlePointerUp);
+ }
+ destroy() {
+ this.pointer.destroy();
+ }
+ setIgnoreMove(bool) {
+ this.shouldIgnoreMove = bool;
+ }
+ setMirrorIsVisible(bool) {
+ if (bool) {
+ if (this.currentMirrorEl) {
+ this.currentMirrorEl.style.visibility = '';
+ this.currentMirrorEl = null;
+ }
+ }
+ else {
+ let mirrorEl = this.mirrorSelector
+ ? document.querySelector(this.mirrorSelector)
+ : null;
+ if (mirrorEl) {
+ this.currentMirrorEl = mirrorEl;
+ mirrorEl.style.visibility = 'hidden';
+ }
+ }
+ }
+ }
+ var index$1 = createPlugin({
+ name: '@fullcalendar/interaction',
+ componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
+ calendarInteractions: [UnselectAuto],
+ elementDraggingImpl: FeaturefulElementDragging,
+ optionRefiners: OPTION_REFINERS,
+ listenerRefiners: LISTENER_REFINERS,
+ });
-fcViews.listDay = {
- type: 'list',
- duration: { days: 1 },
- defaults: {
- listDayFormat: 'dddd' // day-of-week is all we need. full date is probably in header
- }
-};
+ class BootstrapTheme extends Theme {
+ }
+ BootstrapTheme.prototype.classes = {
+ root: 'fc-theme-bootstrap5',
+ tableCellShaded: 'fc-theme-bootstrap5-shaded',
+ buttonGroup: 'btn-group',
+ button: 'btn btn-primary',
+ buttonActive: 'active',
+ popover: 'popover',
+ popoverHeader: 'popover-header',
+ popoverContent: 'popover-body',
+ };
+ BootstrapTheme.prototype.baseIconClass = 'bi';
+ BootstrapTheme.prototype.iconClasses = {
+ close: 'bi-x-lg',
+ prev: 'bi-chevron-left',
+ next: 'bi-chevron-right',
+ prevYear: 'bi-chevron-double-left',
+ nextYear: 'bi-chevron-double-right',
+ };
+ BootstrapTheme.prototype.rtlIconClasses = {
+ prev: 'bi-chevron-right',
+ next: 'bi-chevron-left',
+ prevYear: 'bi-chevron-double-right',
+ nextYear: 'bi-chevron-double-left',
+ };
+ BootstrapTheme.prototype.iconOverrideOption = 'buttonIcons';
+ BootstrapTheme.prototype.iconOverrideCustomButtonOption = 'icon';
+ BootstrapTheme.prototype.iconOverridePrefix = 'bi-';
+ var css_248z = ".fc-theme-bootstrap5 a:not([href]){color:inherit;text-decoration:inherit}.fc-theme-bootstrap5 .fc-list,.fc-theme-bootstrap5 .fc-scrollgrid,.fc-theme-bootstrap5 td,.fc-theme-bootstrap5 th{border:1px solid var(--bs-gray-400)}.fc-theme-bootstrap5 .fc-scrollgrid{border-bottom-width:0;border-right-width:0}.fc-theme-bootstrap5-shaded{background-color:var(--bs-gray-200)}";
+ injectStyles(css_248z);
+
+ var index = createPlugin({
+ name: '@fullcalendar/bootstrap5',
+ themeClasses: {
+ bootstrap5: BootstrapTheme,
+ },
+ });
-fcViews.listWeek = {
- type: 'list',
- duration: { weeks: 1 },
- defaults: {
- listDayFormat: 'dddd', // day-of-week is more important
- listDayAltFormat: 'LL'
- }
-};
+ exports.Calendar = Calendar;
+ exports.bootstrap5Plugin = index;
+ exports.dayGridPlugin = index$4;
+ exports.interactionPlugin = index$1;
+ exports.listPlugin = index$2;
+ exports.timeGridPlugin = index$3;
-fcViews.listMonth = {
- type: 'list',
- duration: { month: 1 },
- defaults: {
- listDayAltFormat: 'dddd' // day-of-week is nice-to-have
- }
-};
+ Object.defineProperty(exports, '__esModule', { value: true });
-fcViews.listYear = {
- type: 'list',
- duration: { year: 1 },
- defaults: {
- listDayAltFormat: 'dddd' // day-of-week is nice-to-have
- }
-};
+ return exports;
-;;
-
-return FC; // export for Node/CommonJS
-});
\ No newline at end of file
+})({});
diff --git a/src/cone/calendar/browser/static/fullcalendar/fullcalendar.min.css b/src/cone/calendar/browser/static/fullcalendar/fullcalendar.min.css
deleted file mode 100644
index 1339120..0000000
--- a/src/cone/calendar/browser/static/fullcalendar/fullcalendar.min.css
+++ /dev/null
@@ -1,5 +0,0 @@
-/*!
- * FullCalendar v3.1.0 Stylesheet
- * Docs & License: http://fullcalendar.io/
- * (c) 2016 Adam Shaw
- */.fc-icon,body .fc{font-size:1em}.fc-button-group,.fc-icon{display:inline-block}.fc-bg,.fc-row .fc-bgevent-skeleton,.fc-row .fc-highlight-skeleton{bottom:0}.fc-icon,.fc-unselectable{-khtml-user-select:none;-webkit-touch-callout:none}.fc{direction:ltr;text-align:left}.fc-rtl{text-align:right}.fc th,.fc-basic-view td.fc-week-number,.fc-icon,.fc-toolbar{text-align:center}.fc-unthemed .fc-content,.fc-unthemed .fc-divider,.fc-unthemed .fc-list-heading td,.fc-unthemed .fc-list-view,.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-list-heading td,.fc-unthemed .fc-popover .fc-header{background:#eee}.fc-unthemed .fc-popover .fc-header .fc-close{color:#666}.fc-unthemed td.fc-today{background:#fcf8e3}.fc-highlight{background:#bce8f1;opacity:.3}.fc-bgevent{background:#8fdf82;opacity:.3}.fc-nonbusiness{background:#d7d7d7}.fc-icon{height:1em;line-height:1em;overflow:hidden;font-family:"Courier New",Courier,monospace;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.fc-icon:after{position:relative}.fc-icon-left-single-arrow:after{content:"\02039";font-weight:700;font-size:200%;top:-7%}.fc-icon-right-single-arrow:after{content:"\0203A";font-weight:700;font-size:200%;top:-7%}.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%}.fc-icon-right-triangle:after{content:"\25BA";font-size:125%;top:3%}.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;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-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-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;box-shadow:none}.fc-event.fc-draggable,.fc-event[href],.fc-popover .fc-header .fc-close,a[data-goto]{cursor:pointer}.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-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-bg table,.fc-row .fc-bgevent-skeleton table,.fc-row .fc-highlight-skeleton table{height:100%}.fc-clear{clear:both}.fc-bg,.fc-bgevent-skeleton,.fc-helper-skeleton,.fc-highlight-skeleton{position:absolute;top:0;left:0;right:0}.fc table{width:100%;box-sizing:border-box;table-layout:fixed;border-collapse:collapse;border-spacing:0;font-size:1em}.fc td,.fc th{border-style:solid;border-width:1px;padding:0;vertical-align:top}.fc td.fc-today{border-style:double}a[data-goto]:hover{text-decoration:underline}.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 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{-webkit-overflow-scrolling:touch}.fc-row.fc-rigid,.fc-time-grid-event{overflow:hidden}.fc-scroller>.fc-day-grid,.fc-scroller>.fc-time-grid{position:relative;width:100%}.fc-event{position:relative;display:block;font-size:.85em;line-height:1.3;border-radius:3px;border:1px solid #3a87ad;font-weight:400}.fc-event,.fc-event-dot{background-color:#3a87ad}.fc-event,.fc-event:hover,.ui-widget .fc-event{color:#fff;text-decoration:none}.fc-not-allowed,.fc-not-allowed .fc-event{cursor:not-allowed}.fc-event .fc-bg{z-index:1;background:#fff;opacity:.25}.fc-event .fc-content{position:relative;z-index:2}.fc-event .fc-resizer{position:absolute;z-index:4;display:none}.fc-event.fc-allow-mouse-resize .fc-resizer,.fc-event.fc-selected .fc-resizer{display:block}.fc-event.fc-selected .fc-resizer:before{content:"";position:absolute;z-index:9999;top:50%;left:50%;width:40px;height:40px;margin-left:-20px;margin-top:-20px}.fc-event.fc-selected{z-index:9999!important;box-shadow:0 2px 5px rgba(0,0,0,.2)}.fc-event.fc-selected.fc-dragging{box-shadow:0 2px 7px rgba(0,0,0,.3)}.fc-h-event.fc-selected:before{content:"";position:absolute;z-index:3;top:-10px;bottom:-10px;left:0;right:0}.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-ltr .fc-h-event .fc-start-resizer,.fc-rtl .fc-h-event .fc-end-resizer{cursor:w-resize;left:-1px}.fc-ltr .fc-h-event .fc-end-resizer,.fc-rtl .fc-h-event .fc-start-resizer{cursor:e-resize;right:-1px}.fc-h-event.fc-allow-mouse-resize .fc-resizer{width:7px;top:-1px;bottom:-1px}.fc-h-event.fc-selected .fc-resizer{border-radius:4px;border-width:1px;width:6px;height:6px;border-style:solid;border-color:inherit;background:#fff;top:50%;margin-top:-4px}.fc-ltr .fc-h-event.fc-selected .fc-start-resizer,.fc-rtl .fc-h-event.fc-selected .fc-end-resizer{margin-left:-4px}.fc-ltr .fc-h-event.fc-selected .fc-end-resizer,.fc-rtl .fc-h-event.fc-selected .fc-start-resizer{margin-right:-4px}.fc-day-grid-event{margin:1px 2px 0;padding:0 1px}tr:first-child>td>.fc-day-grid-event{margin-top:2px}.fc-day-grid-event.fc-selected:after{content:"";position:absolute;z-index:1;top:-1px;right:-1px;bottom:-1px;left:-1px;background:#000;opacity:.25}.fc-day-grid-event .fc-content{white-space:nowrap;overflow:hidden}.fc-day-grid-event .fc-time{font-weight:700}.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer,.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer{margin-left:-2px}.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer,.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer{margin-right:-2px}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-now-indicator{position:absolute;border:0 solid red}.fc-unselectable{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.fc-toolbar.fc-header-toolbar{margin-bottom:1em}.fc-toolbar.fc-footer-toolbar{margin-top: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-bottom:1em}.fc-basic-view .fc-body .fc-row{min-height:4em}.fc-row.fc-rigid .fc-content-skeleton{position:absolute;top:0;left:0;right:0}.fc-day-top.fc-other-month{opacity:.3}.fc-basic-view .fc-day-number,.fc-basic-view .fc-week-number{padding:2px}.fc-basic-view th.fc-day-number,.fc-basic-view th.fc-week-number{padding:0 2px}.fc-ltr .fc-basic-view .fc-day-top .fc-day-number{float:right}.fc-rtl .fc-basic-view .fc-day-top .fc-day-number{float:left}.fc-ltr .fc-basic-view .fc-day-top .fc-week-number{float:left;border-radius:0 0 3px}.fc-rtl .fc-basic-view .fc-day-top .fc-week-number{float:right;border-radius:0 0 0 3px}.fc-basic-view .fc-day-top .fc-week-number{min-width:1.5em;text-align:center;background-color:#f2f2f2;color:grey}.fc-basic-view td.fc-week-number>*{display:inline-block;min-width:1.25em}.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-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-content-col{position:relative}.fc-time-grid .fc-content-skeleton{position:absolute;z-index:3;top:0;left:0;right:0}.fc-time-grid .fc-business-container{position:relative;z-index:1}.fc-time-grid .fc-bgevent-container{position:relative;z-index:2}.fc-time-grid .fc-highlight-container{z-index:3;position:relative}.fc-time-grid .fc-event-container{position:relative;z-index:4}.fc-time-grid .fc-now-indicator-line{z-index:5}.fc-time-grid .fc-helper-container{position:relative;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{position:absolute;left:0;right:0}.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.fc-selected{overflow:visible}.fc-time-grid-event.fc-selected .fc-bg{display:none}.fc-time-grid-event .fc-content{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-allow-mouse-resize .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-allow-mouse-resize .fc-resizer:after{content:"="}.fc-time-grid-event.fc-selected .fc-resizer{border-radius:5px;border-width:1px;width:8px;height:8px;border-style:solid;border-color:inherit;background:#fff;left:50%;margin-left:-5px;bottom:-5px}.fc-time-grid .fc-now-indicator-line{border-top-width:1px;left:0;right:0}.fc-time-grid .fc-now-indicator-arrow{margin-top:-5px}.fc-ltr .fc-time-grid .fc-now-indicator-arrow{left:0;border-width:5px 0 5px 6px;border-top-color:transparent;border-bottom-color:transparent}.fc-rtl .fc-time-grid .fc-now-indicator-arrow{right:0;border-width:5px 6px 5px 0;border-top-color:transparent;border-bottom-color:transparent}.fc-event-dot{display:inline-block;width:10px;height:10px;border-radius:5px}.fc-rtl .fc-list-view{direction:rtl}.fc-list-view{border-width:1px;border-style:solid}.fc .fc-list-table{table-layout:auto}.fc-list-table td{border-width:1px 0 0;padding:8px 14px}.fc-list-table tr:first-child td{border-top-width:0}.fc-list-heading{border-bottom-width:1px}.fc-list-heading td{font-weight:700}.fc-ltr .fc-list-heading-main{float:left}.fc-ltr .fc-list-heading-alt,.fc-rtl .fc-list-heading-main{float:right}.fc-rtl .fc-list-heading-alt{float:left}.fc-list-item.fc-has-url{cursor:pointer}.fc-list-item:hover td{background-color:#f5f5f5}.fc-list-item-marker,.fc-list-item-time{white-space:nowrap;width:1px}.fc-ltr .fc-list-item-marker{padding-right:0}.fc-rtl .fc-list-item-marker{padding-left:0}.fc-list-item-title a{text-decoration:none;color:inherit}.fc-list-item-title a[href]:hover{text-decoration:underline}.fc-list-empty-wrap2{position:absolute;top:0;left:0;right:0;bottom:0}.fc-list-empty-wrap1{width:100%;height:100%;display:table}.fc-list-empty{display:table-cell;vertical-align:middle;text-align:center}.fc-unthemed .fc-list-empty{background-color:#eee}
\ No newline at end of file
diff --git a/src/cone/calendar/browser/static/fullcalendar/fullcalendar.min.js b/src/cone/calendar/browser/static/fullcalendar/fullcalendar.min.js
index 8484b7c..2442ffc 100644
--- a/src/cone/calendar/browser/static/fullcalendar/fullcalendar.min.js
+++ b/src/cone/calendar/browser/static/fullcalendar/fullcalendar.min.js
@@ -1,10 +1 @@
-/*!
- * FullCalendar v3.1.0
- * Docs & License: http://fullcalendar.io/
- * (c) 2016 Adam Shaw
- */
-!function(t){"function"==typeof define&&define.amd?define(["jquery","moment"],t):"object"==typeof exports?module.exports=t(require("jquery"),require("moment")):t(jQuery,moment)}(function(t,e){function n(t){return q(t,$t)}function i(t,e){e.left&&t.css({"border-left-width":1,"margin-left":e.left-1}),e.right&&t.css({"border-right-width":1,"margin-right":e.right-1})}function r(t){t.css({"margin-left":"","margin-right":"","border-left-width":"","border-right-width":""})}function s(){t("body").addClass("fc-not-allowed")}function o(){t("body").removeClass("fc-not-allowed")}function l(e,n,i){var r=Math.floor(n/e.length),s=Math.floor(n-r*(e.length-1)),o=[],l=[],u=[],c=0;a(e),e.each(function(n,i){var a=n===e.length-1?s:r,d=t(i).outerHeight(!0);d *").each(function(e,i){var r=t(i).outerWidth();r>n&&(n=r)}),n++,e.width(n),n}function c(t,e){var n,i=t.add(e);return i.css({position:"relative",left:-1}),n=t.outerHeight()-e.outerHeight(),i.css({position:"",left:""}),n}function d(e){var n=e.css("position"),i=e.parents().filter(function(){var e=t(this);return/(auto|scroll)/.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==n&&i.length?i:t(e[0].ownerDocument||document)}function h(t,e){var n=t.offset(),i=n.left-(e?e.left:0),r=n.top-(e?e.top:0);return{left:i,right:i+t.outerWidth(),top:r,bottom:r+t.outerHeight()}}function f(t,e){var n=t.offset(),i=p(t),r=n.left+y(t,"border-left-width")+i.left-(e?e.left:0),s=n.top+y(t,"border-top-width")+i.top-(e?e.top:0);return{left:r,right:r+t[0].clientWidth,top:s,bottom:s+t[0].clientHeight}}function g(t,e){var n=t.offset(),i=n.left+y(t,"border-left-width")+y(t,"padding-left")-(e?e.left:0),r=n.top+y(t,"border-top-width")+y(t,"padding-top")-(e?e.top:0);return{left:i,right:i+t.width(),top:r,bottom:r+t.height()}}function p(t){var e=t.innerWidth()-t[0].clientWidth,n={left:0,right:0,top:0,bottom:t.innerHeight()-t[0].clientHeight};return v()&&"rtl"==t.css("direction")?n.left=e:n.right=e,n}function v(){return null===Qt&&(Qt=m()),Qt}function m(){var e=t("").css({position:"absolute",top:-1e3,left:0,border:0,padding:0,overflow:"scroll",direction:"rtl"}).appendTo("body"),n=e.children(),i=n.offset().left>e.offset().left;return e.remove(),i}function y(t,e){return parseFloat(t.css(e))||0}function S(t){return 1==t.which&&!t.ctrlKey}function w(t){if(void 0!==t.pageX)return t.pageX;var e=t.originalEvent.touches;return e?e[0].pageX:void 0}function E(t){if(void 0!==t.pageY)return t.pageY;var e=t.originalEvent.touches;return e?e[0].pageY:void 0}function b(t){return/^touch/.test(t.type)}function D(t){t.addClass("fc-unselectable").on("selectstart",T)}function T(t){t.preventDefault()}function C(t){return!!window.addEventListener&&(window.addEventListener("scroll",t,!0),!0)}function H(t){return!!window.removeEventListener&&(window.removeEventListener("scroll",t,!0),!0)}function R(t,e){var n={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)};return n.lefta&&o=a?(n=o.clone(),r=!0):(n=a.clone(),r=!1),l<=u?(i=l.clone(),s=!0):(i=u.clone(),s=!1),{start:n,end:i,isStart:r,isEnd:s}}function N(t,n){return e.duration({days:t.clone().stripTime().diff(n.clone().stripTime(),"days"),ms:t.time()-n.time()})}function G(t,n){return e.duration({days:t.clone().stripTime().diff(n.clone().stripTime(),"days")})}function O(t,n,i){return e.duration(Math.round(t.diff(n,i,!0)),i)}function A(t,e){var n,i,r;for(n=0;n=1&&ot(r)));n++);return i}function V(t,n,i){return null!=i?i.diff(n,t,!0):e.isDuration(n)?n.as(t):n.end.diff(n.start,t,!0)}function P(t,e,n){var i;return W(n)?(e-t)/n:(i=n.asMonths(),Math.abs(i)>=1&&ot(i)?e.diff(t,"months",!0)/i:e.diff(t,"days",!0)/n.asDays())}function _(t,e){var n,i;return W(t)||W(e)?t/e:(n=t.asMonths(),i=e.asMonths(),Math.abs(n)>=1&&ot(n)&&Math.abs(i)>=1&&ot(i)?n/i:t.asDays()/e.asDays())}function Y(t,n){var i;return W(t)?e.duration(t*n):(i=t.asMonths(),Math.abs(i)>=1&&ot(i)?e.duration({months:i*n}):e.duration({days:t.asDays()*n}))}function W(t){return Boolean(t.hours()||t.minutes()||t.seconds()||t.milliseconds())}function U(t){return"[object Date]"===Object.prototype.toString.call(t)||t instanceof Date}function j(t){return/^\d+\:\d+(?:\:\d+\.?(?:\d{3})?)?$/.test(t)}function q(t,e){var n,i,r,s,o,l,a={};if(e)for(n=0;n=0;s--)if(o=t[s][i],"object"==typeof o)r.unshift(o);else if(void 0!==o){a[i]=o;break}r.length&&(a[i]=q(r))}for(n=t.length-1;n>=0;n--){l=t[n];for(i in l)i in a||(a[i]=l[i])}return a}function Z(t){var e=function(){};return e.prototype=t,new e}function $(t,e){for(var n in t)Q(t,n)&&(e[n]=t[n])}function Q(t,e){return Jt.call(t,e)}function X(e){return/undefined|null|boolean|number|string/.test(t.type(e))}function K(e,n,i){if(t.isFunction(e)&&(e=[e]),e){var r,s;for(r=0;r /g,">").replace(/'/g,"'").replace(/"/g,""").replace(/\n/g," ")}function et(t){return t.replace(/&.*?;/g,"")}function nt(e){var n=[];return t.each(e,function(t,e){null!=e&&n.push(t+":"+e)}),n.join(";")}function it(e){var n=[];return t.each(e,function(t,e){null!=e&&n.push(t+'="'+tt(e)+'"')}),n.join(" ")}function rt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function st(t,e){return t-e}function ot(t){return t%1===0}function lt(t,e){var n=t[e];return function(){return n.apply(t,arguments)}}function at(t,e,n){var i,r,s,o,l,a=function(){var u=+new Date-o;uo&&(s=vt(t,e,u,c,n[l]),s!==!1);l--)h=s+h;for(a=o;a<=l;a++)f+=ft(t,n[a]),g+=ft(e,n[a]);return(f||g)&&(p=r?g+i+f:f+i+g),d+p+h}function vt(t,e,n,i,r){var s,o;return"string"==typeof r?r:!!((s=r.token)&&(o=oe[s.charAt(0)],o&&n.isSame(i,o)))&&ct(t,s)}function mt(t){return t in le?le[t]:le[t]=yt(t)}function yt(t){for(var e,n=[],i=/\[([^\]]*)\]|\(([^\)]*)\)|(LTS|LT|(\w)\4*o?)|([^\w\[\(]+)/g;e=i.exec(t);)e[1]?n.push(e[1]):e[2]?n.push({maybe:yt(e[2])}):e[3]?n.push({token:e[3]}):e[5]&&n.push(e[5]);return n}function St(){}function wt(t,e){var n;return Q(e,"constructor")&&(n=e.constructor),"function"!=typeof n&&(n=e.constructor=function(){t.apply(this,arguments)}),n.prototype=Z(t.prototype),$(e,n.prototype),$(t,n),n}function Et(t,e){$(e,t.prototype)}function bt(e){var n=t.Deferred(),i=n.promise();if("function"==typeof e&&e(function(t){bt.immediate&&(i._value=t),n.resolve(t)},function(){n.reject()}),bt.immediate){var r=i.then;i.then=function(t,e){var n=i.state();if("resolved"===n){if("function"==typeof t)return bt.resolve(t(i._value))}else if("rejected"===n&&"function"==typeof e)return e(),i;return r.call(i,t,e)}}return i}function Dt(t){function e(t){return new bt(function(e){var i=function(){bt.resolve(t()).then(e).then(function(){n.shift(),n.length&&n[0]()})};n.push(i),1===n.length&&i()})}var n=[];this.add="number"==typeof t?at(e,t):e,this.addQuickly=e}function Tt(t,e){return!t&&!e||!(!t||!e)&&(t.component===e.component&&Ct(t,e)&&Ct(e,t))}function Ct(t,e){for(var n in t)if(!/^(component|left|right|top|bottom)$/.test(n)&&t[n]!==e[n])return!1;return!0}function Ht(t){return{start:t.start.clone(),end:t.end?t.end.clone():null,allDay:t.allDay}}function Rt(t){var e=It(t);return"background"===e||"inverse-background"===e}function xt(t){return"inverse-background"===It(t)}function It(t){return J((t.source||{}).rendering,t.rendering)}function kt(t){var e,n,i={};for(e=0;e=t.leftCol)return!0;return!1}function zt(t,e){return t.leftCol-e.leftCol}function Ft(t){var e,n,i,r=[];for(e=0;ee.top&&t.top"),g.append(o("left")).append(o("right")).append(o("center")).append('
')):s()}function s(){g&&(g.remove(),g=f.el=null)}function o(i){var r=t('
'),s=n.layout[i];return s&&t.each(s.split(" "),function(n){var i,s=t(),o=!0;t.each(this.split(","),function(n,i){var r,l,a,u,c,d,h,f,g,m;"title"==i?(s=s.add(t(" ")),o=!1):((r=(e.options.customButtons||{})[i])?(a=function(t){r.click&&r.click.call(m[0],t)},u="",c=r.text):(l=e.getViewSpec(i))?(a=function(){e.changeView(i)},v.push(i),u=l.buttonTextOverride,c=l.buttonTextDefault):e[i]&&(a=function(){e[i]()},u=(e.overrides.buttonText||{})[i],c=e.options.buttonText[i]),a&&(d=r?r.themeIcon:e.options.themeButtonIcons[i],h=r?r.icon:e.options.buttonIcons[i],f=u?tt(u):d&&e.options.theme?" ":h&&!e.options.theme?" ":tt(c),g=["fc-"+i+"-button",p+"-button",p+"-state-default"],m=t(''+f+" ").click(function(t){m.hasClass(p+"-state-disabled")||(a(t),(m.hasClass(p+"-state-active")||m.hasClass(p+"-state-disabled"))&&m.removeClass(p+"-state-hover"))}).mousedown(function(){m.not("."+p+"-state-active").not("."+p+"-state-disabled").addClass(p+"-state-down")}).mouseup(function(){m.removeClass(p+"-state-down")}).hover(function(){m.not("."+p+"-state-active").not("."+p+"-state-disabled").addClass(p+"-state-hover")},function(){m.removeClass(p+"-state-hover").removeClass(p+"-state-down")}),s=s.add(m)))}),o&&s.first().addClass(p+"-corner-left").end().last().addClass(p+"-corner-right").end(),s.length>1?(i=t("
"),o&&i.addClass("fc-button-group"),i.append(s),r.append(i)):r.append(s)}),r}function l(t){g&&g.find("h2").text(t)}function a(t){g&&g.find(".fc-"+t+"-button").addClass(p+"-state-active")}function u(t){g&&g.find(".fc-"+t+"-button").removeClass(p+"-state-active")}function c(t){g&&g.find(".fc-"+t+"-button").prop("disabled",!0).addClass(p+"-state-disabled")}function d(t){g&&g.find(".fc-"+t+"-button").prop("disabled",!1).removeClass(p+"-state-disabled")}function h(){return v}var f=this;f.setToolbarOptions=i,f.render=r,f.removeElement=s,f.updateTitle=l,f.activateButton=a,f.deactivateButton=u,f.disableButton=c,f.enableButton=d,f.getViewsWithButtons=h,f.el=null;var g,p,v=[]}function _t(n,i){function r(t){t._locale=Y}function s(){q?a()&&(f(),u()):o()}function o(){n.addClass("fc"),n.on("click.fc","a[data-goto]",function(e){var n=t(this),i=n.data("goto"),r=_.moment(i.date),s=i.type,o=Q.opt("navLink"+rt(s)+"Click");"function"==typeof o?o(r,e):("string"==typeof o&&(s=o),B(r,s))}),_.bindOption("theme",function(t){$=t?"ui":"fc",n.toggleClass("ui-widget",t),n.toggleClass("fc-unthemed",!t)}),_.bindOptions(["isRTL","locale"],function(t){n.toggleClass("fc-ltr",!t),n.toggleClass("fc-rtl",t)}),q=t("
").prependTo(n);var e=y();W=new Vt(e),U=_.header=e[0],j=_.footer=e[1],E(),b(),u(_.options.defaultView),_.options.handleWindowResize&&(K=at(v,_.options.windowResizeDelay),t(window).resize(K))}function l(){Q&&Q.removeElement(),W.proxyCall("removeElement"),q.remove(),n.removeClass("fc fc-ltr fc-rtl fc-unthemed ui-widget"),n.off(".fc"),K&&t(window).unbind("resize",K)}function a(){return n.is(":visible")}function u(e,n){nt++;var i=Q&&e&&Q.type!==e;i&&(F(),c()),!Q&&e&&(Q=_.view=et[e]||(et[e]=_.instantiateView(e)),Q.setElement(t("
").appendTo(q)),W.proxyCall("activateButton",e)),Q&&(J=Q.massageCurrentDate(J),Q.isDateSet&&J>=Q.intervalStart&&J=Q.intervalStart&&tq&&i.push(n);return i}function s(t,e){return!q||tZ}function o(t,e){return q=t,Z=e,l()}function l(){return u(tt,"reset")}function a(t){return u(E(t))}function u(t,e){var n,i;for("reset"===e?nt=[]:"add"!==e&&(nt=C(nt,t)),n=0;nr.value)&&(r=i));return r?r.unit:null},qt.Class=St,St.extend=function(){var t,e,n=arguments.length;for(t=0;t ').addClass(n.className||"").css({top:0,left:0}).append(n.content).appendTo(n.parentEl),this.el.on("click",".fc-close",function(){e.hide()}),n.autoHide&&this.listenTo(t(document),"mousedown",this.documentMousedown)},documentMousedown:function(e){this.el&&!t(e.target).closest(this.el).length&&this.hide()},removeElement:function(){this.hide(),this.el&&(this.el.remove(),this.el=null),this.stopListeningTo(t(document),"mousedown")},position:function(){var e,n,i,r,s,o=this.options,l=this.el.offsetParent().offset(),a=this.el.outerWidth(),u=this.el.outerHeight(),c=t(window),h=d(this.el);r=o.top||0,s=void 0!==o.left?o.left:void 0!==o.right?o.right-a:0,h.is(window)||h.is(document)?(h=c,e=0,n=0):(i=h.offset(),e=i.top,n=i.left),e+=c.scrollTop(),n+=c.scrollLeft(),o.viewportConstrain!==!1&&(r=Math.min(r,e+h.outerHeight()-u-this.margin),r=Math.max(r,e+this.margin),s=Math.min(s,n+h.outerWidth()-a-this.margin),s=Math.max(s,n+this.margin)),this.el.css({top:r-l.top,left:s-l.left})},trigger:function(t){this.options[t]&&this.options[t].apply(this,Array.prototype.slice.call(arguments,1))}}),fe=qt.CoordCache=St.extend({els:null,forcedOffsetParentEl:null,origin:null,boundingRect:null,isHorizontal:!1,isVertical:!1,lefts:null,rights:null,tops:null,bottoms:null,constructor:function(e){this.els=t(e.els),this.isHorizontal=e.isHorizontal,this.isVertical=e.isVertical,this.forcedOffsetParentEl=e.offsetParent?t(e.offsetParent):null},build:function(){var t=this.forcedOffsetParentEl;!t&&this.els.length>0&&(t=this.els.eq(0).offsetParent()),this.origin=t?t.offset():null,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},ensureBuilt:function(){this.origin||this.build()},buildElHorizontals:function(){var e=[],n=[];this.els.each(function(i,r){var s=t(r),o=s.offset().left,l=s.outerWidth();e.push(o),n.push(o+l)}),this.lefts=e,this.rights=n},buildElVerticals:function(){var e=[],n=[];this.els.each(function(i,r){var s=t(r),o=s.offset().top,l=s.outerHeight();e.push(o),n.push(o+l)}),this.tops=e,this.bottoms=n},getHorizontalIndex:function(t){this.ensureBuilt();var e,n=this.lefts,i=this.rights,r=n.length;for(e=0;e=n[e]&&t=n[e]&&t0&&(t=d(this.els.eq(0)),!t.is(document))?f(t):null},isPointInBounds:function(t,e){return this.isLeftInBounds(t)&&this.isTopInBounds(e)},isLeftInBounds:function(t){return!this.boundingRect||t>=this.boundingRect.left&&t=this.boundingRect.top&&t=r*r&&this.handleDistanceSurpassed(t)),this.isDragging&&this.handleDrag(n,i,t)},handleDrag:function(t,e,n){this.trigger("drag",t,e,n),this.updateAutoScroll(n)},endDrag:function(t){this.isDragging&&(this.isDragging=!1,this.handleDragEnd(t))},handleDragEnd:function(t){this.trigger("dragEnd",t)},startDelay:function(t){var e=this;this.delay?this.delayTimeoutId=setTimeout(function(){e.handleDelayEnd(t)},this.delay):this.handleDelayEnd(t)},handleDelayEnd:function(t){this.isDelayEnded=!0,this.isDistanceSurpassed&&this.startDrag(t)},handleDistanceSurpassed:function(t){this.isDistanceSurpassed=!0,this.isDelayEnded&&this.startDrag(t)},handleTouchMove:function(t){this.isDragging&&t.preventDefault(),this.handleMove(t)},handleMouseMove:function(t){this.handleMove(t)},handleTouchScroll:function(t){this.isDragging||this.endInteraction(t,!0)},trigger:function(t){this.options[t]&&this.options[t].apply(this,Array.prototype.slice.call(arguments,1)),this["_"+t]&&this["_"+t].apply(this,Array.prototype.slice.call(arguments,1))}});ge.mixin({isAutoScroll:!1,scrollBounds:null,scrollTopVel:null,scrollLeftVel:null,scrollIntervalId:null,scrollSensitivity:30,scrollSpeed:200,scrollIntervalMs:50,initAutoScroll:function(){var t=this.scrollEl;this.isAutoScroll=this.options.scroll&&t&&!t.is(window)&&!t.is(document),this.isAutoScroll&&this.listenTo(t,"scroll",at(this.handleDebouncedScroll,100))},destroyAutoScroll:function(){this.endAutoScroll(),this.isAutoScroll&&this.stopListeningTo(this.scrollEl,"scroll")},computeScrollBounds:function(){this.isAutoScroll&&(this.scrollBounds=h(this.scrollEl))},updateAutoScroll:function(t){var e,n,i,r,s=this.scrollSensitivity,o=this.scrollBounds,l=0,a=0;o&&(e=(s-(E(t)-o.top))/s,n=(s-(o.bottom-E(t)))/s,i=(s-(w(t)-o.left))/s,r=(s-(o.right-w(t)))/s,e>=0&&e<=1?l=e*this.scrollSpeed*-1:n>=0&&n<=1&&(l=n*this.scrollSpeed),i>=0&&i<=1?a=i*this.scrollSpeed*-1:r>=0&&r<=1&&(a=r*this.scrollSpeed)),this.setScrollVel(l,a)},setScrollVel:function(t,e){this.scrollTopVel=t,this.scrollLeftVel=e,this.constrainScrollVel(),!this.scrollTopVel&&!this.scrollLeftVel||this.scrollIntervalId||(this.scrollIntervalId=setInterval(lt(this,"scrollIntervalFunc"),this.scrollIntervalMs))},constrainScrollVel:function(){var t=this.scrollEl;this.scrollTopVel<0?t.scrollTop()<=0&&(this.scrollTopVel=0):this.scrollTopVel>0&&t.scrollTop()+t[0].clientHeight>=t[0].scrollHeight&&(this.scrollTopVel=0),this.scrollLeftVel<0?t.scrollLeft()<=0&&(this.scrollLeftVel=0):this.scrollLeftVel>0&&t.scrollLeft()+t[0].clientWidth>=t[0].scrollWidth&&(this.scrollLeftVel=0)},scrollIntervalFunc:function(){var t=this.scrollEl,e=this.scrollIntervalMs/1e3;this.scrollTopVel&&t.scrollTop(t.scrollTop()+this.scrollTopVel*e),this.scrollLeftVel&&t.scrollLeft(t.scrollLeft()+this.scrollLeftVel*e),this.constrainScrollVel(),this.scrollTopVel||this.scrollLeftVel||this.endAutoScroll()},endAutoScroll:function(){this.scrollIntervalId&&(clearInterval(this.scrollIntervalId),this.scrollIntervalId=null,this.handleScrollEnd())},handleDebouncedScroll:function(){this.scrollIntervalId||this.handleScrollEnd()},handleScrollEnd:function(){}});var pe=ge.extend({component:null,origHit:null,hit:null,coordAdjust:null,constructor:function(t,e){ge.call(this,e),this.component=t},handleInteractionStart:function(t){var e,n,i,r=this.subjectEl;this.computeCoords(),t?(n={left:w(t),top:E(t)},i=n,r&&(e=h(r),i=x(i,e)),this.origHit=this.queryHit(i.left,i.top),r&&this.options.subjectCenter&&(this.origHit&&(e=R(this.origHit,e)||e),i=I(e)),this.coordAdjust=k(i,n)):(this.origHit=null,this.coordAdjust=null),ge.prototype.handleInteractionStart.apply(this,arguments)},computeCoords:function(){this.component.prepareHits(),this.computeScrollBounds()},handleDragStart:function(t){var e;ge.prototype.handleDragStart.apply(this,arguments),e=this.queryHit(w(t),E(t)),e&&this.handleHitOver(e)},handleDrag:function(t,e,n){var i;ge.prototype.handleDrag.apply(this,arguments),i=this.queryHit(w(n),E(n)),Tt(i,this.hit)||(this.hit&&this.handleHitOut(),i&&this.handleHitOver(i))},handleDragEnd:function(){this.handleHitDone(),ge.prototype.handleDragEnd.apply(this,arguments)},handleHitOver:function(t){var e=Tt(t,this.origHit);this.hit=t,this.trigger("hitOver",this.hit,e,this.origHit)},handleHitOut:function(){this.hit&&(this.trigger("hitOut",this.hit),this.handleHitDone(),this.hit=null)},handleHitDone:function(){this.hit&&this.trigger("hitDone",this.hit)},handleInteractionEnd:function(){ge.prototype.handleInteractionEnd.apply(this,arguments),this.origHit=null,this.hit=null,this.component.releaseHits()},handleScrollEnd:function(){ge.prototype.handleScrollEnd.apply(this,arguments),this.computeCoords()},queryHit:function(t,e){return this.coordAdjust&&(t+=this.coordAdjust.left,e+=this.coordAdjust.top),this.component.queryHit(t,e)}}),ve=St.extend(ce,{options:null,sourceEl:null,el:null,parentEl:null,top0:null,left0:null,y0:null,x0:null,topDelta:null,leftDelta:null,isFollowing:!1,isHidden:!1,isAnimating:!1,constructor:function(e,n){this.options=n=n||{},this.sourceEl=e,this.parentEl=n.parentEl?t(n.parentEl):e.parent()},start:function(e){this.isFollowing||(this.isFollowing=!0,this.y0=E(e),this.x0=w(e),this.topDelta=0,this.leftDelta=0,this.isHidden||this.updatePosition(),b(e)?this.listenTo(t(document),"touchmove",this.handleMove):this.listenTo(t(document),"mousemove",this.handleMove))},stop:function(e,n){function i(){r.isAnimating=!1,r.removeElement(),r.top0=r.left0=null,n&&n()}var r=this,s=this.options.revertDuration;this.isFollowing&&!this.isAnimating&&(this.isFollowing=!1,this.stopListeningTo(t(document)),e&&s&&!this.isHidden?(this.isAnimating=!0,this.el.animate({top:this.top0,left:this.left0},{duration:s,complete:i})):i())},getEl:function(){var t=this.el;return t||(t=this.el=this.sourceEl.clone().addClass(this.options.additionalClass||"").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}),t.addClass("fc-unselectable"),t.appendTo(this.parentEl)),t},removeElement:function(){this.el&&(this.el.remove(),this.el=null)},updatePosition:function(){var t,e;this.getEl(),null===this.top0&&(t=this.sourceEl.offset(),e=this.el.offsetParent().offset(),this.top0=t.top-e.top,this.left0=t.left-e.left),this.el.css({top:this.top0+this.topDelta,left:this.left0+this.leftDelta})},handleMove:function(t){this.topDelta=E(t)-this.y0,this.leftDelta=w(t)-this.x0,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())}}),me=qt.Grid=St.extend(ce,de,{hasDayInteractions:!0,view:null,isRTL:null,start:null,end:null,el:null,elsByFill:null,eventTimeFormat:null,displayEventTime:null,displayEventEnd:null,minResizeDuration:null,largeUnit:null,dayDragListener:null,segDragListener:null,segResizeListener:null,externalDragListener:null,constructor:function(t){this.view=t,this.isRTL=t.opt("isRTL"),this.elsByFill={},this.dayDragListener=this.buildDayDragListener(),this.initMouseIgnoring()},computeEventTimeFormat:function(){return this.view.opt("smallTimeFormat")},computeDisplayEventTime:function(){return!0},computeDisplayEventEnd:function(){return!0},setRange:function(t){this.start=t.start.clone(),this.end=t.end.clone(),this.rangeUpdated(),this.processRangeOptions()},rangeUpdated:function(){},processRangeOptions:function(){var t,e,n=this.view;this.eventTimeFormat=n.opt("eventTimeFormat")||n.opt("timeFormat")||this.computeEventTimeFormat(),t=n.opt("displayEventTime"),null==t&&(t=this.computeDisplayEventTime()),e=n.opt("displayEventEnd"),null==e&&(e=this.computeDisplayEventEnd()),this.displayEventTime=t,this.displayEventEnd=e},spanToSegs:function(t){},diffDates:function(t,e){return this.largeUnit?O(t,e,this.largeUnit):N(t,e)},prepareHits:function(){},releaseHits:function(){},queryHit:function(t,e){},getHitSpan:function(t){},getHitEl:function(t){},setElement:function(t){this.el=t,this.hasDayInteractions&&(D(t),this.bindDayHandler("touchstart",this.dayTouchStart),this.bindDayHandler("mousedown",this.dayMousedown)),this.bindSegHandlers(),this.bindGlobalHandlers()},bindDayHandler:function(e,n){var i=this;this.el.on(e,function(e){if(!t(e.target).is(i.segSelector+","+i.segSelector+" *,.fc-more,a[data-goto]"))return n.call(i,e)})},removeElement:function(){this.unbindGlobalHandlers(),this.clearDragListeners(),this.el.remove()},renderSkeleton:function(){},renderDates:function(){},unrenderDates:function(){},bindGlobalHandlers:function(){this.listenTo(t(document),{dragstart:this.externalDragStart,sortstart:this.externalDragStart})},unbindGlobalHandlers:function(){this.stopListeningTo(t(document))},dayMousedown:function(t){this.isIgnoringMouse||this.dayDragListener.startInteraction(t,{})},dayTouchStart:function(t){var e=this.view,n=e.opt("selectLongPressDelay");(e.isSelected||e.selectedEvent)&&this.tempIgnoreMouse(),null==n&&(n=e.opt("longPressDelay")),this.dayDragListener.startInteraction(t,{delay:n})},buildDayDragListener:function(){var t,e,n=this,i=this.view,r=i.opt("selectable"),l=new pe(this,{scroll:i.opt("dragScroll"),interactionStart:function(){t=l.origHit,e=null},dragStart:function(){i.unselect()},hitOver:function(i,o,l){l&&(o||(t=null),r&&(e=n.computeSelection(n.getHitSpan(l),n.getHitSpan(i)),e?n.renderSelection(e):e===!1&&s()))},hitOut:function(){t=null,e=null,n.unrenderSelection()},hitDone:function(){o()},interactionEnd:function(r,s){s||(t&&!n.isIgnoringMouse&&i.triggerDayClick(n.getHitSpan(t),n.getHitEl(t),r),e&&i.reportSelection(e,r))}});return l},clearDragListeners:function(){this.dayDragListener.endInteraction(),this.segDragListener&&this.segDragListener.endInteraction(),this.segResizeListener&&this.segResizeListener.endInteraction(),this.externalDragListener&&this.externalDragListener.endInteraction()},renderEventLocationHelper:function(t,e){var n=this.fabricateHelperEvent(t,e);return this.renderHelper(n,e)},fabricateHelperEvent:function(t,e){var n=e?Z(e.event):{};return n.start=t.start.clone(),n.end=t.end?t.end.clone():null,n.allDay=null,this.view.calendar.normalizeEventDates(n),n.className=(n.className||[]).concat("fc-helper"),e||(n.editable=!1),n},renderHelper:function(t,e){},unrenderHelper:function(){},renderSelection:function(t){this.renderHighlight(t)},unrenderSelection:function(){this.unrenderHighlight()},computeSelection:function(t,e){var n=this.computeSelectionSpan(t,e);return!(n&&!this.view.calendar.isSelectionSpanAllowed(n))&&n},computeSelectionSpan:function(t,e){var n=[t.start,t.end,e.start,e.end];return n.sort(st),{start:n[0].clone(),end:n[3].clone()}},renderHighlight:function(t){this.renderFill("highlight",this.spanToSegs(t))},unrenderHighlight:function(){this.unrenderFill("highlight")},highlightSegClasses:function(){return["fc-highlight"]},renderBusinessHours:function(){},unrenderBusinessHours:function(){},getNowIndicatorUnit:function(){},renderNowIndicator:function(t){},unrenderNowIndicator:function(){},renderFill:function(t,e){},unrenderFill:function(t){var e=this.elsByFill[t];e&&(e.remove(),delete this.elsByFill[t])},renderFillSegEls:function(e,n){var i,r=this,s=this[e+"SegEl"],o="",l=[];if(n.length){for(i=0;i "},getDayClasses:function(t,e){var n=this.view,i=n.calendar.getNow(),r=["fc-"+Xt[t.day()]];return 1==n.intervalDuration.as("months")&&t.month()!=n.intervalStart.month()&&r.push("fc-other-month"),t.isSame(i,"day")?(r.push("fc-today"),e!==!0&&r.push(n.highlightStateClass)):t *",mousedOverSeg:null,isDraggingSeg:!1,isResizingSeg:!1,isDraggingExternal:!1,segs:null,renderEvents:function(t){var e,n=[],i=[];for(e=0;el&&o.push({start:l,end:n.start}),l=n.end;return l=e.length?e[e.length-1]+1:e[n]},computeColHeadFormat:function(){return this.rowCnt>1||this.colCnt>10?"ddd":this.colCnt>1?this.view.opt("dayOfMonthFormat"):"dddd"},sliceRangeByRow:function(t){var e,n,i,r,s,o=this.daysPerRow,l=this.view.computeDayRange(t),a=this.getDateDayIndex(l.start),u=this.getDateDayIndex(l.end.clone().subtract(1,"days")),c=[];for(e=0;e "},renderHeadIntroHtml:function(){return this.renderIntroHtml()},renderHeadTrHtml:function(){return" "+(this.isRTL?"":this.renderHeadIntroHtml())+this.renderHeadDateCellsHtml()+(this.isRTL?this.renderHeadIntroHtml():"")+" "},renderHeadDateCellsHtml:function(){var t,e,n=[];for(t=0;t1?' colspan="'+e+'"':"")+(n?" "+n:"")+">"+i.buildGotoAnchorHtml({date:t,forceOff:this.rowCnt>1||1===this.colCnt},tt(t.format(this.colHeadFormat)))+""},renderBgTrHtml:function(t){return""+(this.isRTL?"":this.renderBgIntroHtml(t))+this.renderBgCellsHtml(t)+(this.isRTL?this.renderBgIntroHtml(t):"")+" "},renderBgIntroHtml:function(t){return this.renderIntroHtml()},renderBgCellsHtml:function(t){var e,n,i=[];for(e=0;e "},renderIntroHtml:function(){},bookendCells:function(t){var e=this.renderIntroHtml();e&&(this.isRTL?t.append(e):t.prepend(e))}},Se=qt.DayGrid=me.extend(ye,{numbersVisible:!1,bottomCoordPadding:0,rowEls:null,cellEls:null,helperEls:null,rowCoordCache:null,colCoordCache:null,renderDates:function(t){var e,n,i=this.view,r=this.rowCnt,s=this.colCnt,o="";for(e=0;e'+this.renderBgTrHtml(t)+'
'+(this.numbersVisible?""+this.renderNumberTrHtml(t)+" ":"")+"
"},renderNumberTrHtml:function(t){return""+(this.isRTL?"":this.renderNumberIntroHtml(t))+this.renderNumberCellsHtml(t)+(this.isRTL?this.renderNumberIntroHtml(t):"")+" "},renderNumberIntroHtml:function(t){return this.renderIntroHtml()},renderNumberCellsHtml:function(t){var e,n,i=[];for(e=0;e',this.view.cellWeekNumbersVisible&&t.day()==n&&(i+=this.view.buildGotoAnchorHtml({date:t,type:"week"},{class:"fc-week-number"},t.format("w"))),this.view.dayNumbersVisible&&(i+=this.view.buildGotoAnchorHtml(t,{class:"fc-day-number"},t.date())),i+=""):" "},computeEventTimeFormat:function(){return this.view.opt("extraSmallTimeFormat")},computeDisplayEventEnd:function(){return 1==this.colCnt},rangeUpdated:function(){this.updateDayTable()},spanToSegs:function(t){var e,n,i=this.sliceRangeByRow(t);for(e=0;e');o=n&&n.row===e?n.el.position().top:l.find(".fc-content-skeleton tbody").position().top,a.css("top",o).find("table").append(i[e].tbodyEl),l.append(a),r.push(a[0])}),this.helperEls=t(r)},unrenderHelper:function(){this.helperEls&&(this.helperEls.remove(),this.helperEls=null)},fillSegTag:"td",renderFill:function(e,n,i){var r,s,o,l=[];for(n=this.renderFillSegEls(e,n),r=0;r'),s=r.find("tr"),l>0&&s.append(' '),s.append(n.el.attr("colspan",a-l)),a '),this.bookendCells(s),r}});Se.mixin({rowStructs:null,unrenderEvents:function(){this.removeSegPopover(),me.prototype.unrenderEvents.apply(this,arguments)},getEventSegs:function(){return me.prototype.getEventSegs.call(this).concat(this.popoverSegs||[])},renderBgSegs:function(e){var n=t.grep(e,function(t){return t.event.allDay});return me.prototype.renderBgSegs.call(this,n)},renderFgSegs:function(e){var n;return e=this.renderFgSegEls(e),n=this.rowStructs=this.renderSegRows(e),this.rowEls.each(function(e,i){t(i).find(".fc-content-skeleton > table").append(n[e].tbodyEl)}),e},unrenderFgSegs:function(){for(var t,e=this.rowStructs||[];t=e.pop();)t.tbodyEl.remove();this.rowStructs=null},renderSegRows:function(t){var e,n,i=[];for(e=this.groupSegRows(t),n=0;n'+tt(n)+"")),i=''+(tt(s.title||"")||" ")+" ",''+(this.isRTL?i+" "+d:d+" "+i)+"
"+(l?'
':"")+(a?'
':"")+" "},renderSegRow:function(e,n){function i(e){for(;o "),l.append(c)),v[r][o]=c,m[r][o]=c,o++}var r,s,o,l,a,u,c,d=this.colCnt,h=this.buildSegLevels(n),f=Math.max(1,h.length),g=t(" "),p=[],v=[],m=[];for(r=0;r "),p.push([]),v.push([]),m.push([]),s)for(a=0;a ').append(u.el),u.leftCol!=u.rightCol?c.attr("colspan",u.rightCol-u.leftCol+1):m[r][o]=c;o<=u.rightCol;)v[r][o]=c,p[r][o]=u,o++;l.append(c)}i(d),this.bookendCells(l),g.append(l)}return{row:e,tbodyEl:g,cellMatrix:v,segMatrix:p,segLevels:h,segs:n}},buildSegLevels:function(t){var e,n,i,r=[];for(this.sortEventSegs(t),e=0;e td > :first-child").each(n),r.position().top+s>l)return i;return!1},limitRow:function(e,n){function i(i){for(;b ").append(y),h.append(m),E.push(m[0])),b++}var r,s,o,l,a,u,c,d,h,f,g,p,v,m,y,S=this,w=this.rowStructs[e],E=[],b=0;if(n&&n ').attr("rowspan",f),u=d[p],y=this.renderMoreLink(e,a.leftCol+p,[a].concat(u)),m=t("
").append(y),v.append(m),g.push(v[0]),E.push(v[0]);h.addClass("fc-limited").after(t(g)),o.push(h[0])}}i(this.colCnt),w.moreEls=t(E),w.limitedEls=t(o)}},unlimitRow:function(t){var e=this.rowStructs[t];e.moreEls&&(e.moreEls.remove(),e.moreEls=null),e.limitedEls&&(e.limitedEls.removeClass("fc-limited"),e.limitedEls=null)},renderMoreLink:function(e,n,i){var r=this,s=this.view;return t(' ').text(this.getMoreLinkText(i.length)).on("click",function(o){var l=s.opt("eventLimitClick"),a=r.getCellDate(e,n),u=t(this),c=r.getCellEl(e,n),d=r.getCellSegs(e,n),h=r.resliceDaySegs(d,a),f=r.resliceDaySegs(i,a);"function"==typeof l&&(l=s.publiclyTrigger("eventLimitClick",null,{date:a,dayEl:c,moreEl:u,segs:h,hiddenSegs:f},o)),"popover"===l?r.showSegPopover(e,n,u,h):"string"==typeof l&&s.calendar.zoomTo(a,l)})},showSegPopover:function(t,e,n,i){var r,s,o=this,l=this.view,a=n.parent();r=1==this.rowCnt?l.el:this.rowEls.eq(t),s={className:"fc-more-popover",content:this.renderSegPopoverContent(t,e,i),parentEl:this.view.el,top:r.offset().top,autoHide:!0,viewportConstrain:l.opt("popoverViewportConstrain"),hide:function(){if(o.popoverSegs)for(var t,e=0;e