diff options
author | Mario <mario@mariovavti.com> | 2020-06-15 08:19:13 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-06-15 08:19:13 +0000 |
commit | 56ec55110a27a13cc2c7d1fb09f1650f8c4cd842 (patch) | |
tree | 1ed6199b0d09b232b3ba5dce28a0a0134242df55 /library/fullcalendar/packages/daygrid/main.js | |
parent | 570497071d7dc231be6ab0eee951c22f1ad05df2 (diff) | |
download | volse-hubzilla-56ec55110a27a13cc2c7d1fb09f1650f8c4cd842.tar.gz volse-hubzilla-56ec55110a27a13cc2c7d1fb09f1650f8c4cd842.tar.bz2 volse-hubzilla-56ec55110a27a13cc2c7d1fb09f1650f8c4cd842.zip |
update fullcalendar to version 4.4.2
Diffstat (limited to 'library/fullcalendar/packages/daygrid/main.js')
-rw-r--r-- | library/fullcalendar/packages/daygrid/main.js | 369 |
1 files changed, 204 insertions, 165 deletions
diff --git a/library/fullcalendar/packages/daygrid/main.js b/library/fullcalendar/packages/daygrid/main.js index e41463eb9..8ccdef25d 100644 --- a/library/fullcalendar/packages/daygrid/main.js +++ b/library/fullcalendar/packages/daygrid/main.js @@ -1,8 +1,9 @@ /*! -FullCalendar Day Grid Plugin v4.0.2 +FullCalendar Day Grid Plugin v4.4.2 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) : @@ -10,18 +11,18 @@ Docs & License: https://fullcalendar.io/ }(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
+ Copyright (c) Microsoft Corporation.
- 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.
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
@@ -213,14 +214,14 @@ Docs & License: https://fullcalendar.io/ } // Builds the HTML to be used for the default element for an individual segment SimpleDayGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) { - var options = this.context.options; + var context = this.context; var eventRange = seg.eventRange; var eventDef = eventRange.def; var eventUi = eventRange.ui; var allDay = eventDef.allDay; - var isDraggable = eventUi.startEditable; - var isResizableFromStart = allDay && seg.isStart && eventUi.durationEditable && options.eventResizableFromStart; - var isResizableFromEnd = allDay && seg.isEnd && eventUi.durationEditable; + 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 = ''; @@ -247,7 +248,7 @@ Docs & License: https://fullcalendar.io/ '') + '>' + '<div class="fc-content">' + - (options.dir === 'rtl' ? + (context.options.dir === 'rtl' ? titleHtml + ' ' + timeHtml : // put a natural space in between timeHtml + ' ' + titleHtml // ) + @@ -280,7 +281,7 @@ Docs & License: https://fullcalendar.io/ var DayGridEventRenderer = /** @class */ (function (_super) { __extends(DayGridEventRenderer, _super); function DayGridEventRenderer(dayGrid) { - var _this = _super.call(this, dayGrid.context) || this; + var _this = _super.call(this) || this; _this.dayGrid = dayGrid; return _this; } @@ -323,8 +324,9 @@ Docs & License: https://fullcalendar.io/ // the segments. Returns object with a bunch of internal data about how the render was calculated. // NOTE: modifies rowSegs DayGridEventRenderer.prototype.renderSegRow = function (row, rowSegs) { + var isRtl = this.context.isRtl; var dayGrid = this.dayGrid; - var colCnt = dayGrid.colCnt, isRtl = dayGrid.isRtl; + var colCnt = dayGrid.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 = document.createElement('tbody'); @@ -389,7 +391,7 @@ Docs & License: https://fullcalendar.io/ emptyCellsUntil(colCnt); // finish off the row var introHtml = dayGrid.renderProps.renderIntroHtml(); if (introHtml) { - if (dayGrid.isRtl) { + if (isRtl) { core.appendToElement(tr, introHtml); } else { @@ -410,7 +412,8 @@ Docs & License: https://fullcalendar.io/ // Stacks a flat array of segments, which are all assumed to be in the same row, into subarrays of vertical levels. // NOTE: modifies segs DayGridEventRenderer.prototype.buildSegLevels = function (segs) { - var _a = this.dayGrid, isRtl = _a.isRtl, colCnt = _a.colCnt; + var isRtl = this.context.isRtl; + var colCnt = this.dayGrid.colCnt; var levels = []; var i; var seg; @@ -508,22 +511,23 @@ Docs & License: https://fullcalendar.io/ return DayGridMirrorRenderer; }(DayGridEventRenderer)); + var EMPTY_CELL_HTML = '<td style="pointer-events:none"></td>'; var DayGridFillRenderer = /** @class */ (function (_super) { __extends(DayGridFillRenderer, _super); function DayGridFillRenderer(dayGrid) { - var _this = _super.call(this, dayGrid.context) || this; + var _this = _super.call(this) || this; _this.fillSegTag = 'td'; // override the default tag name _this.dayGrid = dayGrid; return _this; } - DayGridFillRenderer.prototype.renderSegs = function (type, segs) { + DayGridFillRenderer.prototype.renderSegs = function (type, context, segs) { // don't render timed background events if (type === 'bgEvent') { segs = segs.filter(function (seg) { return seg.eventRange.def.allDay; }); } - _super.prototype.renderSegs.call(this, type, segs); + _super.prototype.renderSegs.call(this, type, context, segs); }; DayGridFillRenderer.prototype.attachSegs = function (type, segs) { var els = []; @@ -541,7 +545,8 @@ Docs & License: https://fullcalendar.io/ // Generates the HTML needed for one row of a fill. Requires the seg's el to be rendered. DayGridFillRenderer.prototype.renderFillRow = function (type, seg) { var dayGrid = this.dayGrid; - var colCnt = dayGrid.colCnt, isRtl = dayGrid.isRtl; + var isRtl = this.context.isRtl; + var colCnt = dayGrid.colCnt; var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol; var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol; var startCol = leftCol; @@ -562,18 +567,18 @@ Docs & License: https://fullcalendar.io/ if (startCol > 0) { core.appendToElement(trEl, // will create (startCol + 1) td's - new Array(startCol + 1).join('<td></td>')); + new Array(startCol + 1).join(EMPTY_CELL_HTML)); } seg.el.colSpan = endCol - startCol; trEl.appendChild(seg.el); if (endCol < colCnt) { core.appendToElement(trEl, // will create (colCnt - endCol) td's - new Array(colCnt - endCol + 1).join('<td></td>')); + new Array(colCnt - endCol + 1).join(EMPTY_CELL_HTML)); } var introHtml = dayGrid.renderProps.renderIntroHtml(); if (introHtml) { - if (dayGrid.isRtl) { + if (isRtl) { core.appendToElement(trEl, introHtml); } else { @@ -587,23 +592,25 @@ Docs & License: https://fullcalendar.io/ var DayTile = /** @class */ (function (_super) { __extends(DayTile, _super); - function DayTile(context, el) { - var _this = _super.call(this, context, el) || this; + function DayTile(el) { + var _this = _super.call(this, el) || this; var eventRenderer = _this.eventRenderer = new DayTileEventRenderer(_this); var renderFrame = _this.renderFrame = core.memoizeRendering(_this._renderFrame); _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderFrame]); _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]); _this.renderEventDrag = core.memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]); _this.renderEventResize = core.memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]); - context.calendar.registerInteractiveComponent(_this, { - el: _this.el, - useEventCenter: false - }); return _this; } - DayTile.prototype.render = function (props) { + DayTile.prototype.firstContext = function (context) { + context.calendar.registerInteractiveComponent(this, { + el: this.el, + useEventCenter: false + }); + }; + DayTile.prototype.render = function (props, context) { this.renderFrame(props.date); - this.renderFgEvents(props.fgSegs); + this.renderFgEvents(context, props.fgSegs); this.renderEventSelection(props.eventSelection); this.renderEventDrag(props.eventDragInstances); this.renderEventResize(props.eventResizeInstances); @@ -611,11 +618,11 @@ Docs & License: https://fullcalendar.io/ DayTile.prototype.destroy = function () { _super.prototype.destroy.call(this); this.renderFrame.unrender(); // should unrender everything else - this.calendar.unregisterInteractiveComponent(this); + this.context.calendar.unregisterInteractiveComponent(this); }; DayTile.prototype._renderFrame = function (date) { - var _a = this, theme = _a.theme, dateEnv = _a.dateEnv; - var title = dateEnv.format(date, core.createFormatter(this.opt('dayPopoverFormat')) // TODO: cache + var _a = this.context, theme = _a.theme, dateEnv = _a.dateEnv, options = _a.options; + var title = dateEnv.format(date, core.createFormatter(options.dayPopoverFormat) // TODO: cache ); this.el.innerHTML = '<div class="fc-header ' + theme.getClass('popoverHeader') + '">' + @@ -654,7 +661,7 @@ Docs & License: https://fullcalendar.io/ var DayTileEventRenderer = /** @class */ (function (_super) { __extends(DayTileEventRenderer, _super); function DayTileEventRenderer(dayTile) { - var _this = _super.call(this, dayTile.context) || this; + var _this = _super.call(this) || this; _this.dayTile = dayTile; return _this; } @@ -715,10 +722,11 @@ Docs & License: https://fullcalendar.io/ var WEEK_NUM_FORMAT = core.createFormatter({ week: 'numeric' }); var DayGrid = /** @class */ (function (_super) { __extends(DayGrid, _super); - function DayGrid(context, el, renderProps) { - var _this = _super.call(this, context, el) || this; + function DayGrid(el, renderProps) { + var _this = _super.call(this, el) || this; _this.bottomCoordPadding = 0; // hack for extending the hit area for the last row of the coordinate grid _this.isCellSizesDirty = false; + _this.renderProps = renderProps; var eventRenderer = _this.eventRenderer = new DayGridEventRenderer(_this); var fillRenderer = _this.fillRenderer = new DayGridFillRenderer(_this); _this.mirrorRenderer = new DayGridMirrorRenderer(_this); @@ -730,18 +738,17 @@ Docs & License: https://fullcalendar.io/ _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]); _this.renderEventDrag = core.memoizeRendering(_this._renderEventDrag, _this._unrenderEventDrag, [renderCells]); _this.renderEventResize = core.memoizeRendering(_this._renderEventResize, _this._unrenderEventResize, [renderCells]); - _this.renderProps = renderProps; return _this; } - DayGrid.prototype.render = function (props) { + DayGrid.prototype.render = function (props, context) { var cells = props.cells; this.rowCnt = cells.length; this.colCnt = cells[0].length; this.renderCells(cells, props.isRigid); - this.renderBusinessHours(props.businessHourSegs); - this.renderDateSelection(props.dateSelectionSegs); - this.renderBgEvents(props.bgEventSegs); - this.renderFgEvents(props.fgEventSegs); + this.renderBusinessHours(context, props.businessHourSegs); + this.renderDateSelection(context, props.dateSelectionSegs); + this.renderBgEvents(context, props.bgEventSegs); + this.renderFgEvents(context, props.fgEventSegs); this.renderEventSelection(props.eventSelection); this.renderEventDrag(props.eventDrag); this.renderEventResize(props.eventResize); @@ -766,12 +773,12 @@ Docs & License: https://fullcalendar.io/ eventSelection: ownProps.eventSelection, eventDragInstances: ownProps.eventDrag ? ownProps.eventDrag.affectedInstances : null, eventResizeInstances: ownProps.eventResize ? ownProps.eventResize.affectedInstances : null - }); + }, this.context); }; /* Date Rendering ------------------------------------------------------------------------------------------------------------------*/ DayGrid.prototype._renderCells = function (cells, isRigid) { - var _a = this, view = _a.view, dateEnv = _a.dateEnv; + var _a = this.context, calendar = _a.calendar, view = _a.view, isRtl = _a.isRtl, dateEnv = _a.dateEnv; var _b = this, rowCnt = _b.rowCnt, colCnt = _b.colCnt; var html = ''; var row; @@ -782,7 +789,7 @@ Docs & License: https://fullcalendar.io/ this.el.innerHTML = html; this.rowEls = core.findElements(this.el, '.fc-row'); this.cellEls = core.findElements(this.el, '.fc-day, .fc-disabled-day'); - if (this.isRtl) { + if (isRtl) { this.cellEls.reverse(); } this.rowPositions = new core.PositionCache(this.el, this.rowEls, false, true // vertical @@ -793,7 +800,7 @@ Docs & License: https://fullcalendar.io/ // trigger dayRender with each cell's element for (row = 0; row < rowCnt; row++) { for (col = 0; col < colCnt; col++) { - this.publiclyTrigger('dayRender', [ + calendar.publiclyTrigger('dayRender', [ { date: dateEnv.toDate(cells[row][col].date), el: this.getCellEl(row, col), @@ -810,7 +817,7 @@ Docs & License: https://fullcalendar.io/ // Generates the HTML for a single row, which is a div that wraps a table. // `row` is the row number. DayGrid.prototype.renderDayRowHtml = function (row, isRigid) { - var theme = this.theme; + var theme = this.context.theme; var classes = ['fc-row', 'fc-week', theme.getClass('dayRow')]; if (isRigid) { classes.push('fc-rigid'); @@ -849,12 +856,13 @@ Docs & License: https://fullcalendar.io/ /* Grid Number Rendering ------------------------------------------------------------------------------------------------------------------*/ DayGrid.prototype.renderNumberTrHtml = function (row) { + var isRtl = this.context.isRtl; var intro = this.renderProps.renderNumberIntroHtml(row, this); return '' + '<tr>' + - (this.isRtl ? '' : intro) + + (isRtl ? '' : intro) + this.renderNumberCellsHtml(row) + - (this.isRtl ? intro : '') + + (isRtl ? intro : '') + '</tr>'; }; DayGrid.prototype.renderNumberCellsHtml = function (row) { @@ -865,7 +873,7 @@ Docs & License: https://fullcalendar.io/ date = this.props.cells[row][col].date; htmls.push(this.renderNumberCellHtml(date)); } - if (this.isRtl) { + if (this.context.isRtl) { htmls.reverse(); } return htmls.join(''); @@ -873,7 +881,7 @@ Docs & License: https://fullcalendar.io/ // Generates the HTML for the <td>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. DayGrid.prototype.renderNumberCellHtml = function (date) { - var _a = this, view = _a.view, dateEnv = _a.dateEnv; + var _a = this.context, dateEnv = _a.dateEnv, options = _a.options; var html = ''; var isDateValid = core.rangeContainsMarker(this.props.dateProfile.activeRange, date); // TODO: called too frequently. cache somehow. var isDayNumberVisible = this.getIsDayNumbersVisible() && isDateValid; @@ -894,11 +902,11 @@ Docs & License: https://fullcalendar.io/ '') + '>'; if (this.renderProps.cellWeekNumbersVisible && (date.getUTCDay() === weekCalcFirstDow)) { - html += core.buildGotoAnchorHtml(view, { date: date, type: 'week' }, { 'class': 'fc-week-number' }, dateEnv.format(date, WEEK_NUM_FORMAT) // inner HTML + html += core.buildGotoAnchorHtml(options, dateEnv, { date: date, type: 'week' }, { 'class': 'fc-week-number' }, dateEnv.format(date, WEEK_NUM_FORMAT) // inner HTML ); } if (isDayNumberVisible) { - html += core.buildGotoAnchorHtml(view, date, { 'class': 'fc-day-number' }, dateEnv.format(date, DAY_NUM_FORMAT) // inner HTML + html += core.buildGotoAnchorHtml(options, dateEnv, date, { 'class': 'fc-day-number' }, dateEnv.format(date, DAY_NUM_FORMAT) // inner HTML ); } html += '</td>'; @@ -907,10 +915,13 @@ Docs & License: https://fullcalendar.io/ /* Sizing ------------------------------------------------------------------------------------------------------------------*/ DayGrid.prototype.updateSize = function (isResize) { + var calendar = this.context.calendar; var _a = this, fillRenderer = _a.fillRenderer, eventRenderer = _a.eventRenderer, mirrorRenderer = _a.mirrorRenderer; - if (isResize || this.isCellSizesDirty) { - this.buildColPositions(); - this.buildRowPositions(); + if (isResize || + this.isCellSizesDirty || + calendar.isEventsUpdated // hack + ) { + this.buildPositionCaches(); this.isCellSizesDirty = false; } fillRenderer.computeSizes(isResize); @@ -920,6 +931,10 @@ Docs & License: https://fullcalendar.io/ eventRenderer.assignSizes(isResize); mirrorRenderer.assignSizes(isResize); }; + DayGrid.prototype.buildPositionCaches = function () { + this.buildColPositions(); + this.buildRowPositions(); + }; DayGrid.prototype.buildColPositions = function () { this.colPositions.build(); }; @@ -962,13 +977,13 @@ Docs & License: https://fullcalendar.io/ DayGrid.prototype._renderEventDrag = function (state) { if (state) { this.eventRenderer.hideByHash(state.affectedInstances); - this.fillRenderer.renderSegs('highlight', state.segs); + this.fillRenderer.renderSegs('highlight', this.context, state.segs); } }; DayGrid.prototype._unrenderEventDrag = function (state) { if (state) { this.eventRenderer.showByHash(state.affectedInstances); - this.fillRenderer.unrender('highlight'); + this.fillRenderer.unrender('highlight', this.context); } }; /* Event Resize Visualization @@ -976,15 +991,15 @@ Docs & License: https://fullcalendar.io/ DayGrid.prototype._renderEventResize = function (state) { if (state) { this.eventRenderer.hideByHash(state.affectedInstances); - this.fillRenderer.renderSegs('highlight', state.segs); - this.mirrorRenderer.renderSegs(state.segs, { isResizing: true, sourceSeg: state.sourceSeg }); + this.fillRenderer.renderSegs('highlight', this.context, state.segs); + this.mirrorRenderer.renderSegs(this.context, state.segs, { isResizing: true, sourceSeg: state.sourceSeg }); } }; DayGrid.prototype._unrenderEventResize = function (state) { if (state) { this.eventRenderer.showByHash(state.affectedInstances); - this.fillRenderer.unrender('highlight'); - this.mirrorRenderer.unrender(state.segs, { isResizing: true, sourceSeg: state.sourceSeg }); + this.fillRenderer.unrender('highlight', this.context); + this.mirrorRenderer.unrender(this.context, state.segs, { isResizing: true, sourceSeg: state.sourceSeg }); } }; /* More+ Link Popover @@ -1040,7 +1055,8 @@ Docs & License: https://fullcalendar.io/ // `levelLimit` is a number for the maximum (inclusive) number of levels allowed. DayGrid.prototype.limitRow = function (row, levelLimit) { var _this = this; - var _a = this, colCnt = _a.colCnt, isRtl = _a.isRtl; + var colCnt = this.colCnt; + var isRtl = this.context.isRtl; var rowStruct = this.eventRenderer.rowStructs[row]; var moreNodes = []; // array of "more" <a> links and <td> DOM nodes var col = 0; // col #, left-to-right (not chronologically) @@ -1068,7 +1084,7 @@ Docs & License: https://fullcalendar.io/ moreLink = _this.renderMoreLink(row, col, segsBelow); moreWrap = core.createElement('div', null, moreLink); td.appendChild(moreWrap); - moreNodes.push(moreWrap[0]); + moreNodes.push(moreWrap); } col++; } @@ -1139,12 +1155,12 @@ Docs & License: https://fullcalendar.io/ // Responsible for attaching click handler as well. DayGrid.prototype.renderMoreLink = function (row, col, hiddenSegs) { var _this = this; - var _a = this, view = _a.view, dateEnv = _a.dateEnv; + var _a = this.context, calendar = _a.calendar, view = _a.view, dateEnv = _a.dateEnv, options = _a.options, isRtl = _a.isRtl; var a = core.createElement('a', { className: 'fc-more' }); a.innerText = this.getMoreLinkText(hiddenSegs.length); a.addEventListener('click', function (ev) { - var clickOption = _this.opt('eventLimitClick'); - var _col = _this.isRtl ? _this.colCnt - col - 1 : col; // HACK: props.cells has different dir system? + var clickOption = options.eventLimitClick; + var _col = isRtl ? _this.colCnt - col - 1 : col; // HACK: props.cells has different dir system? var date = _this.props.cells[row][_col].date; var moreEl = ev.currentTarget; var dayEl = _this.getCellEl(row, col); @@ -1154,7 +1170,7 @@ Docs & License: https://fullcalendar.io/ var reslicedHiddenSegs = _this.resliceDaySegs(hiddenSegs, date); if (typeof clickOption === 'function') { // the returned value can be an atomic option - clickOption = _this.publiclyTrigger('eventLimitClick', [ + clickOption = calendar.publiclyTrigger('eventLimitClick', [ { date: dateEnv.toDate(date), allDay: true, @@ -1171,7 +1187,7 @@ Docs & License: https://fullcalendar.io/ _this.showSegPopover(row, col, moreEl, reslicedAllSegs); } else if (typeof clickOption === 'string') { // a view name - view.calendar.zoomTo(date, clickOption); + calendar.zoomTo(date, clickOption); } }); return a; @@ -1179,8 +1195,8 @@ Docs & License: https://fullcalendar.io/ // Reveals the popover that displays all events within a cell DayGrid.prototype.showSegPopover = function (row, col, moreLink, segs) { var _this = this; - var _a = this, calendar = _a.calendar, view = _a.view, theme = _a.theme; - var _col = this.isRtl ? this.colCnt - col - 1 : col; // HACK: props.cells has different dir system? + var _a = this.context, calendar = _a.calendar, view = _a.view, theme = _a.theme, isRtl = _a.isRtl; + var _col = isRtl ? this.colCnt - col - 1 : col; // HACK: props.cells has different dir system? var moreWrap = moreLink.parentNode; // the <div> wrapper around the <a> var topEl; // the element we want to match the top coordinate of var options; @@ -1196,7 +1212,7 @@ Docs & License: https://fullcalendar.io/ top: core.computeRect(topEl).top, autoHide: true, content: function (el) { - _this.segPopoverTile = new DayTile(_this.context, el); + _this.segPopoverTile = new DayTile(el); _this.updateSegPopoverTile(_this.props.cells[row][_col].date, segs); }, hide: function () { @@ -1208,7 +1224,7 @@ Docs & License: https://fullcalendar.io/ }; // Determine horizontal coordinate. // We use the moreWrap instead of the <td> to avoid border confusion. - if (this.isRtl) { + if (isRtl) { options.right = core.computeRect(moreWrap).right + 1; // +1 to be over cell border } else { @@ -1242,7 +1258,7 @@ Docs & License: https://fullcalendar.io/ }; // Generates the text that should be inside a "more" link, given the number of events it represents DayGrid.prototype.getMoreLinkText = function (num) { - var opt = this.opt('eventLimitText'); + var opt = this.context.options.eventLimitText; if (typeof opt === 'function') { return opt(num); } @@ -1274,20 +1290,22 @@ Docs & License: https://fullcalendar.io/ ----------------------------------------------------------------------------------------------------------------------*/ // It is a manager for a DayGrid subcomponent, which does most of the heavy lifting. // It is responsible for managing width/height. - var DayGridView = /** @class */ (function (_super) { - __extends(DayGridView, _super); - function DayGridView(context, viewSpec, dateProfileGenerator, parentEl) { - var _this = _super.call(this, context, viewSpec, dateProfileGenerator, parentEl) || this; + var AbstractDayGridView = /** @class */ (function (_super) { + __extends(AbstractDayGridView, _super); + function AbstractDayGridView() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.processOptions = core.memoize(_this._processOptions); + _this.renderSkeleton = core.memoizeRendering(_this._renderSkeleton, _this._unrenderSkeleton); /* Header Rendering ------------------------------------------------------------------------------------------------------------------*/ // Generates the HTML that will go before the day-of week header cells _this.renderHeadIntroHtml = function () { - var theme = _this.theme; + var _a = _this.context, theme = _a.theme, options = _a.options; if (_this.colWeekNumbersVisible) { return '' + '<th class="fc-week-number ' + theme.getClass('widgetHeader') + '" ' + _this.weekNumberStyleAttr() + '>' + '<span>' + // needed for matchCellWidths - core.htmlEscape(_this.opt('weekLabel')) + + core.htmlEscape(options.weekLabel) + '</span>' + '</th>'; } @@ -1297,13 +1315,13 @@ Docs & License: https://fullcalendar.io/ ------------------------------------------------------------------------------------------------------------------*/ // Generates the HTML that will go before content-skeleton cells that display the day/week numbers _this.renderDayGridNumberIntroHtml = function (row, dayGrid) { - var dateEnv = _this.dateEnv; + var _a = _this.context, options = _a.options, dateEnv = _a.dateEnv; var weekStart = dayGrid.props.cells[row][0].date; if (_this.colWeekNumbersVisible) { return '' + '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '>' + core.buildGotoAnchorHtml(// aside from link, important for matchCellWidths - _this, { date: weekStart, type: 'week', forceOff: dayGrid.colCnt === 1 }, dateEnv.format(weekStart, WEEK_NUM_FORMAT$1) // inner HTML + options, dateEnv, { date: weekStart, type: 'week', forceOff: dayGrid.colCnt === 1 }, dateEnv.format(weekStart, WEEK_NUM_FORMAT$1) // inner HTML ) + '</td>'; } @@ -1311,7 +1329,7 @@ Docs & License: https://fullcalendar.io/ }; // Generates the HTML that goes before the day bg cells for each day-row _this.renderDayGridBgIntroHtml = function () { - var theme = _this.theme; + var theme = _this.context.theme; if (_this.colWeekNumbersVisible) { return '<td class="fc-week-number ' + theme.getClass('widgetContent') + '" ' + _this.weekNumberStyleAttr() + '></td>'; } @@ -1325,52 +1343,64 @@ Docs & License: https://fullcalendar.io/ } return ''; }; - _this.el.classList.add('fc-dayGrid-view'); - _this.el.innerHTML = _this.renderSkeletonHtml(); - _this.scroller = new core.ScrollComponent('hidden', // overflow x - 'auto' // overflow y - ); - var dayGridContainerEl = _this.scroller.el; - _this.el.querySelector('.fc-body > tr > td').appendChild(dayGridContainerEl); - dayGridContainerEl.classList.add('fc-day-grid-container'); - var dayGridEl = core.createElement('div', { className: 'fc-day-grid' }); - dayGridContainerEl.appendChild(dayGridEl); - var cellWeekNumbersVisible; - if (_this.opt('weekNumbers')) { - if (_this.opt('weekNumbersWithinDays')) { - cellWeekNumbersVisible = true; - _this.colWeekNumbersVisible = false; + return _this; + } + AbstractDayGridView.prototype._processOptions = function (options) { + if (options.weekNumbers) { + if (options.weekNumbersWithinDays) { + this.cellWeekNumbersVisible = true; + this.colWeekNumbersVisible = false; } else { - cellWeekNumbersVisible = false; - _this.colWeekNumbersVisible = true; + this.cellWeekNumbersVisible = false; + this.colWeekNumbersVisible = true; } } else { - _this.colWeekNumbersVisible = false; - cellWeekNumbersVisible = false; - } - _this.dayGrid = new DayGrid(_this.context, dayGridEl, { - renderNumberIntroHtml: _this.renderDayGridNumberIntroHtml, - renderBgIntroHtml: _this.renderDayGridBgIntroHtml, - renderIntroHtml: _this.renderDayGridIntroHtml, - colWeekNumbersVisible: _this.colWeekNumbersVisible, - cellWeekNumbersVisible: cellWeekNumbersVisible - }); - return _this; - } - DayGridView.prototype.destroy = function () { + this.colWeekNumbersVisible = false; + this.cellWeekNumbersVisible = false; + } + }; + AbstractDayGridView.prototype.render = function (props, context) { + _super.prototype.render.call(this, props, context); + this.processOptions(context.options); + this.renderSkeleton(context); + }; + AbstractDayGridView.prototype.destroy = function () { _super.prototype.destroy.call(this); + this.renderSkeleton.unrender(); + }; + AbstractDayGridView.prototype._renderSkeleton = function (context) { + this.el.classList.add('fc-dayGrid-view'); + this.el.innerHTML = this.renderSkeletonHtml(); + this.scroller = new core.ScrollComponent('hidden', // overflow x + 'auto' // overflow y + ); + var dayGridContainerEl = this.scroller.el; + this.el.querySelector('.fc-body > tr > td').appendChild(dayGridContainerEl); + dayGridContainerEl.classList.add('fc-day-grid-container'); + var dayGridEl = core.createElement('div', { className: 'fc-day-grid' }); + dayGridContainerEl.appendChild(dayGridEl); + this.dayGrid = new DayGrid(dayGridEl, { + renderNumberIntroHtml: this.renderDayGridNumberIntroHtml, + renderBgIntroHtml: this.renderDayGridBgIntroHtml, + renderIntroHtml: this.renderDayGridIntroHtml, + colWeekNumbersVisible: this.colWeekNumbersVisible, + cellWeekNumbersVisible: this.cellWeekNumbersVisible + }); + }; + AbstractDayGridView.prototype._unrenderSkeleton = function () { + this.el.classList.remove('fc-dayGrid-view'); this.dayGrid.destroy(); this.scroller.destroy(); }; // Builds the HTML skeleton for the view. // The day-grid component will render inside of a container defined by this HTML. - DayGridView.prototype.renderSkeletonHtml = function () { - var theme = this.theme; + AbstractDayGridView.prototype.renderSkeletonHtml = function () { + var _a = this.context, theme = _a.theme, options = _a.options; return '' + '<table class="' + theme.getClass('tableGrid') + '">' + - (this.opt('columnHeader') ? + (options.columnHeader ? '<thead class="fc-head">' + '<tr>' + '<td class="fc-head-container ' + theme.getClass('widgetHeader') + '"> </td>' + @@ -1385,27 +1415,27 @@ Docs & License: https://fullcalendar.io/ '</table>'; }; // Generates an HTML attribute string for setting the width of the week number column, if it is known - DayGridView.prototype.weekNumberStyleAttr = function () { + AbstractDayGridView.prototype.weekNumberStyleAttr = function () { if (this.weekNumberWidth != null) { return 'style="width:' + this.weekNumberWidth + 'px"'; } return ''; }; // Determines whether each row should have a constant height - DayGridView.prototype.hasRigidRows = function () { - var eventLimit = this.opt('eventLimit'); + AbstractDayGridView.prototype.hasRigidRows = function () { + var eventLimit = this.context.options.eventLimit; return eventLimit && typeof eventLimit !== 'number'; }; /* Dimensions ------------------------------------------------------------------------------------------------------------------*/ - DayGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) { + AbstractDayGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) { _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto); // will call updateBaseSize. important that executes first this.dayGrid.updateSize(isResize); }; // Refreshes the horizontal dimensions of the view - DayGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) { + AbstractDayGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) { var dayGrid = this.dayGrid; - var eventLimit = this.opt('eventLimit'); + var eventLimit = this.context.options.eventLimit; var headRowEl = this.header ? this.header.el : null; // HACK var scrollerHeight; var scrollbarWidths; @@ -1456,13 +1486,13 @@ Docs & License: https://fullcalendar.io/ } }; // given a desired total height of the view, returns what the height of the scroller should be - DayGridView.prototype.computeScrollerHeight = function (viewHeight) { + AbstractDayGridView.prototype.computeScrollerHeight = function (viewHeight) { return viewHeight - core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller }; // Sets the height of just the DayGrid component in this view - DayGridView.prototype.setGridHeight = function (height, isAuto) { - if (this.opt('monthMode')) { + AbstractDayGridView.prototype.setGridHeight = function (height, isAuto) { + if (this.context.options.monthMode) { // if auto, make the height of each row the height that it would be if there were 6 weeks if (isAuto) { height *= this.dayGrid.rowCnt / 6; @@ -1480,38 +1510,44 @@ Docs & License: https://fullcalendar.io/ }; /* Scroll ------------------------------------------------------------------------------------------------------------------*/ - DayGridView.prototype.computeInitialDateScroll = function () { + AbstractDayGridView.prototype.computeDateScroll = function (duration) { return { top: 0 }; }; - DayGridView.prototype.queryDateScroll = function () { + AbstractDayGridView.prototype.queryDateScroll = function () { return { top: this.scroller.getScrollTop() }; }; - DayGridView.prototype.applyDateScroll = function (scroll) { + AbstractDayGridView.prototype.applyDateScroll = function (scroll) { if (scroll.top !== undefined) { this.scroller.setScrollTop(scroll.top); } }; - return DayGridView; + return AbstractDayGridView; }(core.View)); - DayGridView.prototype.dateProfileGeneratorClass = DayGridDateProfileGenerator; + AbstractDayGridView.prototype.dateProfileGeneratorClass = DayGridDateProfileGenerator; var SimpleDayGrid = /** @class */ (function (_super) { __extends(SimpleDayGrid, _super); - function SimpleDayGrid(context, dayGrid) { - var _this = _super.call(this, context, dayGrid.el) || this; + function SimpleDayGrid(dayGrid) { + var _this = _super.call(this, dayGrid.el) || this; _this.slicer = new DayGridSlicer(); _this.dayGrid = dayGrid; - context.calendar.registerInteractiveComponent(_this, { el: _this.dayGrid.el }); return _this; } + SimpleDayGrid.prototype.firstContext = function (context) { + context.calendar.registerInteractiveComponent(this, { el: this.dayGrid.el }); + }; SimpleDayGrid.prototype.destroy = function () { _super.prototype.destroy.call(this); - this.calendar.unregisterInteractiveComponent(this); + this.context.calendar.unregisterInteractiveComponent(this); }; - SimpleDayGrid.prototype.render = function (props) { + SimpleDayGrid.prototype.render = function (props, context) { var dayGrid = this.dayGrid; var dateProfile = props.dateProfile, dayTable = props.dayTable; - dayGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, props.nextDayThreshold, dayGrid, dayTable), { dateProfile: dateProfile, cells: dayTable.cells, isRigid: props.isRigid })); + dayGrid.receiveContext(context); // hack because context is used in sliceProps + dayGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, props.nextDayThreshold, context.calendar, dayGrid, dayTable), { dateProfile: dateProfile, cells: dayTable.cells, isRigid: props.isRigid }), context); + }; + SimpleDayGrid.prototype.buildPositionCaches = function () { + this.dayGrid.buildPositionCaches(); }; SimpleDayGrid.prototype.queryHit = function (positionLeft, positionTop) { var rawHit = this.dayGrid.positionToHit(positionLeft, positionTop); @@ -1543,36 +1579,25 @@ Docs & License: https://fullcalendar.io/ return DayGridSlicer; }(core.Slicer)); - var DayGridView$1 = /** @class */ (function (_super) { + var DayGridView = /** @class */ (function (_super) { __extends(DayGridView, _super); - function DayGridView(_context, viewSpec, dateProfileGenerator, parentEl) { - var _this = _super.call(this, _context, viewSpec, dateProfileGenerator, parentEl) || this; + function DayGridView() { + var _this = _super !== null && _super.apply(this, arguments) || this; _this.buildDayTable = core.memoize(buildDayTable); - if (_this.opt('columnHeader')) { - _this.header = new core.DayHeader(_this.context, _this.el.querySelector('.fc-head-container')); - } - _this.simpleDayGrid = new SimpleDayGrid(_this.context, _this.dayGrid); return _this; } - DayGridView.prototype.destroy = function () { - _super.prototype.destroy.call(this); - if (this.header) { - this.header.destroy(); - } - this.simpleDayGrid.destroy(); - }; - DayGridView.prototype.render = function (props) { - _super.prototype.render.call(this, props); + DayGridView.prototype.render = function (props, context) { + _super.prototype.render.call(this, props, context); // will call _renderSkeleton/_unrenderSkeleton var dateProfile = this.props.dateProfile; var dayTable = this.dayTable = - this.buildDayTable(dateProfile, this.dateProfileGenerator); + this.buildDayTable(dateProfile, props.dateProfileGenerator); if (this.header) { this.header.receiveProps({ dateProfile: dateProfile, dates: dayTable.headerDates, datesRepDistinctDays: dayTable.rowCnt === 1, renderIntroHtml: this.renderHeadIntroHtml - }); + }, context); } this.simpleDayGrid.receiveProps({ dateProfile: dateProfile, @@ -1585,11 +1610,25 @@ Docs & License: https://fullcalendar.io/ eventDrag: props.eventDrag, eventResize: props.eventResize, isRigid: this.hasRigidRows(), - nextDayThreshold: this.nextDayThreshold - }); + nextDayThreshold: this.context.nextDayThreshold + }, context); + }; + DayGridView.prototype._renderSkeleton = function (context) { + _super.prototype._renderSkeleton.call(this, context); + if (context.options.columnHeader) { + this.header = new core.DayHeader(this.el.querySelector('.fc-head-container')); + } + this.simpleDayGrid = new SimpleDayGrid(this.dayGrid); + }; + DayGridView.prototype._unrenderSkeleton = function () { + _super.prototype._unrenderSkeleton.call(this); + if (this.header) { + this.header.destroy(); + } + this.simpleDayGrid.destroy(); }; return DayGridView; - }(DayGridView)); + }(AbstractDayGridView)); function buildDayTable(dateProfile, dateProfileGenerator) { var daySeries = new core.DaySeries(dateProfile.renderRange, dateProfileGenerator); return new core.DayTable(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit)); @@ -1598,7 +1637,7 @@ Docs & License: https://fullcalendar.io/ var main = core.createPlugin({ defaultView: 'dayGridMonth', views: { - dayGrid: DayGridView$1, + dayGrid: DayGridView, dayGridDay: { type: 'dayGrid', duration: { days: 1 } @@ -1616,11 +1655,11 @@ Docs & License: https://fullcalendar.io/ } }); - exports.AbstractDayGridView = DayGridView; + exports.AbstractDayGridView = AbstractDayGridView; exports.DayBgRow = DayBgRow; exports.DayGrid = DayGrid; exports.DayGridSlicer = DayGridSlicer; - exports.DayGridView = DayGridView$1; + exports.DayGridView = DayGridView; exports.SimpleDayGrid = SimpleDayGrid; exports.buildBasicDayTable = buildDayTable; exports.default = main; |