/*!
FullCalendar Day Grid Plugin v4.4.0
Docs & License: https://fullcalendar.io/
(c) 2019 Adam Shaw
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
(global = global || self, factory(global.FullCalendarDayGrid = {}, global.FullCalendar));
}(this, function (exports, core) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var DayGridDateProfileGenerator = /** @class */ (function (_super) {
__extends(DayGridDateProfileGenerator, _super);
function DayGridDateProfileGenerator() {
return _super !== null && _super.apply(this, arguments) || this;
}
// Computes the date range that will be rendered.
DayGridDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
var dateEnv = this.dateEnv;
var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
var start = renderRange.start;
var end = renderRange.end;
var endOfWeek;
// year and month views should be aligned with weeks. this is already done for week
if (/^(year|month)$/.test(currentRangeUnit)) {
start = dateEnv.startOfWeek(start);
// make end-of-week if not already
endOfWeek = dateEnv.startOfWeek(end);
if (endOfWeek.valueOf() !== end.valueOf()) {
end = core.addWeeks(endOfWeek, 1);
}
}
// ensure 6 weeks
if (this.options.monthMode &&
this.options.fixedWeekCount) {
var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
core.diffWeeks(start, end));
end = core.addWeeks(end, 6 - rowCnt);
}
return { start: start, end: end };
};
return DayGridDateProfileGenerator;
}(core.DateProfileGenerator));
/* A rectangular panel that is absolutely positioned over other content
------------------------------------------------------------------------------------------------------------------------
Options:
- className (string)
- content (HTML string, element, or element array)
- 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 */ (function () {
function Popover(options) {
var _this = this;
this.isHidden = true;
this.margin = 10; // the space required between the popover and the edges of the scroll container
// Triggered when the user clicks *anywhere* in the document, for the autoHide feature
this.documentMousedown = function (ev) {
// only hide the popover if the click happened outside the popover
if (_this.el && !_this.el.contains(ev.target)) {
_this.hide();
}
};
this.options = options;
}
// Shows the popover on the specified position. Renders it if not already
Popover.prototype.show = function () {
if (this.isHidden) {
if (!this.el) {
this.render();
}
this.el.style.display = '';
this.position();
this.isHidden = false;
this.trigger('show');
}
};
// Hides the popover, through CSS, but does not remove it from the DOM
Popover.prototype.hide = function () {
if (!this.isHidden) {
this.el.style.display = 'none';
this.isHidden = true;
this.trigger('hide');
}
};
// Creates `this.el` and renders content inside of it
Popover.prototype.render = function () {
var _this = this;
var options = this.options;
var el = this.el = core.createElement('div', {
className: 'fc-popover ' + (options.className || ''),
style: {
top: '0',
left: '0'
}
});
if (typeof options.content === 'function') {
options.content(el);
}
options.parentEl.appendChild(el);
// when a click happens on anything inside with a 'fc-close' className, hide the popover
core.listenBySelector(el, 'click', '.fc-close', function (ev) {
_this.hide();
});
if (options.autoHide) {
document.addEventListener('mousedown', this.documentMousedown);
}
};
// Hides and unregisters any handlers
Popover.prototype.destroy = function () {
this.hide();
if (this.el) {
core.removeElement(this.el);
this.el = null;
}
document.removeEventListener('mousedown', this.documentMousedown);
};
// Positions the popover optimally, using the top/left/right options
Popover.prototype.position = function () {
var options = this.options;
var el = this.el;
var elDims = el.getBoundingClientRect(); // only used for width,height
var origin = core.computeRect(el.offsetParent);
var clippingRect = core.computeClippingRect(options.parentEl);
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 - elDims.width; // derive the left value from the right value
}
else {
left = 0;
}
// constrain to the view port. if constrained by two edges, give precedence to top/left
top = Math.min(top, clippingRect.bottom - elDims.height - this.margin);
top = Math.max(top, clippingRect.top + this.margin);
left = Math.min(left, clippingRect.right - elDims.width - this.margin);
left = Math.max(left, clippingRect.left + this.margin);
core.applyStyle(el, {
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
// can kill this???
Popover.prototype.trigger = function (name) {
if (this.options[name]) {
this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
}
};
return Popover;
}());
/* Event-rendering methods for the DayGrid class
----------------------------------------------------------------------------------------------------------------------*/
// "Simple" is bad a name. has nothing to do with SimpleDayGrid
var SimpleDayGridEventRenderer = /** @class */ (function (_super) {
__extends(SimpleDayGridEventRenderer, _super);
function SimpleDayGridEventRenderer() {
return _super !== null && _super.apply(this, arguments) || this;
}
// Builds the HTML to be used for the default element for an individual segment
SimpleDayGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) {
var context = this.context;
var eventRange = seg.eventRange;
var eventDef = eventRange.def;
var eventUi = eventRange.ui;
var allDay = eventDef.allDay;
var isDraggable = core.computeEventDraggable(context, eventDef, eventUi);
var isResizableFromStart = allDay && seg.isStart && core.computeEventStartResizable(context, eventDef, eventUi);
var isResizableFromEnd = allDay && seg.isEnd && core.computeEventEndResizable(context, eventDef, eventUi);
var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd, mirrorInfo);
var skinCss = core.cssToStr(this.getSkinCss(eventUi));
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.getTimeText(eventRange);
if (timeText) {
timeHtml = '' + core.htmlEscape(timeText) + '';
}
}
titleHtml =
'' +
(core.htmlEscape(eventDef.title || '') || ' ') + // we always want one line of height
'';
return '' +
'
' + ' |
' + ' |