Açıklama Yok

main.js 78KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641
  1. /*!
  2. FullCalendar Day Grid Plugin v4.3.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')) :
  8. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  9. (global = global || self, factory(global.FullCalendarDayGrid = {}, global.FullCalendar));
  10. }(this, function (exports, core) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. /* global Reflect, Promise */
  24. var extendStatics = function(d, b) {
  25. extendStatics = Object.setPrototypeOf ||
  26. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  27. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  28. return extendStatics(d, b);
  29. };
  30. function __extends(d, b) {
  31. extendStatics(d, b);
  32. function __() { this.constructor = d; }
  33. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34. }
  35. var __assign = function() {
  36. __assign = Object.assign || function __assign(t) {
  37. for (var s, i = 1, n = arguments.length; i < n; i++) {
  38. s = arguments[i];
  39. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  40. }
  41. return t;
  42. };
  43. return __assign.apply(this, arguments);
  44. };
  45. var DayGridDateProfileGenerator = /** @class */ (function (_super) {
  46. __extends(DayGridDateProfileGenerator, _super);
  47. function DayGridDateProfileGenerator() {
  48. return _super !== null && _super.apply(this, arguments) || this;
  49. }
  50. // Computes the date range that will be rendered.
  51. DayGridDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  52. var dateEnv = this.dateEnv;
  53. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  54. var start = renderRange.start;
  55. var end = renderRange.end;
  56. var endOfWeek;
  57. // year and month views should be aligned with weeks. this is already done for week
  58. if (/^(year|month)$/.test(currentRangeUnit)) {
  59. start = dateEnv.startOfWeek(start);
  60. // make end-of-week if not already
  61. endOfWeek = dateEnv.startOfWeek(end);
  62. if (endOfWeek.valueOf() !== end.valueOf()) {
  63. end = core.addWeeks(endOfWeek, 1);
  64. }
  65. }
  66. // ensure 6 weeks
  67. if (this.options.monthMode &&
  68. this.options.fixedWeekCount) {
  69. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  70. core.diffWeeks(start, end));
  71. end = core.addWeeks(end, 6 - rowCnt);
  72. }
  73. return { start: start, end: end };
  74. };
  75. return DayGridDateProfileGenerator;
  76. }(core.DateProfileGenerator));
  77. /* A rectangular panel that is absolutely positioned over other content
  78. ------------------------------------------------------------------------------------------------------------------------
  79. Options:
  80. - className (string)
  81. - content (HTML string, element, or element array)
  82. - parentEl
  83. - top
  84. - left
  85. - right (the x coord of where the right edge should be. not a "CSS" right)
  86. - autoHide (boolean)
  87. - show (callback)
  88. - hide (callback)
  89. */
  90. var Popover = /** @class */ (function () {
  91. function Popover(options) {
  92. var _this = this;
  93. this.isHidden = true;
  94. this.margin = 10; // the space required between the popover and the edges of the scroll container
  95. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  96. this.documentMousedown = function (ev) {
  97. // only hide the popover if the click happened outside the popover
  98. if (_this.el && !_this.el.contains(ev.target)) {
  99. _this.hide();
  100. }
  101. };
  102. this.options = options;
  103. }
  104. // Shows the popover on the specified position. Renders it if not already
  105. Popover.prototype.show = function () {
  106. if (this.isHidden) {
  107. if (!this.el) {
  108. this.render();
  109. }
  110. this.el.style.display = '';
  111. this.position();
  112. this.isHidden = false;
  113. this.trigger('show');
  114. }
  115. };
  116. // Hides the popover, through CSS, but does not remove it from the DOM
  117. Popover.prototype.hide = function () {
  118. if (!this.isHidden) {
  119. this.el.style.display = 'none';
  120. this.isHidden = true;
  121. this.trigger('hide');
  122. }
  123. };
  124. // Creates `this.el` and renders content inside of it
  125. Popover.prototype.render = function () {
  126. var _this = this;
  127. var options = this.options;
  128. var el = this.el = core.createElement('div', {
  129. className: 'fc-popover ' + (options.className || ''),
  130. style: {
  131. top: '0',
  132. left: '0'
  133. }
  134. });
  135. if (typeof options.content === 'function') {
  136. options.content(el);
  137. }
  138. options.parentEl.appendChild(el);
  139. // when a click happens on anything inside with a 'fc-close' className, hide the popover
  140. core.listenBySelector(el, 'click', '.fc-close', function (ev) {
  141. _this.hide();
  142. });
  143. if (options.autoHide) {
  144. document.addEventListener('mousedown', this.documentMousedown);
  145. }
  146. };
  147. // Hides and unregisters any handlers
  148. Popover.prototype.destroy = function () {
  149. this.hide();
  150. if (this.el) {
  151. core.removeElement(this.el);
  152. this.el = null;
  153. }
  154. document.removeEventListener('mousedown', this.documentMousedown);
  155. };
  156. // Positions the popover optimally, using the top/left/right options
  157. Popover.prototype.position = function () {
  158. var options = this.options;
  159. var el = this.el;
  160. var elDims = el.getBoundingClientRect(); // only used for width,height
  161. var origin = core.computeRect(el.offsetParent);
  162. var clippingRect = core.computeClippingRect(options.parentEl);
  163. var top; // the "position" (not "offset") values for the popover
  164. var left; //
  165. // compute top and left
  166. top = options.top || 0;
  167. if (options.left !== undefined) {
  168. left = options.left;
  169. }
  170. else if (options.right !== undefined) {
  171. left = options.right - elDims.width; // derive the left value from the right value
  172. }
  173. else {
  174. left = 0;
  175. }
  176. // constrain to the view port. if constrained by two edges, give precedence to top/left
  177. top = Math.min(top, clippingRect.bottom - elDims.height - this.margin);
  178. top = Math.max(top, clippingRect.top + this.margin);
  179. left = Math.min(left, clippingRect.right - elDims.width - this.margin);
  180. left = Math.max(left, clippingRect.left + this.margin);
  181. core.applyStyle(el, {
  182. top: top - origin.top,
  183. left: left - origin.left
  184. });
  185. };
  186. // Triggers a callback. Calls a function in the option hash of the same name.
  187. // Arguments beyond the first `name` are forwarded on.
  188. // TODO: better code reuse for this. Repeat code
  189. // can kill this???
  190. Popover.prototype.trigger = function (name) {
  191. if (this.options[name]) {
  192. this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
  193. }
  194. };
  195. return Popover;
  196. }());
  197. /* Event-rendering methods for the DayGrid class
  198. ----------------------------------------------------------------------------------------------------------------------*/
  199. // "Simple" is bad a name. has nothing to do with SimpleDayGrid
  200. var SimpleDayGridEventRenderer = /** @class */ (function (_super) {
  201. __extends(SimpleDayGridEventRenderer, _super);
  202. function SimpleDayGridEventRenderer() {
  203. return _super !== null && _super.apply(this, arguments) || this;
  204. }
  205. // Builds the HTML to be used for the default element for an individual segment
  206. SimpleDayGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) {
  207. var _a = this.context, view = _a.view, options = _a.options;
  208. var eventRange = seg.eventRange;
  209. var eventDef = eventRange.def;
  210. var eventUi = eventRange.ui;
  211. var allDay = eventDef.allDay;
  212. var isDraggable = view.computeEventDraggable(eventDef, eventUi);
  213. var isResizableFromStart = allDay && seg.isStart && view.computeEventStartResizable(eventDef, eventUi);
  214. var isResizableFromEnd = allDay && seg.isEnd && view.computeEventEndResizable(eventDef, eventUi);
  215. var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd, mirrorInfo);
  216. var skinCss = core.cssToStr(this.getSkinCss(eventUi));
  217. var timeHtml = '';
  218. var timeText;
  219. var titleHtml;
  220. classes.unshift('fc-day-grid-event', 'fc-h-event');
  221. // Only display a timed events time if it is the starting segment
  222. if (seg.isStart) {
  223. timeText = this.getTimeText(eventRange);
  224. if (timeText) {
  225. timeHtml = '<span class="fc-time">' + core.htmlEscape(timeText) + '</span>';
  226. }
  227. }
  228. titleHtml =
  229. '<span class="fc-title">' +
  230. (core.htmlEscape(eventDef.title || '') || '&nbsp;') + // we always want one line of height
  231. '</span>';
  232. return '<a class="' + classes.join(' ') + '"' +
  233. (eventDef.url ?
  234. ' href="' + core.htmlEscape(eventDef.url) + '"' :
  235. '') +
  236. (skinCss ?
  237. ' style="' + skinCss + '"' :
  238. '') +
  239. '>' +
  240. '<div class="fc-content">' +
  241. (options.dir === 'rtl' ?
  242. titleHtml + ' ' + timeHtml : // put a natural space in between
  243. timeHtml + ' ' + titleHtml //
  244. ) +
  245. '</div>' +
  246. (isResizableFromStart ?
  247. '<div class="fc-resizer fc-start-resizer"></div>' :
  248. '') +
  249. (isResizableFromEnd ?
  250. '<div class="fc-resizer fc-end-resizer"></div>' :
  251. '') +
  252. '</a>';
  253. };
  254. // Computes a default event time formatting string if `eventTimeFormat` is not explicitly defined
  255. SimpleDayGridEventRenderer.prototype.computeEventTimeFormat = function () {
  256. return {
  257. hour: 'numeric',
  258. minute: '2-digit',
  259. omitZeroMinute: true,
  260. meridiem: 'narrow'
  261. };
  262. };
  263. SimpleDayGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  264. return false; // TODO: somehow consider the originating DayGrid's column count
  265. };
  266. return SimpleDayGridEventRenderer;
  267. }(core.FgEventRenderer));
  268. /* Event-rendering methods for the DayGrid class
  269. ----------------------------------------------------------------------------------------------------------------------*/
  270. var DayGridEventRenderer = /** @class */ (function (_super) {
  271. __extends(DayGridEventRenderer, _super);
  272. function DayGridEventRenderer(dayGrid) {
  273. var _this = _super.call(this, dayGrid.context) || this;
  274. _this.dayGrid = dayGrid;
  275. return _this;
  276. }
  277. // Renders the given foreground event segments onto the grid
  278. DayGridEventRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  279. var rowStructs = this.rowStructs = this.renderSegRows(segs);
  280. // append to each row's content skeleton
  281. this.dayGrid.rowEls.forEach(function (rowNode, i) {
  282. rowNode.querySelector('.fc-content-skeleton > table').appendChild(rowStructs[i].tbodyEl);
  283. });
  284. // removes the "more.." events popover
  285. if (!mirrorInfo) {
  286. this.dayGrid.removeSegPopover();
  287. }
  288. };
  289. // Unrenders all currently rendered foreground event segments
  290. DayGridEventRenderer.prototype.detachSegs = function () {
  291. var rowStructs = this.rowStructs || [];
  292. var rowStruct;
  293. while ((rowStruct = rowStructs.pop())) {
  294. core.removeElement(rowStruct.tbodyEl);
  295. }
  296. this.rowStructs = null;
  297. };
  298. // Uses the given events array to generate <tbody> elements that should be appended to each row's content skeleton.
  299. // Returns an array of rowStruct objects (see the bottom of `renderSegRow`).
  300. // PRECONDITION: each segment shoud already have a rendered and assigned `.el`
  301. DayGridEventRenderer.prototype.renderSegRows = function (segs) {
  302. var rowStructs = [];
  303. var segRows;
  304. var row;
  305. segRows = this.groupSegRows(segs); // group into nested arrays
  306. // iterate each row of segment groupings
  307. for (row = 0; row < segRows.length; row++) {
  308. rowStructs.push(this.renderSegRow(row, segRows[row]));
  309. }
  310. return rowStructs;
  311. };
  312. // Given a row # and an array of segments all in the same row, render a <tbody> element, a skeleton that contains
  313. // the segments. Returns object with a bunch of internal data about how the render was calculated.
  314. // NOTE: modifies rowSegs
  315. DayGridEventRenderer.prototype.renderSegRow = function (row, rowSegs) {
  316. var dayGrid = this.dayGrid;
  317. var colCnt = dayGrid.colCnt, isRtl = dayGrid.isRtl;
  318. var segLevels = this.buildSegLevels(rowSegs); // group into sub-arrays of levels
  319. var levelCnt = Math.max(1, segLevels.length); // ensure at least one level
  320. var tbody = document.createElement('tbody');
  321. var segMatrix = []; // lookup for which segments are rendered into which level+col cells
  322. var cellMatrix = []; // lookup for all <td> elements of the level+col matrix
  323. var loneCellMatrix = []; // lookup for <td> elements that only take up a single column
  324. var i;
  325. var levelSegs;
  326. var col;
  327. var tr;
  328. var j;
  329. var seg;
  330. var td;
  331. // populates empty cells from the current column (`col`) to `endCol`
  332. function emptyCellsUntil(endCol) {
  333. while (col < endCol) {
  334. // try to grab a cell from the level above and extend its rowspan. otherwise, create a fresh cell
  335. td = (loneCellMatrix[i - 1] || [])[col];
  336. if (td) {
  337. td.rowSpan = (td.rowSpan || 1) + 1;
  338. }
  339. else {
  340. td = document.createElement('td');
  341. tr.appendChild(td);
  342. }
  343. cellMatrix[i][col] = td;
  344. loneCellMatrix[i][col] = td;
  345. col++;
  346. }
  347. }
  348. for (i = 0; i < levelCnt; i++) { // iterate through all levels
  349. levelSegs = segLevels[i];
  350. col = 0;
  351. tr = document.createElement('tr');
  352. segMatrix.push([]);
  353. cellMatrix.push([]);
  354. loneCellMatrix.push([]);
  355. // levelCnt might be 1 even though there are no actual levels. protect against this.
  356. // this single empty row is useful for styling.
  357. if (levelSegs) {
  358. for (j = 0; j < levelSegs.length; j++) { // iterate through segments in level
  359. seg = levelSegs[j];
  360. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  361. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  362. emptyCellsUntil(leftCol);
  363. // create a container that occupies or more columns. append the event element.
  364. td = core.createElement('td', { className: 'fc-event-container' }, seg.el);
  365. if (leftCol !== rightCol) {
  366. td.colSpan = rightCol - leftCol + 1;
  367. }
  368. else { // a single-column segment
  369. loneCellMatrix[i][col] = td;
  370. }
  371. while (col <= rightCol) {
  372. cellMatrix[i][col] = td;
  373. segMatrix[i][col] = seg;
  374. col++;
  375. }
  376. tr.appendChild(td);
  377. }
  378. }
  379. emptyCellsUntil(colCnt); // finish off the row
  380. var introHtml = dayGrid.renderProps.renderIntroHtml();
  381. if (introHtml) {
  382. if (dayGrid.isRtl) {
  383. core.appendToElement(tr, introHtml);
  384. }
  385. else {
  386. core.prependToElement(tr, introHtml);
  387. }
  388. }
  389. tbody.appendChild(tr);
  390. }
  391. return {
  392. row: row,
  393. tbodyEl: tbody,
  394. cellMatrix: cellMatrix,
  395. segMatrix: segMatrix,
  396. segLevels: segLevels,
  397. segs: rowSegs
  398. };
  399. };
  400. // Stacks a flat array of segments, which are all assumed to be in the same row, into subarrays of vertical levels.
  401. // NOTE: modifies segs
  402. DayGridEventRenderer.prototype.buildSegLevels = function (segs) {
  403. var _a = this.dayGrid, isRtl = _a.isRtl, colCnt = _a.colCnt;
  404. var levels = [];
  405. var i;
  406. var seg;
  407. var j;
  408. // Give preference to elements with certain criteria, so they have
  409. // a chance to be closer to the top.
  410. segs = this.sortEventSegs(segs);
  411. for (i = 0; i < segs.length; i++) {
  412. seg = segs[i];
  413. // loop through levels, starting with the topmost, until the segment doesn't collide with other segments
  414. for (j = 0; j < levels.length; j++) {
  415. if (!isDaySegCollision(seg, levels[j])) {
  416. break;
  417. }
  418. }
  419. // `j` now holds the desired subrow index
  420. seg.level = j;
  421. seg.leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol; // for sorting only
  422. seg.rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol // for sorting only
  423. ;
  424. (levels[j] || (levels[j] = [])).push(seg);
  425. }
  426. // order segments left-to-right. very important if calendar is RTL
  427. for (j = 0; j < levels.length; j++) {
  428. levels[j].sort(compareDaySegCols);
  429. }
  430. return levels;
  431. };
  432. // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's row
  433. DayGridEventRenderer.prototype.groupSegRows = function (segs) {
  434. var segRows = [];
  435. var i;
  436. for (i = 0; i < this.dayGrid.rowCnt; i++) {
  437. segRows.push([]);
  438. }
  439. for (i = 0; i < segs.length; i++) {
  440. segRows[segs[i].row].push(segs[i]);
  441. }
  442. return segRows;
  443. };
  444. // Computes a default `displayEventEnd` value if one is not expliclty defined
  445. DayGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  446. return this.dayGrid.colCnt === 1; // we'll likely have space if there's only one day
  447. };
  448. return DayGridEventRenderer;
  449. }(SimpleDayGridEventRenderer));
  450. // Computes whether two segments' columns collide. They are assumed to be in the same row.
  451. function isDaySegCollision(seg, otherSegs) {
  452. var i;
  453. var otherSeg;
  454. for (i = 0; i < otherSegs.length; i++) {
  455. otherSeg = otherSegs[i];
  456. if (otherSeg.firstCol <= seg.lastCol &&
  457. otherSeg.lastCol >= seg.firstCol) {
  458. return true;
  459. }
  460. }
  461. return false;
  462. }
  463. // A cmp function for determining the leftmost event
  464. function compareDaySegCols(a, b) {
  465. return a.leftCol - b.leftCol;
  466. }
  467. var DayGridMirrorRenderer = /** @class */ (function (_super) {
  468. __extends(DayGridMirrorRenderer, _super);
  469. function DayGridMirrorRenderer() {
  470. return _super !== null && _super.apply(this, arguments) || this;
  471. }
  472. DayGridMirrorRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  473. var sourceSeg = mirrorInfo.sourceSeg;
  474. var rowStructs = this.rowStructs = this.renderSegRows(segs);
  475. // inject each new event skeleton into each associated row
  476. this.dayGrid.rowEls.forEach(function (rowNode, row) {
  477. var skeletonEl = core.htmlToElement('<div class="fc-mirror-skeleton"><table></table></div>'); // will be absolutely positioned
  478. var skeletonTopEl;
  479. var skeletonTop;
  480. // If there is an original segment, match the top position. Otherwise, put it at the row's top level
  481. if (sourceSeg && sourceSeg.row === row) {
  482. skeletonTopEl = sourceSeg.el;
  483. }
  484. else {
  485. skeletonTopEl = rowNode.querySelector('.fc-content-skeleton tbody');
  486. if (!skeletonTopEl) { // when no events
  487. skeletonTopEl = rowNode.querySelector('.fc-content-skeleton table');
  488. }
  489. }
  490. skeletonTop = skeletonTopEl.getBoundingClientRect().top -
  491. rowNode.getBoundingClientRect().top; // the offsetParent origin
  492. skeletonEl.style.top = skeletonTop + 'px';
  493. skeletonEl.querySelector('table').appendChild(rowStructs[row].tbodyEl);
  494. rowNode.appendChild(skeletonEl);
  495. });
  496. };
  497. return DayGridMirrorRenderer;
  498. }(DayGridEventRenderer));
  499. var EMPTY_CELL_HTML = '<td style="pointer-events:none"></td>';
  500. var DayGridFillRenderer = /** @class */ (function (_super) {
  501. __extends(DayGridFillRenderer, _super);
  502. function DayGridFillRenderer(dayGrid) {
  503. var _this = _super.call(this, dayGrid.context) || this;
  504. _this.fillSegTag = 'td'; // override the default tag name
  505. _this.dayGrid = dayGrid;
  506. return _this;
  507. }
  508. DayGridFillRenderer.prototype.renderSegs = function (type, segs) {
  509. // don't render timed background events
  510. if (type === 'bgEvent') {
  511. segs = segs.filter(function (seg) {
  512. return seg.eventRange.def.allDay;
  513. });
  514. }
  515. _super.prototype.renderSegs.call(this, type, segs);
  516. };
  517. DayGridFillRenderer.prototype.attachSegs = function (type, segs) {
  518. var els = [];
  519. var i;
  520. var seg;
  521. var skeletonEl;
  522. for (i = 0; i < segs.length; i++) {
  523. seg = segs[i];
  524. skeletonEl = this.renderFillRow(type, seg);
  525. this.dayGrid.rowEls[seg.row].appendChild(skeletonEl);
  526. els.push(skeletonEl);
  527. }
  528. return els;
  529. };
  530. // Generates the HTML needed for one row of a fill. Requires the seg's el to be rendered.
  531. DayGridFillRenderer.prototype.renderFillRow = function (type, seg) {
  532. var dayGrid = this.dayGrid;
  533. var colCnt = dayGrid.colCnt, isRtl = dayGrid.isRtl;
  534. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  535. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  536. var startCol = leftCol;
  537. var endCol = rightCol + 1;
  538. var className;
  539. var skeletonEl;
  540. var trEl;
  541. if (type === 'businessHours') {
  542. className = 'bgevent';
  543. }
  544. else {
  545. className = type.toLowerCase();
  546. }
  547. skeletonEl = core.htmlToElement('<div class="fc-' + className + '-skeleton">' +
  548. '<table><tr></tr></table>' +
  549. '</div>');
  550. trEl = skeletonEl.getElementsByTagName('tr')[0];
  551. if (startCol > 0) {
  552. core.appendToElement(trEl,
  553. // will create (startCol + 1) td's
  554. new Array(startCol + 1).join(EMPTY_CELL_HTML));
  555. }
  556. seg.el.colSpan = endCol - startCol;
  557. trEl.appendChild(seg.el);
  558. if (endCol < colCnt) {
  559. core.appendToElement(trEl,
  560. // will create (colCnt - endCol) td's
  561. new Array(colCnt - endCol + 1).join(EMPTY_CELL_HTML));
  562. }
  563. var introHtml = dayGrid.renderProps.renderIntroHtml();
  564. if (introHtml) {
  565. if (dayGrid.isRtl) {
  566. core.appendToElement(trEl, introHtml);
  567. }
  568. else {
  569. core.prependToElement(trEl, introHtml);
  570. }
  571. }
  572. return skeletonEl;
  573. };
  574. return DayGridFillRenderer;
  575. }(core.FillRenderer));
  576. var DayTile = /** @class */ (function (_super) {
  577. __extends(DayTile, _super);
  578. function DayTile(context, el) {
  579. var _this = _super.call(this, context, el) || this;
  580. var eventRenderer = _this.eventRenderer = new DayTileEventRenderer(_this);
  581. var renderFrame = _this.renderFrame = core.memoizeRendering(_this._renderFrame);
  582. _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderFrame]);
  583. _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  584. _this.renderEventDrag = core.memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]);
  585. _this.renderEventResize = core.memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]);
  586. context.calendar.registerInteractiveComponent(_this, {
  587. el: _this.el,
  588. useEventCenter: false
  589. });
  590. return _this;
  591. }
  592. DayTile.prototype.render = function (props) {
  593. this.renderFrame(props.date);
  594. this.renderFgEvents(props.fgSegs);
  595. this.renderEventSelection(props.eventSelection);
  596. this.renderEventDrag(props.eventDragInstances);
  597. this.renderEventResize(props.eventResizeInstances);
  598. };
  599. DayTile.prototype.destroy = function () {
  600. _super.prototype.destroy.call(this);
  601. this.renderFrame.unrender(); // should unrender everything else
  602. this.calendar.unregisterInteractiveComponent(this);
  603. };
  604. DayTile.prototype._renderFrame = function (date) {
  605. var _a = this, theme = _a.theme, dateEnv = _a.dateEnv;
  606. var title = dateEnv.format(date, core.createFormatter(this.opt('dayPopoverFormat')) // TODO: cache
  607. );
  608. this.el.innerHTML =
  609. '<div class="fc-header ' + theme.getClass('popoverHeader') + '">' +
  610. '<span class="fc-title">' +
  611. core.htmlEscape(title) +
  612. '</span>' +
  613. '<span class="fc-close ' + theme.getIconClass('close') + '"></span>' +
  614. '</div>' +
  615. '<div class="fc-body ' + theme.getClass('popoverContent') + '">' +
  616. '<div class="fc-event-container"></div>' +
  617. '</div>';
  618. this.segContainerEl = this.el.querySelector('.fc-event-container');
  619. };
  620. DayTile.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  621. var date = this.props.date; // HACK
  622. if (positionLeft < elWidth && positionTop < elHeight) {
  623. return {
  624. component: this,
  625. dateSpan: {
  626. allDay: true,
  627. range: { start: date, end: core.addDays(date, 1) }
  628. },
  629. dayEl: this.el,
  630. rect: {
  631. left: 0,
  632. top: 0,
  633. right: elWidth,
  634. bottom: elHeight
  635. },
  636. layer: 1
  637. };
  638. }
  639. };
  640. return DayTile;
  641. }(core.DateComponent));
  642. var DayTileEventRenderer = /** @class */ (function (_super) {
  643. __extends(DayTileEventRenderer, _super);
  644. function DayTileEventRenderer(dayTile) {
  645. var _this = _super.call(this, dayTile.context) || this;
  646. _this.dayTile = dayTile;
  647. return _this;
  648. }
  649. DayTileEventRenderer.prototype.attachSegs = function (segs) {
  650. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  651. var seg = segs_1[_i];
  652. this.dayTile.segContainerEl.appendChild(seg.el);
  653. }
  654. };
  655. DayTileEventRenderer.prototype.detachSegs = function (segs) {
  656. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  657. var seg = segs_2[_i];
  658. core.removeElement(seg.el);
  659. }
  660. };
  661. return DayTileEventRenderer;
  662. }(SimpleDayGridEventRenderer));
  663. var DayBgRow = /** @class */ (function () {
  664. function DayBgRow(context) {
  665. this.context = context;
  666. }
  667. DayBgRow.prototype.renderHtml = function (props) {
  668. var parts = [];
  669. if (props.renderIntroHtml) {
  670. parts.push(props.renderIntroHtml());
  671. }
  672. for (var _i = 0, _a = props.cells; _i < _a.length; _i++) {
  673. var cell = _a[_i];
  674. parts.push(renderCellHtml(cell.date, props.dateProfile, this.context, cell.htmlAttrs));
  675. }
  676. if (!props.cells.length) {
  677. parts.push('<td class="fc-day ' + this.context.theme.getClass('widgetContent') + '"></td>');
  678. }
  679. if (this.context.options.dir === 'rtl') {
  680. parts.reverse();
  681. }
  682. return '<tr>' + parts.join('') + '</tr>';
  683. };
  684. return DayBgRow;
  685. }());
  686. function renderCellHtml(date, dateProfile, context, otherAttrs) {
  687. var dateEnv = context.dateEnv, theme = context.theme;
  688. var isDateValid = core.rangeContainsMarker(dateProfile.activeRange, date); // TODO: called too frequently. cache somehow.
  689. var classes = core.getDayClasses(date, dateProfile, context);
  690. classes.unshift('fc-day', theme.getClass('widgetContent'));
  691. return '<td class="' + classes.join(' ') + '"' +
  692. (isDateValid ?
  693. ' data-date="' + dateEnv.formatIso(date, { omitTime: true }) + '"' :
  694. '') +
  695. (otherAttrs ?
  696. ' ' + otherAttrs :
  697. '') +
  698. '></td>';
  699. }
  700. var DAY_NUM_FORMAT = core.createFormatter({ day: 'numeric' });
  701. var WEEK_NUM_FORMAT = core.createFormatter({ week: 'numeric' });
  702. var DayGrid = /** @class */ (function (_super) {
  703. __extends(DayGrid, _super);
  704. function DayGrid(context, el, renderProps) {
  705. var _this = _super.call(this, context, el) || this;
  706. _this.bottomCoordPadding = 0; // hack for extending the hit area for the last row of the coordinate grid
  707. _this.isCellSizesDirty = false;
  708. var eventRenderer = _this.eventRenderer = new DayGridEventRenderer(_this);
  709. var fillRenderer = _this.fillRenderer = new DayGridFillRenderer(_this);
  710. _this.mirrorRenderer = new DayGridMirrorRenderer(_this);
  711. var renderCells = _this.renderCells = core.memoizeRendering(_this._renderCells, _this._unrenderCells);
  712. _this.renderBusinessHours = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'businessHours'), fillRenderer.unrender.bind(fillRenderer, 'businessHours'), [renderCells]);
  713. _this.renderDateSelection = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'highlight'), fillRenderer.unrender.bind(fillRenderer, 'highlight'), [renderCells]);
  714. _this.renderBgEvents = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'bgEvent'), fillRenderer.unrender.bind(fillRenderer, 'bgEvent'), [renderCells]);
  715. _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderCells]);
  716. _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  717. _this.renderEventDrag = core.memoizeRendering(_this._renderEventDrag, _this._unrenderEventDrag, [renderCells]);
  718. _this.renderEventResize = core.memoizeRendering(_this._renderEventResize, _this._unrenderEventResize, [renderCells]);
  719. _this.renderProps = renderProps;
  720. return _this;
  721. }
  722. DayGrid.prototype.render = function (props) {
  723. var cells = props.cells;
  724. this.rowCnt = cells.length;
  725. this.colCnt = cells[0].length;
  726. this.renderCells(cells, props.isRigid);
  727. this.renderBusinessHours(props.businessHourSegs);
  728. this.renderDateSelection(props.dateSelectionSegs);
  729. this.renderBgEvents(props.bgEventSegs);
  730. this.renderFgEvents(props.fgEventSegs);
  731. this.renderEventSelection(props.eventSelection);
  732. this.renderEventDrag(props.eventDrag);
  733. this.renderEventResize(props.eventResize);
  734. if (this.segPopoverTile) {
  735. this.updateSegPopoverTile();
  736. }
  737. };
  738. DayGrid.prototype.destroy = function () {
  739. _super.prototype.destroy.call(this);
  740. this.renderCells.unrender(); // will unrender everything else
  741. };
  742. DayGrid.prototype.getCellRange = function (row, col) {
  743. var start = this.props.cells[row][col].date;
  744. var end = core.addDays(start, 1);
  745. return { start: start, end: end };
  746. };
  747. DayGrid.prototype.updateSegPopoverTile = function (date, segs) {
  748. var ownProps = this.props;
  749. this.segPopoverTile.receiveProps({
  750. date: date || this.segPopoverTile.props.date,
  751. fgSegs: segs || this.segPopoverTile.props.fgSegs,
  752. eventSelection: ownProps.eventSelection,
  753. eventDragInstances: ownProps.eventDrag ? ownProps.eventDrag.affectedInstances : null,
  754. eventResizeInstances: ownProps.eventResize ? ownProps.eventResize.affectedInstances : null
  755. });
  756. };
  757. /* Date Rendering
  758. ------------------------------------------------------------------------------------------------------------------*/
  759. DayGrid.prototype._renderCells = function (cells, isRigid) {
  760. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  761. var _b = this, rowCnt = _b.rowCnt, colCnt = _b.colCnt;
  762. var html = '';
  763. var row;
  764. var col;
  765. for (row = 0; row < rowCnt; row++) {
  766. html += this.renderDayRowHtml(row, isRigid);
  767. }
  768. this.el.innerHTML = html;
  769. this.rowEls = core.findElements(this.el, '.fc-row');
  770. this.cellEls = core.findElements(this.el, '.fc-day, .fc-disabled-day');
  771. if (this.isRtl) {
  772. this.cellEls.reverse();
  773. }
  774. this.rowPositions = new core.PositionCache(this.el, this.rowEls, false, true // vertical
  775. );
  776. this.colPositions = new core.PositionCache(this.el, this.cellEls.slice(0, colCnt), // only the first row
  777. true, false // horizontal
  778. );
  779. // trigger dayRender with each cell's element
  780. for (row = 0; row < rowCnt; row++) {
  781. for (col = 0; col < colCnt; col++) {
  782. this.publiclyTrigger('dayRender', [
  783. {
  784. date: dateEnv.toDate(cells[row][col].date),
  785. el: this.getCellEl(row, col),
  786. view: view
  787. }
  788. ]);
  789. }
  790. }
  791. this.isCellSizesDirty = true;
  792. };
  793. DayGrid.prototype._unrenderCells = function () {
  794. this.removeSegPopover();
  795. };
  796. // Generates the HTML for a single row, which is a div that wraps a table.
  797. // `row` is the row number.
  798. DayGrid.prototype.renderDayRowHtml = function (row, isRigid) {
  799. var theme = this.theme;
  800. var classes = ['fc-row', 'fc-week', theme.getClass('dayRow')];
  801. if (isRigid) {
  802. classes.push('fc-rigid');
  803. }
  804. var bgRow = new DayBgRow(this.context);
  805. return '' +
  806. '<div class="' + classes.join(' ') + '">' +
  807. '<div class="fc-bg">' +
  808. '<table class="' + theme.getClass('tableGrid') + '">' +
  809. bgRow.renderHtml({
  810. cells: this.props.cells[row],
  811. dateProfile: this.props.dateProfile,
  812. renderIntroHtml: this.renderProps.renderBgIntroHtml
  813. }) +
  814. '</table>' +
  815. '</div>' +
  816. '<div class="fc-content-skeleton">' +
  817. '<table>' +
  818. (this.getIsNumbersVisible() ?
  819. '<thead>' +
  820. this.renderNumberTrHtml(row) +
  821. '</thead>' :
  822. '') +
  823. '</table>' +
  824. '</div>' +
  825. '</div>';
  826. };
  827. DayGrid.prototype.getIsNumbersVisible = function () {
  828. return this.getIsDayNumbersVisible() ||
  829. this.renderProps.cellWeekNumbersVisible ||
  830. this.renderProps.colWeekNumbersVisible;
  831. };
  832. DayGrid.prototype.getIsDayNumbersVisible = function () {
  833. return this.rowCnt > 1;
  834. };
  835. /* Grid Number Rendering
  836. ------------------------------------------------------------------------------------------------------------------*/
  837. DayGrid.prototype.renderNumberTrHtml = function (row) {
  838. var intro = this.renderProps.renderNumberIntroHtml(row, this);
  839. return '' +
  840. '<tr>' +
  841. (this.isRtl ? '' : intro) +
  842. this.renderNumberCellsHtml(row) +
  843. (this.isRtl ? intro : '') +
  844. '</tr>';
  845. };
  846. DayGrid.prototype.renderNumberCellsHtml = function (row) {
  847. var htmls = [];
  848. var col;
  849. var date;
  850. for (col = 0; col < this.colCnt; col++) {
  851. date = this.props.cells[row][col].date;
  852. htmls.push(this.renderNumberCellHtml(date));
  853. }
  854. if (this.isRtl) {
  855. htmls.reverse();
  856. }
  857. return htmls.join('');
  858. };
  859. // Generates the HTML for the <td>s of the "number" row in the DayGrid's content skeleton.
  860. // The number row will only exist if either day numbers or week numbers are turned on.
  861. DayGrid.prototype.renderNumberCellHtml = function (date) {
  862. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  863. var html = '';
  864. var isDateValid = core.rangeContainsMarker(this.props.dateProfile.activeRange, date); // TODO: called too frequently. cache somehow.
  865. var isDayNumberVisible = this.getIsDayNumbersVisible() && isDateValid;
  866. var classes;
  867. var weekCalcFirstDow;
  868. if (!isDayNumberVisible && !this.renderProps.cellWeekNumbersVisible) {
  869. // no numbers in day cell (week number must be along the side)
  870. return '<td></td>'; // will create an empty space above events :(
  871. }
  872. classes = core.getDayClasses(date, this.props.dateProfile, this.context);
  873. classes.unshift('fc-day-top');
  874. if (this.renderProps.cellWeekNumbersVisible) {
  875. weekCalcFirstDow = dateEnv.weekDow;
  876. }
  877. html += '<td class="' + classes.join(' ') + '"' +
  878. (isDateValid ?
  879. ' data-date="' + dateEnv.formatIso(date, { omitTime: true }) + '"' :
  880. '') +
  881. '>';
  882. if (this.renderProps.cellWeekNumbersVisible && (date.getUTCDay() === weekCalcFirstDow)) {
  883. html += core.buildGotoAnchorHtml(view, { date: date, type: 'week' }, { 'class': 'fc-week-number' }, dateEnv.format(date, WEEK_NUM_FORMAT) // inner HTML
  884. );
  885. }
  886. if (isDayNumberVisible) {
  887. html += core.buildGotoAnchorHtml(view, date, { 'class': 'fc-day-number' }, dateEnv.format(date, DAY_NUM_FORMAT) // inner HTML
  888. );
  889. }
  890. html += '</td>';
  891. return html;
  892. };
  893. /* Sizing
  894. ------------------------------------------------------------------------------------------------------------------*/
  895. DayGrid.prototype.updateSize = function (isResize) {
  896. var _a = this, fillRenderer = _a.fillRenderer, eventRenderer = _a.eventRenderer, mirrorRenderer = _a.mirrorRenderer;
  897. if (isResize ||
  898. this.isCellSizesDirty ||
  899. this.view.calendar.isEventsUpdated // hack
  900. ) {
  901. this.buildPositionCaches();
  902. this.isCellSizesDirty = false;
  903. }
  904. fillRenderer.computeSizes(isResize);
  905. eventRenderer.computeSizes(isResize);
  906. mirrorRenderer.computeSizes(isResize);
  907. fillRenderer.assignSizes(isResize);
  908. eventRenderer.assignSizes(isResize);
  909. mirrorRenderer.assignSizes(isResize);
  910. };
  911. DayGrid.prototype.buildPositionCaches = function () {
  912. this.buildColPositions();
  913. this.buildRowPositions();
  914. };
  915. DayGrid.prototype.buildColPositions = function () {
  916. this.colPositions.build();
  917. };
  918. DayGrid.prototype.buildRowPositions = function () {
  919. this.rowPositions.build();
  920. this.rowPositions.bottoms[this.rowCnt - 1] += this.bottomCoordPadding; // hack
  921. };
  922. /* Hit System
  923. ------------------------------------------------------------------------------------------------------------------*/
  924. DayGrid.prototype.positionToHit = function (leftPosition, topPosition) {
  925. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  926. var col = colPositions.leftToIndex(leftPosition);
  927. var row = rowPositions.topToIndex(topPosition);
  928. if (row != null && col != null) {
  929. return {
  930. row: row,
  931. col: col,
  932. dateSpan: {
  933. range: this.getCellRange(row, col),
  934. allDay: true
  935. },
  936. dayEl: this.getCellEl(row, col),
  937. relativeRect: {
  938. left: colPositions.lefts[col],
  939. right: colPositions.rights[col],
  940. top: rowPositions.tops[row],
  941. bottom: rowPositions.bottoms[row]
  942. }
  943. };
  944. }
  945. };
  946. /* Cell System
  947. ------------------------------------------------------------------------------------------------------------------*/
  948. // FYI: the first column is the leftmost column, regardless of date
  949. DayGrid.prototype.getCellEl = function (row, col) {
  950. return this.cellEls[row * this.colCnt + col];
  951. };
  952. /* Event Drag Visualization
  953. ------------------------------------------------------------------------------------------------------------------*/
  954. DayGrid.prototype._renderEventDrag = function (state) {
  955. if (state) {
  956. this.eventRenderer.hideByHash(state.affectedInstances);
  957. this.fillRenderer.renderSegs('highlight', state.segs);
  958. }
  959. };
  960. DayGrid.prototype._unrenderEventDrag = function (state) {
  961. if (state) {
  962. this.eventRenderer.showByHash(state.affectedInstances);
  963. this.fillRenderer.unrender('highlight');
  964. }
  965. };
  966. /* Event Resize Visualization
  967. ------------------------------------------------------------------------------------------------------------------*/
  968. DayGrid.prototype._renderEventResize = function (state) {
  969. if (state) {
  970. this.eventRenderer.hideByHash(state.affectedInstances);
  971. this.fillRenderer.renderSegs('highlight', state.segs);
  972. this.mirrorRenderer.renderSegs(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  973. }
  974. };
  975. DayGrid.prototype._unrenderEventResize = function (state) {
  976. if (state) {
  977. this.eventRenderer.showByHash(state.affectedInstances);
  978. this.fillRenderer.unrender('highlight');
  979. this.mirrorRenderer.unrender(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  980. }
  981. };
  982. /* More+ Link Popover
  983. ------------------------------------------------------------------------------------------------------------------*/
  984. DayGrid.prototype.removeSegPopover = function () {
  985. if (this.segPopover) {
  986. this.segPopover.hide(); // in handler, will call segPopover's removeElement
  987. }
  988. };
  989. // Limits the number of "levels" (vertically stacking layers of events) for each row of the grid.
  990. // `levelLimit` can be false (don't limit), a number, or true (should be computed).
  991. DayGrid.prototype.limitRows = function (levelLimit) {
  992. var rowStructs = this.eventRenderer.rowStructs || [];
  993. var row; // row #
  994. var rowLevelLimit;
  995. for (row = 0; row < rowStructs.length; row++) {
  996. this.unlimitRow(row);
  997. if (!levelLimit) {
  998. rowLevelLimit = false;
  999. }
  1000. else if (typeof levelLimit === 'number') {
  1001. rowLevelLimit = levelLimit;
  1002. }
  1003. else {
  1004. rowLevelLimit = this.computeRowLevelLimit(row);
  1005. }
  1006. if (rowLevelLimit !== false) {
  1007. this.limitRow(row, rowLevelLimit);
  1008. }
  1009. }
  1010. };
  1011. // Computes the number of levels a row will accomodate without going outside its bounds.
  1012. // Assumes the row is "rigid" (maintains a constant height regardless of what is inside).
  1013. // `row` is the row number.
  1014. DayGrid.prototype.computeRowLevelLimit = function (row) {
  1015. var rowEl = this.rowEls[row]; // the containing "fake" row div
  1016. var rowBottom = rowEl.getBoundingClientRect().bottom; // relative to viewport!
  1017. var trEls = core.findChildren(this.eventRenderer.rowStructs[row].tbodyEl);
  1018. var i;
  1019. var trEl;
  1020. // Reveal one level <tr> at a time and stop when we find one out of bounds
  1021. for (i = 0; i < trEls.length; i++) {
  1022. trEl = trEls[i];
  1023. trEl.classList.remove('fc-limited'); // reset to original state (reveal)
  1024. if (trEl.getBoundingClientRect().bottom > rowBottom) {
  1025. return i;
  1026. }
  1027. }
  1028. return false; // should not limit at all
  1029. };
  1030. // Limits the given grid row to the maximum number of levels and injects "more" links if necessary.
  1031. // `row` is the row number.
  1032. // `levelLimit` is a number for the maximum (inclusive) number of levels allowed.
  1033. DayGrid.prototype.limitRow = function (row, levelLimit) {
  1034. var _this = this;
  1035. var _a = this, colCnt = _a.colCnt, isRtl = _a.isRtl;
  1036. var rowStruct = this.eventRenderer.rowStructs[row];
  1037. var moreNodes = []; // array of "more" <a> links and <td> DOM nodes
  1038. var col = 0; // col #, left-to-right (not chronologically)
  1039. var levelSegs; // array of segment objects in the last allowable level, ordered left-to-right
  1040. var cellMatrix; // a matrix (by level, then column) of all <td> elements in the row
  1041. var limitedNodes; // array of temporarily hidden level <tr> and segment <td> DOM nodes
  1042. var i;
  1043. var seg;
  1044. var segsBelow; // array of segment objects below `seg` in the current `col`
  1045. var totalSegsBelow; // total number of segments below `seg` in any of the columns `seg` occupies
  1046. var colSegsBelow; // array of segment arrays, below seg, one for each column (offset from segs's first column)
  1047. var td;
  1048. var rowSpan;
  1049. var segMoreNodes; // array of "more" <td> cells that will stand-in for the current seg's cell
  1050. var j;
  1051. var moreTd;
  1052. var moreWrap;
  1053. var moreLink;
  1054. // Iterates through empty level cells and places "more" links inside if need be
  1055. var emptyCellsUntil = function (endCol) {
  1056. while (col < endCol) {
  1057. segsBelow = _this.getCellSegs(row, col, levelLimit);
  1058. if (segsBelow.length) {
  1059. td = cellMatrix[levelLimit - 1][col];
  1060. moreLink = _this.renderMoreLink(row, col, segsBelow);
  1061. moreWrap = core.createElement('div', null, moreLink);
  1062. td.appendChild(moreWrap);
  1063. moreNodes.push(moreWrap);
  1064. }
  1065. col++;
  1066. }
  1067. };
  1068. if (levelLimit && levelLimit < rowStruct.segLevels.length) { // is it actually over the limit?
  1069. levelSegs = rowStruct.segLevels[levelLimit - 1];
  1070. cellMatrix = rowStruct.cellMatrix;
  1071. limitedNodes = core.findChildren(rowStruct.tbodyEl).slice(levelLimit); // get level <tr> elements past the limit
  1072. limitedNodes.forEach(function (node) {
  1073. node.classList.add('fc-limited'); // hide elements and get a simple DOM-nodes array
  1074. });
  1075. // iterate though segments in the last allowable level
  1076. for (i = 0; i < levelSegs.length; i++) {
  1077. seg = levelSegs[i];
  1078. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  1079. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  1080. emptyCellsUntil(leftCol); // process empty cells before the segment
  1081. // determine *all* segments below `seg` that occupy the same columns
  1082. colSegsBelow = [];
  1083. totalSegsBelow = 0;
  1084. while (col <= rightCol) {
  1085. segsBelow = this.getCellSegs(row, col, levelLimit);
  1086. colSegsBelow.push(segsBelow);
  1087. totalSegsBelow += segsBelow.length;
  1088. col++;
  1089. }
  1090. if (totalSegsBelow) { // do we need to replace this segment with one or many "more" links?
  1091. td = cellMatrix[levelLimit - 1][leftCol]; // the segment's parent cell
  1092. rowSpan = td.rowSpan || 1;
  1093. segMoreNodes = [];
  1094. // make a replacement <td> for each column the segment occupies. will be one for each colspan
  1095. for (j = 0; j < colSegsBelow.length; j++) {
  1096. moreTd = core.createElement('td', { className: 'fc-more-cell', rowSpan: rowSpan });
  1097. segsBelow = colSegsBelow[j];
  1098. moreLink = this.renderMoreLink(row, leftCol + j, [seg].concat(segsBelow) // count seg as hidden too
  1099. );
  1100. moreWrap = core.createElement('div', null, moreLink);
  1101. moreTd.appendChild(moreWrap);
  1102. segMoreNodes.push(moreTd);
  1103. moreNodes.push(moreTd);
  1104. }
  1105. td.classList.add('fc-limited');
  1106. core.insertAfterElement(td, segMoreNodes);
  1107. limitedNodes.push(td);
  1108. }
  1109. }
  1110. emptyCellsUntil(this.colCnt); // finish off the level
  1111. rowStruct.moreEls = moreNodes; // for easy undoing later
  1112. rowStruct.limitedEls = limitedNodes; // for easy undoing later
  1113. }
  1114. };
  1115. // Reveals all levels and removes all "more"-related elements for a grid's row.
  1116. // `row` is a row number.
  1117. DayGrid.prototype.unlimitRow = function (row) {
  1118. var rowStruct = this.eventRenderer.rowStructs[row];
  1119. if (rowStruct.moreEls) {
  1120. rowStruct.moreEls.forEach(core.removeElement);
  1121. rowStruct.moreEls = null;
  1122. }
  1123. if (rowStruct.limitedEls) {
  1124. rowStruct.limitedEls.forEach(function (limitedEl) {
  1125. limitedEl.classList.remove('fc-limited');
  1126. });
  1127. rowStruct.limitedEls = null;
  1128. }
  1129. };
  1130. // Renders an <a> element that represents hidden event element for a cell.
  1131. // Responsible for attaching click handler as well.
  1132. DayGrid.prototype.renderMoreLink = function (row, col, hiddenSegs) {
  1133. var _this = this;
  1134. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  1135. var a = core.createElement('a', { className: 'fc-more' });
  1136. a.innerText = this.getMoreLinkText(hiddenSegs.length);
  1137. a.addEventListener('click', function (ev) {
  1138. var clickOption = _this.opt('eventLimitClick');
  1139. var _col = _this.isRtl ? _this.colCnt - col - 1 : col; // HACK: props.cells has different dir system?
  1140. var date = _this.props.cells[row][_col].date;
  1141. var moreEl = ev.currentTarget;
  1142. var dayEl = _this.getCellEl(row, col);
  1143. var allSegs = _this.getCellSegs(row, col);
  1144. // rescope the segments to be within the cell's date
  1145. var reslicedAllSegs = _this.resliceDaySegs(allSegs, date);
  1146. var reslicedHiddenSegs = _this.resliceDaySegs(hiddenSegs, date);
  1147. if (typeof clickOption === 'function') {
  1148. // the returned value can be an atomic option
  1149. clickOption = _this.publiclyTrigger('eventLimitClick', [
  1150. {
  1151. date: dateEnv.toDate(date),
  1152. allDay: true,
  1153. dayEl: dayEl,
  1154. moreEl: moreEl,
  1155. segs: reslicedAllSegs,
  1156. hiddenSegs: reslicedHiddenSegs,
  1157. jsEvent: ev,
  1158. view: view
  1159. }
  1160. ]);
  1161. }
  1162. if (clickOption === 'popover') {
  1163. _this.showSegPopover(row, col, moreEl, reslicedAllSegs);
  1164. }
  1165. else if (typeof clickOption === 'string') { // a view name
  1166. view.calendar.zoomTo(date, clickOption);
  1167. }
  1168. });
  1169. return a;
  1170. };
  1171. // Reveals the popover that displays all events within a cell
  1172. DayGrid.prototype.showSegPopover = function (row, col, moreLink, segs) {
  1173. var _this = this;
  1174. var _a = this, calendar = _a.calendar, view = _a.view, theme = _a.theme;
  1175. var _col = this.isRtl ? this.colCnt - col - 1 : col; // HACK: props.cells has different dir system?
  1176. var moreWrap = moreLink.parentNode; // the <div> wrapper around the <a>
  1177. var topEl; // the element we want to match the top coordinate of
  1178. var options;
  1179. if (this.rowCnt === 1) {
  1180. topEl = view.el; // will cause the popover to cover any sort of header
  1181. }
  1182. else {
  1183. topEl = this.rowEls[row]; // will align with top of row
  1184. }
  1185. options = {
  1186. className: 'fc-more-popover ' + theme.getClass('popover'),
  1187. parentEl: view.el,
  1188. top: core.computeRect(topEl).top,
  1189. autoHide: true,
  1190. content: function (el) {
  1191. _this.segPopoverTile = new DayTile(_this.context, el);
  1192. _this.updateSegPopoverTile(_this.props.cells[row][_col].date, segs);
  1193. },
  1194. hide: function () {
  1195. _this.segPopoverTile.destroy();
  1196. _this.segPopoverTile = null;
  1197. _this.segPopover.destroy();
  1198. _this.segPopover = null;
  1199. }
  1200. };
  1201. // Determine horizontal coordinate.
  1202. // We use the moreWrap instead of the <td> to avoid border confusion.
  1203. if (this.isRtl) {
  1204. options.right = core.computeRect(moreWrap).right + 1; // +1 to be over cell border
  1205. }
  1206. else {
  1207. options.left = core.computeRect(moreWrap).left - 1; // -1 to be over cell border
  1208. }
  1209. this.segPopover = new Popover(options);
  1210. this.segPopover.show();
  1211. calendar.releaseAfterSizingTriggers(); // hack for eventPositioned
  1212. };
  1213. // Given the events within an array of segment objects, reslice them to be in a single day
  1214. DayGrid.prototype.resliceDaySegs = function (segs, dayDate) {
  1215. var dayStart = dayDate;
  1216. var dayEnd = core.addDays(dayStart, 1);
  1217. var dayRange = { start: dayStart, end: dayEnd };
  1218. var newSegs = [];
  1219. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  1220. var seg = segs_1[_i];
  1221. var eventRange = seg.eventRange;
  1222. var origRange = eventRange.range;
  1223. var slicedRange = core.intersectRanges(origRange, dayRange);
  1224. if (slicedRange) {
  1225. newSegs.push(__assign({}, seg, { eventRange: {
  1226. def: eventRange.def,
  1227. ui: __assign({}, eventRange.ui, { durationEditable: false }),
  1228. instance: eventRange.instance,
  1229. range: slicedRange
  1230. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() }));
  1231. }
  1232. }
  1233. return newSegs;
  1234. };
  1235. // Generates the text that should be inside a "more" link, given the number of events it represents
  1236. DayGrid.prototype.getMoreLinkText = function (num) {
  1237. var opt = this.opt('eventLimitText');
  1238. if (typeof opt === 'function') {
  1239. return opt(num);
  1240. }
  1241. else {
  1242. return '+' + num + ' ' + opt;
  1243. }
  1244. };
  1245. // Returns segments within a given cell.
  1246. // If `startLevel` is specified, returns only events including and below that level. Otherwise returns all segs.
  1247. DayGrid.prototype.getCellSegs = function (row, col, startLevel) {
  1248. var segMatrix = this.eventRenderer.rowStructs[row].segMatrix;
  1249. var level = startLevel || 0;
  1250. var segs = [];
  1251. var seg;
  1252. while (level < segMatrix.length) {
  1253. seg = segMatrix[level][col];
  1254. if (seg) {
  1255. segs.push(seg);
  1256. }
  1257. level++;
  1258. }
  1259. return segs;
  1260. };
  1261. return DayGrid;
  1262. }(core.DateComponent));
  1263. var WEEK_NUM_FORMAT$1 = core.createFormatter({ week: 'numeric' });
  1264. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  1265. ----------------------------------------------------------------------------------------------------------------------*/
  1266. // It is a manager for a DayGrid subcomponent, which does most of the heavy lifting.
  1267. // It is responsible for managing width/height.
  1268. var DayGridView = /** @class */ (function (_super) {
  1269. __extends(DayGridView, _super);
  1270. function DayGridView(context, viewSpec, dateProfileGenerator, parentEl) {
  1271. var _this = _super.call(this, context, viewSpec, dateProfileGenerator, parentEl) || this;
  1272. /* Header Rendering
  1273. ------------------------------------------------------------------------------------------------------------------*/
  1274. // Generates the HTML that will go before the day-of week header cells
  1275. _this.renderHeadIntroHtml = function () {
  1276. var theme = _this.theme;
  1277. if (_this.colWeekNumbersVisible) {
  1278. return '' +
  1279. '<th class="fc-week-number ' + theme.getClass('widgetHeader') + '" ' + _this.weekNumberStyleAttr() + '>' +
  1280. '<span>' + // needed for matchCellWidths
  1281. core.htmlEscape(_this.opt('weekLabel')) +
  1282. '</span>' +
  1283. '</th>';
  1284. }
  1285. return '';
  1286. };
  1287. /* Day Grid Rendering
  1288. ------------------------------------------------------------------------------------------------------------------*/
  1289. // Generates the HTML that will go before content-skeleton cells that display the day/week numbers
  1290. _this.renderDayGridNumberIntroHtml = function (row, dayGrid) {
  1291. var dateEnv = _this.dateEnv;
  1292. var weekStart = dayGrid.props.cells[row][0].date;
  1293. if (_this.colWeekNumbersVisible) {
  1294. return '' +
  1295. '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '>' +
  1296. core.buildGotoAnchorHtml(// aside from link, important for matchCellWidths
  1297. _this, { date: weekStart, type: 'week', forceOff: dayGrid.colCnt === 1 }, dateEnv.format(weekStart, WEEK_NUM_FORMAT$1) // inner HTML
  1298. ) +
  1299. '</td>';
  1300. }
  1301. return '';
  1302. };
  1303. // Generates the HTML that goes before the day bg cells for each day-row
  1304. _this.renderDayGridBgIntroHtml = function () {
  1305. var theme = _this.theme;
  1306. if (_this.colWeekNumbersVisible) {
  1307. return '<td class="fc-week-number ' + theme.getClass('widgetContent') + '" ' + _this.weekNumberStyleAttr() + '></td>';
  1308. }
  1309. return '';
  1310. };
  1311. // Generates the HTML that goes before every other type of row generated by DayGrid.
  1312. // Affects mirror-skeleton and highlight-skeleton rows.
  1313. _this.renderDayGridIntroHtml = function () {
  1314. if (_this.colWeekNumbersVisible) {
  1315. return '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '></td>';
  1316. }
  1317. return '';
  1318. };
  1319. _this.el.classList.add('fc-dayGrid-view');
  1320. _this.el.innerHTML = _this.renderSkeletonHtml();
  1321. _this.scroller = new core.ScrollComponent('hidden', // overflow x
  1322. 'auto' // overflow y
  1323. );
  1324. var dayGridContainerEl = _this.scroller.el;
  1325. _this.el.querySelector('.fc-body > tr > td').appendChild(dayGridContainerEl);
  1326. dayGridContainerEl.classList.add('fc-day-grid-container');
  1327. var dayGridEl = core.createElement('div', { className: 'fc-day-grid' });
  1328. dayGridContainerEl.appendChild(dayGridEl);
  1329. var cellWeekNumbersVisible;
  1330. if (_this.opt('weekNumbers')) {
  1331. if (_this.opt('weekNumbersWithinDays')) {
  1332. cellWeekNumbersVisible = true;
  1333. _this.colWeekNumbersVisible = false;
  1334. }
  1335. else {
  1336. cellWeekNumbersVisible = false;
  1337. _this.colWeekNumbersVisible = true;
  1338. }
  1339. }
  1340. else {
  1341. _this.colWeekNumbersVisible = false;
  1342. cellWeekNumbersVisible = false;
  1343. }
  1344. _this.dayGrid = new DayGrid(_this.context, dayGridEl, {
  1345. renderNumberIntroHtml: _this.renderDayGridNumberIntroHtml,
  1346. renderBgIntroHtml: _this.renderDayGridBgIntroHtml,
  1347. renderIntroHtml: _this.renderDayGridIntroHtml,
  1348. colWeekNumbersVisible: _this.colWeekNumbersVisible,
  1349. cellWeekNumbersVisible: cellWeekNumbersVisible
  1350. });
  1351. return _this;
  1352. }
  1353. DayGridView.prototype.destroy = function () {
  1354. _super.prototype.destroy.call(this);
  1355. this.dayGrid.destroy();
  1356. this.scroller.destroy();
  1357. };
  1358. // Builds the HTML skeleton for the view.
  1359. // The day-grid component will render inside of a container defined by this HTML.
  1360. DayGridView.prototype.renderSkeletonHtml = function () {
  1361. var theme = this.theme;
  1362. return '' +
  1363. '<table class="' + theme.getClass('tableGrid') + '">' +
  1364. (this.opt('columnHeader') ?
  1365. '<thead class="fc-head">' +
  1366. '<tr>' +
  1367. '<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
  1368. '</tr>' +
  1369. '</thead>' :
  1370. '') +
  1371. '<tbody class="fc-body">' +
  1372. '<tr>' +
  1373. '<td class="' + theme.getClass('widgetContent') + '"></td>' +
  1374. '</tr>' +
  1375. '</tbody>' +
  1376. '</table>';
  1377. };
  1378. // Generates an HTML attribute string for setting the width of the week number column, if it is known
  1379. DayGridView.prototype.weekNumberStyleAttr = function () {
  1380. if (this.weekNumberWidth != null) {
  1381. return 'style="width:' + this.weekNumberWidth + 'px"';
  1382. }
  1383. return '';
  1384. };
  1385. // Determines whether each row should have a constant height
  1386. DayGridView.prototype.hasRigidRows = function () {
  1387. var eventLimit = this.opt('eventLimit');
  1388. return eventLimit && typeof eventLimit !== 'number';
  1389. };
  1390. /* Dimensions
  1391. ------------------------------------------------------------------------------------------------------------------*/
  1392. DayGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  1393. _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto); // will call updateBaseSize. important that executes first
  1394. this.dayGrid.updateSize(isResize);
  1395. };
  1396. // Refreshes the horizontal dimensions of the view
  1397. DayGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  1398. var dayGrid = this.dayGrid;
  1399. var eventLimit = this.opt('eventLimit');
  1400. var headRowEl = this.header ? this.header.el : null; // HACK
  1401. var scrollerHeight;
  1402. var scrollbarWidths;
  1403. // hack to give the view some height prior to dayGrid's columns being rendered
  1404. // TODO: separate setting height from scroller VS dayGrid.
  1405. if (!dayGrid.rowEls) {
  1406. if (!isAuto) {
  1407. scrollerHeight = this.computeScrollerHeight(viewHeight);
  1408. this.scroller.setHeight(scrollerHeight);
  1409. }
  1410. return;
  1411. }
  1412. if (this.colWeekNumbersVisible) {
  1413. // Make sure all week number cells running down the side have the same width.
  1414. this.weekNumberWidth = core.matchCellWidths(core.findElements(this.el, '.fc-week-number'));
  1415. }
  1416. // reset all heights to be natural
  1417. this.scroller.clear();
  1418. if (headRowEl) {
  1419. core.uncompensateScroll(headRowEl);
  1420. }
  1421. dayGrid.removeSegPopover(); // kill the "more" popover if displayed
  1422. // is the event limit a constant level number?
  1423. if (eventLimit && typeof eventLimit === 'number') {
  1424. dayGrid.limitRows(eventLimit); // limit the levels first so the height can redistribute after
  1425. }
  1426. // distribute the height to the rows
  1427. // (viewHeight is a "recommended" value if isAuto)
  1428. scrollerHeight = this.computeScrollerHeight(viewHeight);
  1429. this.setGridHeight(scrollerHeight, isAuto);
  1430. // is the event limit dynamically calculated?
  1431. if (eventLimit && typeof eventLimit !== 'number') {
  1432. dayGrid.limitRows(eventLimit); // limit the levels after the grid's row heights have been set
  1433. }
  1434. if (!isAuto) { // should we force dimensions of the scroll container?
  1435. this.scroller.setHeight(scrollerHeight);
  1436. scrollbarWidths = this.scroller.getScrollbarWidths();
  1437. if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
  1438. if (headRowEl) {
  1439. core.compensateScroll(headRowEl, scrollbarWidths);
  1440. }
  1441. // doing the scrollbar compensation might have created text overflow which created more height. redo
  1442. scrollerHeight = this.computeScrollerHeight(viewHeight);
  1443. this.scroller.setHeight(scrollerHeight);
  1444. }
  1445. // guarantees the same scrollbar widths
  1446. this.scroller.lockOverflow(scrollbarWidths);
  1447. }
  1448. };
  1449. // given a desired total height of the view, returns what the height of the scroller should be
  1450. DayGridView.prototype.computeScrollerHeight = function (viewHeight) {
  1451. return viewHeight -
  1452. core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
  1453. };
  1454. // Sets the height of just the DayGrid component in this view
  1455. DayGridView.prototype.setGridHeight = function (height, isAuto) {
  1456. if (this.opt('monthMode')) {
  1457. // if auto, make the height of each row the height that it would be if there were 6 weeks
  1458. if (isAuto) {
  1459. height *= this.dayGrid.rowCnt / 6;
  1460. }
  1461. core.distributeHeight(this.dayGrid.rowEls, height, !isAuto); // if auto, don't compensate for height-hogging rows
  1462. }
  1463. else {
  1464. if (isAuto) {
  1465. core.undistributeHeight(this.dayGrid.rowEls); // let the rows be their natural height with no expanding
  1466. }
  1467. else {
  1468. core.distributeHeight(this.dayGrid.rowEls, height, true); // true = compensate for height-hogging rows
  1469. }
  1470. }
  1471. };
  1472. /* Scroll
  1473. ------------------------------------------------------------------------------------------------------------------*/
  1474. DayGridView.prototype.computeDateScroll = function (duration) {
  1475. return { top: 0 };
  1476. };
  1477. DayGridView.prototype.queryDateScroll = function () {
  1478. return { top: this.scroller.getScrollTop() };
  1479. };
  1480. DayGridView.prototype.applyDateScroll = function (scroll) {
  1481. if (scroll.top !== undefined) {
  1482. this.scroller.setScrollTop(scroll.top);
  1483. }
  1484. };
  1485. return DayGridView;
  1486. }(core.View));
  1487. DayGridView.prototype.dateProfileGeneratorClass = DayGridDateProfileGenerator;
  1488. var SimpleDayGrid = /** @class */ (function (_super) {
  1489. __extends(SimpleDayGrid, _super);
  1490. function SimpleDayGrid(context, dayGrid) {
  1491. var _this = _super.call(this, context, dayGrid.el) || this;
  1492. _this.slicer = new DayGridSlicer();
  1493. _this.dayGrid = dayGrid;
  1494. context.calendar.registerInteractiveComponent(_this, { el: _this.dayGrid.el });
  1495. return _this;
  1496. }
  1497. SimpleDayGrid.prototype.destroy = function () {
  1498. _super.prototype.destroy.call(this);
  1499. this.calendar.unregisterInteractiveComponent(this);
  1500. };
  1501. SimpleDayGrid.prototype.render = function (props) {
  1502. var dayGrid = this.dayGrid;
  1503. var dateProfile = props.dateProfile, dayTable = props.dayTable;
  1504. dayGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, props.nextDayThreshold, dayGrid, dayTable), { dateProfile: dateProfile, cells: dayTable.cells, isRigid: props.isRigid }));
  1505. };
  1506. SimpleDayGrid.prototype.buildPositionCaches = function () {
  1507. this.dayGrid.buildPositionCaches();
  1508. };
  1509. SimpleDayGrid.prototype.queryHit = function (positionLeft, positionTop) {
  1510. var rawHit = this.dayGrid.positionToHit(positionLeft, positionTop);
  1511. if (rawHit) {
  1512. return {
  1513. component: this.dayGrid,
  1514. dateSpan: rawHit.dateSpan,
  1515. dayEl: rawHit.dayEl,
  1516. rect: {
  1517. left: rawHit.relativeRect.left,
  1518. right: rawHit.relativeRect.right,
  1519. top: rawHit.relativeRect.top,
  1520. bottom: rawHit.relativeRect.bottom
  1521. },
  1522. layer: 0
  1523. };
  1524. }
  1525. };
  1526. return SimpleDayGrid;
  1527. }(core.DateComponent));
  1528. var DayGridSlicer = /** @class */ (function (_super) {
  1529. __extends(DayGridSlicer, _super);
  1530. function DayGridSlicer() {
  1531. return _super !== null && _super.apply(this, arguments) || this;
  1532. }
  1533. DayGridSlicer.prototype.sliceRange = function (dateRange, dayTable) {
  1534. return dayTable.sliceRange(dateRange);
  1535. };
  1536. return DayGridSlicer;
  1537. }(core.Slicer));
  1538. var DayGridView$1 = /** @class */ (function (_super) {
  1539. __extends(DayGridView, _super);
  1540. function DayGridView(_context, viewSpec, dateProfileGenerator, parentEl) {
  1541. var _this = _super.call(this, _context, viewSpec, dateProfileGenerator, parentEl) || this;
  1542. _this.buildDayTable = core.memoize(buildDayTable);
  1543. if (_this.opt('columnHeader')) {
  1544. _this.header = new core.DayHeader(_this.context, _this.el.querySelector('.fc-head-container'));
  1545. }
  1546. _this.simpleDayGrid = new SimpleDayGrid(_this.context, _this.dayGrid);
  1547. return _this;
  1548. }
  1549. DayGridView.prototype.destroy = function () {
  1550. _super.prototype.destroy.call(this);
  1551. if (this.header) {
  1552. this.header.destroy();
  1553. }
  1554. this.simpleDayGrid.destroy();
  1555. };
  1556. DayGridView.prototype.render = function (props) {
  1557. _super.prototype.render.call(this, props);
  1558. var dateProfile = this.props.dateProfile;
  1559. var dayTable = this.dayTable =
  1560. this.buildDayTable(dateProfile, this.dateProfileGenerator);
  1561. if (this.header) {
  1562. this.header.receiveProps({
  1563. dateProfile: dateProfile,
  1564. dates: dayTable.headerDates,
  1565. datesRepDistinctDays: dayTable.rowCnt === 1,
  1566. renderIntroHtml: this.renderHeadIntroHtml
  1567. });
  1568. }
  1569. this.simpleDayGrid.receiveProps({
  1570. dateProfile: dateProfile,
  1571. dayTable: dayTable,
  1572. businessHours: props.businessHours,
  1573. dateSelection: props.dateSelection,
  1574. eventStore: props.eventStore,
  1575. eventUiBases: props.eventUiBases,
  1576. eventSelection: props.eventSelection,
  1577. eventDrag: props.eventDrag,
  1578. eventResize: props.eventResize,
  1579. isRigid: this.hasRigidRows(),
  1580. nextDayThreshold: this.nextDayThreshold
  1581. });
  1582. };
  1583. return DayGridView;
  1584. }(DayGridView));
  1585. function buildDayTable(dateProfile, dateProfileGenerator) {
  1586. var daySeries = new core.DaySeries(dateProfile.renderRange, dateProfileGenerator);
  1587. return new core.DayTable(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  1588. }
  1589. var main = core.createPlugin({
  1590. defaultView: 'dayGridMonth',
  1591. views: {
  1592. dayGrid: DayGridView$1,
  1593. dayGridDay: {
  1594. type: 'dayGrid',
  1595. duration: { days: 1 }
  1596. },
  1597. dayGridWeek: {
  1598. type: 'dayGrid',
  1599. duration: { weeks: 1 }
  1600. },
  1601. dayGridMonth: {
  1602. type: 'dayGrid',
  1603. duration: { months: 1 },
  1604. monthMode: true,
  1605. fixedWeekCount: true
  1606. }
  1607. }
  1608. });
  1609. exports.AbstractDayGridView = DayGridView;
  1610. exports.DayBgRow = DayBgRow;
  1611. exports.DayGrid = DayGrid;
  1612. exports.DayGridSlicer = DayGridSlicer;
  1613. exports.DayGridView = DayGridView$1;
  1614. exports.SimpleDayGrid = SimpleDayGrid;
  1615. exports.buildBasicDayTable = buildDayTable;
  1616. exports.default = main;
  1617. Object.defineProperty(exports, '__esModule', { value: true });
  1618. }));