提交 | 用户 | 时间
|
1ac2bc
|
1 |
/*! |
懒 |
2 |
FullCalendar RRule Plugin v4.3.0 |
|
3 |
Docs & License: https://fullcalendar.io/ |
|
4 |
(c) 2019 Adam Shaw |
|
5 |
*/ |
|
6 |
|
|
7 |
(function (global, factory) { |
|
8 |
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rrule'), require('@fullcalendar/core')) : |
|
9 |
typeof define === 'function' && define.amd ? define(['exports', 'rrule', '@fullcalendar/core'], factory) : |
|
10 |
(global = global || self, factory(global.FullCalendarRrule = {}, global.rrule, global.FullCalendar)); |
|
11 |
}(this, function (exports, rrule, core) { 'use strict'; |
|
12 |
|
|
13 |
/*! ***************************************************************************** |
|
14 |
Copyright (c) Microsoft Corporation. All rights reserved. |
|
15 |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use |
|
16 |
this file except in compliance with the License. You may obtain a copy of the |
|
17 |
License at http://www.apache.org/licenses/LICENSE-2.0 |
|
18 |
|
|
19 |
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
20 |
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED |
|
21 |
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, |
|
22 |
MERCHANTABLITY OR NON-INFRINGEMENT. |
|
23 |
|
|
24 |
See the Apache Version 2.0 License for specific language governing permissions |
|
25 |
and limitations under the License. |
|
26 |
***************************************************************************** */ |
|
27 |
|
|
28 |
var __assign = function() { |
|
29 |
__assign = Object.assign || function __assign(t) { |
|
30 |
for (var s, i = 1, n = arguments.length; i < n; i++) { |
|
31 |
s = arguments[i]; |
|
32 |
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
|
33 |
} |
|
34 |
return t; |
|
35 |
}; |
|
36 |
return __assign.apply(this, arguments); |
|
37 |
}; |
|
38 |
|
|
39 |
var EVENT_DEF_PROPS = { |
|
40 |
rrule: null, |
|
41 |
duration: core.createDuration |
|
42 |
}; |
|
43 |
var recurring = { |
|
44 |
parse: function (rawEvent, leftoverProps, dateEnv) { |
|
45 |
if (rawEvent.rrule != null) { |
|
46 |
var props = core.refineProps(rawEvent, EVENT_DEF_PROPS, {}, leftoverProps); |
|
47 |
var parsed = parseRRule(props.rrule, dateEnv); |
|
48 |
if (parsed) { |
|
49 |
return { |
|
50 |
typeData: parsed.rrule, |
|
51 |
allDayGuess: parsed.allDayGuess, |
|
52 |
duration: props.duration |
|
53 |
}; |
|
54 |
} |
|
55 |
} |
|
56 |
return null; |
|
57 |
}, |
|
58 |
expand: function (rrule, framingRange) { |
|
59 |
// we WANT an inclusive start and in exclusive end, but the js rrule lib will only do either BOTH |
|
60 |
// inclusive or BOTH exclusive, which is stupid: https://github.com/jakubroztocil/rrule/issues/84 |
|
61 |
// Workaround: make inclusive, which will generate extra occurences, and then trim. |
|
62 |
return rrule.between(framingRange.start, framingRange.end, true) |
|
63 |
.filter(function (date) { |
|
64 |
return date.valueOf() < framingRange.end.valueOf(); |
|
65 |
}); |
|
66 |
} |
|
67 |
}; |
|
68 |
var main = core.createPlugin({ |
|
69 |
recurringTypes: [recurring] |
|
70 |
}); |
|
71 |
function parseRRule(input, dateEnv) { |
|
72 |
var allDayGuess = null; |
|
73 |
var rrule$1; |
|
74 |
if (typeof input === 'string') { |
|
75 |
rrule$1 = rrule.rrulestr(input); |
|
76 |
} |
|
77 |
else if (typeof input === 'object' && input) { // non-null object |
|
78 |
var refined = __assign({}, input); // copy |
|
79 |
if (typeof refined.dtstart === 'string') { |
|
80 |
var dtstartMeta = dateEnv.createMarkerMeta(refined.dtstart); |
|
81 |
if (dtstartMeta) { |
|
82 |
refined.dtstart = dtstartMeta.marker; |
|
83 |
allDayGuess = dtstartMeta.isTimeUnspecified; |
|
84 |
} |
|
85 |
else { |
|
86 |
delete refined.dtstart; |
|
87 |
} |
|
88 |
} |
|
89 |
if (typeof refined.until === 'string') { |
|
90 |
refined.until = dateEnv.createMarker(refined.until); |
|
91 |
} |
|
92 |
if (refined.freq != null) { |
|
93 |
refined.freq = convertConstant(refined.freq); |
|
94 |
} |
|
95 |
if (refined.wkst != null) { |
|
96 |
refined.wkst = convertConstant(refined.wkst); |
|
97 |
} |
|
98 |
else { |
|
99 |
refined.wkst = (dateEnv.weekDow - 1 + 7) % 7; // convert Sunday-first to Monday-first |
|
100 |
} |
|
101 |
if (refined.byweekday != null) { |
|
102 |
refined.byweekday = convertConstants(refined.byweekday); // the plural version |
|
103 |
} |
|
104 |
rrule$1 = new rrule.RRule(refined); |
|
105 |
} |
|
106 |
if (rrule$1) { |
|
107 |
return { rrule: rrule$1, allDayGuess: allDayGuess }; |
|
108 |
} |
|
109 |
return null; |
|
110 |
} |
|
111 |
function convertConstants(input) { |
|
112 |
if (Array.isArray(input)) { |
|
113 |
return input.map(convertConstant); |
|
114 |
} |
|
115 |
return convertConstant(input); |
|
116 |
} |
|
117 |
function convertConstant(input) { |
|
118 |
if (typeof input === 'string') { |
|
119 |
return rrule.RRule[input.toUpperCase()]; |
|
120 |
} |
|
121 |
return input; |
|
122 |
} |
|
123 |
|
|
124 |
exports.default = main; |
|
125 |
|
|
126 |
Object.defineProperty(exports, '__esModule', { value: true }); |
|
127 |
|
|
128 |
})); |