full_calendar 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +49 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +21 -0
- data/README.md +102 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/full_calendar.gemspec +28 -0
- data/lib/.DS_Store +0 -0
- data/lib/full_calendar/engine.rb +9 -0
- data/lib/full_calendar/version.rb +3 -0
- data/lib/full_calendar.rb +73 -0
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/fullcalendar/.DS_Store +0 -0
- data/lib/generators/fullcalendar/install_generator.rb +61 -0
- data/lib/generators/fullcalendar/templates/default.js.tt +13 -0
- data/lib/generators/fullcalendar/templates/default.scss.tt +7 -0
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/fullcalendar/.DS_Store +0 -0
- data/vendor/assets/javascripts/fullcalendar/bootstrap/.DS_Store +0 -0
- data/vendor/assets/javascripts/fullcalendar/bootstrap/main.js +90 -0
- data/vendor/assets/javascripts/fullcalendar/bootstrap/main.min.js +20 -0
- data/vendor/assets/javascripts/fullcalendar/core/.DS_Store +0 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/af.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ar-dz.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ar-kw.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ar-ly.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ar-ma.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ar-sa.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ar-tn.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ar.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/bg.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/bs.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ca.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/cs.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/da.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/de.js +33 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/el.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/en-au.js +17 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/en-gb.js +17 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/en-nz.js +17 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/es-us.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/es.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/et.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/eu.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/fa.js +33 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/fi.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/fr-ca.js +27 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/fr-ch.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/fr.js +31 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/gl.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/he.js +27 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/hi.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/hr.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/hu.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/id.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/is.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/it.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ja.js +28 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ka.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/kk.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ko.js +26 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/lb.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/lt.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/lv.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/mk.js +28 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ms.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/nb.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/nl.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/nn.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/pl.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/pt-br.js +28 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/pt.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ro.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/ru.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/sk.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/sl.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/sq.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/sr-cyrl.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/sr.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/sv.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/th.js +25 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/tr.js +30 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/uk.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/vi.js +32 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/zh-cn.js +33 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales/zh-tw.js +26 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales-all.js +1353 -0
- data/vendor/assets/javascripts/fullcalendar/core/locales-all.min.js +6 -0
- data/vendor/assets/javascripts/fullcalendar/core/main.js +8679 -0
- data/vendor/assets/javascripts/fullcalendar/core/main.min.js +9 -0
- data/vendor/assets/javascripts/fullcalendar/daygrid/.DS_Store +0 -0
- data/vendor/assets/javascripts/fullcalendar/daygrid/main.js +1639 -0
- data/vendor/assets/javascripts/fullcalendar/daygrid/main.min.js +20 -0
- data/vendor/assets/javascripts/fullcalendar/google-calendar/main.js +169 -0
- data/vendor/assets/javascripts/fullcalendar/google-calendar/main.min.js +20 -0
- data/vendor/assets/javascripts/fullcalendar/interaction/main.js +2143 -0
- data/vendor/assets/javascripts/fullcalendar/interaction/main.min.js +21 -0
- data/vendor/assets/javascripts/fullcalendar/list/.DS_Store +0 -0
- data/vendor/assets/javascripts/fullcalendar/list/main.js +341 -0
- data/vendor/assets/javascripts/fullcalendar/list/main.min.js +20 -0
- data/vendor/assets/javascripts/fullcalendar/luxon/main.js +162 -0
- data/vendor/assets/javascripts/fullcalendar/luxon/main.min.js +20 -0
- data/vendor/assets/javascripts/fullcalendar/moment/main.js +103 -0
- data/vendor/assets/javascripts/fullcalendar/moment/main.min.js +6 -0
- data/vendor/assets/javascripts/fullcalendar/moment-timezone/main.js +64 -0
- data/vendor/assets/javascripts/fullcalendar/moment-timezone/main.min.js +20 -0
- data/vendor/assets/javascripts/fullcalendar/rrule/main.js +127 -0
- data/vendor/assets/javascripts/fullcalendar/rrule/main.min.js +20 -0
- data/vendor/assets/javascripts/fullcalendar/timegrid/.DS_Store +0 -0
- data/vendor/assets/javascripts/fullcalendar/timegrid/main.js +1354 -0
- data/vendor/assets/javascripts/fullcalendar/timegrid/main.min.js +20 -0
- data/vendor/assets/stylesheets/.DS_Store +0 -0
- data/vendor/assets/stylesheets/fullcalendar/.DS_Store +0 -0
- data/vendor/assets/stylesheets/fullcalendar/bootstrap/.DS_Store +0 -0
- data/vendor/assets/stylesheets/fullcalendar/bootstrap/main.css +33 -0
- data/vendor/assets/stylesheets/fullcalendar/bootstrap/main.min.css +5 -0
- data/vendor/assets/stylesheets/fullcalendar/core/.DS_Store +0 -0
- data/vendor/assets/stylesheets/fullcalendar/core/main.css +900 -0
- data/vendor/assets/stylesheets/fullcalendar/core/main.min.css +5 -0
- data/vendor/assets/stylesheets/fullcalendar/daygrid/.DS_Store +0 -0
- data/vendor/assets/stylesheets/fullcalendar/daygrid/main.css +69 -0
- data/vendor/assets/stylesheets/fullcalendar/daygrid/main.min.css +5 -0
- data/vendor/assets/stylesheets/fullcalendar/list/.DS_Store +0 -0
- data/vendor/assets/stylesheets/fullcalendar/list/main.css +101 -0
- data/vendor/assets/stylesheets/fullcalendar/list/main.min.css +5 -0
- data/vendor/assets/stylesheets/fullcalendar/timegrid/.DS_Store +0 -0
- data/vendor/assets/stylesheets/fullcalendar/timegrid/main.css +266 -0
- data/vendor/assets/stylesheets/fullcalendar/timegrid/main.min.css +5 -0
- metadata +219 -0
@@ -0,0 +1,1354 @@
|
|
1
|
+
/*!
|
2
|
+
FullCalendar Time Grid Plugin v4.2.0
|
3
|
+
Docs & License: https://fullcalendar.io/
|
4
|
+
(c) 2019 Adam Shaw
|
5
|
+
*/
|
6
|
+
(function (global, factory) {
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core'), require('@fullcalendar/daygrid')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core', '@fullcalendar/daygrid'], factory) :
|
9
|
+
(global = global || self, factory(global.FullCalendarTimeGrid = {}, global.FullCalendar, global.FullCalendarDayGrid));
|
10
|
+
}(this, function (exports, core, daygrid) { 'use strict';
|
11
|
+
|
12
|
+
/*! *****************************************************************************
|
13
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
14
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
15
|
+
this file except in compliance with the License. You may obtain a copy of the
|
16
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
|
18
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
19
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
20
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
21
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
22
|
+
|
23
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
24
|
+
and limitations under the License.
|
25
|
+
***************************************************************************** */
|
26
|
+
/* global Reflect, Promise */
|
27
|
+
|
28
|
+
var extendStatics = function(d, b) {
|
29
|
+
extendStatics = Object.setPrototypeOf ||
|
30
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
31
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
32
|
+
return extendStatics(d, b);
|
33
|
+
};
|
34
|
+
|
35
|
+
function __extends(d, b) {
|
36
|
+
extendStatics(d, b);
|
37
|
+
function __() { this.constructor = d; }
|
38
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
39
|
+
}
|
40
|
+
|
41
|
+
var __assign = function() {
|
42
|
+
__assign = Object.assign || function __assign(t) {
|
43
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
44
|
+
s = arguments[i];
|
45
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
46
|
+
}
|
47
|
+
return t;
|
48
|
+
};
|
49
|
+
return __assign.apply(this, arguments);
|
50
|
+
};
|
51
|
+
|
52
|
+
/*
|
53
|
+
Only handles foreground segs.
|
54
|
+
Does not own rendering. Use for low-level util methods by TimeGrid.
|
55
|
+
*/
|
56
|
+
var TimeGridEventRenderer = /** @class */ (function (_super) {
|
57
|
+
__extends(TimeGridEventRenderer, _super);
|
58
|
+
function TimeGridEventRenderer(timeGrid) {
|
59
|
+
var _this = _super.call(this, timeGrid.context) || this;
|
60
|
+
_this.timeGrid = timeGrid;
|
61
|
+
_this.fullTimeFormat = core.createFormatter({
|
62
|
+
hour: 'numeric',
|
63
|
+
minute: '2-digit',
|
64
|
+
separator: _this.context.options.defaultRangeSeparator
|
65
|
+
});
|
66
|
+
return _this;
|
67
|
+
}
|
68
|
+
// Given an array of foreground segments, render a DOM element for each, computes position,
|
69
|
+
// and attaches to the column inner-container elements.
|
70
|
+
TimeGridEventRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
|
71
|
+
var segsByCol = this.timeGrid.groupSegsByCol(segs);
|
72
|
+
// order the segs within each column
|
73
|
+
// TODO: have groupSegsByCol do this?
|
74
|
+
for (var col = 0; col < segsByCol.length; col++) {
|
75
|
+
segsByCol[col] = this.sortEventSegs(segsByCol[col]);
|
76
|
+
}
|
77
|
+
this.segsByCol = segsByCol;
|
78
|
+
this.timeGrid.attachSegsByCol(segsByCol, this.timeGrid.fgContainerEls);
|
79
|
+
};
|
80
|
+
TimeGridEventRenderer.prototype.detachSegs = function (segs) {
|
81
|
+
segs.forEach(function (seg) {
|
82
|
+
core.removeElement(seg.el);
|
83
|
+
});
|
84
|
+
this.segsByCol = null;
|
85
|
+
};
|
86
|
+
TimeGridEventRenderer.prototype.computeSegSizes = function (allSegs) {
|
87
|
+
var _a = this, timeGrid = _a.timeGrid, segsByCol = _a.segsByCol;
|
88
|
+
var colCnt = timeGrid.colCnt;
|
89
|
+
timeGrid.computeSegVerticals(allSegs); // horizontals relies on this
|
90
|
+
if (segsByCol) {
|
91
|
+
for (var col = 0; col < colCnt; col++) {
|
92
|
+
this.computeSegHorizontals(segsByCol[col]); // compute horizontal coordinates, z-index's, and reorder the array
|
93
|
+
}
|
94
|
+
}
|
95
|
+
};
|
96
|
+
TimeGridEventRenderer.prototype.assignSegSizes = function (allSegs) {
|
97
|
+
var _a = this, timeGrid = _a.timeGrid, segsByCol = _a.segsByCol;
|
98
|
+
var colCnt = timeGrid.colCnt;
|
99
|
+
timeGrid.assignSegVerticals(allSegs); // horizontals relies on this
|
100
|
+
if (segsByCol) {
|
101
|
+
for (var col = 0; col < colCnt; col++) {
|
102
|
+
this.assignSegCss(segsByCol[col]);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
};
|
106
|
+
// Computes a default event time formatting string if `eventTimeFormat` is not explicitly defined
|
107
|
+
TimeGridEventRenderer.prototype.computeEventTimeFormat = function () {
|
108
|
+
return {
|
109
|
+
hour: 'numeric',
|
110
|
+
minute: '2-digit',
|
111
|
+
meridiem: false
|
112
|
+
};
|
113
|
+
};
|
114
|
+
// Computes a default `displayEventEnd` value if one is not expliclty defined
|
115
|
+
TimeGridEventRenderer.prototype.computeDisplayEventEnd = function () {
|
116
|
+
return true;
|
117
|
+
};
|
118
|
+
// Renders the HTML for a single event segment's default rendering
|
119
|
+
TimeGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) {
|
120
|
+
var eventRange = seg.eventRange;
|
121
|
+
var eventDef = eventRange.def;
|
122
|
+
var eventUi = eventRange.ui;
|
123
|
+
var allDay = eventDef.allDay;
|
124
|
+
var isDraggable = eventUi.startEditable;
|
125
|
+
var isResizableFromStart = seg.isStart && eventUi.durationEditable && this.context.options.eventResizableFromStart;
|
126
|
+
var isResizableFromEnd = seg.isEnd && eventUi.durationEditable;
|
127
|
+
var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd, mirrorInfo);
|
128
|
+
var skinCss = core.cssToStr(this.getSkinCss(eventUi));
|
129
|
+
var timeText;
|
130
|
+
var fullTimeText; // more verbose time text. for the print stylesheet
|
131
|
+
var startTimeText; // just the start time text
|
132
|
+
classes.unshift('fc-time-grid-event');
|
133
|
+
// if the event appears to span more than one day...
|
134
|
+
if (core.isMultiDayRange(eventRange.range)) {
|
135
|
+
// Don't display time text on segments that run entirely through a day.
|
136
|
+
// That would appear as midnight-midnight and would look dumb.
|
137
|
+
// Otherwise, display the time text for the *segment's* times (like 6pm-midnight or midnight-10am)
|
138
|
+
if (seg.isStart || seg.isEnd) {
|
139
|
+
var unzonedStart = seg.start;
|
140
|
+
var unzonedEnd = seg.end;
|
141
|
+
timeText = this._getTimeText(unzonedStart, unzonedEnd, allDay); // TODO: give the timezones
|
142
|
+
fullTimeText = this._getTimeText(unzonedStart, unzonedEnd, allDay, this.fullTimeFormat);
|
143
|
+
startTimeText = this._getTimeText(unzonedStart, unzonedEnd, allDay, null, false); // displayEnd=false
|
144
|
+
}
|
145
|
+
}
|
146
|
+
else {
|
147
|
+
// Display the normal time text for the *event's* times
|
148
|
+
timeText = this.getTimeText(eventRange);
|
149
|
+
fullTimeText = this.getTimeText(eventRange, this.fullTimeFormat);
|
150
|
+
startTimeText = this.getTimeText(eventRange, null, false); // displayEnd=false
|
151
|
+
}
|
152
|
+
return '<a class="' + classes.join(' ') + '"' +
|
153
|
+
(eventDef.url ?
|
154
|
+
' href="' + core.htmlEscape(eventDef.url) + '"' :
|
155
|
+
'') +
|
156
|
+
(skinCss ?
|
157
|
+
' style="' + skinCss + '"' :
|
158
|
+
'') +
|
159
|
+
'>' +
|
160
|
+
'<div class="fc-content">' +
|
161
|
+
(timeText ?
|
162
|
+
'<div class="fc-time"' +
|
163
|
+
' data-start="' + core.htmlEscape(startTimeText) + '"' +
|
164
|
+
' data-full="' + core.htmlEscape(fullTimeText) + '"' +
|
165
|
+
'>' +
|
166
|
+
'<span>' + core.htmlEscape(timeText) + '</span>' +
|
167
|
+
'</div>' :
|
168
|
+
'') +
|
169
|
+
(eventDef.title ?
|
170
|
+
'<div class="fc-title">' +
|
171
|
+
core.htmlEscape(eventDef.title) +
|
172
|
+
'</div>' :
|
173
|
+
'') +
|
174
|
+
'</div>' +
|
175
|
+
/* TODO: write CSS for this
|
176
|
+
(isResizableFromStart ?
|
177
|
+
'<div class="fc-resizer fc-start-resizer"></div>' :
|
178
|
+
''
|
179
|
+
) +
|
180
|
+
*/
|
181
|
+
(isResizableFromEnd ?
|
182
|
+
'<div class="fc-resizer fc-end-resizer"></div>' :
|
183
|
+
'') +
|
184
|
+
'</a>';
|
185
|
+
};
|
186
|
+
// Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
|
187
|
+
// Assumed the segs are already ordered.
|
188
|
+
// NOTE: Also reorders the given array by date!
|
189
|
+
TimeGridEventRenderer.prototype.computeSegHorizontals = function (segs) {
|
190
|
+
var levels;
|
191
|
+
var level0;
|
192
|
+
var i;
|
193
|
+
levels = buildSlotSegLevels(segs);
|
194
|
+
computeForwardSlotSegs(levels);
|
195
|
+
if ((level0 = levels[0])) {
|
196
|
+
for (i = 0; i < level0.length; i++) {
|
197
|
+
computeSlotSegPressures(level0[i]);
|
198
|
+
}
|
199
|
+
for (i = 0; i < level0.length; i++) {
|
200
|
+
this.computeSegForwardBack(level0[i], 0, 0);
|
201
|
+
}
|
202
|
+
}
|
203
|
+
};
|
204
|
+
// Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
|
205
|
+
// from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
|
206
|
+
// seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
|
207
|
+
//
|
208
|
+
// The segment might be part of a "series", which means consecutive segments with the same pressure
|
209
|
+
// who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
|
210
|
+
// segments behind this one in the current series, and `seriesBackwardCoord` is the starting
|
211
|
+
// coordinate of the first segment in the series.
|
212
|
+
TimeGridEventRenderer.prototype.computeSegForwardBack = function (seg, seriesBackwardPressure, seriesBackwardCoord) {
|
213
|
+
var forwardSegs = seg.forwardSegs;
|
214
|
+
var i;
|
215
|
+
if (seg.forwardCoord === undefined) { // not already computed
|
216
|
+
if (!forwardSegs.length) {
|
217
|
+
// if there are no forward segments, this segment should butt up against the edge
|
218
|
+
seg.forwardCoord = 1;
|
219
|
+
}
|
220
|
+
else {
|
221
|
+
// sort highest pressure first
|
222
|
+
this.sortForwardSegs(forwardSegs);
|
223
|
+
// this segment's forwardCoord will be calculated from the backwardCoord of the
|
224
|
+
// highest-pressure forward segment.
|
225
|
+
this.computeSegForwardBack(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
|
226
|
+
seg.forwardCoord = forwardSegs[0].backwardCoord;
|
227
|
+
}
|
228
|
+
// calculate the backwardCoord from the forwardCoord. consider the series
|
229
|
+
seg.backwardCoord = seg.forwardCoord -
|
230
|
+
(seg.forwardCoord - seriesBackwardCoord) / // available width for series
|
231
|
+
(seriesBackwardPressure + 1); // # of segments in the series
|
232
|
+
// use this segment's coordinates to computed the coordinates of the less-pressurized
|
233
|
+
// forward segments
|
234
|
+
for (i = 0; i < forwardSegs.length; i++) {
|
235
|
+
this.computeSegForwardBack(forwardSegs[i], 0, seg.forwardCoord);
|
236
|
+
}
|
237
|
+
}
|
238
|
+
};
|
239
|
+
TimeGridEventRenderer.prototype.sortForwardSegs = function (forwardSegs) {
|
240
|
+
var objs = forwardSegs.map(buildTimeGridSegCompareObj);
|
241
|
+
var specs = [
|
242
|
+
// put higher-pressure first
|
243
|
+
{ field: 'forwardPressure', order: -1 },
|
244
|
+
// put segments that are closer to initial edge first (and favor ones with no coords yet)
|
245
|
+
{ field: 'backwardCoord', order: 1 }
|
246
|
+
].concat(this.context.view.eventOrderSpecs);
|
247
|
+
objs.sort(function (obj0, obj1) {
|
248
|
+
return core.compareByFieldSpecs(obj0, obj1, specs);
|
249
|
+
});
|
250
|
+
return objs.map(function (c) {
|
251
|
+
return c._seg;
|
252
|
+
});
|
253
|
+
};
|
254
|
+
// Given foreground event segments that have already had their position coordinates computed,
|
255
|
+
// assigns position-related CSS values to their elements.
|
256
|
+
TimeGridEventRenderer.prototype.assignSegCss = function (segs) {
|
257
|
+
for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
|
258
|
+
var seg = segs_1[_i];
|
259
|
+
core.applyStyle(seg.el, this.generateSegCss(seg));
|
260
|
+
if (seg.level > 0) {
|
261
|
+
seg.el.classList.add('fc-time-grid-event-inset');
|
262
|
+
}
|
263
|
+
// if the event is short that the title will be cut off,
|
264
|
+
// attach a className that condenses the title into the time area.
|
265
|
+
if (seg.eventRange.def.title && seg.bottom - seg.top < 30) {
|
266
|
+
seg.el.classList.add('fc-short'); // TODO: "condensed" is a better name
|
267
|
+
}
|
268
|
+
}
|
269
|
+
};
|
270
|
+
// Generates an object with CSS properties/values that should be applied to an event segment element.
|
271
|
+
// Contains important positioning-related properties that should be applied to any event element, customized or not.
|
272
|
+
TimeGridEventRenderer.prototype.generateSegCss = function (seg) {
|
273
|
+
var shouldOverlap = this.context.options.slotEventOverlap;
|
274
|
+
var backwardCoord = seg.backwardCoord; // the left side if LTR. the right side if RTL. floating-point
|
275
|
+
var forwardCoord = seg.forwardCoord; // the right side if LTR. the left side if RTL. floating-point
|
276
|
+
var props = this.timeGrid.generateSegVerticalCss(seg); // get top/bottom first
|
277
|
+
var isRtl = this.timeGrid.isRtl;
|
278
|
+
var left; // amount of space from left edge, a fraction of the total width
|
279
|
+
var right; // amount of space from right edge, a fraction of the total width
|
280
|
+
if (shouldOverlap) {
|
281
|
+
// double the width, but don't go beyond the maximum forward coordinate (1.0)
|
282
|
+
forwardCoord = Math.min(1, backwardCoord + (forwardCoord - backwardCoord) * 2);
|
283
|
+
}
|
284
|
+
if (isRtl) {
|
285
|
+
left = 1 - forwardCoord;
|
286
|
+
right = backwardCoord;
|
287
|
+
}
|
288
|
+
else {
|
289
|
+
left = backwardCoord;
|
290
|
+
right = 1 - forwardCoord;
|
291
|
+
}
|
292
|
+
props.zIndex = seg.level + 1; // convert from 0-base to 1-based
|
293
|
+
props.left = left * 100 + '%';
|
294
|
+
props.right = right * 100 + '%';
|
295
|
+
if (shouldOverlap && seg.forwardPressure) {
|
296
|
+
// add padding to the edge so that forward stacked events don't cover the resizer's icon
|
297
|
+
props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
|
298
|
+
}
|
299
|
+
return props;
|
300
|
+
};
|
301
|
+
return TimeGridEventRenderer;
|
302
|
+
}(core.FgEventRenderer));
|
303
|
+
// Builds an array of segments "levels". The first level will be the leftmost tier of segments if the calendar is
|
304
|
+
// left-to-right, or the rightmost if the calendar is right-to-left. Assumes the segments are already ordered by date.
|
305
|
+
function buildSlotSegLevels(segs) {
|
306
|
+
var levels = [];
|
307
|
+
var i;
|
308
|
+
var seg;
|
309
|
+
var j;
|
310
|
+
for (i = 0; i < segs.length; i++) {
|
311
|
+
seg = segs[i];
|
312
|
+
// go through all the levels and stop on the first level where there are no collisions
|
313
|
+
for (j = 0; j < levels.length; j++) {
|
314
|
+
if (!computeSlotSegCollisions(seg, levels[j]).length) {
|
315
|
+
break;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
seg.level = j;
|
319
|
+
(levels[j] || (levels[j] = [])).push(seg);
|
320
|
+
}
|
321
|
+
return levels;
|
322
|
+
}
|
323
|
+
// For every segment, figure out the other segments that are in subsequent
|
324
|
+
// levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
|
325
|
+
function computeForwardSlotSegs(levels) {
|
326
|
+
var i;
|
327
|
+
var level;
|
328
|
+
var j;
|
329
|
+
var seg;
|
330
|
+
var k;
|
331
|
+
for (i = 0; i < levels.length; i++) {
|
332
|
+
level = levels[i];
|
333
|
+
for (j = 0; j < level.length; j++) {
|
334
|
+
seg = level[j];
|
335
|
+
seg.forwardSegs = [];
|
336
|
+
for (k = i + 1; k < levels.length; k++) {
|
337
|
+
computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}
|
341
|
+
}
|
342
|
+
// Figure out which path forward (via seg.forwardSegs) results in the longest path until
|
343
|
+
// the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
|
344
|
+
function computeSlotSegPressures(seg) {
|
345
|
+
var forwardSegs = seg.forwardSegs;
|
346
|
+
var forwardPressure = 0;
|
347
|
+
var i;
|
348
|
+
var forwardSeg;
|
349
|
+
if (seg.forwardPressure === undefined) { // not already computed
|
350
|
+
for (i = 0; i < forwardSegs.length; i++) {
|
351
|
+
forwardSeg = forwardSegs[i];
|
352
|
+
// figure out the child's maximum forward path
|
353
|
+
computeSlotSegPressures(forwardSeg);
|
354
|
+
// either use the existing maximum, or use the child's forward pressure
|
355
|
+
// plus one (for the forwardSeg itself)
|
356
|
+
forwardPressure = Math.max(forwardPressure, 1 + forwardSeg.forwardPressure);
|
357
|
+
}
|
358
|
+
seg.forwardPressure = forwardPressure;
|
359
|
+
}
|
360
|
+
}
|
361
|
+
// Find all the segments in `otherSegs` that vertically collide with `seg`.
|
362
|
+
// Append into an optionally-supplied `results` array and return.
|
363
|
+
function computeSlotSegCollisions(seg, otherSegs, results) {
|
364
|
+
if (results === void 0) { results = []; }
|
365
|
+
for (var i = 0; i < otherSegs.length; i++) {
|
366
|
+
if (isSlotSegCollision(seg, otherSegs[i])) {
|
367
|
+
results.push(otherSegs[i]);
|
368
|
+
}
|
369
|
+
}
|
370
|
+
return results;
|
371
|
+
}
|
372
|
+
// Do these segments occupy the same vertical space?
|
373
|
+
function isSlotSegCollision(seg1, seg2) {
|
374
|
+
return seg1.bottom > seg2.top && seg1.top < seg2.bottom;
|
375
|
+
}
|
376
|
+
function buildTimeGridSegCompareObj(seg) {
|
377
|
+
var obj = core.buildSegCompareObj(seg);
|
378
|
+
obj.forwardPressure = seg.forwardPressure;
|
379
|
+
obj.backwardCoord = seg.backwardCoord;
|
380
|
+
return obj;
|
381
|
+
}
|
382
|
+
|
383
|
+
var TimeGridMirrorRenderer = /** @class */ (function (_super) {
|
384
|
+
__extends(TimeGridMirrorRenderer, _super);
|
385
|
+
function TimeGridMirrorRenderer() {
|
386
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
387
|
+
}
|
388
|
+
TimeGridMirrorRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
|
389
|
+
this.segsByCol = this.timeGrid.groupSegsByCol(segs);
|
390
|
+
this.timeGrid.attachSegsByCol(this.segsByCol, this.timeGrid.mirrorContainerEls);
|
391
|
+
this.sourceSeg = mirrorInfo.sourceSeg;
|
392
|
+
};
|
393
|
+
TimeGridMirrorRenderer.prototype.generateSegCss = function (seg) {
|
394
|
+
var props = _super.prototype.generateSegCss.call(this, seg);
|
395
|
+
var sourceSeg = this.sourceSeg;
|
396
|
+
if (sourceSeg && sourceSeg.col === seg.col) {
|
397
|
+
var sourceSegProps = _super.prototype.generateSegCss.call(this, sourceSeg);
|
398
|
+
props.left = sourceSegProps.left;
|
399
|
+
props.right = sourceSegProps.right;
|
400
|
+
props.marginLeft = sourceSegProps.marginLeft;
|
401
|
+
props.marginRight = sourceSegProps.marginRight;
|
402
|
+
}
|
403
|
+
return props;
|
404
|
+
};
|
405
|
+
return TimeGridMirrorRenderer;
|
406
|
+
}(TimeGridEventRenderer));
|
407
|
+
|
408
|
+
var TimeGridFillRenderer = /** @class */ (function (_super) {
|
409
|
+
__extends(TimeGridFillRenderer, _super);
|
410
|
+
function TimeGridFillRenderer(timeGrid) {
|
411
|
+
var _this = _super.call(this, timeGrid.context) || this;
|
412
|
+
_this.timeGrid = timeGrid;
|
413
|
+
return _this;
|
414
|
+
}
|
415
|
+
TimeGridFillRenderer.prototype.attachSegs = function (type, segs) {
|
416
|
+
var timeGrid = this.timeGrid;
|
417
|
+
var containerEls;
|
418
|
+
// TODO: more efficient lookup
|
419
|
+
if (type === 'bgEvent') {
|
420
|
+
containerEls = timeGrid.bgContainerEls;
|
421
|
+
}
|
422
|
+
else if (type === 'businessHours') {
|
423
|
+
containerEls = timeGrid.businessContainerEls;
|
424
|
+
}
|
425
|
+
else if (type === 'highlight') {
|
426
|
+
containerEls = timeGrid.highlightContainerEls;
|
427
|
+
}
|
428
|
+
timeGrid.attachSegsByCol(timeGrid.groupSegsByCol(segs), containerEls);
|
429
|
+
return segs.map(function (seg) {
|
430
|
+
return seg.el;
|
431
|
+
});
|
432
|
+
};
|
433
|
+
TimeGridFillRenderer.prototype.computeSegSizes = function (segs) {
|
434
|
+
this.timeGrid.computeSegVerticals(segs);
|
435
|
+
};
|
436
|
+
TimeGridFillRenderer.prototype.assignSegSizes = function (segs) {
|
437
|
+
this.timeGrid.assignSegVerticals(segs);
|
438
|
+
};
|
439
|
+
return TimeGridFillRenderer;
|
440
|
+
}(core.FillRenderer));
|
441
|
+
|
442
|
+
/* A component that renders one or more columns of vertical time slots
|
443
|
+
----------------------------------------------------------------------------------------------------------------------*/
|
444
|
+
// potential nice values for the slot-duration and interval-duration
|
445
|
+
// from largest to smallest
|
446
|
+
var AGENDA_STOCK_SUB_DURATIONS = [
|
447
|
+
{ hours: 1 },
|
448
|
+
{ minutes: 30 },
|
449
|
+
{ minutes: 15 },
|
450
|
+
{ seconds: 30 },
|
451
|
+
{ seconds: 15 }
|
452
|
+
];
|
453
|
+
var TimeGrid = /** @class */ (function (_super) {
|
454
|
+
__extends(TimeGrid, _super);
|
455
|
+
function TimeGrid(context, el, renderProps) {
|
456
|
+
var _this = _super.call(this, context, el) || this;
|
457
|
+
_this.isSlatSizesDirty = false;
|
458
|
+
_this.isColSizesDirty = false;
|
459
|
+
_this.renderSlats = core.memoizeRendering(_this._renderSlats);
|
460
|
+
var eventRenderer = _this.eventRenderer = new TimeGridEventRenderer(_this);
|
461
|
+
var fillRenderer = _this.fillRenderer = new TimeGridFillRenderer(_this);
|
462
|
+
_this.mirrorRenderer = new TimeGridMirrorRenderer(_this);
|
463
|
+
var renderColumns = _this.renderColumns = core.memoizeRendering(_this._renderColumns, _this._unrenderColumns);
|
464
|
+
_this.renderBusinessHours = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'businessHours'), fillRenderer.unrender.bind(fillRenderer, 'businessHours'), [renderColumns]);
|
465
|
+
_this.renderDateSelection = core.memoizeRendering(_this._renderDateSelection, _this._unrenderDateSelection, [renderColumns]);
|
466
|
+
_this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderColumns]);
|
467
|
+
_this.renderBgEvents = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'bgEvent'), fillRenderer.unrender.bind(fillRenderer, 'bgEvent'), [renderColumns]);
|
468
|
+
_this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
|
469
|
+
_this.renderEventDrag = core.memoizeRendering(_this._renderEventDrag, _this._unrenderEventDrag, [renderColumns]);
|
470
|
+
_this.renderEventResize = core.memoizeRendering(_this._renderEventResize, _this._unrenderEventResize, [renderColumns]);
|
471
|
+
_this.processOptions();
|
472
|
+
el.innerHTML =
|
473
|
+
'<div class="fc-bg"></div>' +
|
474
|
+
'<div class="fc-slats"></div>' +
|
475
|
+
'<hr class="fc-divider ' + _this.theme.getClass('widgetHeader') + '" style="display:none" />';
|
476
|
+
_this.rootBgContainerEl = el.querySelector('.fc-bg');
|
477
|
+
_this.slatContainerEl = el.querySelector('.fc-slats');
|
478
|
+
_this.bottomRuleEl = el.querySelector('.fc-divider');
|
479
|
+
_this.renderProps = renderProps;
|
480
|
+
return _this;
|
481
|
+
}
|
482
|
+
/* Options
|
483
|
+
------------------------------------------------------------------------------------------------------------------*/
|
484
|
+
// Parses various options into properties of this object
|
485
|
+
TimeGrid.prototype.processOptions = function () {
|
486
|
+
var slotDuration = this.opt('slotDuration');
|
487
|
+
var snapDuration = this.opt('snapDuration');
|
488
|
+
var snapsPerSlot;
|
489
|
+
var input;
|
490
|
+
slotDuration = core.createDuration(slotDuration);
|
491
|
+
snapDuration = snapDuration ? core.createDuration(snapDuration) : slotDuration;
|
492
|
+
snapsPerSlot = core.wholeDivideDurations(slotDuration, snapDuration);
|
493
|
+
if (snapsPerSlot === null) {
|
494
|
+
snapDuration = slotDuration;
|
495
|
+
snapsPerSlot = 1;
|
496
|
+
// TODO: say warning?
|
497
|
+
}
|
498
|
+
this.slotDuration = slotDuration;
|
499
|
+
this.snapDuration = snapDuration;
|
500
|
+
this.snapsPerSlot = snapsPerSlot;
|
501
|
+
// might be an array value (for TimelineView).
|
502
|
+
// if so, getting the most granular entry (the last one probably).
|
503
|
+
input = this.opt('slotLabelFormat');
|
504
|
+
if (Array.isArray(input)) {
|
505
|
+
input = input[input.length - 1];
|
506
|
+
}
|
507
|
+
this.labelFormat = core.createFormatter(input || {
|
508
|
+
hour: 'numeric',
|
509
|
+
minute: '2-digit',
|
510
|
+
omitZeroMinute: true,
|
511
|
+
meridiem: 'short'
|
512
|
+
});
|
513
|
+
input = this.opt('slotLabelInterval');
|
514
|
+
this.labelInterval = input ?
|
515
|
+
core.createDuration(input) :
|
516
|
+
this.computeLabelInterval(slotDuration);
|
517
|
+
};
|
518
|
+
// Computes an automatic value for slotLabelInterval
|
519
|
+
TimeGrid.prototype.computeLabelInterval = function (slotDuration) {
|
520
|
+
var i;
|
521
|
+
var labelInterval;
|
522
|
+
var slotsPerLabel;
|
523
|
+
// find the smallest stock label interval that results in more than one slots-per-label
|
524
|
+
for (i = AGENDA_STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) {
|
525
|
+
labelInterval = core.createDuration(AGENDA_STOCK_SUB_DURATIONS[i]);
|
526
|
+
slotsPerLabel = core.wholeDivideDurations(labelInterval, slotDuration);
|
527
|
+
if (slotsPerLabel !== null && slotsPerLabel > 1) {
|
528
|
+
return labelInterval;
|
529
|
+
}
|
530
|
+
}
|
531
|
+
return slotDuration; // fall back
|
532
|
+
};
|
533
|
+
/* Rendering
|
534
|
+
------------------------------------------------------------------------------------------------------------------*/
|
535
|
+
TimeGrid.prototype.render = function (props) {
|
536
|
+
var cells = props.cells;
|
537
|
+
this.colCnt = cells.length;
|
538
|
+
this.renderSlats(props.dateProfile);
|
539
|
+
this.renderColumns(props.cells, props.dateProfile);
|
540
|
+
this.renderBusinessHours(props.businessHourSegs);
|
541
|
+
this.renderDateSelection(props.dateSelectionSegs);
|
542
|
+
this.renderFgEvents(props.fgEventSegs);
|
543
|
+
this.renderBgEvents(props.bgEventSegs);
|
544
|
+
this.renderEventSelection(props.eventSelection);
|
545
|
+
this.renderEventDrag(props.eventDrag);
|
546
|
+
this.renderEventResize(props.eventResize);
|
547
|
+
};
|
548
|
+
TimeGrid.prototype.destroy = function () {
|
549
|
+
_super.prototype.destroy.call(this);
|
550
|
+
// should unrender everything else too
|
551
|
+
this.renderSlats.unrender();
|
552
|
+
this.renderColumns.unrender();
|
553
|
+
};
|
554
|
+
TimeGrid.prototype.updateSize = function (isResize) {
|
555
|
+
var _a = this, fillRenderer = _a.fillRenderer, eventRenderer = _a.eventRenderer, mirrorRenderer = _a.mirrorRenderer;
|
556
|
+
if (isResize || this.isSlatSizesDirty) {
|
557
|
+
this.buildSlatPositions();
|
558
|
+
this.isSlatSizesDirty = false;
|
559
|
+
}
|
560
|
+
if (isResize || this.isColSizesDirty) {
|
561
|
+
this.buildColPositions();
|
562
|
+
this.isColSizesDirty = false;
|
563
|
+
}
|
564
|
+
fillRenderer.computeSizes(isResize);
|
565
|
+
eventRenderer.computeSizes(isResize);
|
566
|
+
mirrorRenderer.computeSizes(isResize);
|
567
|
+
fillRenderer.assignSizes(isResize);
|
568
|
+
eventRenderer.assignSizes(isResize);
|
569
|
+
mirrorRenderer.assignSizes(isResize);
|
570
|
+
};
|
571
|
+
TimeGrid.prototype._renderSlats = function (dateProfile) {
|
572
|
+
var theme = this.theme;
|
573
|
+
this.slatContainerEl.innerHTML =
|
574
|
+
'<table class="' + theme.getClass('tableGrid') + '">' +
|
575
|
+
this.renderSlatRowHtml(dateProfile) +
|
576
|
+
'</table>';
|
577
|
+
this.slatEls = core.findElements(this.slatContainerEl, 'tr');
|
578
|
+
this.slatPositions = new core.PositionCache(this.el, this.slatEls, false, true // vertical
|
579
|
+
);
|
580
|
+
this.isSlatSizesDirty = true;
|
581
|
+
};
|
582
|
+
// Generates the HTML for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
|
583
|
+
TimeGrid.prototype.renderSlatRowHtml = function (dateProfile) {
|
584
|
+
var _a = this, dateEnv = _a.dateEnv, theme = _a.theme, isRtl = _a.isRtl;
|
585
|
+
var html = '';
|
586
|
+
var dayStart = core.startOfDay(dateProfile.renderRange.start);
|
587
|
+
var slotTime = dateProfile.minTime;
|
588
|
+
var slotIterator = core.createDuration(0);
|
589
|
+
var slotDate; // will be on the view's first day, but we only care about its time
|
590
|
+
var isLabeled;
|
591
|
+
var axisHtml;
|
592
|
+
// Calculate the time for each slot
|
593
|
+
while (core.asRoughMs(slotTime) < core.asRoughMs(dateProfile.maxTime)) {
|
594
|
+
slotDate = dateEnv.add(dayStart, slotTime);
|
595
|
+
isLabeled = core.wholeDivideDurations(slotIterator, this.labelInterval) !== null;
|
596
|
+
axisHtml =
|
597
|
+
'<td class="fc-axis fc-time ' + theme.getClass('widgetContent') + '">' +
|
598
|
+
(isLabeled ?
|
599
|
+
'<span>' + // for matchCellWidths
|
600
|
+
core.htmlEscape(dateEnv.format(slotDate, this.labelFormat)) +
|
601
|
+
'</span>' :
|
602
|
+
'') +
|
603
|
+
'</td>';
|
604
|
+
html +=
|
605
|
+
'<tr data-time="' + core.formatIsoTimeString(slotDate) + '"' +
|
606
|
+
(isLabeled ? '' : ' class="fc-minor"') +
|
607
|
+
'>' +
|
608
|
+
(!isRtl ? axisHtml : '') +
|
609
|
+
'<td class="' + theme.getClass('widgetContent') + '"></td>' +
|
610
|
+
(isRtl ? axisHtml : '') +
|
611
|
+
'</tr>';
|
612
|
+
slotTime = core.addDurations(slotTime, this.slotDuration);
|
613
|
+
slotIterator = core.addDurations(slotIterator, this.slotDuration);
|
614
|
+
}
|
615
|
+
return html;
|
616
|
+
};
|
617
|
+
TimeGrid.prototype._renderColumns = function (cells, dateProfile) {
|
618
|
+
var _a = this, theme = _a.theme, dateEnv = _a.dateEnv, view = _a.view;
|
619
|
+
var bgRow = new daygrid.DayBgRow(this.context);
|
620
|
+
this.rootBgContainerEl.innerHTML =
|
621
|
+
'<table class="' + theme.getClass('tableGrid') + '">' +
|
622
|
+
bgRow.renderHtml({
|
623
|
+
cells: cells,
|
624
|
+
dateProfile: dateProfile,
|
625
|
+
renderIntroHtml: this.renderProps.renderBgIntroHtml
|
626
|
+
}) +
|
627
|
+
'</table>';
|
628
|
+
this.colEls = core.findElements(this.el, '.fc-day, .fc-disabled-day');
|
629
|
+
for (var col = 0; col < this.colCnt; col++) {
|
630
|
+
this.publiclyTrigger('dayRender', [
|
631
|
+
{
|
632
|
+
date: dateEnv.toDate(cells[col].date),
|
633
|
+
el: this.colEls[col],
|
634
|
+
view: view
|
635
|
+
}
|
636
|
+
]);
|
637
|
+
}
|
638
|
+
if (this.isRtl) {
|
639
|
+
this.colEls.reverse();
|
640
|
+
}
|
641
|
+
this.colPositions = new core.PositionCache(this.el, this.colEls, true, // horizontal
|
642
|
+
false);
|
643
|
+
this.renderContentSkeleton();
|
644
|
+
this.isColSizesDirty = true;
|
645
|
+
};
|
646
|
+
TimeGrid.prototype._unrenderColumns = function () {
|
647
|
+
this.unrenderContentSkeleton();
|
648
|
+
};
|
649
|
+
/* Content Skeleton
|
650
|
+
------------------------------------------------------------------------------------------------------------------*/
|
651
|
+
// Renders the DOM that the view's content will live in
|
652
|
+
TimeGrid.prototype.renderContentSkeleton = function () {
|
653
|
+
var parts = [];
|
654
|
+
var skeletonEl;
|
655
|
+
parts.push(this.renderProps.renderIntroHtml());
|
656
|
+
for (var i = 0; i < this.colCnt; i++) {
|
657
|
+
parts.push('<td>' +
|
658
|
+
'<div class="fc-content-col">' +
|
659
|
+
'<div class="fc-event-container fc-mirror-container"></div>' +
|
660
|
+
'<div class="fc-event-container"></div>' +
|
661
|
+
'<div class="fc-highlight-container"></div>' +
|
662
|
+
'<div class="fc-bgevent-container"></div>' +
|
663
|
+
'<div class="fc-business-container"></div>' +
|
664
|
+
'</div>' +
|
665
|
+
'</td>');
|
666
|
+
}
|
667
|
+
if (this.isRtl) {
|
668
|
+
parts.reverse();
|
669
|
+
}
|
670
|
+
skeletonEl = this.contentSkeletonEl = core.htmlToElement('<div class="fc-content-skeleton">' +
|
671
|
+
'<table>' +
|
672
|
+
'<tr>' + parts.join('') + '</tr>' +
|
673
|
+
'</table>' +
|
674
|
+
'</div>');
|
675
|
+
this.colContainerEls = core.findElements(skeletonEl, '.fc-content-col');
|
676
|
+
this.mirrorContainerEls = core.findElements(skeletonEl, '.fc-mirror-container');
|
677
|
+
this.fgContainerEls = core.findElements(skeletonEl, '.fc-event-container:not(.fc-mirror-container)');
|
678
|
+
this.bgContainerEls = core.findElements(skeletonEl, '.fc-bgevent-container');
|
679
|
+
this.highlightContainerEls = core.findElements(skeletonEl, '.fc-highlight-container');
|
680
|
+
this.businessContainerEls = core.findElements(skeletonEl, '.fc-business-container');
|
681
|
+
if (this.isRtl) {
|
682
|
+
this.colContainerEls.reverse();
|
683
|
+
this.mirrorContainerEls.reverse();
|
684
|
+
this.fgContainerEls.reverse();
|
685
|
+
this.bgContainerEls.reverse();
|
686
|
+
this.highlightContainerEls.reverse();
|
687
|
+
this.businessContainerEls.reverse();
|
688
|
+
}
|
689
|
+
this.el.appendChild(skeletonEl);
|
690
|
+
};
|
691
|
+
TimeGrid.prototype.unrenderContentSkeleton = function () {
|
692
|
+
core.removeElement(this.contentSkeletonEl);
|
693
|
+
};
|
694
|
+
// Given a flat array of segments, return an array of sub-arrays, grouped by each segment's col
|
695
|
+
TimeGrid.prototype.groupSegsByCol = function (segs) {
|
696
|
+
var segsByCol = [];
|
697
|
+
var i;
|
698
|
+
for (i = 0; i < this.colCnt; i++) {
|
699
|
+
segsByCol.push([]);
|
700
|
+
}
|
701
|
+
for (i = 0; i < segs.length; i++) {
|
702
|
+
segsByCol[segs[i].col].push(segs[i]);
|
703
|
+
}
|
704
|
+
return segsByCol;
|
705
|
+
};
|
706
|
+
// Given segments grouped by column, insert the segments' elements into a parallel array of container
|
707
|
+
// elements, each living within a column.
|
708
|
+
TimeGrid.prototype.attachSegsByCol = function (segsByCol, containerEls) {
|
709
|
+
var col;
|
710
|
+
var segs;
|
711
|
+
var i;
|
712
|
+
for (col = 0; col < this.colCnt; col++) { // iterate each column grouping
|
713
|
+
segs = segsByCol[col];
|
714
|
+
for (i = 0; i < segs.length; i++) {
|
715
|
+
containerEls[col].appendChild(segs[i].el);
|
716
|
+
}
|
717
|
+
}
|
718
|
+
};
|
719
|
+
/* Now Indicator
|
720
|
+
------------------------------------------------------------------------------------------------------------------*/
|
721
|
+
TimeGrid.prototype.getNowIndicatorUnit = function () {
|
722
|
+
return 'minute'; // will refresh on the minute
|
723
|
+
};
|
724
|
+
TimeGrid.prototype.renderNowIndicator = function (segs, date) {
|
725
|
+
// HACK: if date columns not ready for some reason (scheduler)
|
726
|
+
if (!this.colContainerEls) {
|
727
|
+
return;
|
728
|
+
}
|
729
|
+
var top = this.computeDateTop(date);
|
730
|
+
var nodes = [];
|
731
|
+
var i;
|
732
|
+
// render lines within the columns
|
733
|
+
for (i = 0; i < segs.length; i++) {
|
734
|
+
var lineEl = core.createElement('div', { className: 'fc-now-indicator fc-now-indicator-line' });
|
735
|
+
lineEl.style.top = top + 'px';
|
736
|
+
this.colContainerEls[segs[i].col].appendChild(lineEl);
|
737
|
+
nodes.push(lineEl);
|
738
|
+
}
|
739
|
+
// render an arrow over the axis
|
740
|
+
if (segs.length > 0) { // is the current time in view?
|
741
|
+
var arrowEl = core.createElement('div', { className: 'fc-now-indicator fc-now-indicator-arrow' });
|
742
|
+
arrowEl.style.top = top + 'px';
|
743
|
+
this.contentSkeletonEl.appendChild(arrowEl);
|
744
|
+
nodes.push(arrowEl);
|
745
|
+
}
|
746
|
+
this.nowIndicatorEls = nodes;
|
747
|
+
};
|
748
|
+
TimeGrid.prototype.unrenderNowIndicator = function () {
|
749
|
+
if (this.nowIndicatorEls) {
|
750
|
+
this.nowIndicatorEls.forEach(core.removeElement);
|
751
|
+
this.nowIndicatorEls = null;
|
752
|
+
}
|
753
|
+
};
|
754
|
+
/* Coordinates
|
755
|
+
------------------------------------------------------------------------------------------------------------------*/
|
756
|
+
TimeGrid.prototype.getTotalSlatHeight = function () {
|
757
|
+
return this.slatContainerEl.offsetHeight;
|
758
|
+
};
|
759
|
+
// Computes the top coordinate, relative to the bounds of the grid, of the given date.
|
760
|
+
// A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
|
761
|
+
TimeGrid.prototype.computeDateTop = function (when, startOfDayDate) {
|
762
|
+
if (!startOfDayDate) {
|
763
|
+
startOfDayDate = core.startOfDay(when);
|
764
|
+
}
|
765
|
+
return this.computeTimeTop(when.valueOf() - startOfDayDate.valueOf());
|
766
|
+
};
|
767
|
+
// Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
|
768
|
+
TimeGrid.prototype.computeTimeTop = function (timeMs) {
|
769
|
+
var len = this.slatEls.length;
|
770
|
+
var dateProfile = this.props.dateProfile;
|
771
|
+
var slatCoverage = (timeMs - core.asRoughMs(dateProfile.minTime)) / core.asRoughMs(this.slotDuration); // floating-point value of # of slots covered
|
772
|
+
var slatIndex;
|
773
|
+
var slatRemainder;
|
774
|
+
// compute a floating-point number for how many slats should be progressed through.
|
775
|
+
// from 0 to number of slats (inclusive)
|
776
|
+
// constrained because minTime/maxTime might be customized.
|
777
|
+
slatCoverage = Math.max(0, slatCoverage);
|
778
|
+
slatCoverage = Math.min(len, slatCoverage);
|
779
|
+
// an integer index of the furthest whole slat
|
780
|
+
// from 0 to number slats (*exclusive*, so len-1)
|
781
|
+
slatIndex = Math.floor(slatCoverage);
|
782
|
+
slatIndex = Math.min(slatIndex, len - 1);
|
783
|
+
// how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
|
784
|
+
// could be 1.0 if slatCoverage is covering *all* the slots
|
785
|
+
slatRemainder = slatCoverage - slatIndex;
|
786
|
+
return this.slatPositions.tops[slatIndex] +
|
787
|
+
this.slatPositions.getHeight(slatIndex) * slatRemainder;
|
788
|
+
};
|
789
|
+
// For each segment in an array, computes and assigns its top and bottom properties
|
790
|
+
TimeGrid.prototype.computeSegVerticals = function (segs) {
|
791
|
+
var eventMinHeight = this.opt('timeGridEventMinHeight');
|
792
|
+
var i;
|
793
|
+
var seg;
|
794
|
+
var dayDate;
|
795
|
+
for (i = 0; i < segs.length; i++) {
|
796
|
+
seg = segs[i];
|
797
|
+
dayDate = this.props.cells[seg.col].date;
|
798
|
+
seg.top = this.computeDateTop(seg.start, dayDate);
|
799
|
+
seg.bottom = Math.max(seg.top + eventMinHeight, this.computeDateTop(seg.end, dayDate));
|
800
|
+
}
|
801
|
+
};
|
802
|
+
// Given segments that already have their top/bottom properties computed, applies those values to
|
803
|
+
// the segments' elements.
|
804
|
+
TimeGrid.prototype.assignSegVerticals = function (segs) {
|
805
|
+
var i;
|
806
|
+
var seg;
|
807
|
+
for (i = 0; i < segs.length; i++) {
|
808
|
+
seg = segs[i];
|
809
|
+
core.applyStyle(seg.el, this.generateSegVerticalCss(seg));
|
810
|
+
}
|
811
|
+
};
|
812
|
+
// Generates an object with CSS properties for the top/bottom coordinates of a segment element
|
813
|
+
TimeGrid.prototype.generateSegVerticalCss = function (seg) {
|
814
|
+
return {
|
815
|
+
top: seg.top,
|
816
|
+
bottom: -seg.bottom // flipped because needs to be space beyond bottom edge of event container
|
817
|
+
};
|
818
|
+
};
|
819
|
+
/* Sizing
|
820
|
+
------------------------------------------------------------------------------------------------------------------*/
|
821
|
+
TimeGrid.prototype.buildPositionCaches = function () {
|
822
|
+
this.buildColPositions();
|
823
|
+
this.buildSlatPositions();
|
824
|
+
};
|
825
|
+
TimeGrid.prototype.buildColPositions = function () {
|
826
|
+
this.colPositions.build();
|
827
|
+
};
|
828
|
+
TimeGrid.prototype.buildSlatPositions = function () {
|
829
|
+
this.slatPositions.build();
|
830
|
+
};
|
831
|
+
/* Hit System
|
832
|
+
------------------------------------------------------------------------------------------------------------------*/
|
833
|
+
TimeGrid.prototype.positionToHit = function (positionLeft, positionTop) {
|
834
|
+
var _a = this, dateEnv = _a.dateEnv, snapsPerSlot = _a.snapsPerSlot, slatPositions = _a.slatPositions, colPositions = _a.colPositions;
|
835
|
+
var colIndex = colPositions.leftToIndex(positionLeft);
|
836
|
+
var slatIndex = slatPositions.topToIndex(positionTop);
|
837
|
+
if (colIndex != null && slatIndex != null) {
|
838
|
+
var slatTop = slatPositions.tops[slatIndex];
|
839
|
+
var slatHeight = slatPositions.getHeight(slatIndex);
|
840
|
+
var partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
|
841
|
+
var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
|
842
|
+
var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
|
843
|
+
var dayDate = this.props.cells[colIndex].date;
|
844
|
+
var time = core.addDurations(this.props.dateProfile.minTime, core.multiplyDuration(this.snapDuration, snapIndex));
|
845
|
+
var start = dateEnv.add(dayDate, time);
|
846
|
+
var end = dateEnv.add(start, this.snapDuration);
|
847
|
+
return {
|
848
|
+
col: colIndex,
|
849
|
+
dateSpan: {
|
850
|
+
range: { start: start, end: end },
|
851
|
+
allDay: false
|
852
|
+
},
|
853
|
+
dayEl: this.colEls[colIndex],
|
854
|
+
relativeRect: {
|
855
|
+
left: colPositions.lefts[colIndex],
|
856
|
+
right: colPositions.rights[colIndex],
|
857
|
+
top: slatTop,
|
858
|
+
bottom: slatTop + slatHeight
|
859
|
+
}
|
860
|
+
};
|
861
|
+
}
|
862
|
+
};
|
863
|
+
/* Event Drag Visualization
|
864
|
+
------------------------------------------------------------------------------------------------------------------*/
|
865
|
+
TimeGrid.prototype._renderEventDrag = function (state) {
|
866
|
+
if (state) {
|
867
|
+
this.eventRenderer.hideByHash(state.affectedInstances);
|
868
|
+
if (state.isEvent) {
|
869
|
+
this.mirrorRenderer.renderSegs(state.segs, { isDragging: true, sourceSeg: state.sourceSeg });
|
870
|
+
}
|
871
|
+
else {
|
872
|
+
this.fillRenderer.renderSegs('highlight', state.segs);
|
873
|
+
}
|
874
|
+
}
|
875
|
+
};
|
876
|
+
TimeGrid.prototype._unrenderEventDrag = function (state) {
|
877
|
+
if (state) {
|
878
|
+
this.eventRenderer.showByHash(state.affectedInstances);
|
879
|
+
this.mirrorRenderer.unrender(state.segs, { isDragging: true, sourceSeg: state.sourceSeg });
|
880
|
+
this.fillRenderer.unrender('highlight');
|
881
|
+
}
|
882
|
+
};
|
883
|
+
/* Event Resize Visualization
|
884
|
+
------------------------------------------------------------------------------------------------------------------*/
|
885
|
+
TimeGrid.prototype._renderEventResize = function (state) {
|
886
|
+
if (state) {
|
887
|
+
this.eventRenderer.hideByHash(state.affectedInstances);
|
888
|
+
this.mirrorRenderer.renderSegs(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
|
889
|
+
}
|
890
|
+
};
|
891
|
+
TimeGrid.prototype._unrenderEventResize = function (state) {
|
892
|
+
if (state) {
|
893
|
+
this.eventRenderer.showByHash(state.affectedInstances);
|
894
|
+
this.mirrorRenderer.unrender(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
|
895
|
+
}
|
896
|
+
};
|
897
|
+
/* Selection
|
898
|
+
------------------------------------------------------------------------------------------------------------------*/
|
899
|
+
// Renders a visual indication of a selection. Overrides the default, which was to simply render a highlight.
|
900
|
+
TimeGrid.prototype._renderDateSelection = function (segs) {
|
901
|
+
if (segs) {
|
902
|
+
if (this.opt('selectMirror')) {
|
903
|
+
this.mirrorRenderer.renderSegs(segs, { isSelecting: true });
|
904
|
+
}
|
905
|
+
else {
|
906
|
+
this.fillRenderer.renderSegs('highlight', segs);
|
907
|
+
}
|
908
|
+
}
|
909
|
+
};
|
910
|
+
TimeGrid.prototype._unrenderDateSelection = function (segs) {
|
911
|
+
this.mirrorRenderer.unrender(segs, { isSelecting: true });
|
912
|
+
this.fillRenderer.unrender('highlight');
|
913
|
+
};
|
914
|
+
return TimeGrid;
|
915
|
+
}(core.DateComponent));
|
916
|
+
|
917
|
+
var AllDaySplitter = /** @class */ (function (_super) {
|
918
|
+
__extends(AllDaySplitter, _super);
|
919
|
+
function AllDaySplitter() {
|
920
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
921
|
+
}
|
922
|
+
AllDaySplitter.prototype.getKeyInfo = function () {
|
923
|
+
return {
|
924
|
+
allDay: {},
|
925
|
+
timed: {}
|
926
|
+
};
|
927
|
+
};
|
928
|
+
AllDaySplitter.prototype.getKeysForDateSpan = function (dateSpan) {
|
929
|
+
if (dateSpan.allDay) {
|
930
|
+
return ['allDay'];
|
931
|
+
}
|
932
|
+
else {
|
933
|
+
return ['timed'];
|
934
|
+
}
|
935
|
+
};
|
936
|
+
AllDaySplitter.prototype.getKeysForEventDef = function (eventDef) {
|
937
|
+
if (!eventDef.allDay) {
|
938
|
+
return ['timed'];
|
939
|
+
}
|
940
|
+
else if (core.hasBgRendering(eventDef)) {
|
941
|
+
return ['timed', 'allDay'];
|
942
|
+
}
|
943
|
+
else {
|
944
|
+
return ['allDay'];
|
945
|
+
}
|
946
|
+
};
|
947
|
+
return AllDaySplitter;
|
948
|
+
}(core.Splitter));
|
949
|
+
|
950
|
+
var TIMEGRID_ALL_DAY_EVENT_LIMIT = 5;
|
951
|
+
var WEEK_HEADER_FORMAT = core.createFormatter({ week: 'short' });
|
952
|
+
/* An abstract class for all timegrid-related views. Displays one more columns with time slots running vertically.
|
953
|
+
----------------------------------------------------------------------------------------------------------------------*/
|
954
|
+
// Is a manager for the TimeGrid subcomponent and possibly the DayGrid subcomponent (if allDaySlot is on).
|
955
|
+
// Responsible for managing width/height.
|
956
|
+
var TimeGridView = /** @class */ (function (_super) {
|
957
|
+
__extends(TimeGridView, _super);
|
958
|
+
function TimeGridView(context, viewSpec, dateProfileGenerator, parentEl) {
|
959
|
+
var _this = _super.call(this, context, viewSpec, dateProfileGenerator, parentEl) || this;
|
960
|
+
_this.splitter = new AllDaySplitter();
|
961
|
+
/* Header Render Methods
|
962
|
+
------------------------------------------------------------------------------------------------------------------*/
|
963
|
+
// Generates the HTML that will go before the day-of week header cells
|
964
|
+
_this.renderHeadIntroHtml = function () {
|
965
|
+
var _a = _this, theme = _a.theme, dateEnv = _a.dateEnv;
|
966
|
+
var range = _this.props.dateProfile.renderRange;
|
967
|
+
var dayCnt = core.diffDays(range.start, range.end);
|
968
|
+
var weekText;
|
969
|
+
if (_this.opt('weekNumbers')) {
|
970
|
+
weekText = dateEnv.format(range.start, WEEK_HEADER_FORMAT);
|
971
|
+
return '' +
|
972
|
+
'<th class="fc-axis fc-week-number ' + theme.getClass('widgetHeader') + '" ' + _this.axisStyleAttr() + '>' +
|
973
|
+
core.buildGotoAnchorHtml(// aside from link, important for matchCellWidths
|
974
|
+
_this, { date: range.start, type: 'week', forceOff: dayCnt > 1 }, core.htmlEscape(weekText) // inner HTML
|
975
|
+
) +
|
976
|
+
'</th>';
|
977
|
+
}
|
978
|
+
else {
|
979
|
+
return '<th class="fc-axis ' + theme.getClass('widgetHeader') + '" ' + _this.axisStyleAttr() + '></th>';
|
980
|
+
}
|
981
|
+
};
|
982
|
+
/* Time Grid Render Methods
|
983
|
+
------------------------------------------------------------------------------------------------------------------*/
|
984
|
+
// Generates the HTML that goes before the bg of the TimeGrid slot area. Long vertical column.
|
985
|
+
_this.renderTimeGridBgIntroHtml = function () {
|
986
|
+
var theme = _this.theme;
|
987
|
+
return '<td class="fc-axis ' + theme.getClass('widgetContent') + '" ' + _this.axisStyleAttr() + '></td>';
|
988
|
+
};
|
989
|
+
// Generates the HTML that goes before all other types of cells.
|
990
|
+
// Affects content-skeleton, mirror-skeleton, highlight-skeleton for both the time-grid and day-grid.
|
991
|
+
_this.renderTimeGridIntroHtml = function () {
|
992
|
+
return '<td class="fc-axis" ' + _this.axisStyleAttr() + '></td>';
|
993
|
+
};
|
994
|
+
/* Day Grid Render Methods
|
995
|
+
------------------------------------------------------------------------------------------------------------------*/
|
996
|
+
// Generates the HTML that goes before the all-day cells
|
997
|
+
_this.renderDayGridBgIntroHtml = function () {
|
998
|
+
var theme = _this.theme;
|
999
|
+
return '' +
|
1000
|
+
'<td class="fc-axis ' + theme.getClass('widgetContent') + '" ' + _this.axisStyleAttr() + '>' +
|
1001
|
+
'<span>' + // needed for matchCellWidths
|
1002
|
+
core.getAllDayHtml(_this) +
|
1003
|
+
'</span>' +
|
1004
|
+
'</td>';
|
1005
|
+
};
|
1006
|
+
// Generates the HTML that goes before all other types of cells.
|
1007
|
+
// Affects content-skeleton, mirror-skeleton, highlight-skeleton for both the time-grid and day-grid.
|
1008
|
+
_this.renderDayGridIntroHtml = function () {
|
1009
|
+
return '<td class="fc-axis" ' + _this.axisStyleAttr() + '></td>';
|
1010
|
+
};
|
1011
|
+
_this.el.classList.add('fc-timeGrid-view');
|
1012
|
+
_this.el.innerHTML = _this.renderSkeletonHtml();
|
1013
|
+
_this.scroller = new core.ScrollComponent('hidden', // overflow x
|
1014
|
+
'auto' // overflow y
|
1015
|
+
);
|
1016
|
+
var timeGridWrapEl = _this.scroller.el;
|
1017
|
+
_this.el.querySelector('.fc-body > tr > td').appendChild(timeGridWrapEl);
|
1018
|
+
timeGridWrapEl.classList.add('fc-time-grid-container');
|
1019
|
+
var timeGridEl = core.createElement('div', { className: 'fc-time-grid' });
|
1020
|
+
timeGridWrapEl.appendChild(timeGridEl);
|
1021
|
+
_this.timeGrid = new TimeGrid(_this.context, timeGridEl, {
|
1022
|
+
renderBgIntroHtml: _this.renderTimeGridBgIntroHtml,
|
1023
|
+
renderIntroHtml: _this.renderTimeGridIntroHtml
|
1024
|
+
});
|
1025
|
+
if (_this.opt('allDaySlot')) { // should we display the "all-day" area?
|
1026
|
+
_this.dayGrid = new daygrid.DayGrid(// the all-day subcomponent of this view
|
1027
|
+
_this.context, _this.el.querySelector('.fc-day-grid'), {
|
1028
|
+
renderNumberIntroHtml: _this.renderDayGridIntroHtml,
|
1029
|
+
renderBgIntroHtml: _this.renderDayGridBgIntroHtml,
|
1030
|
+
renderIntroHtml: _this.renderDayGridIntroHtml,
|
1031
|
+
colWeekNumbersVisible: false,
|
1032
|
+
cellWeekNumbersVisible: false
|
1033
|
+
});
|
1034
|
+
// have the day-grid extend it's coordinate area over the <hr> dividing the two grids
|
1035
|
+
_this.dayGrid.bottomCoordPadding = _this.el.querySelector('.fc-divider').offsetHeight;
|
1036
|
+
}
|
1037
|
+
return _this;
|
1038
|
+
}
|
1039
|
+
TimeGridView.prototype.destroy = function () {
|
1040
|
+
_super.prototype.destroy.call(this);
|
1041
|
+
this.timeGrid.destroy();
|
1042
|
+
if (this.dayGrid) {
|
1043
|
+
this.dayGrid.destroy();
|
1044
|
+
}
|
1045
|
+
this.scroller.destroy();
|
1046
|
+
};
|
1047
|
+
/* Rendering
|
1048
|
+
------------------------------------------------------------------------------------------------------------------*/
|
1049
|
+
// Builds the HTML skeleton for the view.
|
1050
|
+
// The day-grid and time-grid components will render inside containers defined by this HTML.
|
1051
|
+
TimeGridView.prototype.renderSkeletonHtml = function () {
|
1052
|
+
var theme = this.theme;
|
1053
|
+
return '' +
|
1054
|
+
'<table class="' + theme.getClass('tableGrid') + '">' +
|
1055
|
+
(this.opt('columnHeader') ?
|
1056
|
+
'<thead class="fc-head">' +
|
1057
|
+
'<tr>' +
|
1058
|
+
'<td class="fc-head-container ' + theme.getClass('widgetHeader') + '"> </td>' +
|
1059
|
+
'</tr>' +
|
1060
|
+
'</thead>' :
|
1061
|
+
'') +
|
1062
|
+
'<tbody class="fc-body">' +
|
1063
|
+
'<tr>' +
|
1064
|
+
'<td class="' + theme.getClass('widgetContent') + '">' +
|
1065
|
+
(this.opt('allDaySlot') ?
|
1066
|
+
'<div class="fc-day-grid"></div>' +
|
1067
|
+
'<hr class="fc-divider ' + theme.getClass('widgetHeader') + '" />' :
|
1068
|
+
'') +
|
1069
|
+
'</td>' +
|
1070
|
+
'</tr>' +
|
1071
|
+
'</tbody>' +
|
1072
|
+
'</table>';
|
1073
|
+
};
|
1074
|
+
/* Now Indicator
|
1075
|
+
------------------------------------------------------------------------------------------------------------------*/
|
1076
|
+
TimeGridView.prototype.getNowIndicatorUnit = function () {
|
1077
|
+
return this.timeGrid.getNowIndicatorUnit();
|
1078
|
+
};
|
1079
|
+
// subclasses should implement
|
1080
|
+
// renderNowIndicator(date: DateMarker) {
|
1081
|
+
// }
|
1082
|
+
TimeGridView.prototype.unrenderNowIndicator = function () {
|
1083
|
+
this.timeGrid.unrenderNowIndicator();
|
1084
|
+
};
|
1085
|
+
/* Dimensions
|
1086
|
+
------------------------------------------------------------------------------------------------------------------*/
|
1087
|
+
TimeGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
|
1088
|
+
_super.prototype.updateSize.call(this, isResize, viewHeight, isAuto); // will call updateBaseSize. important that executes first
|
1089
|
+
this.timeGrid.updateSize(isResize);
|
1090
|
+
if (this.dayGrid) {
|
1091
|
+
this.dayGrid.updateSize(isResize);
|
1092
|
+
}
|
1093
|
+
};
|
1094
|
+
// Adjusts the vertical dimensions of the view to the specified values
|
1095
|
+
TimeGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
|
1096
|
+
var _this = this;
|
1097
|
+
var eventLimit;
|
1098
|
+
var scrollerHeight;
|
1099
|
+
var scrollbarWidths;
|
1100
|
+
// make all axis cells line up
|
1101
|
+
this.axisWidth = core.matchCellWidths(core.findElements(this.el, '.fc-axis'));
|
1102
|
+
// hack to give the view some height prior to timeGrid's columns being rendered
|
1103
|
+
// TODO: separate setting height from scroller VS timeGrid.
|
1104
|
+
if (!this.timeGrid.colEls) {
|
1105
|
+
if (!isAuto) {
|
1106
|
+
scrollerHeight = this.computeScrollerHeight(viewHeight);
|
1107
|
+
this.scroller.setHeight(scrollerHeight);
|
1108
|
+
}
|
1109
|
+
return;
|
1110
|
+
}
|
1111
|
+
// set of fake row elements that must compensate when scroller has scrollbars
|
1112
|
+
var noScrollRowEls = core.findElements(this.el, '.fc-row').filter(function (node) {
|
1113
|
+
return !_this.scroller.el.contains(node);
|
1114
|
+
});
|
1115
|
+
// reset all dimensions back to the original state
|
1116
|
+
this.timeGrid.bottomRuleEl.style.display = 'none'; // will be shown later if this <hr> is necessary
|
1117
|
+
this.scroller.clear(); // sets height to 'auto' and clears overflow
|
1118
|
+
noScrollRowEls.forEach(core.uncompensateScroll);
|
1119
|
+
// limit number of events in the all-day area
|
1120
|
+
if (this.dayGrid) {
|
1121
|
+
this.dayGrid.removeSegPopover(); // kill the "more" popover if displayed
|
1122
|
+
eventLimit = this.opt('eventLimit');
|
1123
|
+
if (eventLimit && typeof eventLimit !== 'number') {
|
1124
|
+
eventLimit = TIMEGRID_ALL_DAY_EVENT_LIMIT; // make sure "auto" goes to a real number
|
1125
|
+
}
|
1126
|
+
if (eventLimit) {
|
1127
|
+
this.dayGrid.limitRows(eventLimit);
|
1128
|
+
}
|
1129
|
+
}
|
1130
|
+
if (!isAuto) { // should we force dimensions of the scroll container?
|
1131
|
+
scrollerHeight = this.computeScrollerHeight(viewHeight);
|
1132
|
+
this.scroller.setHeight(scrollerHeight);
|
1133
|
+
scrollbarWidths = this.scroller.getScrollbarWidths();
|
1134
|
+
if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
|
1135
|
+
// make the all-day and header rows lines up
|
1136
|
+
noScrollRowEls.forEach(function (rowEl) {
|
1137
|
+
core.compensateScroll(rowEl, scrollbarWidths);
|
1138
|
+
});
|
1139
|
+
// the scrollbar compensation might have changed text flow, which might affect height, so recalculate
|
1140
|
+
// and reapply the desired height to the scroller.
|
1141
|
+
scrollerHeight = this.computeScrollerHeight(viewHeight);
|
1142
|
+
this.scroller.setHeight(scrollerHeight);
|
1143
|
+
}
|
1144
|
+
// guarantees the same scrollbar widths
|
1145
|
+
this.scroller.lockOverflow(scrollbarWidths);
|
1146
|
+
// if there's any space below the slats, show the horizontal rule.
|
1147
|
+
// this won't cause any new overflow, because lockOverflow already called.
|
1148
|
+
if (this.timeGrid.getTotalSlatHeight() < scrollerHeight) {
|
1149
|
+
this.timeGrid.bottomRuleEl.style.display = '';
|
1150
|
+
}
|
1151
|
+
}
|
1152
|
+
};
|
1153
|
+
// given a desired total height of the view, returns what the height of the scroller should be
|
1154
|
+
TimeGridView.prototype.computeScrollerHeight = function (viewHeight) {
|
1155
|
+
return viewHeight -
|
1156
|
+
core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
|
1157
|
+
};
|
1158
|
+
/* Scroll
|
1159
|
+
------------------------------------------------------------------------------------------------------------------*/
|
1160
|
+
// Computes the initial pre-configured scroll state prior to allowing the user to change it
|
1161
|
+
TimeGridView.prototype.computeDateScroll = function (timeMs) {
|
1162
|
+
var top = this.timeGrid.computeTimeTop(timeMs);
|
1163
|
+
// zoom can give weird floating-point values. rather scroll a little bit further
|
1164
|
+
top = Math.ceil(top);
|
1165
|
+
if (top) {
|
1166
|
+
top++; // to overcome top border that slots beyond the first have. looks better
|
1167
|
+
}
|
1168
|
+
return { top: top };
|
1169
|
+
};
|
1170
|
+
TimeGridView.prototype.queryDateScroll = function () {
|
1171
|
+
return { top: this.scroller.getScrollTop() };
|
1172
|
+
};
|
1173
|
+
TimeGridView.prototype.applyDateScroll = function (scroll) {
|
1174
|
+
if (scroll.top !== undefined) {
|
1175
|
+
this.scroller.setScrollTop(scroll.top);
|
1176
|
+
}
|
1177
|
+
};
|
1178
|
+
// Generates an HTML attribute string for setting the width of the axis, if it is known
|
1179
|
+
TimeGridView.prototype.axisStyleAttr = function () {
|
1180
|
+
if (this.axisWidth != null) {
|
1181
|
+
return 'style="width:' + this.axisWidth + 'px"';
|
1182
|
+
}
|
1183
|
+
return '';
|
1184
|
+
};
|
1185
|
+
return TimeGridView;
|
1186
|
+
}(core.View));
|
1187
|
+
TimeGridView.prototype.usesMinMaxTime = true; // indicates that minTime/maxTime affects rendering
|
1188
|
+
|
1189
|
+
var SimpleTimeGrid = /** @class */ (function (_super) {
|
1190
|
+
__extends(SimpleTimeGrid, _super);
|
1191
|
+
function SimpleTimeGrid(context, timeGrid) {
|
1192
|
+
var _this = _super.call(this, context, timeGrid.el) || this;
|
1193
|
+
_this.buildDayRanges = core.memoize(buildDayRanges);
|
1194
|
+
_this.slicer = new TimeGridSlicer();
|
1195
|
+
_this.timeGrid = timeGrid;
|
1196
|
+
context.calendar.registerInteractiveComponent(_this, {
|
1197
|
+
el: _this.timeGrid.el
|
1198
|
+
});
|
1199
|
+
return _this;
|
1200
|
+
}
|
1201
|
+
SimpleTimeGrid.prototype.destroy = function () {
|
1202
|
+
_super.prototype.destroy.call(this);
|
1203
|
+
this.calendar.unregisterInteractiveComponent(this);
|
1204
|
+
};
|
1205
|
+
SimpleTimeGrid.prototype.render = function (props) {
|
1206
|
+
var dateProfile = props.dateProfile, dayTable = props.dayTable;
|
1207
|
+
var dayRanges = this.dayRanges = this.buildDayRanges(dayTable, dateProfile, this.dateEnv);
|
1208
|
+
this.timeGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, null, this.timeGrid, dayRanges), { dateProfile: dateProfile, cells: dayTable.cells[0] }));
|
1209
|
+
};
|
1210
|
+
SimpleTimeGrid.prototype.renderNowIndicator = function (date) {
|
1211
|
+
this.timeGrid.renderNowIndicator(this.slicer.sliceNowDate(date, this.timeGrid, this.dayRanges), date);
|
1212
|
+
};
|
1213
|
+
SimpleTimeGrid.prototype.buildPositionCaches = function () {
|
1214
|
+
this.timeGrid.buildPositionCaches();
|
1215
|
+
};
|
1216
|
+
SimpleTimeGrid.prototype.queryHit = function (positionLeft, positionTop) {
|
1217
|
+
var rawHit = this.timeGrid.positionToHit(positionLeft, positionTop);
|
1218
|
+
if (rawHit) {
|
1219
|
+
return {
|
1220
|
+
component: this.timeGrid,
|
1221
|
+
dateSpan: rawHit.dateSpan,
|
1222
|
+
dayEl: rawHit.dayEl,
|
1223
|
+
rect: {
|
1224
|
+
left: rawHit.relativeRect.left,
|
1225
|
+
right: rawHit.relativeRect.right,
|
1226
|
+
top: rawHit.relativeRect.top,
|
1227
|
+
bottom: rawHit.relativeRect.bottom
|
1228
|
+
},
|
1229
|
+
layer: 0
|
1230
|
+
};
|
1231
|
+
}
|
1232
|
+
};
|
1233
|
+
return SimpleTimeGrid;
|
1234
|
+
}(core.DateComponent));
|
1235
|
+
function buildDayRanges(dayTable, dateProfile, dateEnv) {
|
1236
|
+
var ranges = [];
|
1237
|
+
for (var _i = 0, _a = dayTable.headerDates; _i < _a.length; _i++) {
|
1238
|
+
var date = _a[_i];
|
1239
|
+
ranges.push({
|
1240
|
+
start: dateEnv.add(date, dateProfile.minTime),
|
1241
|
+
end: dateEnv.add(date, dateProfile.maxTime)
|
1242
|
+
});
|
1243
|
+
}
|
1244
|
+
return ranges;
|
1245
|
+
}
|
1246
|
+
var TimeGridSlicer = /** @class */ (function (_super) {
|
1247
|
+
__extends(TimeGridSlicer, _super);
|
1248
|
+
function TimeGridSlicer() {
|
1249
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
1250
|
+
}
|
1251
|
+
TimeGridSlicer.prototype.sliceRange = function (range, dayRanges) {
|
1252
|
+
var segs = [];
|
1253
|
+
for (var col = 0; col < dayRanges.length; col++) {
|
1254
|
+
var segRange = core.intersectRanges(range, dayRanges[col]);
|
1255
|
+
if (segRange) {
|
1256
|
+
segs.push({
|
1257
|
+
start: segRange.start,
|
1258
|
+
end: segRange.end,
|
1259
|
+
isStart: segRange.start.valueOf() === range.start.valueOf(),
|
1260
|
+
isEnd: segRange.end.valueOf() === range.end.valueOf(),
|
1261
|
+
col: col
|
1262
|
+
});
|
1263
|
+
}
|
1264
|
+
}
|
1265
|
+
return segs;
|
1266
|
+
};
|
1267
|
+
return TimeGridSlicer;
|
1268
|
+
}(core.Slicer));
|
1269
|
+
|
1270
|
+
var TimeGridView$1 = /** @class */ (function (_super) {
|
1271
|
+
__extends(TimeGridView, _super);
|
1272
|
+
function TimeGridView(_context, viewSpec, dateProfileGenerator, parentEl) {
|
1273
|
+
var _this = _super.call(this, _context, viewSpec, dateProfileGenerator, parentEl) || this;
|
1274
|
+
_this.buildDayTable = core.memoize(buildDayTable);
|
1275
|
+
if (_this.opt('columnHeader')) {
|
1276
|
+
_this.header = new core.DayHeader(_this.context, _this.el.querySelector('.fc-head-container'));
|
1277
|
+
}
|
1278
|
+
_this.simpleTimeGrid = new SimpleTimeGrid(_this.context, _this.timeGrid);
|
1279
|
+
if (_this.dayGrid) {
|
1280
|
+
_this.simpleDayGrid = new daygrid.SimpleDayGrid(_this.context, _this.dayGrid);
|
1281
|
+
}
|
1282
|
+
return _this;
|
1283
|
+
}
|
1284
|
+
TimeGridView.prototype.destroy = function () {
|
1285
|
+
_super.prototype.destroy.call(this);
|
1286
|
+
if (this.header) {
|
1287
|
+
this.header.destroy();
|
1288
|
+
}
|
1289
|
+
this.simpleTimeGrid.destroy();
|
1290
|
+
if (this.simpleDayGrid) {
|
1291
|
+
this.simpleDayGrid.destroy();
|
1292
|
+
}
|
1293
|
+
};
|
1294
|
+
TimeGridView.prototype.render = function (props) {
|
1295
|
+
_super.prototype.render.call(this, props); // for flags for updateSize
|
1296
|
+
var dateProfile = this.props.dateProfile;
|
1297
|
+
var dayTable = this.buildDayTable(dateProfile, this.dateProfileGenerator);
|
1298
|
+
var splitProps = this.splitter.splitProps(props);
|
1299
|
+
if (this.header) {
|
1300
|
+
this.header.receiveProps({
|
1301
|
+
dateProfile: dateProfile,
|
1302
|
+
dates: dayTable.headerDates,
|
1303
|
+
datesRepDistinctDays: true,
|
1304
|
+
renderIntroHtml: this.renderHeadIntroHtml
|
1305
|
+
});
|
1306
|
+
}
|
1307
|
+
this.simpleTimeGrid.receiveProps(__assign({}, splitProps['timed'], { dateProfile: dateProfile,
|
1308
|
+
dayTable: dayTable }));
|
1309
|
+
if (this.simpleDayGrid) {
|
1310
|
+
this.simpleDayGrid.receiveProps(__assign({}, splitProps['allDay'], { dateProfile: dateProfile,
|
1311
|
+
dayTable: dayTable, nextDayThreshold: this.nextDayThreshold, isRigid: false }));
|
1312
|
+
}
|
1313
|
+
};
|
1314
|
+
TimeGridView.prototype.renderNowIndicator = function (date) {
|
1315
|
+
this.simpleTimeGrid.renderNowIndicator(date);
|
1316
|
+
};
|
1317
|
+
return TimeGridView;
|
1318
|
+
}(TimeGridView));
|
1319
|
+
function buildDayTable(dateProfile, dateProfileGenerator) {
|
1320
|
+
var daySeries = new core.DaySeries(dateProfile.renderRange, dateProfileGenerator);
|
1321
|
+
return new core.DayTable(daySeries, false);
|
1322
|
+
}
|
1323
|
+
|
1324
|
+
var main = core.createPlugin({
|
1325
|
+
defaultView: 'timeGridWeek',
|
1326
|
+
views: {
|
1327
|
+
timeGrid: {
|
1328
|
+
class: TimeGridView$1,
|
1329
|
+
allDaySlot: true,
|
1330
|
+
slotDuration: '00:30:00',
|
1331
|
+
slotEventOverlap: true // a bad name. confused with overlap/constraint system
|
1332
|
+
},
|
1333
|
+
timeGridDay: {
|
1334
|
+
type: 'timeGrid',
|
1335
|
+
duration: { days: 1 }
|
1336
|
+
},
|
1337
|
+
timeGridWeek: {
|
1338
|
+
type: 'timeGrid',
|
1339
|
+
duration: { weeks: 1 }
|
1340
|
+
}
|
1341
|
+
}
|
1342
|
+
});
|
1343
|
+
|
1344
|
+
exports.AbstractTimeGridView = TimeGridView;
|
1345
|
+
exports.TimeGrid = TimeGrid;
|
1346
|
+
exports.TimeGridSlicer = TimeGridSlicer;
|
1347
|
+
exports.TimeGridView = TimeGridView$1;
|
1348
|
+
exports.buildDayRanges = buildDayRanges;
|
1349
|
+
exports.buildDayTable = buildDayTable;
|
1350
|
+
exports.default = main;
|
1351
|
+
|
1352
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
1353
|
+
|
1354
|
+
}));
|