flatpickr 4.5.2.1 → 4.5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flatpickr/version.rb +1 -1
- data/vendor/assets/javascripts/flatpickr.js +2400 -2075
- data/vendor/assets/javascripts/flatpickr/l10n/ar.js +42 -20
- data/vendor/assets/javascripts/flatpickr/l10n/at.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/az.js +73 -0
- data/vendor/assets/javascripts/flatpickr/l10n/be.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/bg.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/bn.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/cat.js +71 -40
- data/vendor/assets/javascripts/flatpickr/l10n/cs.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/cy.js +81 -29
- data/vendor/assets/javascripts/flatpickr/l10n/da.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/de.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/default.js +62 -32
- data/vendor/assets/javascripts/flatpickr/l10n/eo.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/es.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/et.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/fa.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/fi.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/fo.js +73 -0
- data/vendor/assets/javascripts/flatpickr/l10n/fr.js +59 -23
- data/vendor/assets/javascripts/flatpickr/l10n/gr.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/he.js +49 -21
- data/vendor/assets/javascripts/flatpickr/l10n/hi.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/hr.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/hu.js +59 -23
- data/vendor/assets/javascripts/flatpickr/l10n/id.js +49 -22
- data/vendor/assets/javascripts/flatpickr/l10n/index.js +3147 -1036
- data/vendor/assets/javascripts/flatpickr/l10n/is.js +71 -0
- data/vendor/assets/javascripts/flatpickr/l10n/it.js +56 -23
- data/vendor/assets/javascripts/flatpickr/l10n/ja.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/km.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/ko.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/kz.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/lt.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/lv.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/mk.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/mn.js +47 -20
- data/vendor/assets/javascripts/flatpickr/l10n/ms.js +56 -21
- data/vendor/assets/javascripts/flatpickr/l10n/my.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/nl.js +59 -23
- data/vendor/assets/javascripts/flatpickr/l10n/no.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/pa.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/pl.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/pt.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/ro.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/ru.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/si.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/sk.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/sl.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/sq.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/sr-cyr.js +67 -0
- data/vendor/assets/javascripts/flatpickr/l10n/sr.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/sv.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/th.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/tr.js +57 -22
- data/vendor/assets/javascripts/flatpickr/l10n/uk.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/vn.js +55 -20
- data/vendor/assets/javascripts/flatpickr/l10n/zh-tw.js +68 -0
- data/vendor/assets/javascripts/flatpickr/l10n/zh.js +55 -20
- data/vendor/assets/javascripts/flatpickr/plugins/confirmDate/confirmDate.js +63 -35
- data/vendor/assets/javascripts/flatpickr/plugins/labelPlugin/labelPlugin.js +24 -26
- data/vendor/assets/javascripts/flatpickr/plugins/minMaxTimePlugin.js +229 -200
- data/vendor/assets/javascripts/flatpickr/plugins/monthSelect/monthSelect.js +68 -51
- data/vendor/assets/javascripts/flatpickr/plugins/rangePlugin.js +136 -141
- data/vendor/assets/javascripts/flatpickr/plugins/scrollPlugin.js +43 -49
- data/vendor/assets/javascripts/flatpickr/plugins/weekSelect/weekSelect.js +70 -67
- data/vendor/assets/stylesheets/flatpickr.css +12 -1
- data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +12 -1
- data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +12 -1
- data/vendor/assets/stylesheets/flatpickr/themes/dark.css +12 -1
- data/vendor/assets/stylesheets/flatpickr/themes/light.css +12 -1
- data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +12 -1
- data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +12 -1
- data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +12 -1
- data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +12 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 363900ab1897e4c7ad6ae0c1abe4d522779053255d77840f8c928e6eed45cbc6
|
4
|
+
data.tar.gz: cd1fbb5d2eca02ef58ad0034219babc3def6d3282df572ea7187b5fca60888ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0243daaf2f18956fd3a3f6db5fc5ac636a0370d03a09b92e712b99b1faa191cb67e7f95e63dd1d656f46eefb1f8c840d0c1941ecf6f28dc51a77602261c1cb3d
|
7
|
+
data.tar.gz: 65db014284fbf78124206f75cfb547b1371597ee5e9f906d6a584fd548a48d7a20fe30137f8774033b6ad5823a5942b5c1dbac15ef580a479287ffd47731710c
|
data/lib/flatpickr/version.rb
CHANGED
@@ -1,2174 +1,2499 @@
|
|
1
|
-
/* flatpickr v4.5.
|
1
|
+
/* flatpickr v4.5.7, @license MIT */
|
2
2
|
(function (global, factory) {
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
5
|
-
(global.flatpickr = factory());
|
6
|
-
}(this,
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
return obj instanceof Array ? obj : [obj];
|
33
|
-
};
|
34
|
-
|
35
|
-
var do_nothing = function do_nothing() {
|
36
|
-
return undefined;
|
5
|
+
(global = global || self, global.flatpickr = factory());
|
6
|
+
}(this, function () { 'use strict';
|
7
|
+
|
8
|
+
/*! *****************************************************************************
|
9
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
10
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
11
|
+
this file except in compliance with the License. You may obtain a copy of the
|
12
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
|
14
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
16
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
17
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
18
|
+
|
19
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
20
|
+
and limitations under the License.
|
21
|
+
***************************************************************************** */
|
22
|
+
|
23
|
+
var __assign = function() {
|
24
|
+
__assign = Object.assign || function __assign(t) {
|
25
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
26
|
+
s = arguments[i];
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
28
|
+
}
|
29
|
+
return t;
|
30
|
+
};
|
31
|
+
return __assign.apply(this, arguments);
|
37
32
|
};
|
38
33
|
|
39
|
-
var
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
m: "(\\d\\d|\\d)",
|
124
|
-
n: "(\\d\\d|\\d)",
|
125
|
-
s: "(\\d\\d|\\d)",
|
126
|
-
w: "(\\d\\d|\\d)",
|
127
|
-
y: "(\\d{2})"
|
128
|
-
};
|
129
|
-
var formats = {
|
130
|
-
Z: function Z(date) {
|
131
|
-
return date.toISOString();
|
132
|
-
},
|
133
|
-
D: function D(date, locale, options) {
|
134
|
-
return locale.weekdays.shorthand[formats.w(date, locale, options)];
|
135
|
-
},
|
136
|
-
F: function F(date, locale, options) {
|
137
|
-
return monthToStr(formats.n(date, locale, options) - 1, false, locale);
|
138
|
-
},
|
139
|
-
G: function G(date, locale, options) {
|
140
|
-
return pad(formats.h(date, locale, options));
|
141
|
-
},
|
142
|
-
H: function H(date) {
|
143
|
-
return pad(date.getHours());
|
144
|
-
},
|
145
|
-
J: function J(date, locale) {
|
146
|
-
return locale.ordinal !== undefined ? date.getDate() + locale.ordinal(date.getDate()) : date.getDate();
|
147
|
-
},
|
148
|
-
K: function K(date, locale) {
|
149
|
-
return locale.amPM[int(date.getHours() > 11)];
|
150
|
-
},
|
151
|
-
M: function M(date, locale) {
|
152
|
-
return monthToStr(date.getMonth(), true, locale);
|
153
|
-
},
|
154
|
-
S: function S(date) {
|
155
|
-
return pad(date.getSeconds());
|
156
|
-
},
|
157
|
-
U: function U(date) {
|
158
|
-
return date.getTime() / 1000;
|
159
|
-
},
|
160
|
-
W: function W(date, _, options) {
|
161
|
-
return options.getWeek(date);
|
162
|
-
},
|
163
|
-
Y: function Y(date) {
|
164
|
-
return date.getFullYear();
|
165
|
-
},
|
166
|
-
d: function d(date) {
|
167
|
-
return pad(date.getDate());
|
168
|
-
},
|
169
|
-
h: function h(date) {
|
170
|
-
return date.getHours() % 12 ? date.getHours() % 12 : 12;
|
171
|
-
},
|
172
|
-
i: function i(date) {
|
173
|
-
return pad(date.getMinutes());
|
174
|
-
},
|
175
|
-
j: function j(date) {
|
176
|
-
return date.getDate();
|
177
|
-
},
|
178
|
-
l: function l(date, locale) {
|
179
|
-
return locale.weekdays.longhand[date.getDay()];
|
180
|
-
},
|
181
|
-
m: function m(date) {
|
182
|
-
return pad(date.getMonth() + 1);
|
183
|
-
},
|
184
|
-
n: function n(date) {
|
185
|
-
return date.getMonth() + 1;
|
186
|
-
},
|
187
|
-
s: function s(date) {
|
188
|
-
return date.getSeconds();
|
189
|
-
},
|
190
|
-
w: function w(date) {
|
191
|
-
return date.getDay();
|
192
|
-
},
|
193
|
-
y: function y(date) {
|
194
|
-
return String(date.getFullYear()).substring(2);
|
195
|
-
}
|
34
|
+
var HOOKS = [
|
35
|
+
"onChange",
|
36
|
+
"onClose",
|
37
|
+
"onDayCreate",
|
38
|
+
"onDestroy",
|
39
|
+
"onKeyDown",
|
40
|
+
"onMonthChange",
|
41
|
+
"onOpen",
|
42
|
+
"onParseConfig",
|
43
|
+
"onReady",
|
44
|
+
"onValueUpdate",
|
45
|
+
"onYearChange",
|
46
|
+
"onPreCalendarPosition",
|
47
|
+
];
|
48
|
+
var defaults = {
|
49
|
+
_disable: [],
|
50
|
+
_enable: [],
|
51
|
+
allowInput: false,
|
52
|
+
altFormat: "F j, Y",
|
53
|
+
altInput: false,
|
54
|
+
altInputClass: "form-control input",
|
55
|
+
animate: typeof window === "object" &&
|
56
|
+
window.navigator.userAgent.indexOf("MSIE") === -1,
|
57
|
+
ariaDateFormat: "F j, Y",
|
58
|
+
clickOpens: true,
|
59
|
+
closeOnSelect: true,
|
60
|
+
conjunction: ", ",
|
61
|
+
dateFormat: "Y-m-d",
|
62
|
+
defaultHour: 12,
|
63
|
+
defaultMinute: 0,
|
64
|
+
defaultSeconds: 0,
|
65
|
+
disable: [],
|
66
|
+
disableMobile: false,
|
67
|
+
enable: [],
|
68
|
+
enableSeconds: false,
|
69
|
+
enableTime: false,
|
70
|
+
errorHandler: function (err) {
|
71
|
+
return typeof console !== "undefined" && console.warn(err);
|
72
|
+
},
|
73
|
+
getWeek: function (givenDate) {
|
74
|
+
var date = new Date(givenDate.getTime());
|
75
|
+
date.setHours(0, 0, 0, 0);
|
76
|
+
// Thursday in current week decides the year.
|
77
|
+
date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7));
|
78
|
+
// January 4 is always in week 1.
|
79
|
+
var week1 = new Date(date.getFullYear(), 0, 4);
|
80
|
+
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
|
81
|
+
return (1 +
|
82
|
+
Math.round(((date.getTime() - week1.getTime()) / 86400000 -
|
83
|
+
3 +
|
84
|
+
((week1.getDay() + 6) % 7)) /
|
85
|
+
7));
|
86
|
+
},
|
87
|
+
hourIncrement: 1,
|
88
|
+
ignoredFocusElements: [],
|
89
|
+
inline: false,
|
90
|
+
locale: "default",
|
91
|
+
minuteIncrement: 5,
|
92
|
+
mode: "single",
|
93
|
+
nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
|
94
|
+
noCalendar: false,
|
95
|
+
now: new Date(),
|
96
|
+
onChange: [],
|
97
|
+
onClose: [],
|
98
|
+
onDayCreate: [],
|
99
|
+
onDestroy: [],
|
100
|
+
onKeyDown: [],
|
101
|
+
onMonthChange: [],
|
102
|
+
onOpen: [],
|
103
|
+
onParseConfig: [],
|
104
|
+
onReady: [],
|
105
|
+
onValueUpdate: [],
|
106
|
+
onYearChange: [],
|
107
|
+
onPreCalendarPosition: [],
|
108
|
+
plugins: [],
|
109
|
+
position: "auto",
|
110
|
+
positionElement: undefined,
|
111
|
+
prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
|
112
|
+
shorthandCurrentMonth: false,
|
113
|
+
showMonths: 1,
|
114
|
+
static: false,
|
115
|
+
time_24hr: false,
|
116
|
+
weekNumbers: false,
|
117
|
+
wrap: false
|
196
118
|
};
|
197
119
|
|
198
120
|
var english = {
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
l10n = _ref2$l10n === void 0 ? english : _ref2$l10n;
|
257
|
-
return function (date, givenFormat, timeless, customLocale) {
|
258
|
-
if (date !== 0 && !date) return undefined;
|
259
|
-
var locale = customLocale || l10n;
|
260
|
-
var parsedDate;
|
261
|
-
var date_orig = date;
|
262
|
-
if (date instanceof Date) parsedDate = new Date(date.getTime());else if (typeof date !== "string" && date.toFixed !== undefined) parsedDate = new Date(date);else if (typeof date === "string") {
|
263
|
-
var format = givenFormat || (config || defaults).dateFormat;
|
264
|
-
var datestr = String(date).trim();
|
265
|
-
|
266
|
-
if (datestr === "today") {
|
267
|
-
parsedDate = new Date();
|
268
|
-
timeless = true;
|
269
|
-
} else if (/Z$/.test(datestr) || /GMT$/.test(datestr)) parsedDate = new Date(date);else if (config && config.parseDate) parsedDate = config.parseDate(date, format);else {
|
270
|
-
parsedDate = !config || !config.noCalendar ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0) : new Date(new Date().setHours(0, 0, 0, 0));
|
271
|
-
var matched,
|
272
|
-
ops = [];
|
273
|
-
|
274
|
-
for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
|
275
|
-
var token = format[i];
|
276
|
-
var isBackSlash = token === "\\";
|
277
|
-
var escaped = format[i - 1] === "\\" || isBackSlash;
|
278
|
-
|
279
|
-
if (tokenRegex[token] && !escaped) {
|
280
|
-
regexStr += tokenRegex[token];
|
281
|
-
var match = new RegExp(regexStr).exec(date);
|
282
|
-
|
283
|
-
if (match && (matched = true)) {
|
284
|
-
ops[token !== "Y" ? "push" : "unshift"]({
|
285
|
-
fn: revFormat[token],
|
286
|
-
val: match[++matchIndex]
|
287
|
-
});
|
288
|
-
}
|
289
|
-
} else if (!isBackSlash) regexStr += ".";
|
290
|
-
|
291
|
-
ops.forEach(function (_ref3) {
|
292
|
-
var fn = _ref3.fn,
|
293
|
-
val = _ref3.val;
|
294
|
-
return parsedDate = fn(parsedDate, val, locale) || parsedDate;
|
295
|
-
});
|
121
|
+
weekdays: {
|
122
|
+
shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
123
|
+
longhand: [
|
124
|
+
"Sunday",
|
125
|
+
"Monday",
|
126
|
+
"Tuesday",
|
127
|
+
"Wednesday",
|
128
|
+
"Thursday",
|
129
|
+
"Friday",
|
130
|
+
"Saturday",
|
131
|
+
]
|
132
|
+
},
|
133
|
+
months: {
|
134
|
+
shorthand: [
|
135
|
+
"Jan",
|
136
|
+
"Feb",
|
137
|
+
"Mar",
|
138
|
+
"Apr",
|
139
|
+
"May",
|
140
|
+
"Jun",
|
141
|
+
"Jul",
|
142
|
+
"Aug",
|
143
|
+
"Sep",
|
144
|
+
"Oct",
|
145
|
+
"Nov",
|
146
|
+
"Dec",
|
147
|
+
],
|
148
|
+
longhand: [
|
149
|
+
"January",
|
150
|
+
"February",
|
151
|
+
"March",
|
152
|
+
"April",
|
153
|
+
"May",
|
154
|
+
"June",
|
155
|
+
"July",
|
156
|
+
"August",
|
157
|
+
"September",
|
158
|
+
"October",
|
159
|
+
"November",
|
160
|
+
"December",
|
161
|
+
]
|
162
|
+
},
|
163
|
+
daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
|
164
|
+
firstDayOfWeek: 0,
|
165
|
+
ordinal: function (nth) {
|
166
|
+
var s = nth % 100;
|
167
|
+
if (s > 3 && s < 21)
|
168
|
+
return "th";
|
169
|
+
switch (s % 10) {
|
170
|
+
case 1:
|
171
|
+
return "st";
|
172
|
+
case 2:
|
173
|
+
return "nd";
|
174
|
+
case 3:
|
175
|
+
return "rd";
|
176
|
+
default:
|
177
|
+
return "th";
|
296
178
|
}
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
return undefined;
|
305
|
-
}
|
306
|
-
|
307
|
-
if (timeless === true) parsedDate.setHours(0, 0, 0, 0);
|
308
|
-
return parsedDate;
|
309
|
-
};
|
179
|
+
},
|
180
|
+
rangeSeparator: " to ",
|
181
|
+
weekAbbreviation: "Wk",
|
182
|
+
scrollTitle: "Scroll to increment",
|
183
|
+
toggleTitle: "Click to toggle",
|
184
|
+
amPM: ["AM", "PM"],
|
185
|
+
yearAriaLabel: "Year"
|
310
186
|
};
|
311
|
-
function compareDates(date1, date2, timeless) {
|
312
|
-
if (timeless === void 0) {
|
313
|
-
timeless = true;
|
314
|
-
}
|
315
|
-
|
316
|
-
if (timeless !== false) {
|
317
|
-
return new Date(date1.getTime()).setHours(0, 0, 0, 0) - new Date(date2.getTime()).setHours(0, 0, 0, 0);
|
318
|
-
}
|
319
187
|
|
320
|
-
|
188
|
+
var pad = function (number) { return ("0" + number).slice(-2); };
|
189
|
+
var int = function (bool) { return (bool === true ? 1 : 0); };
|
190
|
+
/* istanbul ignore next */
|
191
|
+
function debounce(func, wait, immediate) {
|
192
|
+
if (immediate === void 0) { immediate = false; }
|
193
|
+
var timeout;
|
194
|
+
return function () {
|
195
|
+
var context = this, args = arguments;
|
196
|
+
timeout !== null && clearTimeout(timeout);
|
197
|
+
timeout = window.setTimeout(function () {
|
198
|
+
timeout = null;
|
199
|
+
if (!immediate)
|
200
|
+
func.apply(context, args);
|
201
|
+
}, wait);
|
202
|
+
if (immediate && !timeout)
|
203
|
+
func.apply(context, args);
|
204
|
+
};
|
321
205
|
}
|
322
|
-
var
|
323
|
-
|
324
|
-
date.setHours(0, 0, 0, 0);
|
325
|
-
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
|
326
|
-
var week1 = new Date(date.getFullYear(), 0, 4);
|
327
|
-
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
|
328
|
-
};
|
329
|
-
var isBetween = function isBetween(ts, ts1, ts2) {
|
330
|
-
return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
|
331
|
-
};
|
332
|
-
var duration = {
|
333
|
-
DAY: 86400000
|
334
|
-
};
|
335
|
-
|
336
|
-
var HOOKS = ["onChange", "onClose", "onDayCreate", "onDestroy", "onKeyDown", "onMonthChange", "onOpen", "onParseConfig", "onReady", "onValueUpdate", "onYearChange", "onPreCalendarPosition"];
|
337
|
-
var defaults = {
|
338
|
-
_disable: [],
|
339
|
-
_enable: [],
|
340
|
-
allowInput: false,
|
341
|
-
altFormat: "F j, Y",
|
342
|
-
altInput: false,
|
343
|
-
altInputClass: "form-control input",
|
344
|
-
animate: typeof window === "object" && window.navigator.userAgent.indexOf("MSIE") === -1,
|
345
|
-
ariaDateFormat: "F j, Y",
|
346
|
-
clickOpens: true,
|
347
|
-
closeOnSelect: true,
|
348
|
-
conjunction: ", ",
|
349
|
-
dateFormat: "Y-m-d",
|
350
|
-
defaultHour: 12,
|
351
|
-
defaultMinute: 0,
|
352
|
-
defaultSeconds: 0,
|
353
|
-
disable: [],
|
354
|
-
disableMobile: false,
|
355
|
-
enable: [],
|
356
|
-
enableSeconds: false,
|
357
|
-
enableTime: false,
|
358
|
-
errorHandler: function errorHandler(err) {
|
359
|
-
return typeof console !== "undefined" && console.warn(err);
|
360
|
-
},
|
361
|
-
getWeek: getWeek,
|
362
|
-
hourIncrement: 1,
|
363
|
-
ignoredFocusElements: [],
|
364
|
-
inline: false,
|
365
|
-
locale: "default",
|
366
|
-
minuteIncrement: 5,
|
367
|
-
mode: "single",
|
368
|
-
nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
|
369
|
-
noCalendar: false,
|
370
|
-
now: new Date(),
|
371
|
-
onChange: [],
|
372
|
-
onClose: [],
|
373
|
-
onDayCreate: [],
|
374
|
-
onDestroy: [],
|
375
|
-
onKeyDown: [],
|
376
|
-
onMonthChange: [],
|
377
|
-
onOpen: [],
|
378
|
-
onParseConfig: [],
|
379
|
-
onReady: [],
|
380
|
-
onValueUpdate: [],
|
381
|
-
onYearChange: [],
|
382
|
-
onPreCalendarPosition: [],
|
383
|
-
plugins: [],
|
384
|
-
position: "auto",
|
385
|
-
positionElement: undefined,
|
386
|
-
prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
|
387
|
-
shorthandCurrentMonth: false,
|
388
|
-
showMonths: 1,
|
389
|
-
static: false,
|
390
|
-
time_24hr: false,
|
391
|
-
weekNumbers: false,
|
392
|
-
wrap: false
|
206
|
+
var arrayify = function (obj) {
|
207
|
+
return obj instanceof Array ? obj : [obj];
|
393
208
|
};
|
394
209
|
|
395
210
|
function toggleClass(elem, className, bool) {
|
396
|
-
|
397
|
-
|
211
|
+
if (bool === true)
|
212
|
+
return elem.classList.add(className);
|
213
|
+
elem.classList.remove(className);
|
398
214
|
}
|
399
215
|
function createElement(tag, className, content) {
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
216
|
+
var e = window.document.createElement(tag);
|
217
|
+
className = className || "";
|
218
|
+
content = content || "";
|
219
|
+
e.className = className;
|
220
|
+
if (content !== undefined)
|
221
|
+
e.textContent = content;
|
222
|
+
return e;
|
406
223
|
}
|
407
224
|
function clearNode(node) {
|
408
|
-
|
409
|
-
|
410
|
-
}
|
225
|
+
while (node.firstChild)
|
226
|
+
node.removeChild(node.firstChild);
|
411
227
|
}
|
412
228
|
function findParent(node, condition) {
|
413
|
-
|
414
|
-
|
229
|
+
if (condition(node))
|
230
|
+
return node;
|
231
|
+
else if (node.parentNode)
|
232
|
+
return findParent(node.parentNode, condition);
|
233
|
+
return undefined; // nothing found
|
415
234
|
}
|
416
235
|
function createNumberInput(inputClassName, opts) {
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
236
|
+
var wrapper = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown");
|
237
|
+
if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
|
238
|
+
numInput.type = "number";
|
239
|
+
}
|
240
|
+
else {
|
241
|
+
numInput.type = "text";
|
242
|
+
numInput.pattern = "\\d*";
|
243
|
+
}
|
244
|
+
if (opts !== undefined)
|
245
|
+
for (var key in opts)
|
246
|
+
numInput.setAttribute(key, opts[key]);
|
247
|
+
wrapper.appendChild(numInput);
|
248
|
+
wrapper.appendChild(arrowUp);
|
249
|
+
wrapper.appendChild(arrowDown);
|
250
|
+
return wrapper;
|
430
251
|
}
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
throw TypeError("Cannot convert undefined or null to object");
|
252
|
+
function getEventTarget(event) {
|
253
|
+
if (typeof event.composedPath === "function") {
|
254
|
+
var path = event.composedPath();
|
255
|
+
return path[0];
|
436
256
|
}
|
257
|
+
return event.target;
|
258
|
+
}
|
437
259
|
|
438
|
-
|
439
|
-
|
260
|
+
var do_nothing = function () { return undefined; };
|
261
|
+
var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
|
262
|
+
var revFormat = {
|
263
|
+
D: do_nothing,
|
264
|
+
F: function (dateObj, monthName, locale) {
|
265
|
+
dateObj.setMonth(locale.months.longhand.indexOf(monthName));
|
266
|
+
},
|
267
|
+
G: function (dateObj, hour) {
|
268
|
+
dateObj.setHours(parseFloat(hour));
|
269
|
+
},
|
270
|
+
H: function (dateObj, hour) {
|
271
|
+
dateObj.setHours(parseFloat(hour));
|
272
|
+
},
|
273
|
+
J: function (dateObj, day) {
|
274
|
+
dateObj.setDate(parseFloat(day));
|
275
|
+
},
|
276
|
+
K: function (dateObj, amPM, locale) {
|
277
|
+
dateObj.setHours((dateObj.getHours() % 12) +
|
278
|
+
12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
|
279
|
+
},
|
280
|
+
M: function (dateObj, shortMonth, locale) {
|
281
|
+
dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
|
282
|
+
},
|
283
|
+
S: function (dateObj, seconds) {
|
284
|
+
dateObj.setSeconds(parseFloat(seconds));
|
285
|
+
},
|
286
|
+
U: function (_, unixSeconds) { return new Date(parseFloat(unixSeconds) * 1000); },
|
287
|
+
W: function (dateObj, weekNum) {
|
288
|
+
var weekNumber = parseInt(weekNum);
|
289
|
+
return new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
|
290
|
+
},
|
291
|
+
Y: function (dateObj, year) {
|
292
|
+
dateObj.setFullYear(parseFloat(year));
|
293
|
+
},
|
294
|
+
Z: function (_, ISODate) { return new Date(ISODate); },
|
295
|
+
d: function (dateObj, day) {
|
296
|
+
dateObj.setDate(parseFloat(day));
|
297
|
+
},
|
298
|
+
h: function (dateObj, hour) {
|
299
|
+
dateObj.setHours(parseFloat(hour));
|
300
|
+
},
|
301
|
+
i: function (dateObj, minutes) {
|
302
|
+
dateObj.setMinutes(parseFloat(minutes));
|
303
|
+
},
|
304
|
+
j: function (dateObj, day) {
|
305
|
+
dateObj.setDate(parseFloat(day));
|
306
|
+
},
|
307
|
+
l: do_nothing,
|
308
|
+
m: function (dateObj, month) {
|
309
|
+
dateObj.setMonth(parseFloat(month) - 1);
|
310
|
+
},
|
311
|
+
n: function (dateObj, month) {
|
312
|
+
dateObj.setMonth(parseFloat(month) - 1);
|
313
|
+
},
|
314
|
+
s: function (dateObj, seconds) {
|
315
|
+
dateObj.setSeconds(parseFloat(seconds));
|
316
|
+
},
|
317
|
+
u: function (_, unixMillSeconds) {
|
318
|
+
return new Date(parseFloat(unixMillSeconds));
|
319
|
+
},
|
320
|
+
w: do_nothing,
|
321
|
+
y: function (dateObj, year) {
|
322
|
+
dateObj.setFullYear(2000 + parseFloat(year));
|
440
323
|
}
|
324
|
+
};
|
325
|
+
var tokenRegex = {
|
326
|
+
D: "(\\w+)",
|
327
|
+
F: "(\\w+)",
|
328
|
+
G: "(\\d\\d|\\d)",
|
329
|
+
H: "(\\d\\d|\\d)",
|
330
|
+
J: "(\\d\\d|\\d)\\w+",
|
331
|
+
K: "",
|
332
|
+
M: "(\\w+)",
|
333
|
+
S: "(\\d\\d|\\d)",
|
334
|
+
U: "(.+)",
|
335
|
+
W: "(\\d\\d|\\d)",
|
336
|
+
Y: "(\\d{4})",
|
337
|
+
Z: "(.+)",
|
338
|
+
d: "(\\d\\d|\\d)",
|
339
|
+
h: "(\\d\\d|\\d)",
|
340
|
+
i: "(\\d\\d|\\d)",
|
341
|
+
j: "(\\d\\d|\\d)",
|
342
|
+
l: "(\\w+)",
|
343
|
+
m: "(\\d\\d|\\d)",
|
344
|
+
n: "(\\d\\d|\\d)",
|
345
|
+
s: "(\\d\\d|\\d)",
|
346
|
+
u: "(.+)",
|
347
|
+
w: "(\\d\\d|\\d)",
|
348
|
+
y: "(\\d{2})"
|
349
|
+
};
|
350
|
+
var formats = {
|
351
|
+
// get the date in UTC
|
352
|
+
Z: function (date) { return date.toISOString(); },
|
353
|
+
// weekday name, short, e.g. Thu
|
354
|
+
D: function (date, locale, options) {
|
355
|
+
return locale.weekdays.shorthand[formats.w(date, locale, options)];
|
356
|
+
},
|
357
|
+
// full month name e.g. January
|
358
|
+
F: function (date, locale, options) {
|
359
|
+
return monthToStr(formats.n(date, locale, options) - 1, false, locale);
|
360
|
+
},
|
361
|
+
// padded hour 1-12
|
362
|
+
G: function (date, locale, options) {
|
363
|
+
return pad(formats.h(date, locale, options));
|
364
|
+
},
|
365
|
+
// hours with leading zero e.g. 03
|
366
|
+
H: function (date) { return pad(date.getHours()); },
|
367
|
+
// day (1-30) with ordinal suffix e.g. 1st, 2nd
|
368
|
+
J: function (date, locale) {
|
369
|
+
return locale.ordinal !== undefined
|
370
|
+
? date.getDate() + locale.ordinal(date.getDate())
|
371
|
+
: date.getDate();
|
372
|
+
},
|
373
|
+
// AM/PM
|
374
|
+
K: function (date, locale) { return locale.amPM[int(date.getHours() > 11)]; },
|
375
|
+
// shorthand month e.g. Jan, Sep, Oct, etc
|
376
|
+
M: function (date, locale) {
|
377
|
+
return monthToStr(date.getMonth(), true, locale);
|
378
|
+
},
|
379
|
+
// seconds 00-59
|
380
|
+
S: function (date) { return pad(date.getSeconds()); },
|
381
|
+
// unix timestamp
|
382
|
+
U: function (date) { return date.getTime() / 1000; },
|
383
|
+
W: function (date, _, options) {
|
384
|
+
return options.getWeek(date);
|
385
|
+
},
|
386
|
+
// full year e.g. 2016
|
387
|
+
Y: function (date) { return date.getFullYear(); },
|
388
|
+
// day in month, padded (01-30)
|
389
|
+
d: function (date) { return pad(date.getDate()); },
|
390
|
+
// hour from 1-12 (am/pm)
|
391
|
+
h: function (date) { return (date.getHours() % 12 ? date.getHours() % 12 : 12); },
|
392
|
+
// minutes, padded with leading zero e.g. 09
|
393
|
+
i: function (date) { return pad(date.getMinutes()); },
|
394
|
+
// day in month (1-30)
|
395
|
+
j: function (date) { return date.getDate(); },
|
396
|
+
// weekday name, full, e.g. Thursday
|
397
|
+
l: function (date, locale) {
|
398
|
+
return locale.weekdays.longhand[date.getDay()];
|
399
|
+
},
|
400
|
+
// padded month number (01-12)
|
401
|
+
m: function (date) { return pad(date.getMonth() + 1); },
|
402
|
+
// the month number (1-12)
|
403
|
+
n: function (date) { return date.getMonth() + 1; },
|
404
|
+
// seconds 0-59
|
405
|
+
s: function (date) { return date.getSeconds(); },
|
406
|
+
// Unix Milliseconds
|
407
|
+
u: function (date) { return date.getTime(); },
|
408
|
+
// number of the day of the week
|
409
|
+
w: function (date) { return date.getDay(); },
|
410
|
+
// last two digits of year e.g. 16 for 2016
|
411
|
+
y: function (date) { return String(date.getFullYear()).substring(2); }
|
412
|
+
};
|
441
413
|
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
}
|
449
|
-
|
414
|
+
var createDateFormatter = function (_a) {
|
415
|
+
var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
|
416
|
+
return function (dateObj, frmt, overrideLocale) {
|
417
|
+
var locale = overrideLocale || l10n;
|
418
|
+
if (config.formatDate !== undefined) {
|
419
|
+
return config.formatDate(dateObj, frmt, locale);
|
420
|
+
}
|
421
|
+
return frmt
|
422
|
+
.split("")
|
423
|
+
.map(function (c, i, arr) {
|
424
|
+
return formats[c] && arr[i - 1] !== "\\"
|
425
|
+
? formats[c](dateObj, locale, config)
|
426
|
+
: c !== "\\"
|
427
|
+
? c
|
428
|
+
: "";
|
429
|
+
})
|
430
|
+
.join("");
|
450
431
|
};
|
451
|
-
|
452
|
-
|
453
|
-
|
432
|
+
};
|
433
|
+
var createDateParser = function (_a) {
|
434
|
+
var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
|
435
|
+
return function (date, givenFormat, timeless, customLocale) {
|
436
|
+
if (date !== 0 && !date)
|
437
|
+
return undefined;
|
438
|
+
var locale = customLocale || l10n;
|
439
|
+
var parsedDate;
|
440
|
+
var date_orig = date;
|
441
|
+
if (date instanceof Date)
|
442
|
+
parsedDate = new Date(date.getTime());
|
443
|
+
else if (typeof date !== "string" &&
|
444
|
+
date.toFixed !== undefined // timestamp
|
445
|
+
)
|
446
|
+
// create a copy
|
447
|
+
parsedDate = new Date(date);
|
448
|
+
else if (typeof date === "string") {
|
449
|
+
// date string
|
450
|
+
var format = givenFormat || (config || defaults).dateFormat;
|
451
|
+
var datestr = String(date).trim();
|
452
|
+
if (datestr === "today") {
|
453
|
+
parsedDate = new Date();
|
454
|
+
timeless = true;
|
455
|
+
}
|
456
|
+
else if (/Z$/.test(datestr) ||
|
457
|
+
/GMT$/.test(datestr) // datestrings w/ timezone
|
458
|
+
)
|
459
|
+
parsedDate = new Date(date);
|
460
|
+
else if (config && config.parseDate)
|
461
|
+
parsedDate = config.parseDate(date, format);
|
462
|
+
else {
|
463
|
+
parsedDate =
|
464
|
+
!config || !config.noCalendar
|
465
|
+
? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0)
|
466
|
+
: new Date(new Date().setHours(0, 0, 0, 0));
|
467
|
+
var matched = void 0, ops = [];
|
468
|
+
for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
|
469
|
+
var token_1 = format[i];
|
470
|
+
var isBackSlash = token_1 === "\\";
|
471
|
+
var escaped = format[i - 1] === "\\" || isBackSlash;
|
472
|
+
if (tokenRegex[token_1] && !escaped) {
|
473
|
+
regexStr += tokenRegex[token_1];
|
474
|
+
var match = new RegExp(regexStr).exec(date);
|
475
|
+
if (match && (matched = true)) {
|
476
|
+
ops[token_1 !== "Y" ? "push" : "unshift"]({
|
477
|
+
fn: revFormat[token_1],
|
478
|
+
val: match[++matchIndex]
|
479
|
+
});
|
480
|
+
}
|
481
|
+
}
|
482
|
+
else if (!isBackSlash)
|
483
|
+
regexStr += "."; // don't really care
|
484
|
+
ops.forEach(function (_a) {
|
485
|
+
var fn = _a.fn, val = _a.val;
|
486
|
+
return (parsedDate = fn(parsedDate, val, locale) || parsedDate);
|
487
|
+
});
|
488
|
+
}
|
489
|
+
parsedDate = matched ? parsedDate : undefined;
|
490
|
+
}
|
491
|
+
}
|
492
|
+
/* istanbul ignore next */
|
493
|
+
if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
|
494
|
+
config.errorHandler(new Error("Invalid date provided: " + date_orig));
|
495
|
+
return undefined;
|
496
|
+
}
|
497
|
+
if (timeless === true)
|
498
|
+
parsedDate.setHours(0, 0, 0, 0);
|
499
|
+
return parsedDate;
|
500
|
+
};
|
501
|
+
};
|
502
|
+
/**
|
503
|
+
* Compute the difference in dates, measured in ms
|
504
|
+
*/
|
505
|
+
function compareDates(date1, date2, timeless) {
|
506
|
+
if (timeless === void 0) { timeless = true; }
|
507
|
+
if (timeless !== false) {
|
508
|
+
return (new Date(date1.getTime()).setHours(0, 0, 0, 0) -
|
509
|
+
new Date(date2.getTime()).setHours(0, 0, 0, 0));
|
454
510
|
}
|
511
|
+
return date1.getTime() - date2.getTime();
|
512
|
+
}
|
513
|
+
var isBetween = function (ts, ts1, ts2) {
|
514
|
+
return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
|
515
|
+
};
|
516
|
+
var duration = {
|
517
|
+
DAY: 86400000
|
518
|
+
};
|
455
519
|
|
456
|
-
|
457
|
-
|
520
|
+
if (typeof Object.assign !== "function") {
|
521
|
+
Object.assign = function (target) {
|
522
|
+
var args = [];
|
523
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
524
|
+
args[_i - 1] = arguments[_i];
|
525
|
+
}
|
526
|
+
if (!target) {
|
527
|
+
throw TypeError("Cannot convert undefined or null to object");
|
528
|
+
}
|
529
|
+
var _loop_1 = function (source) {
|
530
|
+
if (source) {
|
531
|
+
Object.keys(source).forEach(function (key) { return (target[key] = source[key]); });
|
532
|
+
}
|
533
|
+
};
|
534
|
+
for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
535
|
+
var source = args_1[_a];
|
536
|
+
_loop_1(source);
|
537
|
+
}
|
538
|
+
return target;
|
539
|
+
};
|
458
540
|
}
|
459
541
|
|
460
542
|
var DEBOUNCED_CHANGE_MS = 300;
|
461
|
-
|
462
543
|
function FlatpickrInstance(element, instanceConfig) {
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
544
|
+
var self = {
|
545
|
+
config: __assign({}, flatpickr.defaultConfig),
|
546
|
+
l10n: english
|
547
|
+
};
|
548
|
+
self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
|
549
|
+
self._handlers = [];
|
550
|
+
self._bind = bind;
|
551
|
+
self._setHoursFromDate = setHoursFromDate;
|
552
|
+
self._positionCalendar = positionCalendar;
|
553
|
+
self.changeMonth = changeMonth;
|
554
|
+
self.changeYear = changeYear;
|
555
|
+
self.clear = clear;
|
556
|
+
self.close = close;
|
557
|
+
self._createElement = createElement;
|
558
|
+
self.destroy = destroy;
|
559
|
+
self.isEnabled = isEnabled;
|
560
|
+
self.jumpToDate = jumpToDate;
|
561
|
+
self.open = open;
|
562
|
+
self.redraw = redraw;
|
563
|
+
self.set = set;
|
564
|
+
self.setDate = setDate;
|
565
|
+
self.toggle = toggle;
|
566
|
+
function setupHelperFunctions() {
|
567
|
+
self.utils = {
|
568
|
+
getDaysInMonth: function (month, yr) {
|
569
|
+
if (month === void 0) { month = self.currentMonth; }
|
570
|
+
if (yr === void 0) { yr = self.currentYear; }
|
571
|
+
if (month === 1 && ((yr % 4 === 0 && yr % 100 !== 0) || yr % 400 === 0))
|
572
|
+
return 29;
|
573
|
+
return self.l10n.daysInMonth[month];
|
574
|
+
}
|
575
|
+
};
|
576
|
+
}
|
577
|
+
function init() {
|
578
|
+
self.element = self.input = element;
|
579
|
+
self.isOpen = false;
|
580
|
+
parseConfig();
|
581
|
+
setupLocale();
|
582
|
+
setupInputs();
|
583
|
+
setupDates();
|
584
|
+
setupHelperFunctions();
|
585
|
+
if (!self.isMobile)
|
586
|
+
build();
|
587
|
+
bindEvents();
|
588
|
+
if (self.selectedDates.length || self.config.noCalendar) {
|
589
|
+
if (self.config.enableTime) {
|
590
|
+
setHoursFromDate(self.config.noCalendar
|
591
|
+
? self.latestSelectedDateObj || self.config.minDate
|
592
|
+
: undefined);
|
593
|
+
}
|
594
|
+
updateValue(false);
|
494
595
|
}
|
495
|
-
|
496
|
-
|
497
|
-
|
596
|
+
setCalendarWidth();
|
597
|
+
self.showTimeInput =
|
598
|
+
self.selectedDates.length > 0 || self.config.noCalendar;
|
599
|
+
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
600
|
+
/* TODO: investigate this further
|
601
|
+
|
602
|
+
Currently, there is weird positioning behavior in safari causing pages
|
603
|
+
to scroll up. https://github.com/chmln/flatpickr/issues/563
|
604
|
+
|
605
|
+
However, most browsers are not Safari and positioning is expensive when used
|
606
|
+
in scale. https://github.com/chmln/flatpickr/issues/1096
|
607
|
+
*/
|
608
|
+
if (!self.isMobile && isSafari) {
|
609
|
+
positionCalendar();
|
498
610
|
}
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
}
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
528
|
-
|
529
|
-
if (!self.isMobile && isSafari) {
|
530
|
-
positionCalendar();
|
531
|
-
}
|
532
|
-
|
533
|
-
triggerEvent("onReady");
|
534
|
-
}
|
535
|
-
|
536
|
-
function bindToInstance(fn) {
|
537
|
-
return fn.bind(self);
|
538
|
-
}
|
539
|
-
|
540
|
-
function setCalendarWidth() {
|
541
|
-
var config = self.config;
|
542
|
-
if (config.weekNumbers === false && config.showMonths === 1) return;else if (config.noCalendar !== true) {
|
543
|
-
window.requestAnimationFrame(function () {
|
544
|
-
self.calendarContainer.style.visibility = "hidden";
|
545
|
-
self.calendarContainer.style.display = "block";
|
546
|
-
|
547
|
-
if (self.daysContainer !== undefined) {
|
548
|
-
var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
|
549
|
-
self.daysContainer.style.width = daysWidth + "px";
|
550
|
-
self.calendarContainer.style.width = daysWidth + (self.weekWrapper !== undefined ? self.weekWrapper.offsetWidth : 0) + "px";
|
551
|
-
self.calendarContainer.style.removeProperty("visibility");
|
552
|
-
self.calendarContainer.style.removeProperty("display");
|
611
|
+
triggerEvent("onReady");
|
612
|
+
}
|
613
|
+
function bindToInstance(fn) {
|
614
|
+
return fn.bind(self);
|
615
|
+
}
|
616
|
+
function setCalendarWidth() {
|
617
|
+
var config = self.config;
|
618
|
+
if (config.weekNumbers === false && config.showMonths === 1)
|
619
|
+
return;
|
620
|
+
else if (config.noCalendar !== true) {
|
621
|
+
window.requestAnimationFrame(function () {
|
622
|
+
if (self.calendarContainer !== undefined) {
|
623
|
+
self.calendarContainer.style.visibility = "hidden";
|
624
|
+
self.calendarContainer.style.display = "block";
|
625
|
+
}
|
626
|
+
if (self.daysContainer !== undefined) {
|
627
|
+
var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
|
628
|
+
self.daysContainer.style.width = daysWidth + "px";
|
629
|
+
self.calendarContainer.style.width =
|
630
|
+
daysWidth +
|
631
|
+
(self.weekWrapper !== undefined
|
632
|
+
? self.weekWrapper.offsetWidth
|
633
|
+
: 0) +
|
634
|
+
"px";
|
635
|
+
self.calendarContainer.style.removeProperty("visibility");
|
636
|
+
self.calendarContainer.style.removeProperty("display");
|
637
|
+
}
|
638
|
+
});
|
553
639
|
}
|
554
|
-
});
|
555
|
-
}
|
556
|
-
}
|
557
|
-
|
558
|
-
function updateTime(e) {
|
559
|
-
if (self.selectedDates.length === 0) return;
|
560
|
-
|
561
|
-
if (e !== undefined && e.type !== "blur") {
|
562
|
-
timeWrapper(e);
|
563
|
-
}
|
564
|
-
|
565
|
-
var prevValue = self._input.value;
|
566
|
-
setHoursFromInputs();
|
567
|
-
updateValue();
|
568
|
-
|
569
|
-
if (self._input.value !== prevValue) {
|
570
|
-
self._debouncedChange();
|
571
|
-
}
|
572
|
-
}
|
573
|
-
|
574
|
-
function ampm2military(hour, amPM) {
|
575
|
-
return hour % 12 + 12 * int(amPM === self.l10n.amPM[1]);
|
576
|
-
}
|
577
|
-
|
578
|
-
function military2ampm(hour) {
|
579
|
-
switch (hour % 24) {
|
580
|
-
case 0:
|
581
|
-
case 12:
|
582
|
-
return 12;
|
583
|
-
|
584
|
-
default:
|
585
|
-
return hour % 12;
|
586
640
|
}
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
641
|
+
/**
|
642
|
+
* The handler for all events targeting the time inputs
|
643
|
+
*/
|
644
|
+
function updateTime(e) {
|
645
|
+
if (self.selectedDates.length === 0) {
|
646
|
+
setDefaultTime();
|
647
|
+
}
|
648
|
+
if (e !== undefined && e.type !== "blur") {
|
649
|
+
timeWrapper(e);
|
650
|
+
}
|
651
|
+
var prevValue = self._input.value;
|
652
|
+
setHoursFromInputs();
|
653
|
+
updateValue();
|
654
|
+
if (self._input.value !== prevValue) {
|
655
|
+
self._debouncedChange();
|
656
|
+
}
|
597
657
|
}
|
598
|
-
|
599
|
-
|
600
|
-
var limitMaxHours = self.config.maxTime !== undefined || self.config.maxDate && self.maxDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.maxDate, true) === 0;
|
601
|
-
|
602
|
-
if (limitMaxHours) {
|
603
|
-
var maxTime = self.config.maxTime !== undefined ? self.config.maxTime : self.config.maxDate;
|
604
|
-
hours = Math.min(hours, maxTime.getHours());
|
605
|
-
if (hours === maxTime.getHours()) minutes = Math.min(minutes, maxTime.getMinutes());
|
606
|
-
if (minutes === maxTime.getMinutes()) seconds = Math.min(seconds, maxTime.getSeconds());
|
658
|
+
function ampm2military(hour, amPM) {
|
659
|
+
return (hour % 12) + 12 * int(amPM === self.l10n.amPM[1]);
|
607
660
|
}
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
661
|
+
function military2ampm(hour) {
|
662
|
+
switch (hour % 24) {
|
663
|
+
case 0:
|
664
|
+
case 12:
|
665
|
+
return 12;
|
666
|
+
default:
|
667
|
+
return hour % 12;
|
668
|
+
}
|
614
669
|
}
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
670
|
+
/**
|
671
|
+
* Syncs the selected date object time with user's time input
|
672
|
+
*/
|
673
|
+
function setHoursFromInputs() {
|
674
|
+
if (self.hourElement === undefined || self.minuteElement === undefined)
|
675
|
+
return;
|
676
|
+
var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60, seconds = self.secondElement !== undefined
|
677
|
+
? (parseInt(self.secondElement.value, 10) || 0) % 60
|
678
|
+
: 0;
|
679
|
+
if (self.amPM !== undefined) {
|
680
|
+
hours = ampm2military(hours, self.amPM.textContent);
|
681
|
+
}
|
682
|
+
var limitMinHours = self.config.minTime !== undefined ||
|
683
|
+
(self.config.minDate &&
|
684
|
+
self.minDateHasTime &&
|
685
|
+
self.latestSelectedDateObj &&
|
686
|
+
compareDates(self.latestSelectedDateObj, self.config.minDate, true) ===
|
687
|
+
0);
|
688
|
+
var limitMaxHours = self.config.maxTime !== undefined ||
|
689
|
+
(self.config.maxDate &&
|
690
|
+
self.maxDateHasTime &&
|
691
|
+
self.latestSelectedDateObj &&
|
692
|
+
compareDates(self.latestSelectedDateObj, self.config.maxDate, true) ===
|
693
|
+
0);
|
694
|
+
if (limitMaxHours) {
|
695
|
+
var maxTime = self.config.maxTime !== undefined
|
696
|
+
? self.config.maxTime
|
697
|
+
: self.config.maxDate;
|
698
|
+
hours = Math.min(hours, maxTime.getHours());
|
699
|
+
if (hours === maxTime.getHours())
|
700
|
+
minutes = Math.min(minutes, maxTime.getMinutes());
|
701
|
+
if (minutes === maxTime.getMinutes())
|
702
|
+
seconds = Math.min(seconds, maxTime.getSeconds());
|
703
|
+
}
|
704
|
+
if (limitMinHours) {
|
705
|
+
var minTime = self.config.minTime !== undefined
|
706
|
+
? self.config.minTime
|
707
|
+
: self.config.minDate;
|
708
|
+
hours = Math.max(hours, minTime.getHours());
|
709
|
+
if (hours === minTime.getHours())
|
710
|
+
minutes = Math.max(minutes, minTime.getMinutes());
|
711
|
+
if (minutes === minTime.getMinutes())
|
712
|
+
seconds = Math.max(seconds, minTime.getSeconds());
|
713
|
+
}
|
714
|
+
setHours(hours, minutes, seconds);
|
715
|
+
}
|
716
|
+
/**
|
717
|
+
* Syncs time input values with a date
|
718
|
+
*/
|
719
|
+
function setHoursFromDate(dateObj) {
|
720
|
+
var date = dateObj || self.latestSelectedDateObj;
|
721
|
+
if (date)
|
722
|
+
setHours(date.getHours(), date.getMinutes(), date.getSeconds());
|
723
|
+
}
|
724
|
+
function setDefaultHours() {
|
725
|
+
var hours = self.config.defaultHour;
|
726
|
+
var minutes = self.config.defaultMinute;
|
727
|
+
var seconds = self.config.defaultSeconds;
|
728
|
+
if (self.config.minDate !== undefined) {
|
729
|
+
var min_hr = self.config.minDate.getHours();
|
730
|
+
var min_minutes = self.config.minDate.getMinutes();
|
731
|
+
hours = Math.max(hours, min_hr);
|
732
|
+
if (hours === min_hr)
|
733
|
+
minutes = Math.max(min_minutes, minutes);
|
734
|
+
if (hours === min_hr && minutes === min_minutes)
|
735
|
+
seconds = self.config.minDate.getSeconds();
|
736
|
+
}
|
737
|
+
if (self.config.maxDate !== undefined) {
|
738
|
+
var max_hr = self.config.maxDate.getHours();
|
739
|
+
var max_minutes = self.config.maxDate.getMinutes();
|
740
|
+
hours = Math.min(hours, max_hr);
|
741
|
+
if (hours === max_hr)
|
742
|
+
minutes = Math.min(max_minutes, minutes);
|
743
|
+
if (hours === max_hr && minutes === max_minutes)
|
744
|
+
seconds = self.config.maxDate.getSeconds();
|
745
|
+
}
|
746
|
+
setHours(hours, minutes, seconds);
|
747
|
+
}
|
748
|
+
/**
|
749
|
+
* Sets the hours, minutes, and optionally seconds
|
750
|
+
* of the latest selected date object and the
|
751
|
+
* corresponding time inputs
|
752
|
+
* @param {Number} hours the hour. whether its military
|
753
|
+
* or am-pm gets inferred from config
|
754
|
+
* @param {Number} minutes the minutes
|
755
|
+
* @param {Number} seconds the seconds (optional)
|
756
|
+
*/
|
757
|
+
function setHours(hours, minutes, seconds) {
|
758
|
+
if (self.latestSelectedDateObj !== undefined) {
|
759
|
+
self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
|
760
|
+
}
|
761
|
+
if (!self.hourElement || !self.minuteElement || self.isMobile)
|
762
|
+
return;
|
763
|
+
self.hourElement.value = pad(!self.config.time_24hr
|
764
|
+
? ((12 + hours) % 12) + 12 * int(hours % 12 === 0)
|
765
|
+
: hours);
|
766
|
+
self.minuteElement.value = pad(minutes);
|
767
|
+
if (self.amPM !== undefined)
|
768
|
+
self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
|
769
|
+
if (self.secondElement !== undefined)
|
770
|
+
self.secondElement.value = pad(seconds);
|
771
|
+
}
|
772
|
+
/**
|
773
|
+
* Handles the year input and incrementing events
|
774
|
+
* @param {Event} event the keyup or increment event
|
775
|
+
*/
|
776
|
+
function onYearInput(event) {
|
777
|
+
var year = parseInt(event.target.value) + (event.delta || 0);
|
778
|
+
if (year / 1000 > 1 ||
|
779
|
+
(event.key === "Enter" && !/[^\d]/.test(year.toString()))) {
|
780
|
+
changeYear(year);
|
781
|
+
}
|
635
782
|
}
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
783
|
+
/**
|
784
|
+
* Essentially addEventListener + tracking
|
785
|
+
* @param {Element} element the element to addEventListener to
|
786
|
+
* @param {String} event the event name
|
787
|
+
* @param {Function} handler the event handler
|
788
|
+
*/
|
789
|
+
function bind(element, event, handler, options) {
|
790
|
+
if (event instanceof Array)
|
791
|
+
return event.forEach(function (ev) { return bind(element, ev, handler, options); });
|
792
|
+
if (element instanceof Array)
|
793
|
+
return element.forEach(function (el) { return bind(el, event, handler, options); });
|
794
|
+
element.addEventListener(event, handler, options);
|
795
|
+
self._handlers.push({
|
796
|
+
element: element,
|
797
|
+
event: event,
|
798
|
+
handler: handler,
|
799
|
+
options: options
|
800
|
+
});
|
643
801
|
}
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
802
|
+
/**
|
803
|
+
* A mousedown handler which mimics click.
|
804
|
+
* Minimizes latency, since we don't need to wait for mouseup in most cases.
|
805
|
+
* Also, avoids handling right clicks.
|
806
|
+
*
|
807
|
+
* @param {Function} handler the event handler
|
808
|
+
*/
|
809
|
+
function onClick(handler) {
|
810
|
+
return function (evt) {
|
811
|
+
evt.which === 1 && handler(evt);
|
812
|
+
};
|
813
|
+
}
|
814
|
+
function triggerChange() {
|
815
|
+
triggerEvent("onChange");
|
816
|
+
}
|
817
|
+
/**
|
818
|
+
* Adds all the necessary event listeners
|
819
|
+
*/
|
820
|
+
function bindEvents() {
|
821
|
+
if (self.config.wrap) {
|
822
|
+
["open", "close", "toggle", "clear"].forEach(function (evt) {
|
823
|
+
Array.prototype.forEach.call(self.element.querySelectorAll("[data-" + evt + "]"), function (el) {
|
824
|
+
return bind(el, "click", self[evt]);
|
825
|
+
});
|
826
|
+
});
|
827
|
+
}
|
828
|
+
if (self.isMobile) {
|
829
|
+
setupMobile();
|
830
|
+
return;
|
831
|
+
}
|
832
|
+
var debouncedResize = debounce(onResize, 50);
|
833
|
+
self._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
|
834
|
+
if (self.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent))
|
835
|
+
bind(self.daysContainer, "mouseover", function (e) {
|
836
|
+
if (self.config.mode === "range")
|
837
|
+
onMouseOver(e.target);
|
838
|
+
});
|
839
|
+
bind(window.document.body, "keydown", onKeyDown);
|
840
|
+
if (!self.config.static)
|
841
|
+
bind(self._input, "keydown", onKeyDown);
|
842
|
+
if (!self.config.inline && !self.config.static)
|
843
|
+
bind(window, "resize", debouncedResize);
|
844
|
+
if (window.ontouchstart !== undefined)
|
845
|
+
bind(window.document, "click", documentClick);
|
846
|
+
else
|
847
|
+
bind(window.document, "mousedown", onClick(documentClick));
|
848
|
+
bind(window.document, "focus", documentClick, { capture: true });
|
849
|
+
if (self.config.clickOpens === true) {
|
850
|
+
bind(self._input, "focus", self.open);
|
851
|
+
bind(self._input, "mousedown", onClick(self.open));
|
852
|
+
}
|
853
|
+
if (self.daysContainer !== undefined) {
|
854
|
+
bind(self.monthNav, "mousedown", onClick(onMonthNavClick));
|
855
|
+
bind(self.monthNav, ["keyup", "increment"], onYearInput);
|
856
|
+
bind(self.daysContainer, "mousedown", onClick(selectDate));
|
857
|
+
}
|
858
|
+
if (self.timeContainer !== undefined &&
|
859
|
+
self.minuteElement !== undefined &&
|
860
|
+
self.hourElement !== undefined) {
|
861
|
+
var selText = function (e) {
|
862
|
+
return e.target.select();
|
863
|
+
};
|
864
|
+
bind(self.timeContainer, ["increment"], updateTime);
|
865
|
+
bind(self.timeContainer, "blur", updateTime, { capture: true });
|
866
|
+
bind(self.timeContainer, "mousedown", onClick(timeIncrement));
|
867
|
+
bind([self.hourElement, self.minuteElement], ["focus", "click"], selText);
|
868
|
+
if (self.secondElement !== undefined)
|
869
|
+
bind(self.secondElement, "focus", function () { return self.secondElement && self.secondElement.select(); });
|
870
|
+
if (self.amPM !== undefined) {
|
871
|
+
bind(self.amPM, "mousedown", onClick(function (e) {
|
872
|
+
updateTime(e);
|
873
|
+
triggerChange();
|
874
|
+
}));
|
875
|
+
}
|
876
|
+
}
|
651
877
|
}
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
878
|
+
/**
|
879
|
+
* Set the calendar view to a particular date.
|
880
|
+
* @param {Date} jumpDate the date to set the view to
|
881
|
+
*/
|
882
|
+
function jumpToDate(jumpDate) {
|
883
|
+
var jumpTo = jumpDate !== undefined
|
884
|
+
? self.parseDate(jumpDate)
|
885
|
+
: self.latestSelectedDateObj ||
|
886
|
+
(self.config.minDate && self.config.minDate > self.now
|
887
|
+
? self.config.minDate
|
888
|
+
: self.config.maxDate && self.config.maxDate < self.now
|
889
|
+
? self.config.maxDate
|
890
|
+
: self.now);
|
891
|
+
try {
|
892
|
+
if (jumpTo !== undefined) {
|
893
|
+
self.currentYear = jumpTo.getFullYear();
|
894
|
+
self.currentMonth = jumpTo.getMonth();
|
895
|
+
}
|
896
|
+
}
|
897
|
+
catch (e) {
|
898
|
+
/* istanbul ignore next */
|
899
|
+
e.message = "Invalid date supplied: " + jumpTo;
|
900
|
+
self.config.errorHandler(e);
|
901
|
+
}
|
902
|
+
self.redraw();
|
903
|
+
}
|
904
|
+
/**
|
905
|
+
* The up/down arrow handler for time inputs
|
906
|
+
* @param {Event} e the click event
|
907
|
+
*/
|
908
|
+
function timeIncrement(e) {
|
909
|
+
if (~e.target.className.indexOf("arrow"))
|
910
|
+
incrementNumInput(e, e.target.classList.contains("arrowUp") ? 1 : -1);
|
911
|
+
}
|
912
|
+
/**
|
913
|
+
* Increments/decrements the value of input associ-
|
914
|
+
* ated with the up/down arrow by dispatching an
|
915
|
+
* "increment" event on the input.
|
916
|
+
*
|
917
|
+
* @param {Event} e the click event
|
918
|
+
* @param {Number} delta the diff (usually 1 or -1)
|
919
|
+
* @param {Element} inputElem the input element
|
920
|
+
*/
|
921
|
+
function incrementNumInput(e, delta, inputElem) {
|
922
|
+
var target = e && e.target;
|
923
|
+
var input = inputElem ||
|
924
|
+
(target && target.parentNode && target.parentNode.firstChild);
|
925
|
+
var event = createEvent("increment");
|
926
|
+
event.delta = delta;
|
927
|
+
input && input.dispatchEvent(event);
|
928
|
+
}
|
929
|
+
function build() {
|
930
|
+
var fragment = window.document.createDocumentFragment();
|
931
|
+
self.calendarContainer = createElement("div", "flatpickr-calendar");
|
932
|
+
self.calendarContainer.tabIndex = -1;
|
933
|
+
if (!self.config.noCalendar) {
|
934
|
+
fragment.appendChild(buildMonthNav());
|
935
|
+
self.innerContainer = createElement("div", "flatpickr-innerContainer");
|
936
|
+
if (self.config.weekNumbers) {
|
937
|
+
var _a = buildWeeks(), weekWrapper = _a.weekWrapper, weekNumbers = _a.weekNumbers;
|
938
|
+
self.innerContainer.appendChild(weekWrapper);
|
939
|
+
self.weekNumbers = weekNumbers;
|
940
|
+
self.weekWrapper = weekWrapper;
|
941
|
+
}
|
942
|
+
self.rContainer = createElement("div", "flatpickr-rContainer");
|
943
|
+
self.rContainer.appendChild(buildWeekdays());
|
944
|
+
if (!self.daysContainer) {
|
945
|
+
self.daysContainer = createElement("div", "flatpickr-days");
|
946
|
+
self.daysContainer.tabIndex = -1;
|
947
|
+
}
|
948
|
+
buildDays();
|
949
|
+
self.rContainer.appendChild(self.daysContainer);
|
950
|
+
self.innerContainer.appendChild(self.rContainer);
|
951
|
+
fragment.appendChild(self.innerContainer);
|
952
|
+
}
|
953
|
+
if (self.config.enableTime) {
|
954
|
+
fragment.appendChild(buildTime());
|
955
|
+
}
|
956
|
+
toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
|
957
|
+
toggleClass(self.calendarContainer, "animate", self.config.animate === true);
|
958
|
+
toggleClass(self.calendarContainer, "multiMonth", self.config.showMonths > 1);
|
959
|
+
self.calendarContainer.appendChild(fragment);
|
960
|
+
var customAppend = self.config.appendTo !== undefined &&
|
961
|
+
self.config.appendTo.nodeType !== undefined;
|
962
|
+
if (self.config.inline || self.config.static) {
|
963
|
+
self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
|
964
|
+
if (self.config.inline) {
|
965
|
+
if (!customAppend && self.element.parentNode)
|
966
|
+
self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling);
|
967
|
+
else if (self.config.appendTo !== undefined)
|
968
|
+
self.config.appendTo.appendChild(self.calendarContainer);
|
969
|
+
}
|
970
|
+
if (self.config.static) {
|
971
|
+
var wrapper = createElement("div", "flatpickr-wrapper");
|
972
|
+
if (self.element.parentNode)
|
973
|
+
self.element.parentNode.insertBefore(wrapper, self.element);
|
974
|
+
wrapper.appendChild(self.element);
|
975
|
+
if (self.altInput)
|
976
|
+
wrapper.appendChild(self.altInput);
|
977
|
+
wrapper.appendChild(self.calendarContainer);
|
978
|
+
}
|
979
|
+
}
|
980
|
+
if (!self.config.static && !self.config.inline)
|
981
|
+
(self.config.appendTo !== undefined
|
982
|
+
? self.config.appendTo
|
983
|
+
: window.document.body).appendChild(self.calendarContainer);
|
984
|
+
}
|
985
|
+
function createDay(className, date, dayNumber, i) {
|
986
|
+
var dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", "flatpickr-day " + className, date.getDate().toString());
|
987
|
+
dayElement.dateObj = date;
|
988
|
+
dayElement.$i = i;
|
989
|
+
dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
|
990
|
+
if (className.indexOf("hidden") === -1 &&
|
991
|
+
compareDates(date, self.now) === 0) {
|
992
|
+
self.todayDateElem = dayElement;
|
993
|
+
dayElement.classList.add("today");
|
994
|
+
dayElement.setAttribute("aria-current", "date");
|
995
|
+
}
|
996
|
+
if (dateIsEnabled) {
|
997
|
+
dayElement.tabIndex = -1;
|
998
|
+
if (isDateSelected(date)) {
|
999
|
+
dayElement.classList.add("selected");
|
1000
|
+
self.selectedDateElem = dayElement;
|
1001
|
+
if (self.config.mode === "range") {
|
1002
|
+
toggleClass(dayElement, "startRange", self.selectedDates[0] &&
|
1003
|
+
compareDates(date, self.selectedDates[0], true) === 0);
|
1004
|
+
toggleClass(dayElement, "endRange", self.selectedDates[1] &&
|
1005
|
+
compareDates(date, self.selectedDates[1], true) === 0);
|
1006
|
+
if (className === "nextMonthDay")
|
1007
|
+
dayElement.classList.add("inRange");
|
1008
|
+
}
|
1009
|
+
}
|
1010
|
+
}
|
1011
|
+
else {
|
1012
|
+
dayElement.classList.add("disabled");
|
1013
|
+
}
|
1014
|
+
if (self.config.mode === "range") {
|
1015
|
+
if (isDateInRange(date) && !isDateSelected(date))
|
1016
|
+
dayElement.classList.add("inRange");
|
1017
|
+
}
|
1018
|
+
if (self.weekNumbers &&
|
1019
|
+
self.config.showMonths === 1 &&
|
1020
|
+
className !== "prevMonthDay" &&
|
1021
|
+
dayNumber % 7 === 1) {
|
1022
|
+
self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
|
1023
|
+
}
|
1024
|
+
triggerEvent("onDayCreate", dayElement);
|
1025
|
+
return dayElement;
|
1026
|
+
}
|
1027
|
+
function focusOnDayElem(targetNode) {
|
1028
|
+
targetNode.focus();
|
1029
|
+
if (self.config.mode === "range")
|
1030
|
+
onMouseOver(targetNode);
|
1031
|
+
}
|
1032
|
+
function getFirstAvailableDay(delta) {
|
1033
|
+
var startMonth = delta > 0 ? 0 : self.config.showMonths - 1;
|
1034
|
+
var endMonth = delta > 0 ? self.config.showMonths : -1;
|
1035
|
+
for (var m = startMonth; m != endMonth; m += delta) {
|
1036
|
+
var month = self.daysContainer.children[m];
|
1037
|
+
var startIndex = delta > 0 ? 0 : month.children.length - 1;
|
1038
|
+
var endIndex = delta > 0 ? month.children.length : -1;
|
1039
|
+
for (var i = startIndex; i != endIndex; i += delta) {
|
1040
|
+
var c = month.children[i];
|
1041
|
+
if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj))
|
1042
|
+
return c;
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
return undefined;
|
1046
|
+
}
|
1047
|
+
function getNextAvailableDay(current, delta) {
|
1048
|
+
var givenMonth = current.className.indexOf("Month") === -1
|
1049
|
+
? current.dateObj.getMonth()
|
1050
|
+
: self.currentMonth;
|
1051
|
+
var endMonth = delta > 0 ? self.config.showMonths : -1;
|
1052
|
+
var loopDelta = delta > 0 ? 1 : -1;
|
1053
|
+
for (var m = givenMonth - self.currentMonth; m != endMonth; m += loopDelta) {
|
1054
|
+
var month = self.daysContainer.children[m];
|
1055
|
+
var startIndex = givenMonth - self.currentMonth === m
|
1056
|
+
? current.$i + delta
|
1057
|
+
: delta < 0
|
1058
|
+
? month.children.length - 1
|
1059
|
+
: 0;
|
1060
|
+
var numMonthDays = month.children.length;
|
1061
|
+
for (var i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta) {
|
1062
|
+
var c = month.children[i];
|
1063
|
+
if (c.className.indexOf("hidden") === -1 &&
|
1064
|
+
isEnabled(c.dateObj) &&
|
1065
|
+
Math.abs(current.$i - i) >= Math.abs(delta))
|
1066
|
+
return focusOnDayElem(c);
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
self.changeMonth(loopDelta);
|
1070
|
+
focusOnDay(getFirstAvailableDay(loopDelta), 0);
|
1071
|
+
return undefined;
|
1072
|
+
}
|
1073
|
+
function focusOnDay(current, offset) {
|
1074
|
+
var dayFocused = isInView(document.activeElement || document.body);
|
1075
|
+
var startElem = current !== undefined
|
1076
|
+
? current
|
1077
|
+
: dayFocused
|
1078
|
+
? document.activeElement
|
1079
|
+
: self.selectedDateElem !== undefined && isInView(self.selectedDateElem)
|
1080
|
+
? self.selectedDateElem
|
1081
|
+
: self.todayDateElem !== undefined && isInView(self.todayDateElem)
|
1082
|
+
? self.todayDateElem
|
1083
|
+
: getFirstAvailableDay(offset > 0 ? 1 : -1);
|
1084
|
+
if (startElem === undefined)
|
1085
|
+
return self._input.focus();
|
1086
|
+
if (!dayFocused)
|
1087
|
+
return focusOnDayElem(startElem);
|
1088
|
+
getNextAvailableDay(startElem, offset);
|
1089
|
+
}
|
1090
|
+
function buildMonthDays(year, month) {
|
1091
|
+
var firstOfMonth = (new Date(year, month, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7;
|
1092
|
+
var prevMonthDays = self.utils.getDaysInMonth((month - 1 + 12) % 12);
|
1093
|
+
var daysInMonth = self.utils.getDaysInMonth(month), days = window.document.createDocumentFragment(), isMultiMonth = self.config.showMonths > 1, prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay", nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
|
1094
|
+
var dayNumber = prevMonthDays + 1 - firstOfMonth, dayIndex = 0;
|
1095
|
+
// prepend days from the ending of previous month
|
1096
|
+
for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
|
1097
|
+
days.appendChild(createDay(prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
|
1098
|
+
}
|
1099
|
+
// Start at 1 since there is no 0th day
|
1100
|
+
for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
|
1101
|
+
days.appendChild(createDay("", new Date(year, month, dayNumber), dayNumber, dayIndex));
|
1102
|
+
}
|
1103
|
+
// append days from the next month
|
1104
|
+
for (var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth &&
|
1105
|
+
(self.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++) {
|
1106
|
+
days.appendChild(createDay(nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
|
1107
|
+
}
|
1108
|
+
//updateNavigationCurrentMonth();
|
1109
|
+
var dayContainer = createElement("div", "dayContainer");
|
1110
|
+
dayContainer.appendChild(days);
|
1111
|
+
return dayContainer;
|
1112
|
+
}
|
1113
|
+
function buildDays() {
|
1114
|
+
if (self.daysContainer === undefined) {
|
1115
|
+
return;
|
1116
|
+
}
|
1117
|
+
clearNode(self.daysContainer);
|
1118
|
+
// TODO: week numbers for each month
|
1119
|
+
if (self.weekNumbers)
|
1120
|
+
clearNode(self.weekNumbers);
|
1121
|
+
var frag = document.createDocumentFragment();
|
1122
|
+
for (var i = 0; i < self.config.showMonths; i++) {
|
1123
|
+
var d = new Date(self.currentYear, self.currentMonth, 1);
|
1124
|
+
d.setMonth(self.currentMonth + i);
|
1125
|
+
frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
|
1126
|
+
}
|
1127
|
+
self.daysContainer.appendChild(frag);
|
1128
|
+
self.days = self.daysContainer.firstChild;
|
1129
|
+
if (self.config.mode === "range" && self.selectedDates.length === 1) {
|
1130
|
+
onMouseOver();
|
1131
|
+
}
|
665
1132
|
}
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
1133
|
+
function buildMonth() {
|
1134
|
+
var container = createElement("div", "flatpickr-month");
|
1135
|
+
var monthNavFragment = window.document.createDocumentFragment();
|
1136
|
+
var monthElement = createElement("span", "cur-month");
|
1137
|
+
var yearInput = createNumberInput("cur-year", { tabindex: "-1" });
|
1138
|
+
var yearElement = yearInput.getElementsByTagName("input")[0];
|
1139
|
+
yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
|
1140
|
+
if (self.config.minDate) {
|
1141
|
+
yearElement.setAttribute("min", self.config.minDate.getFullYear().toString());
|
1142
|
+
}
|
1143
|
+
if (self.config.maxDate) {
|
1144
|
+
yearElement.setAttribute("max", self.config.maxDate.getFullYear().toString());
|
1145
|
+
yearElement.disabled =
|
1146
|
+
!!self.config.minDate &&
|
1147
|
+
self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
|
1148
|
+
}
|
1149
|
+
var currentMonth = createElement("div", "flatpickr-current-month");
|
1150
|
+
currentMonth.appendChild(monthElement);
|
1151
|
+
currentMonth.appendChild(yearInput);
|
1152
|
+
monthNavFragment.appendChild(currentMonth);
|
1153
|
+
container.appendChild(monthNavFragment);
|
1154
|
+
return {
|
1155
|
+
container: container,
|
1156
|
+
yearElement: yearElement,
|
1157
|
+
monthElement: monthElement
|
1158
|
+
};
|
1159
|
+
}
|
1160
|
+
function buildMonths() {
|
1161
|
+
clearNode(self.monthNav);
|
1162
|
+
self.monthNav.appendChild(self.prevMonthNav);
|
1163
|
+
if (self.config.showMonths) {
|
1164
|
+
self.yearElements = [];
|
1165
|
+
self.monthElements = [];
|
1166
|
+
}
|
1167
|
+
for (var m = self.config.showMonths; m--;) {
|
1168
|
+
var month = buildMonth();
|
1169
|
+
self.yearElements.push(month.yearElement);
|
1170
|
+
self.monthElements.push(month.monthElement);
|
1171
|
+
self.monthNav.appendChild(month.container);
|
1172
|
+
}
|
1173
|
+
self.monthNav.appendChild(self.nextMonthNav);
|
1174
|
+
}
|
1175
|
+
function buildMonthNav() {
|
1176
|
+
self.monthNav = createElement("div", "flatpickr-months");
|
1177
|
+
self.yearElements = [];
|
1178
|
+
self.monthElements = [];
|
1179
|
+
self.prevMonthNav = createElement("span", "flatpickr-prev-month");
|
1180
|
+
self.prevMonthNav.innerHTML = self.config.prevArrow;
|
1181
|
+
self.nextMonthNav = createElement("span", "flatpickr-next-month");
|
1182
|
+
self.nextMonthNav.innerHTML = self.config.nextArrow;
|
1183
|
+
buildMonths();
|
1184
|
+
Object.defineProperty(self, "_hidePrevMonthArrow", {
|
1185
|
+
get: function () { return self.__hidePrevMonthArrow; },
|
1186
|
+
set: function (bool) {
|
1187
|
+
if (self.__hidePrevMonthArrow !== bool) {
|
1188
|
+
toggleClass(self.prevMonthNav, "disabled", bool);
|
1189
|
+
self.__hidePrevMonthArrow = bool;
|
1190
|
+
}
|
1191
|
+
}
|
700
1192
|
});
|
701
|
-
|
1193
|
+
Object.defineProperty(self, "_hideNextMonthArrow", {
|
1194
|
+
get: function () { return self.__hideNextMonthArrow; },
|
1195
|
+
set: function (bool) {
|
1196
|
+
if (self.__hideNextMonthArrow !== bool) {
|
1197
|
+
toggleClass(self.nextMonthNav, "disabled", bool);
|
1198
|
+
self.__hideNextMonthArrow = bool;
|
1199
|
+
}
|
1200
|
+
}
|
1201
|
+
});
|
1202
|
+
self.currentYearElement = self.yearElements[0];
|
1203
|
+
updateNavigationCurrentMonth();
|
1204
|
+
return self.monthNav;
|
1205
|
+
}
|
1206
|
+
function buildTime() {
|
1207
|
+
self.calendarContainer.classList.add("hasTime");
|
1208
|
+
if (self.config.noCalendar)
|
1209
|
+
self.calendarContainer.classList.add("noCalendar");
|
1210
|
+
self.timeContainer = createElement("div", "flatpickr-time");
|
1211
|
+
self.timeContainer.tabIndex = -1;
|
1212
|
+
var separator = createElement("span", "flatpickr-time-separator", ":");
|
1213
|
+
var hourInput = createNumberInput("flatpickr-hour");
|
1214
|
+
self.hourElement = hourInput.getElementsByTagName("input")[0];
|
1215
|
+
var minuteInput = createNumberInput("flatpickr-minute");
|
1216
|
+
self.minuteElement = minuteInput.getElementsByTagName("input")[0];
|
1217
|
+
self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
|
1218
|
+
self.hourElement.value = pad(self.latestSelectedDateObj
|
1219
|
+
? self.latestSelectedDateObj.getHours()
|
1220
|
+
: self.config.time_24hr
|
1221
|
+
? self.config.defaultHour
|
1222
|
+
: military2ampm(self.config.defaultHour));
|
1223
|
+
self.minuteElement.value = pad(self.latestSelectedDateObj
|
1224
|
+
? self.latestSelectedDateObj.getMinutes()
|
1225
|
+
: self.config.defaultMinute);
|
1226
|
+
self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
|
1227
|
+
self.minuteElement.setAttribute("step", self.config.minuteIncrement.toString());
|
1228
|
+
self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
|
1229
|
+
self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
|
1230
|
+
self.minuteElement.setAttribute("min", "0");
|
1231
|
+
self.minuteElement.setAttribute("max", "59");
|
1232
|
+
self.timeContainer.appendChild(hourInput);
|
1233
|
+
self.timeContainer.appendChild(separator);
|
1234
|
+
self.timeContainer.appendChild(minuteInput);
|
1235
|
+
if (self.config.time_24hr)
|
1236
|
+
self.timeContainer.classList.add("time24hr");
|
1237
|
+
if (self.config.enableSeconds) {
|
1238
|
+
self.timeContainer.classList.add("hasSeconds");
|
1239
|
+
var secondInput = createNumberInput("flatpickr-second");
|
1240
|
+
self.secondElement = secondInput.getElementsByTagName("input")[0];
|
1241
|
+
self.secondElement.value = pad(self.latestSelectedDateObj
|
1242
|
+
? self.latestSelectedDateObj.getSeconds()
|
1243
|
+
: self.config.defaultSeconds);
|
1244
|
+
self.secondElement.setAttribute("step", self.minuteElement.getAttribute("step"));
|
1245
|
+
self.secondElement.setAttribute("min", "0");
|
1246
|
+
self.secondElement.setAttribute("max", "59");
|
1247
|
+
self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
|
1248
|
+
self.timeContainer.appendChild(secondInput);
|
1249
|
+
}
|
1250
|
+
if (!self.config.time_24hr) {
|
1251
|
+
// add self.amPM if appropriate
|
1252
|
+
self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj
|
1253
|
+
? self.hourElement.value
|
1254
|
+
: self.config.defaultHour) > 11)]);
|
1255
|
+
self.amPM.title = self.l10n.toggleTitle;
|
1256
|
+
self.amPM.tabIndex = -1;
|
1257
|
+
self.timeContainer.appendChild(self.amPM);
|
1258
|
+
}
|
1259
|
+
return self.timeContainer;
|
1260
|
+
}
|
1261
|
+
function buildWeekdays() {
|
1262
|
+
if (!self.weekdayContainer)
|
1263
|
+
self.weekdayContainer = createElement("div", "flatpickr-weekdays");
|
1264
|
+
else
|
1265
|
+
clearNode(self.weekdayContainer);
|
1266
|
+
for (var i = self.config.showMonths; i--;) {
|
1267
|
+
var container = createElement("div", "flatpickr-weekdaycontainer");
|
1268
|
+
self.weekdayContainer.appendChild(container);
|
1269
|
+
}
|
1270
|
+
updateWeekdays();
|
1271
|
+
return self.weekdayContainer;
|
1272
|
+
}
|
1273
|
+
function updateWeekdays() {
|
1274
|
+
var firstDayOfWeek = self.l10n.firstDayOfWeek;
|
1275
|
+
var weekdays = self.l10n.weekdays.shorthand.slice();
|
1276
|
+
if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
|
1277
|
+
weekdays = weekdays.splice(firstDayOfWeek, weekdays.length).concat(weekdays.splice(0, firstDayOfWeek));
|
1278
|
+
}
|
1279
|
+
for (var i = self.config.showMonths; i--;) {
|
1280
|
+
self.weekdayContainer.children[i].innerHTML = "\n <span class='flatpickr-weekday'>\n " + weekdays.join("</span><span class='flatpickr-weekday'>") + "\n </span>\n ";
|
1281
|
+
}
|
702
1282
|
}
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
1283
|
+
/* istanbul ignore next */
|
1284
|
+
function buildWeeks() {
|
1285
|
+
self.calendarContainer.classList.add("hasWeeks");
|
1286
|
+
var weekWrapper = createElement("div", "flatpickr-weekwrapper");
|
1287
|
+
weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
|
1288
|
+
var weekNumbers = createElement("div", "flatpickr-weeks");
|
1289
|
+
weekWrapper.appendChild(weekNumbers);
|
1290
|
+
return {
|
1291
|
+
weekWrapper: weekWrapper,
|
1292
|
+
weekNumbers: weekNumbers
|
1293
|
+
};
|
1294
|
+
}
|
1295
|
+
function changeMonth(value, is_offset) {
|
1296
|
+
if (is_offset === void 0) { is_offset = true; }
|
1297
|
+
var delta = is_offset ? value : value - self.currentMonth;
|
1298
|
+
if ((delta < 0 && self._hidePrevMonthArrow === true) ||
|
1299
|
+
(delta > 0 && self._hideNextMonthArrow === true))
|
1300
|
+
return;
|
1301
|
+
self.currentMonth += delta;
|
1302
|
+
if (self.currentMonth < 0 || self.currentMonth > 11) {
|
1303
|
+
self.currentYear += self.currentMonth > 11 ? 1 : -1;
|
1304
|
+
self.currentMonth = (self.currentMonth + 12) % 12;
|
1305
|
+
triggerEvent("onYearChange");
|
1306
|
+
}
|
1307
|
+
buildDays();
|
1308
|
+
triggerEvent("onMonthChange");
|
1309
|
+
updateNavigationCurrentMonth();
|
1310
|
+
}
|
1311
|
+
function clear(triggerChangeEvent, toInitial) {
|
1312
|
+
if (triggerChangeEvent === void 0) { triggerChangeEvent = true; }
|
1313
|
+
if (toInitial === void 0) { toInitial = true; }
|
1314
|
+
self.input.value = "";
|
1315
|
+
if (self.altInput !== undefined)
|
1316
|
+
self.altInput.value = "";
|
1317
|
+
if (self.mobileInput !== undefined)
|
1318
|
+
self.mobileInput.value = "";
|
1319
|
+
self.selectedDates = [];
|
1320
|
+
self.latestSelectedDateObj = undefined;
|
1321
|
+
if (toInitial === true) {
|
1322
|
+
self.currentYear = self._initialDate.getFullYear();
|
1323
|
+
self.currentMonth = self._initialDate.getMonth();
|
1324
|
+
}
|
1325
|
+
self.showTimeInput = false;
|
1326
|
+
if (self.config.enableTime === true) {
|
1327
|
+
setDefaultHours();
|
1328
|
+
}
|
1329
|
+
self.redraw();
|
1330
|
+
if (triggerChangeEvent)
|
1331
|
+
// triggerChangeEvent is true (default) or an Event
|
1332
|
+
triggerEvent("onChange");
|
1333
|
+
}
|
1334
|
+
function close() {
|
1335
|
+
self.isOpen = false;
|
1336
|
+
if (!self.isMobile) {
|
1337
|
+
if (self.calendarContainer !== undefined) {
|
1338
|
+
self.calendarContainer.classList.remove("open");
|
1339
|
+
}
|
1340
|
+
if (self._input !== undefined) {
|
1341
|
+
self._input.classList.remove("active");
|
1342
|
+
}
|
1343
|
+
}
|
1344
|
+
triggerEvent("onClose");
|
1345
|
+
}
|
1346
|
+
function destroy() {
|
1347
|
+
if (self.config !== undefined)
|
1348
|
+
triggerEvent("onDestroy");
|
1349
|
+
for (var i = self._handlers.length; i--;) {
|
1350
|
+
var h = self._handlers[i];
|
1351
|
+
h.element.removeEventListener(h.event, h.handler, h.options);
|
1352
|
+
}
|
1353
|
+
self._handlers = [];
|
1354
|
+
if (self.mobileInput) {
|
1355
|
+
if (self.mobileInput.parentNode)
|
1356
|
+
self.mobileInput.parentNode.removeChild(self.mobileInput);
|
1357
|
+
self.mobileInput = undefined;
|
1358
|
+
}
|
1359
|
+
else if (self.calendarContainer && self.calendarContainer.parentNode) {
|
1360
|
+
if (self.config.static && self.calendarContainer.parentNode) {
|
1361
|
+
var wrapper = self.calendarContainer.parentNode;
|
1362
|
+
wrapper.lastChild && wrapper.removeChild(wrapper.lastChild);
|
1363
|
+
if (wrapper.parentNode) {
|
1364
|
+
while (wrapper.firstChild)
|
1365
|
+
wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper);
|
1366
|
+
wrapper.parentNode.removeChild(wrapper);
|
1367
|
+
}
|
1368
|
+
}
|
1369
|
+
else
|
1370
|
+
self.calendarContainer.parentNode.removeChild(self.calendarContainer);
|
1371
|
+
}
|
1372
|
+
if (self.altInput) {
|
1373
|
+
self.input.type = "text";
|
1374
|
+
if (self.altInput.parentNode)
|
1375
|
+
self.altInput.parentNode.removeChild(self.altInput);
|
1376
|
+
delete self.altInput;
|
1377
|
+
}
|
1378
|
+
if (self.input) {
|
1379
|
+
self.input.type = self.input._type;
|
1380
|
+
self.input.classList.remove("flatpickr-input");
|
1381
|
+
self.input.removeAttribute("readonly");
|
1382
|
+
self.input.value = "";
|
1383
|
+
}
|
1384
|
+
[
|
1385
|
+
"_showTimeInput",
|
1386
|
+
"latestSelectedDateObj",
|
1387
|
+
"_hideNextMonthArrow",
|
1388
|
+
"_hidePrevMonthArrow",
|
1389
|
+
"__hideNextMonthArrow",
|
1390
|
+
"__hidePrevMonthArrow",
|
1391
|
+
"isMobile",
|
1392
|
+
"isOpen",
|
1393
|
+
"selectedDateElem",
|
1394
|
+
"minDateHasTime",
|
1395
|
+
"maxDateHasTime",
|
1396
|
+
"days",
|
1397
|
+
"daysContainer",
|
1398
|
+
"_input",
|
1399
|
+
"_positionElement",
|
1400
|
+
"innerContainer",
|
1401
|
+
"rContainer",
|
1402
|
+
"monthNav",
|
1403
|
+
"todayDateElem",
|
1404
|
+
"calendarContainer",
|
1405
|
+
"weekdayContainer",
|
1406
|
+
"prevMonthNav",
|
1407
|
+
"nextMonthNav",
|
1408
|
+
"currentMonthElement",
|
1409
|
+
"currentYearElement",
|
1410
|
+
"navigationCurrentMonth",
|
1411
|
+
"selectedDateElem",
|
1412
|
+
"config",
|
1413
|
+
].forEach(function (k) {
|
1414
|
+
try {
|
1415
|
+
delete self[k];
|
1416
|
+
}
|
1417
|
+
catch (_) { }
|
1418
|
+
});
|
707
1419
|
}
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
1420
|
+
function isCalendarElem(elem) {
|
1421
|
+
if (self.config.appendTo && self.config.appendTo.contains(elem))
|
1422
|
+
return true;
|
1423
|
+
return self.calendarContainer.contains(elem);
|
1424
|
+
}
|
1425
|
+
function documentClick(e) {
|
1426
|
+
if (self.isOpen && !self.config.inline) {
|
1427
|
+
var eventTarget_1 = getEventTarget(e);
|
1428
|
+
var isCalendarElement = isCalendarElem(eventTarget_1);
|
1429
|
+
var isInput = eventTarget_1 === self.input ||
|
1430
|
+
eventTarget_1 === self.altInput ||
|
1431
|
+
self.element.contains(eventTarget_1) ||
|
1432
|
+
// web components
|
1433
|
+
// e.path is not present in all browsers. circumventing typechecks
|
1434
|
+
(e.path &&
|
1435
|
+
e.path.indexOf &&
|
1436
|
+
(~e.path.indexOf(self.input) ||
|
1437
|
+
~e.path.indexOf(self.altInput)));
|
1438
|
+
var lostFocus = e.type === "blur"
|
1439
|
+
? isInput &&
|
1440
|
+
e.relatedTarget &&
|
1441
|
+
!isCalendarElem(e.relatedTarget)
|
1442
|
+
: !isInput &&
|
1443
|
+
!isCalendarElement &&
|
1444
|
+
!isCalendarElem(e.relatedTarget);
|
1445
|
+
var isIgnored = !self.config.ignoredFocusElements.some(function (elem) {
|
1446
|
+
return elem.contains(eventTarget_1);
|
1447
|
+
});
|
1448
|
+
if (lostFocus && isIgnored) {
|
1449
|
+
self.close();
|
1450
|
+
if (self.config.mode === "range" && self.selectedDates.length === 1) {
|
1451
|
+
self.clear(false);
|
1452
|
+
self.redraw();
|
1453
|
+
}
|
1454
|
+
}
|
1455
|
+
}
|
725
1456
|
}
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
1457
|
+
function changeYear(newYear) {
|
1458
|
+
if (!newYear ||
|
1459
|
+
(self.config.minDate && newYear < self.config.minDate.getFullYear()) ||
|
1460
|
+
(self.config.maxDate && newYear > self.config.maxDate.getFullYear()))
|
1461
|
+
return;
|
1462
|
+
var newYearNum = newYear, isNewYear = self.currentYear !== newYearNum;
|
1463
|
+
self.currentYear = newYearNum || self.currentYear;
|
1464
|
+
if (self.config.maxDate &&
|
1465
|
+
self.currentYear === self.config.maxDate.getFullYear()) {
|
1466
|
+
self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
|
1467
|
+
}
|
1468
|
+
else if (self.config.minDate &&
|
1469
|
+
self.currentYear === self.config.minDate.getFullYear()) {
|
1470
|
+
self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
|
1471
|
+
}
|
1472
|
+
if (isNewYear) {
|
1473
|
+
self.redraw();
|
1474
|
+
triggerEvent("onYearChange");
|
1475
|
+
}
|
731
1476
|
}
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
1477
|
+
function isEnabled(date, timeless) {
|
1478
|
+
if (timeless === void 0) { timeless = true; }
|
1479
|
+
var dateToCheck = self.parseDate(date, undefined, timeless); // timeless
|
1480
|
+
if ((self.config.minDate &&
|
1481
|
+
dateToCheck &&
|
1482
|
+
compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0) ||
|
1483
|
+
(self.config.maxDate &&
|
1484
|
+
dateToCheck &&
|
1485
|
+
compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0))
|
1486
|
+
return false;
|
1487
|
+
if (self.config.enable.length === 0 && self.config.disable.length === 0)
|
1488
|
+
return true;
|
1489
|
+
if (dateToCheck === undefined)
|
1490
|
+
return false;
|
1491
|
+
var bool = self.config.enable.length > 0, array = bool ? self.config.enable : self.config.disable;
|
1492
|
+
for (var i = 0, d = void 0; i < array.length; i++) {
|
1493
|
+
d = array[i];
|
1494
|
+
if (typeof d === "function" &&
|
1495
|
+
d(dateToCheck) // disabled by function
|
1496
|
+
)
|
1497
|
+
return bool;
|
1498
|
+
else if (d instanceof Date &&
|
1499
|
+
dateToCheck !== undefined &&
|
1500
|
+
d.getTime() === dateToCheck.getTime())
|
1501
|
+
// disabled by date
|
1502
|
+
return bool;
|
1503
|
+
else if (typeof d === "string" && dateToCheck !== undefined) {
|
1504
|
+
// disabled by date string
|
1505
|
+
var parsed = self.parseDate(d, undefined, true);
|
1506
|
+
return parsed && parsed.getTime() === dateToCheck.getTime()
|
1507
|
+
? bool
|
1508
|
+
: !bool;
|
1509
|
+
}
|
1510
|
+
else if (
|
1511
|
+
// disabled by range
|
1512
|
+
typeof d === "object" &&
|
1513
|
+
dateToCheck !== undefined &&
|
1514
|
+
d.from &&
|
1515
|
+
d.to &&
|
1516
|
+
dateToCheck.getTime() >= d.from.getTime() &&
|
1517
|
+
dateToCheck.getTime() <= d.to.getTime())
|
1518
|
+
return bool;
|
1519
|
+
}
|
1520
|
+
return !bool;
|
1521
|
+
}
|
1522
|
+
function isInView(elem) {
|
1523
|
+
if (self.daysContainer !== undefined)
|
1524
|
+
return (elem.className.indexOf("hidden") === -1 &&
|
1525
|
+
self.daysContainer.contains(elem));
|
1526
|
+
return false;
|
1527
|
+
}
|
1528
|
+
function onKeyDown(e) {
|
1529
|
+
// e.key e.keyCode
|
1530
|
+
// "Backspace" 8
|
1531
|
+
// "Tab" 9
|
1532
|
+
// "Enter" 13
|
1533
|
+
// "Escape" (IE "Esc") 27
|
1534
|
+
// "ArrowLeft" (IE "Left") 37
|
1535
|
+
// "ArrowUp" (IE "Up") 38
|
1536
|
+
// "ArrowRight" (IE "Right") 39
|
1537
|
+
// "ArrowDown" (IE "Down") 40
|
1538
|
+
// "Delete" (IE "Del") 46
|
1539
|
+
var isInput = e.target === self._input;
|
1540
|
+
var allowInput = self.config.allowInput;
|
1541
|
+
var allowKeydown = self.isOpen && (!allowInput || !isInput);
|
1542
|
+
var allowInlineKeydown = self.config.inline && isInput && !allowInput;
|
1543
|
+
if (e.keyCode === 13 && isInput) {
|
1544
|
+
if (allowInput) {
|
1545
|
+
self.setDate(self._input.value, true, e.target === self.altInput
|
1546
|
+
? self.config.altFormat
|
1547
|
+
: self.config.dateFormat);
|
1548
|
+
return e.target.blur();
|
1549
|
+
}
|
1550
|
+
else
|
1551
|
+
self.open();
|
1552
|
+
}
|
1553
|
+
else if (isCalendarElem(e.target) ||
|
1554
|
+
allowKeydown ||
|
1555
|
+
allowInlineKeydown) {
|
1556
|
+
var isTimeObj = !!self.timeContainer &&
|
1557
|
+
self.timeContainer.contains(e.target);
|
1558
|
+
switch (e.keyCode) {
|
1559
|
+
case 13:
|
1560
|
+
if (isTimeObj) {
|
1561
|
+
updateTime();
|
1562
|
+
focusAndClose();
|
1563
|
+
}
|
1564
|
+
else
|
1565
|
+
selectDate(e);
|
1566
|
+
break;
|
1567
|
+
case 27: // escape
|
1568
|
+
e.preventDefault();
|
1569
|
+
focusAndClose();
|
1570
|
+
break;
|
1571
|
+
case 8:
|
1572
|
+
case 46:
|
1573
|
+
if (isInput && !self.config.allowInput) {
|
1574
|
+
e.preventDefault();
|
1575
|
+
self.clear();
|
1576
|
+
}
|
1577
|
+
break;
|
1578
|
+
case 37:
|
1579
|
+
case 39:
|
1580
|
+
if (!isTimeObj) {
|
1581
|
+
e.preventDefault();
|
1582
|
+
if (self.daysContainer !== undefined &&
|
1583
|
+
(allowInput === false ||
|
1584
|
+
(document.activeElement && isInView(document.activeElement)))) {
|
1585
|
+
var delta_1 = e.keyCode === 39 ? 1 : -1;
|
1586
|
+
if (!e.ctrlKey)
|
1587
|
+
focusOnDay(undefined, delta_1);
|
1588
|
+
else {
|
1589
|
+
e.stopPropagation();
|
1590
|
+
changeMonth(delta_1);
|
1591
|
+
focusOnDay(getFirstAvailableDay(1), 0);
|
1592
|
+
}
|
1593
|
+
}
|
1594
|
+
}
|
1595
|
+
else if (self.hourElement)
|
1596
|
+
self.hourElement.focus();
|
1597
|
+
break;
|
1598
|
+
case 38:
|
1599
|
+
case 40:
|
1600
|
+
e.preventDefault();
|
1601
|
+
var delta = e.keyCode === 40 ? 1 : -1;
|
1602
|
+
if ((self.daysContainer && e.target.$i !== undefined) ||
|
1603
|
+
e.target === self.input) {
|
1604
|
+
if (e.ctrlKey) {
|
1605
|
+
e.stopPropagation();
|
1606
|
+
changeYear(self.currentYear - delta);
|
1607
|
+
focusOnDay(getFirstAvailableDay(1), 0);
|
1608
|
+
}
|
1609
|
+
else if (!isTimeObj)
|
1610
|
+
focusOnDay(undefined, delta * 7);
|
1611
|
+
}
|
1612
|
+
else if (self.config.enableTime) {
|
1613
|
+
if (!isTimeObj && self.hourElement)
|
1614
|
+
self.hourElement.focus();
|
1615
|
+
updateTime(e);
|
1616
|
+
self._debouncedChange();
|
1617
|
+
}
|
1618
|
+
break;
|
1619
|
+
case 9:
|
1620
|
+
if (isTimeObj) {
|
1621
|
+
var elems = [
|
1622
|
+
self.hourElement,
|
1623
|
+
self.minuteElement,
|
1624
|
+
self.secondElement,
|
1625
|
+
self.amPM,
|
1626
|
+
].filter(function (x) { return x; });
|
1627
|
+
var i = elems.indexOf(e.target);
|
1628
|
+
if (i !== -1) {
|
1629
|
+
var target = elems[i + (e.shiftKey ? -1 : 1)];
|
1630
|
+
if (target !== undefined) {
|
1631
|
+
e.preventDefault();
|
1632
|
+
target.focus();
|
1633
|
+
}
|
1634
|
+
else if (e.shiftKey) {
|
1635
|
+
e.preventDefault();
|
1636
|
+
self._input.focus();
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
}
|
1640
|
+
break;
|
1641
|
+
default:
|
1642
|
+
break;
|
1643
|
+
}
|
1644
|
+
}
|
1645
|
+
if (self.amPM !== undefined && e.target === self.amPM) {
|
1646
|
+
switch (e.key) {
|
1647
|
+
case self.l10n.amPM[0].charAt(0):
|
1648
|
+
case self.l10n.amPM[0].charAt(0).toLowerCase():
|
1649
|
+
self.amPM.textContent = self.l10n.amPM[0];
|
1650
|
+
setHoursFromInputs();
|
1651
|
+
updateValue();
|
1652
|
+
break;
|
1653
|
+
case self.l10n.amPM[1].charAt(0):
|
1654
|
+
case self.l10n.amPM[1].charAt(0).toLowerCase():
|
1655
|
+
self.amPM.textContent = self.l10n.amPM[1];
|
1656
|
+
setHoursFromInputs();
|
1657
|
+
updateValue();
|
1658
|
+
break;
|
1659
|
+
}
|
1660
|
+
}
|
1661
|
+
triggerEvent("onKeyDown", e);
|
1662
|
+
}
|
1663
|
+
function onMouseOver(elem) {
|
1664
|
+
if (self.selectedDates.length !== 1 ||
|
1665
|
+
(elem &&
|
1666
|
+
(!elem.classList.contains("flatpickr-day") ||
|
1667
|
+
elem.classList.contains("disabled"))))
|
1668
|
+
return;
|
1669
|
+
var hoverDate = elem
|
1670
|
+
? elem.dateObj.getTime()
|
1671
|
+
: self.days.firstElementChild.dateObj.getTime(), initialDate = self.parseDate(self.selectedDates[0], undefined, true).getTime(), rangeStartDate = Math.min(hoverDate, self.selectedDates[0].getTime()), rangeEndDate = Math.max(hoverDate, self.selectedDates[0].getTime()), lastDate = self.daysContainer.lastChild
|
1672
|
+
.lastChild.dateObj.getTime();
|
1673
|
+
var containsDisabled = false;
|
1674
|
+
var minRange = 0, maxRange = 0;
|
1675
|
+
for (var t = rangeStartDate; t < lastDate; t += duration.DAY) {
|
1676
|
+
if (!isEnabled(new Date(t), true)) {
|
1677
|
+
containsDisabled =
|
1678
|
+
containsDisabled || (t > rangeStartDate && t < rangeEndDate);
|
1679
|
+
if (t < initialDate && (!minRange || t > minRange))
|
1680
|
+
minRange = t;
|
1681
|
+
else if (t > initialDate && (!maxRange || t < maxRange))
|
1682
|
+
maxRange = t;
|
1683
|
+
}
|
1684
|
+
}
|
1685
|
+
for (var m = 0; m < self.config.showMonths; m++) {
|
1686
|
+
var month = self.daysContainer.children[m];
|
1687
|
+
var prevMonth = self.daysContainer.children[m - 1];
|
1688
|
+
var _loop_1 = function (i, l) {
|
1689
|
+
var dayElem = month.children[i], date = dayElem.dateObj;
|
1690
|
+
var timestamp = date.getTime();
|
1691
|
+
var outOfRange = (minRange > 0 && timestamp < minRange) ||
|
1692
|
+
(maxRange > 0 && timestamp > maxRange);
|
1693
|
+
if (outOfRange) {
|
1694
|
+
dayElem.classList.add("notAllowed");
|
1695
|
+
["inRange", "startRange", "endRange"].forEach(function (c) {
|
1696
|
+
dayElem.classList.remove(c);
|
1697
|
+
});
|
1698
|
+
return "continue";
|
1699
|
+
}
|
1700
|
+
else if (containsDisabled && !outOfRange)
|
1701
|
+
return "continue";
|
1702
|
+
["startRange", "inRange", "endRange", "notAllowed"].forEach(function (c) {
|
1703
|
+
dayElem.classList.remove(c);
|
1704
|
+
});
|
1705
|
+
if (elem !== undefined) {
|
1706
|
+
elem.classList.add(hoverDate < self.selectedDates[0].getTime()
|
1707
|
+
? "startRange"
|
1708
|
+
: "endRange");
|
1709
|
+
if (month.contains(elem) ||
|
1710
|
+
!(m > 0 &&
|
1711
|
+
prevMonth &&
|
1712
|
+
prevMonth.lastChild.dateObj.getTime() >= timestamp)) {
|
1713
|
+
if (initialDate < hoverDate && timestamp === initialDate)
|
1714
|
+
dayElem.classList.add("startRange");
|
1715
|
+
else if (initialDate > hoverDate && timestamp === initialDate)
|
1716
|
+
dayElem.classList.add("endRange");
|
1717
|
+
if (timestamp >= minRange &&
|
1718
|
+
(maxRange === 0 || timestamp <= maxRange) &&
|
1719
|
+
isBetween(timestamp, initialDate, hoverDate))
|
1720
|
+
dayElem.classList.add("inRange");
|
1721
|
+
}
|
1722
|
+
}
|
1723
|
+
};
|
1724
|
+
for (var i = 0, l = month.children.length; i < l; i++) {
|
1725
|
+
_loop_1(i, l);
|
1726
|
+
}
|
1727
|
+
}
|
768
1728
|
}
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
function timeIncrement(e) {
|
774
|
-
if (~e.target.className.indexOf("arrow")) incrementNumInput(e, e.target.classList.contains("arrowUp") ? 1 : -1);
|
775
|
-
}
|
776
|
-
|
777
|
-
function incrementNumInput(e, delta, inputElem) {
|
778
|
-
var target = e && e.target;
|
779
|
-
var input = inputElem || target && target.parentNode && target.parentNode.firstChild;
|
780
|
-
var event = createEvent("increment");
|
781
|
-
event.delta = delta;
|
782
|
-
input && input.dispatchEvent(event);
|
783
|
-
}
|
784
|
-
|
785
|
-
function build() {
|
786
|
-
var fragment = window.document.createDocumentFragment();
|
787
|
-
self.calendarContainer = createElement("div", "flatpickr-calendar");
|
788
|
-
self.calendarContainer.tabIndex = -1;
|
789
|
-
|
790
|
-
if (!self.config.noCalendar) {
|
791
|
-
fragment.appendChild(buildMonthNav());
|
792
|
-
self.innerContainer = createElement("div", "flatpickr-innerContainer");
|
793
|
-
|
794
|
-
if (self.config.weekNumbers) {
|
795
|
-
var _buildWeeks = buildWeeks(),
|
796
|
-
weekWrapper = _buildWeeks.weekWrapper,
|
797
|
-
weekNumbers = _buildWeeks.weekNumbers;
|
798
|
-
|
799
|
-
self.innerContainer.appendChild(weekWrapper);
|
800
|
-
self.weekNumbers = weekNumbers;
|
801
|
-
self.weekWrapper = weekWrapper;
|
802
|
-
}
|
803
|
-
|
804
|
-
self.rContainer = createElement("div", "flatpickr-rContainer");
|
805
|
-
self.rContainer.appendChild(buildWeekdays());
|
806
|
-
|
807
|
-
if (!self.daysContainer) {
|
808
|
-
self.daysContainer = createElement("div", "flatpickr-days");
|
809
|
-
self.daysContainer.tabIndex = -1;
|
810
|
-
}
|
811
|
-
|
812
|
-
buildDays();
|
813
|
-
self.rContainer.appendChild(self.daysContainer);
|
814
|
-
self.innerContainer.appendChild(self.rContainer);
|
815
|
-
fragment.appendChild(self.innerContainer);
|
1729
|
+
function onResize() {
|
1730
|
+
if (self.isOpen && !self.config.static && !self.config.inline)
|
1731
|
+
positionCalendar();
|
816
1732
|
}
|
817
|
-
|
818
|
-
|
819
|
-
|
1733
|
+
function setDefaultTime() {
|
1734
|
+
self.setDate(self.config.minDate !== undefined
|
1735
|
+
? new Date(self.config.minDate.getTime())
|
1736
|
+
: new Date(), false);
|
1737
|
+
setDefaultHours();
|
1738
|
+
updateValue();
|
820
1739
|
}
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
if (
|
840
|
-
|
841
|
-
|
1740
|
+
function open(e, positionElement) {
|
1741
|
+
if (positionElement === void 0) { positionElement = self._positionElement; }
|
1742
|
+
if (self.isMobile === true) {
|
1743
|
+
if (e) {
|
1744
|
+
e.preventDefault();
|
1745
|
+
e.target && e.target.blur();
|
1746
|
+
}
|
1747
|
+
if (self.mobileInput !== undefined) {
|
1748
|
+
self.mobileInput.focus();
|
1749
|
+
self.mobileInput.click();
|
1750
|
+
}
|
1751
|
+
triggerEvent("onOpen");
|
1752
|
+
return;
|
1753
|
+
}
|
1754
|
+
if (self._input.disabled || self.config.inline)
|
1755
|
+
return;
|
1756
|
+
var wasOpen = self.isOpen;
|
1757
|
+
self.isOpen = true;
|
1758
|
+
if (!wasOpen) {
|
1759
|
+
self.calendarContainer.classList.add("open");
|
1760
|
+
self._input.classList.add("active");
|
1761
|
+
triggerEvent("onOpen");
|
1762
|
+
positionCalendar(positionElement);
|
1763
|
+
}
|
1764
|
+
if (self.config.enableTime === true && self.config.noCalendar === true) {
|
1765
|
+
if (self.selectedDates.length === 0) {
|
1766
|
+
setDefaultTime();
|
1767
|
+
}
|
1768
|
+
if (self.config.allowInput === false &&
|
1769
|
+
(e === undefined ||
|
1770
|
+
!self.timeContainer.contains(e.relatedTarget))) {
|
1771
|
+
setTimeout(function () { return self.hourElement.select(); }, 50);
|
1772
|
+
}
|
1773
|
+
}
|
842
1774
|
}
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
1775
|
+
function minMaxDateSetter(type) {
|
1776
|
+
return function (date) {
|
1777
|
+
var dateObj = (self.config["_" + type + "Date"] = self.parseDate(date, self.config.dateFormat));
|
1778
|
+
var inverseDateObj = self.config["_" + (type === "min" ? "max" : "min") + "Date"];
|
1779
|
+
if (dateObj !== undefined) {
|
1780
|
+
self[type === "min" ? "minDateHasTime" : "maxDateHasTime"] =
|
1781
|
+
dateObj.getHours() > 0 ||
|
1782
|
+
dateObj.getMinutes() > 0 ||
|
1783
|
+
dateObj.getSeconds() > 0;
|
1784
|
+
}
|
1785
|
+
if (self.selectedDates) {
|
1786
|
+
self.selectedDates = self.selectedDates.filter(function (d) { return isEnabled(d); });
|
1787
|
+
if (!self.selectedDates.length && type === "min")
|
1788
|
+
setHoursFromDate(dateObj);
|
1789
|
+
updateValue();
|
1790
|
+
}
|
1791
|
+
if (self.daysContainer) {
|
1792
|
+
redraw();
|
1793
|
+
if (dateObj !== undefined)
|
1794
|
+
self.currentYearElement[type] = dateObj.getFullYear().toString();
|
1795
|
+
else
|
1796
|
+
self.currentYearElement.removeAttribute(type);
|
1797
|
+
self.currentYearElement.disabled =
|
1798
|
+
!!inverseDateObj &&
|
1799
|
+
dateObj !== undefined &&
|
1800
|
+
inverseDateObj.getFullYear() === dateObj.getFullYear();
|
1801
|
+
}
|
1802
|
+
};
|
1803
|
+
}
|
1804
|
+
function parseConfig() {
|
1805
|
+
var boolOpts = [
|
1806
|
+
"wrap",
|
1807
|
+
"weekNumbers",
|
1808
|
+
"allowInput",
|
1809
|
+
"clickOpens",
|
1810
|
+
"time_24hr",
|
1811
|
+
"enableTime",
|
1812
|
+
"noCalendar",
|
1813
|
+
"altInput",
|
1814
|
+
"shorthandCurrentMonth",
|
1815
|
+
"inline",
|
1816
|
+
"static",
|
1817
|
+
"enableSeconds",
|
1818
|
+
"disableMobile",
|
1819
|
+
];
|
1820
|
+
var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
|
1821
|
+
var formats$$1 = {};
|
1822
|
+
self.config.parseDate = userConfig.parseDate;
|
1823
|
+
self.config.formatDate = userConfig.formatDate;
|
1824
|
+
Object.defineProperty(self.config, "enable", {
|
1825
|
+
get: function () { return self.config._enable; },
|
1826
|
+
set: function (dates) {
|
1827
|
+
self.config._enable = parseDateRules(dates);
|
1828
|
+
}
|
1829
|
+
});
|
1830
|
+
Object.defineProperty(self.config, "disable", {
|
1831
|
+
get: function () { return self.config._disable; },
|
1832
|
+
set: function (dates) {
|
1833
|
+
self.config._disable = parseDateRules(dates);
|
1834
|
+
}
|
1835
|
+
});
|
1836
|
+
var timeMode = userConfig.mode === "time";
|
1837
|
+
if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
|
1838
|
+
formats$$1.dateFormat =
|
1839
|
+
userConfig.noCalendar || timeMode
|
1840
|
+
? "H:i" + (userConfig.enableSeconds ? ":S" : "")
|
1841
|
+
: flatpickr.defaultConfig.dateFormat +
|
1842
|
+
" H:i" +
|
1843
|
+
(userConfig.enableSeconds ? ":S" : "");
|
871
1844
|
}
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
if (self.weekNumbers && self.config.showMonths === 1 && className !== "prevMonthDay" && dayNumber % 7 === 1) {
|
882
|
-
self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
|
883
|
-
}
|
884
|
-
|
885
|
-
triggerEvent("onDayCreate", dayElement);
|
886
|
-
return dayElement;
|
887
|
-
}
|
888
|
-
|
889
|
-
function focusOnDayElem(targetNode) {
|
890
|
-
targetNode.focus();
|
891
|
-
if (self.config.mode === "range") onMouseOver(targetNode);
|
892
|
-
}
|
893
|
-
|
894
|
-
function getFirstAvailableDay(delta) {
|
895
|
-
var startMonth = delta > 0 ? 0 : self.config.showMonths - 1;
|
896
|
-
var endMonth = delta > 0 ? self.config.showMonths : -1;
|
897
|
-
|
898
|
-
for (var m = startMonth; m != endMonth; m += delta) {
|
899
|
-
var month = self.daysContainer.children[m];
|
900
|
-
var startIndex = delta > 0 ? 0 : month.children.length - 1;
|
901
|
-
var endIndex = delta > 0 ? month.children.length : -1;
|
902
|
-
|
903
|
-
for (var i = startIndex; i != endIndex; i += delta) {
|
904
|
-
var c = month.children[i];
|
905
|
-
if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj)) return c;
|
906
|
-
}
|
907
|
-
}
|
908
|
-
|
909
|
-
return undefined;
|
910
|
-
}
|
911
|
-
|
912
|
-
function getNextAvailableDay(current, delta) {
|
913
|
-
var givenMonth = current.className.indexOf("Month") === -1 ? current.dateObj.getMonth() : self.currentMonth;
|
914
|
-
var endMonth = delta > 0 ? self.config.showMonths : -1;
|
915
|
-
var loopDelta = delta > 0 ? 1 : -1;
|
916
|
-
|
917
|
-
for (var m = givenMonth - self.currentMonth; m != endMonth; m += loopDelta) {
|
918
|
-
var month = self.daysContainer.children[m];
|
919
|
-
var startIndex = givenMonth - self.currentMonth === m ? current.$i + delta : delta < 0 ? month.children.length - 1 : 0;
|
920
|
-
var numMonthDays = month.children.length;
|
921
|
-
|
922
|
-
for (var i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta) {
|
923
|
-
var c = month.children[i];
|
924
|
-
if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj) && Math.abs(current.$i - i) >= Math.abs(delta)) return focusOnDayElem(c);
|
925
|
-
}
|
926
|
-
}
|
927
|
-
|
928
|
-
self.changeMonth(loopDelta);
|
929
|
-
focusOnDay(getFirstAvailableDay(loopDelta), 0);
|
930
|
-
return undefined;
|
931
|
-
}
|
932
|
-
|
933
|
-
function focusOnDay(current, offset) {
|
934
|
-
var dayFocused = isInView(document.activeElement || document.body);
|
935
|
-
var startElem = current !== undefined ? current : dayFocused ? document.activeElement : self.selectedDateElem !== undefined && isInView(self.selectedDateElem) ? self.selectedDateElem : self.todayDateElem !== undefined && isInView(self.todayDateElem) ? self.todayDateElem : getFirstAvailableDay(offset > 0 ? 1 : -1);
|
936
|
-
if (startElem === undefined) return self._input.focus();
|
937
|
-
if (!dayFocused) return focusOnDayElem(startElem);
|
938
|
-
getNextAvailableDay(startElem, offset);
|
939
|
-
}
|
940
|
-
|
941
|
-
function buildMonthDays(year, month) {
|
942
|
-
var firstOfMonth = (new Date(year, month, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7;
|
943
|
-
var prevMonthDays = self.utils.getDaysInMonth((month - 1 + 12) % 12);
|
944
|
-
var daysInMonth = self.utils.getDaysInMonth(month),
|
945
|
-
days = window.document.createDocumentFragment(),
|
946
|
-
isMultiMonth = self.config.showMonths > 1,
|
947
|
-
prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay",
|
948
|
-
nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
|
949
|
-
var dayNumber = prevMonthDays + 1 - firstOfMonth,
|
950
|
-
dayIndex = 0;
|
951
|
-
|
952
|
-
for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
|
953
|
-
days.appendChild(createDay(prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
|
954
|
-
}
|
955
|
-
|
956
|
-
for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
|
957
|
-
days.appendChild(createDay("", new Date(year, month, dayNumber), dayNumber, dayIndex));
|
958
|
-
}
|
959
|
-
|
960
|
-
for (var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth && (self.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++) {
|
961
|
-
days.appendChild(createDay(nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
|
962
|
-
}
|
963
|
-
|
964
|
-
var dayContainer = createElement("div", "dayContainer");
|
965
|
-
dayContainer.appendChild(days);
|
966
|
-
return dayContainer;
|
967
|
-
}
|
968
|
-
|
969
|
-
function buildDays() {
|
970
|
-
if (self.daysContainer === undefined) {
|
971
|
-
return;
|
972
|
-
}
|
973
|
-
|
974
|
-
clearNode(self.daysContainer);
|
975
|
-
if (self.weekNumbers) clearNode(self.weekNumbers);
|
976
|
-
var frag = document.createDocumentFragment();
|
977
|
-
|
978
|
-
for (var i = 0; i < self.config.showMonths; i++) {
|
979
|
-
var d = new Date(self.currentYear, self.currentMonth, 1);
|
980
|
-
d.setMonth(self.currentMonth + i);
|
981
|
-
frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
|
982
|
-
}
|
983
|
-
|
984
|
-
self.daysContainer.appendChild(frag);
|
985
|
-
self.days = self.daysContainer.firstChild;
|
986
|
-
|
987
|
-
if (self.config.mode === "range" && self.selectedDates.length === 1) {
|
988
|
-
onMouseOver();
|
989
|
-
}
|
990
|
-
}
|
991
|
-
|
992
|
-
function buildMonth() {
|
993
|
-
var container = createElement("div", "flatpickr-month");
|
994
|
-
var monthNavFragment = window.document.createDocumentFragment();
|
995
|
-
var monthElement = createElement("span", "cur-month");
|
996
|
-
var yearInput = createNumberInput("cur-year", {
|
997
|
-
tabindex: "-1"
|
998
|
-
});
|
999
|
-
var yearElement = yearInput.getElementsByTagName("input")[0];
|
1000
|
-
yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
|
1001
|
-
if (self.config.minDate) yearElement.setAttribute("data-min", self.config.minDate.getFullYear().toString());
|
1002
|
-
|
1003
|
-
if (self.config.maxDate) {
|
1004
|
-
yearElement.setAttribute("data-max", self.config.maxDate.getFullYear().toString());
|
1005
|
-
yearElement.disabled = !!self.config.minDate && self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
|
1006
|
-
}
|
1007
|
-
|
1008
|
-
var currentMonth = createElement("div", "flatpickr-current-month");
|
1009
|
-
currentMonth.appendChild(monthElement);
|
1010
|
-
currentMonth.appendChild(yearInput);
|
1011
|
-
monthNavFragment.appendChild(currentMonth);
|
1012
|
-
container.appendChild(monthNavFragment);
|
1013
|
-
return {
|
1014
|
-
container: container,
|
1015
|
-
yearElement: yearElement,
|
1016
|
-
monthElement: monthElement
|
1017
|
-
};
|
1018
|
-
}
|
1019
|
-
|
1020
|
-
function buildMonths() {
|
1021
|
-
clearNode(self.monthNav);
|
1022
|
-
self.monthNav.appendChild(self.prevMonthNav);
|
1023
|
-
|
1024
|
-
for (var m = self.config.showMonths; m--;) {
|
1025
|
-
var month = buildMonth();
|
1026
|
-
self.yearElements.push(month.yearElement);
|
1027
|
-
self.monthElements.push(month.monthElement);
|
1028
|
-
self.monthNav.appendChild(month.container);
|
1029
|
-
}
|
1030
|
-
|
1031
|
-
self.monthNav.appendChild(self.nextMonthNav);
|
1032
|
-
}
|
1033
|
-
|
1034
|
-
function buildMonthNav() {
|
1035
|
-
self.monthNav = createElement("div", "flatpickr-months");
|
1036
|
-
self.yearElements = [];
|
1037
|
-
self.monthElements = [];
|
1038
|
-
self.prevMonthNav = createElement("span", "flatpickr-prev-month");
|
1039
|
-
self.prevMonthNav.innerHTML = self.config.prevArrow;
|
1040
|
-
self.nextMonthNav = createElement("span", "flatpickr-next-month");
|
1041
|
-
self.nextMonthNav.innerHTML = self.config.nextArrow;
|
1042
|
-
buildMonths();
|
1043
|
-
Object.defineProperty(self, "_hidePrevMonthArrow", {
|
1044
|
-
get: function get() {
|
1045
|
-
return self.__hidePrevMonthArrow;
|
1046
|
-
},
|
1047
|
-
set: function set(bool) {
|
1048
|
-
if (self.__hidePrevMonthArrow !== bool) {
|
1049
|
-
toggleClass(self.prevMonthNav, "disabled", bool);
|
1050
|
-
self.__hidePrevMonthArrow = bool;
|
1051
|
-
}
|
1052
|
-
}
|
1053
|
-
});
|
1054
|
-
Object.defineProperty(self, "_hideNextMonthArrow", {
|
1055
|
-
get: function get() {
|
1056
|
-
return self.__hideNextMonthArrow;
|
1057
|
-
},
|
1058
|
-
set: function set(bool) {
|
1059
|
-
if (self.__hideNextMonthArrow !== bool) {
|
1060
|
-
toggleClass(self.nextMonthNav, "disabled", bool);
|
1061
|
-
self.__hideNextMonthArrow = bool;
|
1062
|
-
}
|
1063
|
-
}
|
1064
|
-
});
|
1065
|
-
self.currentYearElement = self.yearElements[0];
|
1066
|
-
updateNavigationCurrentMonth();
|
1067
|
-
return self.monthNav;
|
1068
|
-
}
|
1069
|
-
|
1070
|
-
function buildTime() {
|
1071
|
-
self.calendarContainer.classList.add("hasTime");
|
1072
|
-
if (self.config.noCalendar) self.calendarContainer.classList.add("noCalendar");
|
1073
|
-
self.timeContainer = createElement("div", "flatpickr-time");
|
1074
|
-
self.timeContainer.tabIndex = -1;
|
1075
|
-
var separator = createElement("span", "flatpickr-time-separator", ":");
|
1076
|
-
var hourInput = createNumberInput("flatpickr-hour");
|
1077
|
-
self.hourElement = hourInput.getElementsByTagName("input")[0];
|
1078
|
-
var minuteInput = createNumberInput("flatpickr-minute");
|
1079
|
-
self.minuteElement = minuteInput.getElementsByTagName("input")[0];
|
1080
|
-
self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
|
1081
|
-
self.hourElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getHours() : self.config.time_24hr ? self.config.defaultHour : military2ampm(self.config.defaultHour));
|
1082
|
-
self.minuteElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getMinutes() : self.config.defaultMinute);
|
1083
|
-
self.hourElement.setAttribute("data-step", self.config.hourIncrement.toString());
|
1084
|
-
self.minuteElement.setAttribute("data-step", self.config.minuteIncrement.toString());
|
1085
|
-
self.hourElement.setAttribute("data-min", self.config.time_24hr ? "0" : "1");
|
1086
|
-
self.hourElement.setAttribute("data-max", self.config.time_24hr ? "23" : "12");
|
1087
|
-
self.minuteElement.setAttribute("data-min", "0");
|
1088
|
-
self.minuteElement.setAttribute("data-max", "59");
|
1089
|
-
self.timeContainer.appendChild(hourInput);
|
1090
|
-
self.timeContainer.appendChild(separator);
|
1091
|
-
self.timeContainer.appendChild(minuteInput);
|
1092
|
-
if (self.config.time_24hr) self.timeContainer.classList.add("time24hr");
|
1093
|
-
|
1094
|
-
if (self.config.enableSeconds) {
|
1095
|
-
self.timeContainer.classList.add("hasSeconds");
|
1096
|
-
var secondInput = createNumberInput("flatpickr-second");
|
1097
|
-
self.secondElement = secondInput.getElementsByTagName("input")[0];
|
1098
|
-
self.secondElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getSeconds() : self.config.defaultSeconds);
|
1099
|
-
self.secondElement.setAttribute("data-step", self.minuteElement.getAttribute("data-step"));
|
1100
|
-
self.secondElement.setAttribute("data-min", self.minuteElement.getAttribute("data-min"));
|
1101
|
-
self.secondElement.setAttribute("data-max", self.minuteElement.getAttribute("data-max"));
|
1102
|
-
self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
|
1103
|
-
self.timeContainer.appendChild(secondInput);
|
1104
|
-
}
|
1105
|
-
|
1106
|
-
if (!self.config.time_24hr) {
|
1107
|
-
self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj ? self.hourElement.value : self.config.defaultHour) > 11)]);
|
1108
|
-
self.amPM.title = self.l10n.toggleTitle;
|
1109
|
-
self.amPM.tabIndex = -1;
|
1110
|
-
self.timeContainer.appendChild(self.amPM);
|
1111
|
-
}
|
1112
|
-
|
1113
|
-
return self.timeContainer;
|
1114
|
-
}
|
1115
|
-
|
1116
|
-
function buildWeekdays() {
|
1117
|
-
if (!self.weekdayContainer) self.weekdayContainer = createElement("div", "flatpickr-weekdays");else clearNode(self.weekdayContainer);
|
1118
|
-
|
1119
|
-
for (var i = self.config.showMonths; i--;) {
|
1120
|
-
var container = createElement("div", "flatpickr-weekdaycontainer");
|
1121
|
-
self.weekdayContainer.appendChild(container);
|
1122
|
-
}
|
1123
|
-
|
1124
|
-
updateWeekdays();
|
1125
|
-
return self.weekdayContainer;
|
1126
|
-
}
|
1127
|
-
|
1128
|
-
function updateWeekdays() {
|
1129
|
-
var firstDayOfWeek = self.l10n.firstDayOfWeek;
|
1130
|
-
var weekdays = self.l10n.weekdays.shorthand.concat();
|
1131
|
-
|
1132
|
-
if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
|
1133
|
-
weekdays = weekdays.splice(firstDayOfWeek, weekdays.length).concat(weekdays.splice(0, firstDayOfWeek));
|
1134
|
-
}
|
1135
|
-
|
1136
|
-
for (var i = self.config.showMonths; i--;) {
|
1137
|
-
self.weekdayContainer.children[i].innerHTML = "\n <span class=flatpickr-weekday>\n " + weekdays.join("</span><span class=flatpickr-weekday>") + "\n </span>\n ";
|
1138
|
-
}
|
1139
|
-
}
|
1140
|
-
|
1141
|
-
function buildWeeks() {
|
1142
|
-
self.calendarContainer.classList.add("hasWeeks");
|
1143
|
-
var weekWrapper = createElement("div", "flatpickr-weekwrapper");
|
1144
|
-
weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
|
1145
|
-
var weekNumbers = createElement("div", "flatpickr-weeks");
|
1146
|
-
weekWrapper.appendChild(weekNumbers);
|
1147
|
-
return {
|
1148
|
-
weekWrapper: weekWrapper,
|
1149
|
-
weekNumbers: weekNumbers
|
1150
|
-
};
|
1151
|
-
}
|
1152
|
-
|
1153
|
-
function changeMonth(value, is_offset) {
|
1154
|
-
if (is_offset === void 0) {
|
1155
|
-
is_offset = true;
|
1156
|
-
}
|
1157
|
-
|
1158
|
-
var delta = is_offset ? value : value - self.currentMonth;
|
1159
|
-
if (delta < 0 && self._hidePrevMonthArrow === true || delta > 0 && self._hideNextMonthArrow === true) return;
|
1160
|
-
self.currentMonth += delta;
|
1161
|
-
|
1162
|
-
if (self.currentMonth < 0 || self.currentMonth > 11) {
|
1163
|
-
self.currentYear += self.currentMonth > 11 ? 1 : -1;
|
1164
|
-
self.currentMonth = (self.currentMonth + 12) % 12;
|
1165
|
-
triggerEvent("onYearChange");
|
1166
|
-
}
|
1167
|
-
|
1168
|
-
buildDays();
|
1169
|
-
triggerEvent("onMonthChange");
|
1170
|
-
updateNavigationCurrentMonth();
|
1171
|
-
}
|
1172
|
-
|
1173
|
-
function clear(triggerChangeEvent) {
|
1174
|
-
if (triggerChangeEvent === void 0) {
|
1175
|
-
triggerChangeEvent = true;
|
1176
|
-
}
|
1177
|
-
|
1178
|
-
self.input.value = "";
|
1179
|
-
if (self.altInput !== undefined) self.altInput.value = "";
|
1180
|
-
if (self.mobileInput !== undefined) self.mobileInput.value = "";
|
1181
|
-
self.selectedDates = [];
|
1182
|
-
self.latestSelectedDateObj = undefined;
|
1183
|
-
self.showTimeInput = false;
|
1184
|
-
|
1185
|
-
if (self.config.enableTime === true) {
|
1186
|
-
setDefaultHours();
|
1187
|
-
}
|
1188
|
-
|
1189
|
-
self.redraw();
|
1190
|
-
if (triggerChangeEvent) triggerEvent("onChange");
|
1191
|
-
}
|
1192
|
-
|
1193
|
-
function close() {
|
1194
|
-
self.isOpen = false;
|
1195
|
-
|
1196
|
-
if (!self.isMobile) {
|
1197
|
-
self.calendarContainer.classList.remove("open");
|
1198
|
-
|
1199
|
-
self._input.classList.remove("active");
|
1200
|
-
}
|
1201
|
-
|
1202
|
-
triggerEvent("onClose");
|
1203
|
-
}
|
1204
|
-
|
1205
|
-
function destroy() {
|
1206
|
-
if (self.config !== undefined) triggerEvent("onDestroy");
|
1207
|
-
|
1208
|
-
for (var i = self._handlers.length; i--;) {
|
1209
|
-
var h = self._handlers[i];
|
1210
|
-
h.element.removeEventListener(h.event, h.handler, h.options);
|
1211
|
-
}
|
1212
|
-
|
1213
|
-
self._handlers = [];
|
1214
|
-
|
1215
|
-
if (self.mobileInput) {
|
1216
|
-
if (self.mobileInput.parentNode) self.mobileInput.parentNode.removeChild(self.mobileInput);
|
1217
|
-
self.mobileInput = undefined;
|
1218
|
-
} else if (self.calendarContainer && self.calendarContainer.parentNode) {
|
1219
|
-
if (self.config.static && self.calendarContainer.parentNode) {
|
1220
|
-
var wrapper = self.calendarContainer.parentNode;
|
1221
|
-
wrapper.lastChild && wrapper.removeChild(wrapper.lastChild);
|
1222
|
-
|
1223
|
-
if (wrapper.parentNode) {
|
1224
|
-
while (wrapper.firstChild) {
|
1225
|
-
wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper);
|
1226
|
-
}
|
1227
|
-
|
1228
|
-
wrapper.parentNode.removeChild(wrapper);
|
1845
|
+
if (userConfig.altInput &&
|
1846
|
+
(userConfig.enableTime || timeMode) &&
|
1847
|
+
!userConfig.altFormat) {
|
1848
|
+
formats$$1.altFormat =
|
1849
|
+
userConfig.noCalendar || timeMode
|
1850
|
+
? "h:i" + (userConfig.enableSeconds ? ":S K" : " K")
|
1851
|
+
: flatpickr.defaultConfig.altFormat +
|
1852
|
+
(" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
|
1229
1853
|
}
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
function isCalendarElem(elem) {
|
1254
|
-
if (self.config.appendTo && self.config.appendTo.contains(elem)) return true;
|
1255
|
-
return self.calendarContainer.contains(elem);
|
1256
|
-
}
|
1257
|
-
|
1258
|
-
function documentClick(e) {
|
1259
|
-
if (self.isOpen && !self.config.inline) {
|
1260
|
-
var isCalendarElement = isCalendarElem(e.target);
|
1261
|
-
var isInput = e.target === self.input || e.target === self.altInput || self.element.contains(e.target) || e.path && e.path.indexOf && (~e.path.indexOf(self.input) || ~e.path.indexOf(self.altInput));
|
1262
|
-
var lostFocus = e.type === "blur" ? isInput && e.relatedTarget && !isCalendarElem(e.relatedTarget) : !isInput && !isCalendarElement;
|
1263
|
-
var isIgnored = !self.config.ignoredFocusElements.some(function (elem) {
|
1264
|
-
return elem.contains(e.target);
|
1265
|
-
});
|
1266
|
-
|
1267
|
-
if (lostFocus && isIgnored) {
|
1268
|
-
self.close();
|
1269
|
-
|
1270
|
-
if (self.config.mode === "range" && self.selectedDates.length === 1) {
|
1271
|
-
self.clear(false);
|
1272
|
-
self.redraw();
|
1854
|
+
Object.defineProperty(self.config, "minDate", {
|
1855
|
+
get: function () { return self.config._minDate; },
|
1856
|
+
set: minMaxDateSetter("min")
|
1857
|
+
});
|
1858
|
+
Object.defineProperty(self.config, "maxDate", {
|
1859
|
+
get: function () { return self.config._maxDate; },
|
1860
|
+
set: minMaxDateSetter("max")
|
1861
|
+
});
|
1862
|
+
var minMaxTimeSetter = function (type) { return function (val) {
|
1863
|
+
self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i");
|
1864
|
+
}; };
|
1865
|
+
Object.defineProperty(self.config, "minTime", {
|
1866
|
+
get: function () { return self.config._minTime; },
|
1867
|
+
set: minMaxTimeSetter("min")
|
1868
|
+
});
|
1869
|
+
Object.defineProperty(self.config, "maxTime", {
|
1870
|
+
get: function () { return self.config._maxTime; },
|
1871
|
+
set: minMaxTimeSetter("max")
|
1872
|
+
});
|
1873
|
+
if (userConfig.mode === "time") {
|
1874
|
+
self.config.noCalendar = true;
|
1875
|
+
self.config.enableTime = true;
|
1273
1876
|
}
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
isNewYear = self.currentYear !== newYearNum;
|
1282
|
-
self.currentYear = newYearNum || self.currentYear;
|
1283
|
-
|
1284
|
-
if (self.config.maxDate && self.currentYear === self.config.maxDate.getFullYear()) {
|
1285
|
-
self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
|
1286
|
-
} else if (self.config.minDate && self.currentYear === self.config.minDate.getFullYear()) {
|
1287
|
-
self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
|
1288
|
-
}
|
1289
|
-
|
1290
|
-
if (isNewYear) {
|
1291
|
-
self.redraw();
|
1292
|
-
triggerEvent("onYearChange");
|
1293
|
-
}
|
1294
|
-
}
|
1295
|
-
|
1296
|
-
function isEnabled(date, timeless) {
|
1297
|
-
if (timeless === void 0) {
|
1298
|
-
timeless = true;
|
1299
|
-
}
|
1300
|
-
|
1301
|
-
var dateToCheck = self.parseDate(date, undefined, timeless);
|
1302
|
-
if (self.config.minDate && dateToCheck && compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0 || self.config.maxDate && dateToCheck && compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0) return false;
|
1303
|
-
if (self.config.enable.length === 0 && self.config.disable.length === 0) return true;
|
1304
|
-
if (dateToCheck === undefined) return false;
|
1305
|
-
var bool = self.config.enable.length > 0,
|
1306
|
-
array = bool ? self.config.enable : self.config.disable;
|
1307
|
-
|
1308
|
-
for (var i = 0, d; i < array.length; i++) {
|
1309
|
-
d = array[i];
|
1310
|
-
if (typeof d === "function" && d(dateToCheck)) return bool;else if (d instanceof Date && dateToCheck !== undefined && d.getTime() === dateToCheck.getTime()) return bool;else if (typeof d === "string" && dateToCheck !== undefined) {
|
1311
|
-
var parsed = self.parseDate(d, undefined, true);
|
1312
|
-
return parsed && parsed.getTime() === dateToCheck.getTime() ? bool : !bool;
|
1313
|
-
} else if (typeof d === "object" && dateToCheck !== undefined && d.from && d.to && dateToCheck.getTime() >= d.from.getTime() && dateToCheck.getTime() <= d.to.getTime()) return bool;
|
1314
|
-
}
|
1315
|
-
|
1316
|
-
return !bool;
|
1317
|
-
}
|
1318
|
-
|
1319
|
-
function isInView(elem) {
|
1320
|
-
if (self.daysContainer !== undefined) return elem.className.indexOf("hidden") === -1 && self.daysContainer.contains(elem);
|
1321
|
-
return false;
|
1322
|
-
}
|
1323
|
-
|
1324
|
-
function onKeyDown(e) {
|
1325
|
-
var isInput = e.target === self._input;
|
1326
|
-
var allowInput = self.config.allowInput;
|
1327
|
-
var allowKeydown = self.isOpen && (!allowInput || !isInput);
|
1328
|
-
var allowInlineKeydown = self.config.inline && isInput && !allowInput;
|
1329
|
-
|
1330
|
-
if (e.keyCode === 13 && isInput) {
|
1331
|
-
if (allowInput) {
|
1332
|
-
self.setDate(self._input.value, true, e.target === self.altInput ? self.config.altFormat : self.config.dateFormat);
|
1333
|
-
return e.target.blur();
|
1334
|
-
} else self.open();
|
1335
|
-
} else if (isCalendarElem(e.target) || allowKeydown || allowInlineKeydown) {
|
1336
|
-
var isTimeObj = !!self.timeContainer && self.timeContainer.contains(e.target);
|
1337
|
-
|
1338
|
-
switch (e.keyCode) {
|
1339
|
-
case 13:
|
1340
|
-
if (isTimeObj) updateTime();else selectDate(e);
|
1341
|
-
break;
|
1342
|
-
|
1343
|
-
case 27:
|
1344
|
-
e.preventDefault();
|
1345
|
-
focusAndClose();
|
1346
|
-
break;
|
1347
|
-
|
1348
|
-
case 8:
|
1349
|
-
case 46:
|
1350
|
-
if (isInput && !self.config.allowInput) {
|
1351
|
-
e.preventDefault();
|
1352
|
-
self.clear();
|
1353
|
-
}
|
1354
|
-
|
1355
|
-
break;
|
1356
|
-
|
1357
|
-
case 37:
|
1358
|
-
case 39:
|
1359
|
-
if (!isTimeObj) {
|
1360
|
-
e.preventDefault();
|
1361
|
-
|
1362
|
-
if (self.daysContainer !== undefined && (allowInput === false || isInView(document.activeElement))) {
|
1363
|
-
var _delta = e.keyCode === 39 ? 1 : -1;
|
1364
|
-
|
1365
|
-
if (!e.ctrlKey) focusOnDay(undefined, _delta);else {
|
1366
|
-
changeMonth(_delta);
|
1367
|
-
focusOnDay(getFirstAvailableDay(1), 0);
|
1368
|
-
}
|
1369
|
-
}
|
1370
|
-
} else if (self.hourElement) self.hourElement.focus();
|
1371
|
-
|
1372
|
-
break;
|
1373
|
-
|
1374
|
-
case 38:
|
1375
|
-
case 40:
|
1376
|
-
e.preventDefault();
|
1377
|
-
var delta = e.keyCode === 40 ? 1 : -1;
|
1378
|
-
|
1379
|
-
if (self.daysContainer && e.target.$i !== undefined) {
|
1380
|
-
if (e.ctrlKey) {
|
1381
|
-
changeYear(self.currentYear - delta);
|
1382
|
-
focusOnDay(getFirstAvailableDay(1), 0);
|
1383
|
-
} else if (!isTimeObj) focusOnDay(undefined, delta * 7);
|
1384
|
-
} else if (self.config.enableTime) {
|
1385
|
-
if (!isTimeObj && self.hourElement) self.hourElement.focus();
|
1386
|
-
updateTime(e);
|
1387
|
-
|
1388
|
-
self._debouncedChange();
|
1389
|
-
}
|
1390
|
-
|
1391
|
-
break;
|
1392
|
-
|
1393
|
-
case 9:
|
1394
|
-
if (!isTimeObj) {
|
1395
|
-
self.element.focus();
|
1396
|
-
break;
|
1397
|
-
}
|
1398
|
-
|
1399
|
-
var elems = [self.hourElement, self.minuteElement, self.secondElement, self.amPM].filter(function (x) {
|
1400
|
-
return x;
|
1401
|
-
});
|
1402
|
-
var i = elems.indexOf(e.target);
|
1403
|
-
|
1404
|
-
if (i !== -1) {
|
1405
|
-
var target = elems[i + (e.shiftKey ? -1 : 1)];
|
1406
|
-
|
1407
|
-
if (target !== undefined) {
|
1408
|
-
e.preventDefault();
|
1409
|
-
target.focus();
|
1410
|
-
} else {
|
1411
|
-
self.element.focus();
|
1412
|
-
}
|
1413
|
-
}
|
1414
|
-
|
1415
|
-
break;
|
1416
|
-
|
1417
|
-
default:
|
1418
|
-
break;
|
1419
|
-
}
|
1420
|
-
}
|
1421
|
-
|
1422
|
-
if (self.amPM !== undefined && e.target === self.amPM) {
|
1423
|
-
switch (e.key) {
|
1424
|
-
case self.l10n.amPM[0].charAt(0):
|
1425
|
-
case self.l10n.amPM[0].charAt(0).toLowerCase():
|
1426
|
-
self.amPM.textContent = self.l10n.amPM[0];
|
1427
|
-
setHoursFromInputs();
|
1428
|
-
updateValue();
|
1429
|
-
break;
|
1430
|
-
|
1431
|
-
case self.l10n.amPM[1].charAt(0):
|
1432
|
-
case self.l10n.amPM[1].charAt(0).toLowerCase():
|
1433
|
-
self.amPM.textContent = self.l10n.amPM[1];
|
1434
|
-
setHoursFromInputs();
|
1435
|
-
updateValue();
|
1436
|
-
break;
|
1437
|
-
}
|
1438
|
-
}
|
1439
|
-
|
1440
|
-
triggerEvent("onKeyDown", e);
|
1441
|
-
}
|
1442
|
-
|
1443
|
-
function onMouseOver(elem) {
|
1444
|
-
if (self.selectedDates.length !== 1 || elem && (!elem.classList.contains("flatpickr-day") || elem.classList.contains("disabled"))) return;
|
1445
|
-
var hoverDate = elem ? elem.dateObj.getTime() : self.days.firstElementChild.dateObj.getTime(),
|
1446
|
-
initialDate = self.parseDate(self.selectedDates[0], undefined, true).getTime(),
|
1447
|
-
rangeStartDate = Math.min(hoverDate, self.selectedDates[0].getTime()),
|
1448
|
-
rangeEndDate = Math.max(hoverDate, self.selectedDates[0].getTime()),
|
1449
|
-
lastDate = self.daysContainer.lastChild.lastChild.dateObj.getTime();
|
1450
|
-
var containsDisabled = false;
|
1451
|
-
var minRange = 0,
|
1452
|
-
maxRange = 0;
|
1453
|
-
|
1454
|
-
for (var t = rangeStartDate; t < lastDate; t += duration.DAY) {
|
1455
|
-
if (!isEnabled(new Date(t), true)) {
|
1456
|
-
containsDisabled = containsDisabled || t > rangeStartDate && t < rangeEndDate;
|
1457
|
-
if (t < initialDate && (!minRange || t > minRange)) minRange = t;else if (t > initialDate && (!maxRange || t < maxRange)) maxRange = t;
|
1458
|
-
}
|
1459
|
-
}
|
1460
|
-
|
1461
|
-
for (var m = 0; m < self.config.showMonths; m++) {
|
1462
|
-
var month = self.daysContainer.children[m];
|
1463
|
-
var prevMonth = self.daysContainer.children[m - 1];
|
1464
|
-
|
1465
|
-
var _loop = function _loop(i, l) {
|
1466
|
-
var dayElem = month.children[i],
|
1467
|
-
date = dayElem.dateObj;
|
1468
|
-
var timestamp = date.getTime();
|
1469
|
-
var outOfRange = minRange > 0 && timestamp < minRange || maxRange > 0 && timestamp > maxRange;
|
1470
|
-
|
1471
|
-
if (outOfRange) {
|
1472
|
-
dayElem.classList.add("notAllowed");
|
1473
|
-
["inRange", "startRange", "endRange"].forEach(function (c) {
|
1474
|
-
dayElem.classList.remove(c);
|
1475
|
-
});
|
1476
|
-
return "continue";
|
1477
|
-
} else if (containsDisabled && !outOfRange) return "continue";
|
1478
|
-
|
1479
|
-
["startRange", "inRange", "endRange", "notAllowed"].forEach(function (c) {
|
1480
|
-
dayElem.classList.remove(c);
|
1877
|
+
Object.assign(self.config, formats$$1, userConfig);
|
1878
|
+
for (var i = 0; i < boolOpts.length; i++)
|
1879
|
+
self.config[boolOpts[i]] =
|
1880
|
+
self.config[boolOpts[i]] === true ||
|
1881
|
+
self.config[boolOpts[i]] === "true";
|
1882
|
+
HOOKS.filter(function (hook) { return self.config[hook] !== undefined; }).forEach(function (hook) {
|
1883
|
+
self.config[hook] = arrayify(self.config[hook] || []).map(bindToInstance);
|
1481
1884
|
});
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1885
|
+
self.isMobile =
|
1886
|
+
!self.config.disableMobile &&
|
1887
|
+
!self.config.inline &&
|
1888
|
+
self.config.mode === "single" &&
|
1889
|
+
!self.config.disable.length &&
|
1890
|
+
!self.config.enable.length &&
|
1891
|
+
!self.config.weekNumbers &&
|
1892
|
+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
1893
|
+
for (var i = 0; i < self.config.plugins.length; i++) {
|
1894
|
+
var pluginConf = self.config.plugins[i](self) || {};
|
1895
|
+
for (var key in pluginConf) {
|
1896
|
+
if (HOOKS.indexOf(key) > -1) {
|
1897
|
+
self.config[key] = arrayify(pluginConf[key])
|
1898
|
+
.map(bindToInstance)
|
1899
|
+
.concat(self.config[key]);
|
1900
|
+
}
|
1901
|
+
else if (typeof userConfig[key] === "undefined")
|
1902
|
+
self.config[key] = pluginConf[key];
|
1903
|
+
}
|
1904
|
+
}
|
1905
|
+
triggerEvent("onParseConfig");
|
1906
|
+
}
|
1907
|
+
function setupLocale() {
|
1908
|
+
if (typeof self.config.locale !== "object" &&
|
1909
|
+
typeof flatpickr.l10ns[self.config.locale] === "undefined")
|
1910
|
+
self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
|
1911
|
+
self.l10n = __assign({}, flatpickr.l10ns["default"], (typeof self.config.locale === "object"
|
1912
|
+
? self.config.locale
|
1913
|
+
: self.config.locale !== "default"
|
1914
|
+
? flatpickr.l10ns[self.config.locale]
|
1915
|
+
: undefined));
|
1916
|
+
tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
|
1917
|
+
self.formatDate = createDateFormatter(self);
|
1918
|
+
self.parseDate = createDateParser({ config: self.config, l10n: self.l10n });
|
1919
|
+
}
|
1920
|
+
function positionCalendar(customPositionElement) {
|
1921
|
+
if (self.calendarContainer === undefined)
|
1922
|
+
return;
|
1923
|
+
triggerEvent("onPreCalendarPosition");
|
1924
|
+
var positionElement = customPositionElement || self._positionElement;
|
1925
|
+
var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, (function (acc, child) { return acc + child.offsetHeight; }), 0), calendarWidth = self.calendarContainer.offsetWidth, configPos = self.config.position.split(" "), configPosVertical = configPos[0], configPosHorizontal = configPos.length > 1 ? configPos[1] : null, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = window.innerHeight - inputBounds.bottom, showOnTop = configPosVertical === "above" ||
|
1926
|
+
(configPosVertical !== "below" &&
|
1927
|
+
distanceFromBottom < calendarHeight &&
|
1928
|
+
inputBounds.top > calendarHeight);
|
1929
|
+
var top = window.pageYOffset +
|
1930
|
+
inputBounds.top +
|
1931
|
+
(!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
|
1932
|
+
toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
|
1933
|
+
toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
|
1934
|
+
if (self.config.inline)
|
1935
|
+
return;
|
1936
|
+
var left = window.pageXOffset +
|
1937
|
+
inputBounds.left -
|
1938
|
+
(configPosHorizontal != null && configPosHorizontal === "center"
|
1939
|
+
? (calendarWidth - inputBounds.width) / 2
|
1940
|
+
: 0);
|
1941
|
+
var right = window.document.body.offsetWidth - inputBounds.right;
|
1942
|
+
var rightMost = left + calendarWidth > window.document.body.offsetWidth;
|
1943
|
+
var centerMost = right + calendarWidth > window.document.body.offsetWidth;
|
1944
|
+
toggleClass(self.calendarContainer, "rightMost", rightMost);
|
1945
|
+
if (self.config.static)
|
1946
|
+
return;
|
1947
|
+
self.calendarContainer.style.top = top + "px";
|
1948
|
+
if (!rightMost) {
|
1949
|
+
self.calendarContainer.style.left = left + "px";
|
1950
|
+
self.calendarContainer.style.right = "auto";
|
1951
|
+
}
|
1952
|
+
else if (!centerMost) {
|
1953
|
+
self.calendarContainer.style.left = "auto";
|
1954
|
+
self.calendarContainer.style.right = right + "px";
|
1955
|
+
}
|
1956
|
+
else {
|
1957
|
+
var doc = document.styleSheets[0];
|
1958
|
+
// some testing environments don't have css support
|
1959
|
+
if (doc === undefined)
|
1960
|
+
return;
|
1961
|
+
var bodyWidth = window.document.body.offsetWidth;
|
1962
|
+
var centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
|
1963
|
+
var centerBefore = ".flatpickr-calendar.centerMost:before";
|
1964
|
+
var centerAfter = ".flatpickr-calendar.centerMost:after";
|
1965
|
+
var centerIndex = doc.cssRules.length;
|
1966
|
+
var centerStyle = "{left:" + inputBounds.left + "px;right:auto;}";
|
1967
|
+
toggleClass(self.calendarContainer, "rightMost", false);
|
1968
|
+
toggleClass(self.calendarContainer, "centerMost", true);
|
1969
|
+
doc.insertRule(centerBefore + "," + centerAfter + centerStyle, centerIndex);
|
1970
|
+
self.calendarContainer.style.left = centerLeft + "px";
|
1971
|
+
self.calendarContainer.style.right = "auto";
|
1490
1972
|
}
|
1491
|
-
};
|
1492
|
-
|
1493
|
-
for (var i = 0, l = month.children.length; i < l; i++) {
|
1494
|
-
var _ret = _loop(i, l);
|
1495
|
-
|
1496
|
-
if (_ret === "continue") continue;
|
1497
|
-
}
|
1498
1973
|
}
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1974
|
+
function redraw() {
|
1975
|
+
if (self.config.noCalendar || self.isMobile)
|
1976
|
+
return;
|
1977
|
+
updateNavigationCurrentMonth();
|
1978
|
+
buildDays();
|
1979
|
+
}
|
1980
|
+
function focusAndClose() {
|
1981
|
+
self._input.focus();
|
1982
|
+
if (window.navigator.userAgent.indexOf("MSIE") !== -1 ||
|
1983
|
+
navigator.msMaxTouchPoints !== undefined) {
|
1984
|
+
// hack - bugs in the way IE handles focus keeps the calendar open
|
1985
|
+
setTimeout(self.close, 0);
|
1986
|
+
}
|
1987
|
+
else {
|
1988
|
+
self.close();
|
1989
|
+
}
|
1508
1990
|
}
|
1509
|
-
|
1510
|
-
if (self.isMobile === true) {
|
1511
|
-
if (e) {
|
1991
|
+
function selectDate(e) {
|
1512
1992
|
e.preventDefault();
|
1513
|
-
e.
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
}
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
}
|
1561
|
-
|
1562
|
-
if (self.selectedDates) {
|
1563
|
-
self.selectedDates = self.selectedDates.filter(function (d) {
|
1564
|
-
return isEnabled(d);
|
1565
|
-
});
|
1566
|
-
if (!self.selectedDates.length && type === "min") setHoursFromDate(dateObj);
|
1993
|
+
e.stopPropagation();
|
1994
|
+
var isSelectable = function (day) {
|
1995
|
+
return day.classList &&
|
1996
|
+
day.classList.contains("flatpickr-day") &&
|
1997
|
+
!day.classList.contains("disabled") &&
|
1998
|
+
!day.classList.contains("notAllowed");
|
1999
|
+
};
|
2000
|
+
var t = findParent(e.target, isSelectable);
|
2001
|
+
if (t === undefined)
|
2002
|
+
return;
|
2003
|
+
var target = t;
|
2004
|
+
var selectedDate = (self.latestSelectedDateObj = new Date(target.dateObj.getTime()));
|
2005
|
+
var shouldChangeMonth = (selectedDate.getMonth() < self.currentMonth ||
|
2006
|
+
selectedDate.getMonth() >
|
2007
|
+
self.currentMonth + self.config.showMonths - 1) &&
|
2008
|
+
self.config.mode !== "range";
|
2009
|
+
self.selectedDateElem = target;
|
2010
|
+
if (self.config.mode === "single")
|
2011
|
+
self.selectedDates = [selectedDate];
|
2012
|
+
else if (self.config.mode === "multiple") {
|
2013
|
+
var selectedIndex = isDateSelected(selectedDate);
|
2014
|
+
if (selectedIndex)
|
2015
|
+
self.selectedDates.splice(parseInt(selectedIndex), 1);
|
2016
|
+
else
|
2017
|
+
self.selectedDates.push(selectedDate);
|
2018
|
+
}
|
2019
|
+
else if (self.config.mode === "range") {
|
2020
|
+
if (self.selectedDates.length === 2) {
|
2021
|
+
self.clear(false, false);
|
2022
|
+
}
|
2023
|
+
self.latestSelectedDateObj = selectedDate;
|
2024
|
+
self.selectedDates.push(selectedDate);
|
2025
|
+
// unless selecting same date twice, sort ascendingly
|
2026
|
+
if (compareDates(selectedDate, self.selectedDates[0], true) !== 0)
|
2027
|
+
self.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
|
2028
|
+
}
|
2029
|
+
setHoursFromInputs();
|
2030
|
+
if (shouldChangeMonth) {
|
2031
|
+
var isNewYear = self.currentYear !== selectedDate.getFullYear();
|
2032
|
+
self.currentYear = selectedDate.getFullYear();
|
2033
|
+
self.currentMonth = selectedDate.getMonth();
|
2034
|
+
if (isNewYear)
|
2035
|
+
triggerEvent("onYearChange");
|
2036
|
+
triggerEvent("onMonthChange");
|
2037
|
+
}
|
2038
|
+
updateNavigationCurrentMonth();
|
2039
|
+
buildDays();
|
1567
2040
|
updateValue();
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
});
|
1592
|
-
Object.defineProperty(self.config, "disable", {
|
1593
|
-
get: function get() {
|
1594
|
-
return self.config._disable;
|
1595
|
-
},
|
1596
|
-
set: function set(dates) {
|
1597
|
-
self.config._disable = parseDateRules(dates);
|
1598
|
-
}
|
1599
|
-
});
|
1600
|
-
var timeMode = userConfig.mode === "time";
|
1601
|
-
|
1602
|
-
if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
|
1603
|
-
formats$$1.dateFormat = userConfig.noCalendar || timeMode ? "H:i" + (userConfig.enableSeconds ? ":S" : "") : flatpickr.defaultConfig.dateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
|
1604
|
-
}
|
1605
|
-
|
1606
|
-
if (userConfig.altInput && (userConfig.enableTime || timeMode) && !userConfig.altFormat) {
|
1607
|
-
formats$$1.altFormat = userConfig.noCalendar || timeMode ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K") : flatpickr.defaultConfig.altFormat + (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
|
1608
|
-
}
|
1609
|
-
|
1610
|
-
Object.defineProperty(self.config, "minDate", {
|
1611
|
-
get: function get() {
|
1612
|
-
return self.config._minDate;
|
1613
|
-
},
|
1614
|
-
set: minMaxDateSetter("min")
|
1615
|
-
});
|
1616
|
-
Object.defineProperty(self.config, "maxDate", {
|
1617
|
-
get: function get() {
|
1618
|
-
return self.config._maxDate;
|
1619
|
-
},
|
1620
|
-
set: minMaxDateSetter("max")
|
1621
|
-
});
|
1622
|
-
|
1623
|
-
var minMaxTimeSetter = function minMaxTimeSetter(type) {
|
1624
|
-
return function (val) {
|
1625
|
-
self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i");
|
1626
|
-
};
|
1627
|
-
};
|
1628
|
-
|
1629
|
-
Object.defineProperty(self.config, "minTime", {
|
1630
|
-
get: function get() {
|
1631
|
-
return self.config._minTime;
|
1632
|
-
},
|
1633
|
-
set: minMaxTimeSetter("min")
|
1634
|
-
});
|
1635
|
-
Object.defineProperty(self.config, "maxTime", {
|
1636
|
-
get: function get() {
|
1637
|
-
return self.config._maxTime;
|
1638
|
-
},
|
1639
|
-
set: minMaxTimeSetter("max")
|
1640
|
-
});
|
1641
|
-
|
1642
|
-
if (userConfig.mode === "time") {
|
1643
|
-
self.config.noCalendar = true;
|
1644
|
-
self.config.enableTime = true;
|
1645
|
-
}
|
1646
|
-
|
1647
|
-
Object.assign(self.config, formats$$1, userConfig);
|
1648
|
-
|
1649
|
-
for (var i = 0; i < boolOpts.length; i++) {
|
1650
|
-
self.config[boolOpts[i]] = self.config[boolOpts[i]] === true || self.config[boolOpts[i]] === "true";
|
1651
|
-
}
|
1652
|
-
|
1653
|
-
HOOKS.filter(function (hook) {
|
1654
|
-
return self.config[hook] !== undefined;
|
1655
|
-
}).forEach(function (hook) {
|
1656
|
-
self.config[hook] = arrayify(self.config[hook] || []).map(bindToInstance);
|
1657
|
-
});
|
1658
|
-
self.isMobile = !self.config.disableMobile && !self.config.inline && self.config.mode === "single" && !self.config.disable.length && !self.config.enable.length && !self.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
1659
|
-
|
1660
|
-
for (var _i = 0; _i < self.config.plugins.length; _i++) {
|
1661
|
-
var pluginConf = self.config.plugins[_i](self) || {};
|
1662
|
-
|
1663
|
-
for (var key in pluginConf) {
|
1664
|
-
if (HOOKS.indexOf(key) > -1) {
|
1665
|
-
self.config[key] = arrayify(pluginConf[key]).map(bindToInstance).concat(self.config[key]);
|
1666
|
-
} else if (typeof userConfig[key] === "undefined") self.config[key] = pluginConf[key];
|
1667
|
-
}
|
1668
|
-
}
|
1669
|
-
|
1670
|
-
triggerEvent("onParseConfig");
|
1671
|
-
}
|
1672
|
-
|
1673
|
-
function setupLocale() {
|
1674
|
-
if (typeof self.config.locale !== "object" && typeof flatpickr.l10ns[self.config.locale] === "undefined") self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
|
1675
|
-
self.l10n = Object.assign({}, flatpickr.l10ns.default, typeof self.config.locale === "object" ? self.config.locale : self.config.locale !== "default" ? flatpickr.l10ns[self.config.locale] : undefined);
|
1676
|
-
tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
|
1677
|
-
self.formatDate = createDateFormatter(self);
|
1678
|
-
self.parseDate = createDateParser({
|
1679
|
-
config: self.config,
|
1680
|
-
l10n: self.l10n
|
1681
|
-
});
|
1682
|
-
}
|
1683
|
-
|
1684
|
-
function positionCalendar(customPositionElement) {
|
1685
|
-
if (self.calendarContainer === undefined) return;
|
1686
|
-
triggerEvent("onPreCalendarPosition");
|
1687
|
-
var positionElement = customPositionElement || self._positionElement;
|
1688
|
-
var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, function (acc, child) {
|
1689
|
-
return acc + child.offsetHeight;
|
1690
|
-
}, 0),
|
1691
|
-
calendarWidth = self.calendarContainer.offsetWidth,
|
1692
|
-
configPos = self.config.position.split(" "),
|
1693
|
-
configPosVertical = configPos[0],
|
1694
|
-
configPosHorizontal = configPos.length > 1 ? configPos[1] : null,
|
1695
|
-
inputBounds = positionElement.getBoundingClientRect(),
|
1696
|
-
distanceFromBottom = window.innerHeight - inputBounds.bottom,
|
1697
|
-
showOnTop = configPosVertical === "above" || configPosVertical !== "below" && distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight;
|
1698
|
-
var top = window.pageYOffset + inputBounds.top + (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
|
1699
|
-
toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
|
1700
|
-
toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
|
1701
|
-
if (self.config.inline) return;
|
1702
|
-
var left = window.pageXOffset + inputBounds.left - (configPosHorizontal != null && configPosHorizontal === "center" ? (calendarWidth - inputBounds.width) / 2 : 0);
|
1703
|
-
var right = window.document.body.offsetWidth - inputBounds.right;
|
1704
|
-
var rightMost = left + calendarWidth > window.document.body.offsetWidth;
|
1705
|
-
toggleClass(self.calendarContainer, "rightMost", rightMost);
|
1706
|
-
if (self.config.static) return;
|
1707
|
-
self.calendarContainer.style.top = top + "px";
|
1708
|
-
|
1709
|
-
if (!rightMost) {
|
1710
|
-
self.calendarContainer.style.left = left + "px";
|
1711
|
-
self.calendarContainer.style.right = "auto";
|
1712
|
-
} else {
|
1713
|
-
self.calendarContainer.style.left = "auto";
|
1714
|
-
self.calendarContainer.style.right = right + "px";
|
1715
|
-
}
|
1716
|
-
}
|
1717
|
-
|
1718
|
-
function redraw() {
|
1719
|
-
if (self.config.noCalendar || self.isMobile) return;
|
1720
|
-
updateNavigationCurrentMonth();
|
1721
|
-
buildDays();
|
1722
|
-
}
|
1723
|
-
|
1724
|
-
function focusAndClose() {
|
1725
|
-
self._input.focus();
|
1726
|
-
|
1727
|
-
if (window.navigator.userAgent.indexOf("MSIE") !== -1 || navigator.msMaxTouchPoints !== undefined) {
|
1728
|
-
setTimeout(self.close, 0);
|
1729
|
-
} else {
|
1730
|
-
self.close();
|
2041
|
+
if (self.config.enableTime)
|
2042
|
+
setTimeout(function () { return (self.showTimeInput = true); }, 50);
|
2043
|
+
// maintain focus
|
2044
|
+
if (!shouldChangeMonth &&
|
2045
|
+
self.config.mode !== "range" &&
|
2046
|
+
self.config.showMonths === 1)
|
2047
|
+
focusOnDayElem(target);
|
2048
|
+
else if (self.selectedDateElem !== undefined &&
|
2049
|
+
self.hourElement === undefined) {
|
2050
|
+
self.selectedDateElem && self.selectedDateElem.focus();
|
2051
|
+
}
|
2052
|
+
if (self.hourElement !== undefined)
|
2053
|
+
self.hourElement !== undefined && self.hourElement.focus();
|
2054
|
+
if (self.config.closeOnSelect) {
|
2055
|
+
var single = self.config.mode === "single" && !self.config.enableTime;
|
2056
|
+
var range = self.config.mode === "range" &&
|
2057
|
+
self.selectedDates.length === 2 &&
|
2058
|
+
!self.config.enableTime;
|
2059
|
+
if (single || range) {
|
2060
|
+
focusAndClose();
|
2061
|
+
}
|
2062
|
+
}
|
2063
|
+
triggerChange();
|
1731
2064
|
}
|
1732
|
-
|
1733
|
-
|
1734
|
-
|
1735
|
-
e.preventDefault();
|
1736
|
-
e.stopPropagation();
|
1737
|
-
|
1738
|
-
var isSelectable = function isSelectable(day) {
|
1739
|
-
return day.classList && day.classList.contains("flatpickr-day") && !day.classList.contains("disabled") && !day.classList.contains("notAllowed");
|
2065
|
+
var CALLBACKS = {
|
2066
|
+
locale: [setupLocale, updateWeekdays],
|
2067
|
+
showMonths: [buildMonths, setCalendarWidth, buildWeekdays]
|
1740
2068
|
};
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
return rule;
|
1873
|
-
}).filter(function (x) {
|
1874
|
-
return x;
|
1875
|
-
});
|
1876
|
-
}
|
1877
|
-
|
1878
|
-
function setupDates() {
|
1879
|
-
self.selectedDates = [];
|
1880
|
-
self.now = self.parseDate(self.config.now) || new Date();
|
1881
|
-
var preloadedDate = self.config.defaultDate || ((self.input.nodeName === "INPUT" || self.input.nodeName === "TEXTAREA") && self.input.placeholder && self.input.value === self.input.placeholder ? null : self.input.value);
|
1882
|
-
if (preloadedDate) setSelectedDate(preloadedDate, self.config.dateFormat);
|
1883
|
-
var initialDate = self.selectedDates.length > 0 ? self.selectedDates[0] : self.config.minDate && self.config.minDate.getTime() > self.now.getTime() ? self.config.minDate : self.config.maxDate && self.config.maxDate.getTime() < self.now.getTime() ? self.config.maxDate : self.now;
|
1884
|
-
self.currentYear = initialDate.getFullYear();
|
1885
|
-
self.currentMonth = initialDate.getMonth();
|
1886
|
-
if (self.selectedDates.length > 0) self.latestSelectedDateObj = self.selectedDates[0];
|
1887
|
-
if (self.config.minTime !== undefined) self.config.minTime = self.parseDate(self.config.minTime, "H:i");
|
1888
|
-
if (self.config.maxTime !== undefined) self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
|
1889
|
-
self.minDateHasTime = !!self.config.minDate && (self.config.minDate.getHours() > 0 || self.config.minDate.getMinutes() > 0 || self.config.minDate.getSeconds() > 0);
|
1890
|
-
self.maxDateHasTime = !!self.config.maxDate && (self.config.maxDate.getHours() > 0 || self.config.maxDate.getMinutes() > 0 || self.config.maxDate.getSeconds() > 0);
|
1891
|
-
Object.defineProperty(self, "showTimeInput", {
|
1892
|
-
get: function get() {
|
1893
|
-
return self._showTimeInput;
|
1894
|
-
},
|
1895
|
-
set: function set(bool) {
|
1896
|
-
self._showTimeInput = bool;
|
1897
|
-
if (self.calendarContainer) toggleClass(self.calendarContainer, "showTimeInput", bool);
|
1898
|
-
self.isOpen && positionCalendar();
|
1899
|
-
}
|
1900
|
-
});
|
1901
|
-
}
|
1902
|
-
|
1903
|
-
function setupInputs() {
|
1904
|
-
self.input = self.config.wrap ? element.querySelector("[data-input]") : element;
|
1905
|
-
|
1906
|
-
if (!self.input) {
|
1907
|
-
self.config.errorHandler(new Error("Invalid input element specified"));
|
1908
|
-
return;
|
1909
|
-
}
|
1910
|
-
|
1911
|
-
self.input._type = self.input.type;
|
1912
|
-
self.input.type = "text";
|
1913
|
-
self.input.classList.add("flatpickr-input");
|
1914
|
-
self._input = self.input;
|
1915
|
-
|
1916
|
-
if (self.config.altInput) {
|
1917
|
-
self.altInput = createElement(self.input.nodeName, self.input.className + " " + self.config.altInputClass);
|
1918
|
-
self._input = self.altInput;
|
1919
|
-
self.altInput.placeholder = self.input.placeholder;
|
1920
|
-
self.altInput.disabled = self.input.disabled;
|
1921
|
-
self.altInput.required = self.input.required;
|
1922
|
-
self.altInput.tabIndex = self.input.tabIndex;
|
1923
|
-
self.altInput.type = "text";
|
1924
|
-
self.input.setAttribute("type", "hidden");
|
1925
|
-
if (!self.config.static && self.input.parentNode) self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
|
1926
|
-
}
|
1927
|
-
|
1928
|
-
if (!self.config.allowInput) self._input.setAttribute("readonly", "readonly");
|
1929
|
-
self._positionElement = self.config.positionElement || self._input;
|
1930
|
-
}
|
1931
|
-
|
1932
|
-
function setupMobile() {
|
1933
|
-
var inputType = self.config.enableTime ? self.config.noCalendar ? "time" : "datetime-local" : "date";
|
1934
|
-
self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
|
1935
|
-
self.mobileInput.step = self.input.getAttribute("step") || "any";
|
1936
|
-
self.mobileInput.tabIndex = 1;
|
1937
|
-
self.mobileInput.type = inputType;
|
1938
|
-
self.mobileInput.disabled = self.input.disabled;
|
1939
|
-
self.mobileInput.required = self.input.required;
|
1940
|
-
self.mobileInput.placeholder = self.input.placeholder;
|
1941
|
-
self.mobileFormatStr = inputType === "datetime-local" ? "Y-m-d\\TH:i:S" : inputType === "date" ? "Y-m-d" : "H:i:S";
|
1942
|
-
|
1943
|
-
if (self.selectedDates.length > 0) {
|
1944
|
-
self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
|
1945
|
-
}
|
1946
|
-
|
1947
|
-
if (self.config.minDate) self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
|
1948
|
-
if (self.config.maxDate) self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
|
1949
|
-
self.input.type = "hidden";
|
1950
|
-
if (self.altInput !== undefined) self.altInput.type = "hidden";
|
1951
|
-
|
1952
|
-
try {
|
1953
|
-
if (self.input.parentNode) self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
|
1954
|
-
} catch (_a) {}
|
1955
|
-
|
1956
|
-
bind(self.mobileInput, "change", function (e) {
|
1957
|
-
self.setDate(e.target.value, false, self.mobileFormatStr);
|
1958
|
-
triggerEvent("onChange");
|
1959
|
-
triggerEvent("onClose");
|
1960
|
-
});
|
1961
|
-
}
|
1962
|
-
|
1963
|
-
function toggle(e) {
|
1964
|
-
if (self.isOpen === true) return self.close();
|
1965
|
-
self.open(e);
|
1966
|
-
}
|
1967
|
-
|
1968
|
-
function triggerEvent(event, data) {
|
1969
|
-
if (self.config === undefined) return;
|
1970
|
-
var hooks = self.config[event];
|
1971
|
-
|
1972
|
-
if (hooks !== undefined && hooks.length > 0) {
|
1973
|
-
for (var i = 0; hooks[i] && i < hooks.length; i++) {
|
1974
|
-
hooks[i](self.selectedDates, self.input.value, self, data);
|
1975
|
-
}
|
1976
|
-
}
|
1977
|
-
|
1978
|
-
if (event === "onChange") {
|
1979
|
-
self.input.dispatchEvent(createEvent("change"));
|
1980
|
-
self.input.dispatchEvent(createEvent("input"));
|
2069
|
+
function set(option, value) {
|
2070
|
+
if (option !== null && typeof option === "object")
|
2071
|
+
Object.assign(self.config, option);
|
2072
|
+
else {
|
2073
|
+
self.config[option] = value;
|
2074
|
+
if (CALLBACKS[option] !== undefined)
|
2075
|
+
CALLBACKS[option].forEach(function (x) { return x(); });
|
2076
|
+
else if (HOOKS.indexOf(option) > -1)
|
2077
|
+
self.config[option] = arrayify(value);
|
2078
|
+
}
|
2079
|
+
self.redraw();
|
2080
|
+
updateValue(false);
|
2081
|
+
}
|
2082
|
+
function setSelectedDate(inputDate, format) {
|
2083
|
+
var dates = [];
|
2084
|
+
if (inputDate instanceof Array)
|
2085
|
+
dates = inputDate.map(function (d) { return self.parseDate(d, format); });
|
2086
|
+
else if (inputDate instanceof Date || typeof inputDate === "number")
|
2087
|
+
dates = [self.parseDate(inputDate, format)];
|
2088
|
+
else if (typeof inputDate === "string") {
|
2089
|
+
switch (self.config.mode) {
|
2090
|
+
case "single":
|
2091
|
+
case "time":
|
2092
|
+
dates = [self.parseDate(inputDate, format)];
|
2093
|
+
break;
|
2094
|
+
case "multiple":
|
2095
|
+
dates = inputDate
|
2096
|
+
.split(self.config.conjunction)
|
2097
|
+
.map(function (date) { return self.parseDate(date, format); });
|
2098
|
+
break;
|
2099
|
+
case "range":
|
2100
|
+
dates = inputDate
|
2101
|
+
.split(self.l10n.rangeSeparator)
|
2102
|
+
.map(function (date) { return self.parseDate(date, format); });
|
2103
|
+
break;
|
2104
|
+
default:
|
2105
|
+
break;
|
2106
|
+
}
|
2107
|
+
}
|
2108
|
+
else
|
2109
|
+
self.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(inputDate)));
|
2110
|
+
self.selectedDates = dates.filter(function (d) { return d instanceof Date && isEnabled(d, false); });
|
2111
|
+
if (self.config.mode === "range")
|
2112
|
+
self.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
|
2113
|
+
}
|
2114
|
+
function setDate(date, triggerChange, format) {
|
2115
|
+
if (triggerChange === void 0) { triggerChange = false; }
|
2116
|
+
if (format === void 0) { format = self.config.dateFormat; }
|
2117
|
+
if ((date !== 0 && !date) || (date instanceof Array && date.length === 0))
|
2118
|
+
return self.clear(triggerChange);
|
2119
|
+
setSelectedDate(date, format);
|
2120
|
+
self.showTimeInput = self.selectedDates.length > 0;
|
2121
|
+
self.latestSelectedDateObj = self.selectedDates[0];
|
2122
|
+
self.redraw();
|
2123
|
+
jumpToDate();
|
2124
|
+
setHoursFromDate();
|
2125
|
+
updateValue(triggerChange);
|
2126
|
+
if (triggerChange)
|
2127
|
+
triggerEvent("onChange");
|
2128
|
+
}
|
2129
|
+
function parseDateRules(arr) {
|
2130
|
+
return arr
|
2131
|
+
.slice()
|
2132
|
+
.map(function (rule) {
|
2133
|
+
if (typeof rule === "string" ||
|
2134
|
+
typeof rule === "number" ||
|
2135
|
+
rule instanceof Date) {
|
2136
|
+
return self.parseDate(rule, undefined, true);
|
2137
|
+
}
|
2138
|
+
else if (rule &&
|
2139
|
+
typeof rule === "object" &&
|
2140
|
+
rule.from &&
|
2141
|
+
rule.to)
|
2142
|
+
return {
|
2143
|
+
from: self.parseDate(rule.from, undefined),
|
2144
|
+
to: self.parseDate(rule.to, undefined)
|
2145
|
+
};
|
2146
|
+
return rule;
|
2147
|
+
})
|
2148
|
+
.filter(function (x) { return x; }); // remove falsy values
|
2149
|
+
}
|
2150
|
+
function setupDates() {
|
2151
|
+
self.selectedDates = [];
|
2152
|
+
self.now = self.parseDate(self.config.now) || new Date();
|
2153
|
+
// Workaround IE11 setting placeholder as the input's value
|
2154
|
+
var preloadedDate = self.config.defaultDate ||
|
2155
|
+
((self.input.nodeName === "INPUT" ||
|
2156
|
+
self.input.nodeName === "TEXTAREA") &&
|
2157
|
+
self.input.placeholder &&
|
2158
|
+
self.input.value === self.input.placeholder
|
2159
|
+
? null
|
2160
|
+
: self.input.value);
|
2161
|
+
if (preloadedDate)
|
2162
|
+
setSelectedDate(preloadedDate, self.config.dateFormat);
|
2163
|
+
self._initialDate =
|
2164
|
+
self.selectedDates.length > 0
|
2165
|
+
? self.selectedDates[0]
|
2166
|
+
: self.config.minDate &&
|
2167
|
+
self.config.minDate.getTime() > self.now.getTime()
|
2168
|
+
? self.config.minDate
|
2169
|
+
: self.config.maxDate &&
|
2170
|
+
self.config.maxDate.getTime() < self.now.getTime()
|
2171
|
+
? self.config.maxDate
|
2172
|
+
: self.now;
|
2173
|
+
self.currentYear = self._initialDate.getFullYear();
|
2174
|
+
self.currentMonth = self._initialDate.getMonth();
|
2175
|
+
if (self.selectedDates.length > 0)
|
2176
|
+
self.latestSelectedDateObj = self.selectedDates[0];
|
2177
|
+
if (self.config.minTime !== undefined)
|
2178
|
+
self.config.minTime = self.parseDate(self.config.minTime, "H:i");
|
2179
|
+
if (self.config.maxTime !== undefined)
|
2180
|
+
self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
|
2181
|
+
self.minDateHasTime =
|
2182
|
+
!!self.config.minDate &&
|
2183
|
+
(self.config.minDate.getHours() > 0 ||
|
2184
|
+
self.config.minDate.getMinutes() > 0 ||
|
2185
|
+
self.config.minDate.getSeconds() > 0);
|
2186
|
+
self.maxDateHasTime =
|
2187
|
+
!!self.config.maxDate &&
|
2188
|
+
(self.config.maxDate.getHours() > 0 ||
|
2189
|
+
self.config.maxDate.getMinutes() > 0 ||
|
2190
|
+
self.config.maxDate.getSeconds() > 0);
|
2191
|
+
Object.defineProperty(self, "showTimeInput", {
|
2192
|
+
get: function () { return self._showTimeInput; },
|
2193
|
+
set: function (bool) {
|
2194
|
+
self._showTimeInput = bool;
|
2195
|
+
if (self.calendarContainer)
|
2196
|
+
toggleClass(self.calendarContainer, "showTimeInput", bool);
|
2197
|
+
self.isOpen && positionCalendar();
|
2198
|
+
}
|
2199
|
+
});
|
1981
2200
|
}
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
2201
|
+
function setupInputs() {
|
2202
|
+
self.input = self.config.wrap
|
2203
|
+
? element.querySelector("[data-input]")
|
2204
|
+
: element;
|
2205
|
+
/* istanbul ignore next */
|
2206
|
+
if (!self.input) {
|
2207
|
+
self.config.errorHandler(new Error("Invalid input element specified"));
|
2208
|
+
return;
|
2209
|
+
}
|
2210
|
+
// hack: store previous type to restore it after destroy()
|
2211
|
+
self.input._type = self.input.type;
|
2212
|
+
self.input.type = "text";
|
2213
|
+
self.input.classList.add("flatpickr-input");
|
2214
|
+
self._input = self.input;
|
2215
|
+
if (self.config.altInput) {
|
2216
|
+
// replicate self.element
|
2217
|
+
self.altInput = createElement(self.input.nodeName, self.input.className + " " + self.config.altInputClass);
|
2218
|
+
self._input = self.altInput;
|
2219
|
+
self.altInput.placeholder = self.input.placeholder;
|
2220
|
+
self.altInput.disabled = self.input.disabled;
|
2221
|
+
self.altInput.required = self.input.required;
|
2222
|
+
self.altInput.tabIndex = self.input.tabIndex;
|
2223
|
+
self.altInput.type = "text";
|
2224
|
+
self.input.setAttribute("type", "hidden");
|
2225
|
+
if (!self.config.static && self.input.parentNode)
|
2226
|
+
self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
|
2227
|
+
}
|
2228
|
+
if (!self.config.allowInput)
|
2229
|
+
self._input.setAttribute("readonly", "readonly");
|
2230
|
+
self._positionElement = self.config.positionElement || self._input;
|
2231
|
+
}
|
2232
|
+
function setupMobile() {
|
2233
|
+
var inputType = self.config.enableTime
|
2234
|
+
? self.config.noCalendar
|
2235
|
+
? "time"
|
2236
|
+
: "datetime-local"
|
2237
|
+
: "date";
|
2238
|
+
self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
|
2239
|
+
self.mobileInput.step = self.input.getAttribute("step") || "any";
|
2240
|
+
self.mobileInput.tabIndex = 1;
|
2241
|
+
self.mobileInput.type = inputType;
|
2242
|
+
self.mobileInput.disabled = self.input.disabled;
|
2243
|
+
self.mobileInput.required = self.input.required;
|
2244
|
+
self.mobileInput.placeholder = self.input.placeholder;
|
2245
|
+
self.mobileFormatStr =
|
2246
|
+
inputType === "datetime-local"
|
2247
|
+
? "Y-m-d\\TH:i:S"
|
2248
|
+
: inputType === "date"
|
2249
|
+
? "Y-m-d"
|
2250
|
+
: "H:i:S";
|
2251
|
+
if (self.selectedDates.length > 0) {
|
2252
|
+
self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
|
2253
|
+
}
|
2254
|
+
if (self.config.minDate)
|
2255
|
+
self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
|
2256
|
+
if (self.config.maxDate)
|
2257
|
+
self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
|
2258
|
+
self.input.type = "hidden";
|
2259
|
+
if (self.altInput !== undefined)
|
2260
|
+
self.altInput.type = "hidden";
|
2261
|
+
try {
|
2262
|
+
if (self.input.parentNode)
|
2263
|
+
self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
|
2264
|
+
}
|
2265
|
+
catch (_a) { }
|
2266
|
+
bind(self.mobileInput, "change", function (e) {
|
2267
|
+
self.setDate(e.target.value, false, self.mobileFormatStr);
|
2268
|
+
triggerEvent("onChange");
|
2269
|
+
triggerEvent("onClose");
|
2270
|
+
});
|
1993
2271
|
}
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
}
|
2014
|
-
|
2015
|
-
function getDateStr(format) {
|
2016
|
-
return self.selectedDates.map(function (dObj) {
|
2017
|
-
return self.formatDate(dObj, format);
|
2018
|
-
}).filter(function (d, i, arr) {
|
2019
|
-
return self.config.mode !== "range" || self.config.enableTime || arr.indexOf(d) === i;
|
2020
|
-
}).join(self.config.mode !== "range" ? self.config.conjunction : self.l10n.rangeSeparator);
|
2021
|
-
}
|
2022
|
-
|
2023
|
-
function updateValue(triggerChange) {
|
2024
|
-
if (triggerChange === void 0) {
|
2025
|
-
triggerChange = true;
|
2272
|
+
function toggle(e) {
|
2273
|
+
if (self.isOpen === true)
|
2274
|
+
return self.close();
|
2275
|
+
self.open(e);
|
2276
|
+
}
|
2277
|
+
function triggerEvent(event, data) {
|
2278
|
+
// If the instance has been destroyed already, all hooks have been removed
|
2279
|
+
if (self.config === undefined)
|
2280
|
+
return;
|
2281
|
+
var hooks = self.config[event];
|
2282
|
+
if (hooks !== undefined && hooks.length > 0) {
|
2283
|
+
for (var i = 0; hooks[i] && i < hooks.length; i++)
|
2284
|
+
hooks[i](self.selectedDates, self.input.value, self, data);
|
2285
|
+
}
|
2286
|
+
if (event === "onChange") {
|
2287
|
+
self.input.dispatchEvent(createEvent("change"));
|
2288
|
+
// many front-end frameworks bind to the input event
|
2289
|
+
self.input.dispatchEvent(createEvent("input"));
|
2290
|
+
}
|
2026
2291
|
}
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
self.mobileInput.value = self.latestSelectedDateObj !== undefined ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr) : "";
|
2292
|
+
function createEvent(name) {
|
2293
|
+
var e = document.createEvent("Event");
|
2294
|
+
e.initEvent(name, true, true);
|
2295
|
+
return e;
|
2032
2296
|
}
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2297
|
+
function isDateSelected(date) {
|
2298
|
+
for (var i = 0; i < self.selectedDates.length; i++) {
|
2299
|
+
if (compareDates(self.selectedDates[i], date) === 0)
|
2300
|
+
return "" + i;
|
2301
|
+
}
|
2302
|
+
return false;
|
2303
|
+
}
|
2304
|
+
function isDateInRange(date) {
|
2305
|
+
if (self.config.mode !== "range" || self.selectedDates.length < 2)
|
2306
|
+
return false;
|
2307
|
+
return (compareDates(date, self.selectedDates[0]) >= 0 &&
|
2308
|
+
compareDates(date, self.selectedDates[1]) <= 0);
|
2309
|
+
}
|
2310
|
+
function updateNavigationCurrentMonth() {
|
2311
|
+
if (self.config.noCalendar || self.isMobile || !self.monthNav)
|
2312
|
+
return;
|
2313
|
+
self.yearElements.forEach(function (yearElement, i) {
|
2314
|
+
var d = new Date(self.currentYear, self.currentMonth, 1);
|
2315
|
+
d.setMonth(self.currentMonth + i);
|
2316
|
+
self.monthElements[i].textContent =
|
2317
|
+
monthToStr(d.getMonth(), self.config.shorthandCurrentMonth, self.l10n) +
|
2318
|
+
" ";
|
2319
|
+
yearElement.value = d.getFullYear().toString();
|
2320
|
+
});
|
2321
|
+
self._hidePrevMonthArrow =
|
2322
|
+
self.config.minDate !== undefined &&
|
2323
|
+
(self.currentYear === self.config.minDate.getFullYear()
|
2324
|
+
? self.currentMonth <= self.config.minDate.getMonth()
|
2325
|
+
: self.currentYear < self.config.minDate.getFullYear());
|
2326
|
+
self._hideNextMonthArrow =
|
2327
|
+
self.config.maxDate !== undefined &&
|
2328
|
+
(self.currentYear === self.config.maxDate.getFullYear()
|
2329
|
+
? self.currentMonth + 1 > self.config.maxDate.getMonth()
|
2330
|
+
: self.currentYear > self.config.maxDate.getFullYear());
|
2331
|
+
}
|
2332
|
+
function getDateStr(format) {
|
2333
|
+
return self.selectedDates
|
2334
|
+
.map(function (dObj) { return self.formatDate(dObj, format); })
|
2335
|
+
.filter(function (d, i, arr) {
|
2336
|
+
return self.config.mode !== "range" ||
|
2337
|
+
self.config.enableTime ||
|
2338
|
+
arr.indexOf(d) === i;
|
2339
|
+
})
|
2340
|
+
.join(self.config.mode !== "range"
|
2341
|
+
? self.config.conjunction
|
2342
|
+
: self.l10n.rangeSeparator);
|
2343
|
+
}
|
2344
|
+
/**
|
2345
|
+
* Updates the values of inputs associated with the calendar
|
2346
|
+
*/
|
2347
|
+
function updateValue(triggerChange) {
|
2348
|
+
if (triggerChange === void 0) { triggerChange = true; }
|
2349
|
+
if (self.selectedDates.length === 0)
|
2350
|
+
return self.clear(triggerChange);
|
2351
|
+
if (self.mobileInput !== undefined && self.mobileFormatStr) {
|
2352
|
+
self.mobileInput.value =
|
2353
|
+
self.latestSelectedDateObj !== undefined
|
2354
|
+
? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr)
|
2355
|
+
: "";
|
2356
|
+
}
|
2357
|
+
self.input.value = getDateStr(self.config.dateFormat);
|
2358
|
+
if (self.altInput !== undefined) {
|
2359
|
+
self.altInput.value = getDateStr(self.config.altFormat);
|
2360
|
+
}
|
2361
|
+
if (triggerChange !== false)
|
2362
|
+
triggerEvent("onValueUpdate");
|
2038
2363
|
}
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
self.changeYear(self.currentYear - 1);
|
2056
|
-
}
|
2057
|
-
}
|
2058
|
-
|
2059
|
-
function timeWrapper(e) {
|
2060
|
-
e.preventDefault();
|
2061
|
-
var isKeyDown = e.type === "keydown",
|
2062
|
-
input = e.target;
|
2063
|
-
|
2064
|
-
if (self.amPM !== undefined && e.target === self.amPM) {
|
2065
|
-
self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
|
2364
|
+
function onMonthNavClick(e) {
|
2365
|
+
e.preventDefault();
|
2366
|
+
var isPrevMonth = self.prevMonthNav.contains(e.target);
|
2367
|
+
var isNextMonth = self.nextMonthNav.contains(e.target);
|
2368
|
+
if (isPrevMonth || isNextMonth) {
|
2369
|
+
changeMonth(isPrevMonth ? -1 : 1);
|
2370
|
+
}
|
2371
|
+
else if (self.yearElements.indexOf(e.target) >= 0) {
|
2372
|
+
e.target.select();
|
2373
|
+
}
|
2374
|
+
else if (e.target.classList.contains("arrowUp")) {
|
2375
|
+
self.changeYear(self.currentYear + 1);
|
2376
|
+
}
|
2377
|
+
else if (e.target.classList.contains("arrowDown")) {
|
2378
|
+
self.changeYear(self.currentYear - 1);
|
2379
|
+
}
|
2066
2380
|
}
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
2074
|
-
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2381
|
+
function timeWrapper(e) {
|
2382
|
+
e.preventDefault();
|
2383
|
+
var isKeyDown = e.type === "keydown", input = e.target;
|
2384
|
+
if (self.amPM !== undefined && e.target === self.amPM) {
|
2385
|
+
self.amPM.textContent =
|
2386
|
+
self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
|
2387
|
+
}
|
2388
|
+
var min = parseFloat(input.getAttribute("min")), max = parseFloat(input.getAttribute("max")), step = parseFloat(input.getAttribute("step")), curValue = parseInt(input.value, 10), delta = e.delta ||
|
2389
|
+
(isKeyDown ? (e.which === 38 ? 1 : -1) : 0);
|
2390
|
+
var newValue = curValue + step * delta;
|
2391
|
+
if (typeof input.value !== "undefined" && input.value.length === 2) {
|
2392
|
+
var isHourElem = input === self.hourElement, isMinuteElem = input === self.minuteElement;
|
2393
|
+
if (newValue < min) {
|
2394
|
+
newValue =
|
2395
|
+
max +
|
2396
|
+
newValue +
|
2397
|
+
int(!isHourElem) +
|
2398
|
+
(int(isHourElem) && int(!self.amPM));
|
2399
|
+
if (isMinuteElem)
|
2400
|
+
incrementNumInput(undefined, -1, self.hourElement);
|
2401
|
+
}
|
2402
|
+
else if (newValue > max) {
|
2403
|
+
newValue =
|
2404
|
+
input === self.hourElement ? newValue - max - int(!self.amPM) : min;
|
2405
|
+
if (isMinuteElem)
|
2406
|
+
incrementNumInput(undefined, 1, self.hourElement);
|
2407
|
+
}
|
2408
|
+
if (self.amPM &&
|
2409
|
+
isHourElem &&
|
2410
|
+
(step === 1
|
2411
|
+
? newValue + curValue === 23
|
2412
|
+
: Math.abs(newValue - curValue) > step)) {
|
2413
|
+
self.amPM.textContent =
|
2414
|
+
self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
|
2415
|
+
}
|
2416
|
+
input.value = pad(newValue);
|
2417
|
+
}
|
2092
2418
|
}
|
2093
|
-
|
2094
|
-
|
2095
|
-
init();
|
2096
|
-
return self;
|
2419
|
+
init();
|
2420
|
+
return self;
|
2097
2421
|
}
|
2098
|
-
|
2422
|
+
/* istanbul ignore next */
|
2099
2423
|
function _flatpickr(nodeList, config) {
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
var
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2424
|
+
// static list
|
2425
|
+
var nodes = Array.prototype.slice
|
2426
|
+
.call(nodeList)
|
2427
|
+
.filter(function (x) { return x instanceof HTMLElement; });
|
2428
|
+
var instances = [];
|
2429
|
+
for (var i = 0; i < nodes.length; i++) {
|
2430
|
+
var node = nodes[i];
|
2431
|
+
try {
|
2432
|
+
if (node.getAttribute("data-fp-omit") !== null)
|
2433
|
+
continue;
|
2434
|
+
if (node._flatpickr !== undefined) {
|
2435
|
+
node._flatpickr.destroy();
|
2436
|
+
node._flatpickr = undefined;
|
2437
|
+
}
|
2438
|
+
node._flatpickr = FlatpickrInstance(node, config || {});
|
2439
|
+
instances.push(node._flatpickr);
|
2440
|
+
}
|
2441
|
+
catch (e) {
|
2442
|
+
console.error(e);
|
2443
|
+
}
|
2119
2444
|
}
|
2120
|
-
|
2121
|
-
|
2122
|
-
return instances.length === 1 ? instances[0] : instances;
|
2445
|
+
return instances.length === 1 ? instances[0] : instances;
|
2123
2446
|
}
|
2124
|
-
|
2447
|
+
/* istanbul ignore next */
|
2125
2448
|
if (typeof HTMLElement !== "undefined") {
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2449
|
+
// browser env
|
2450
|
+
HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function (config) {
|
2451
|
+
return _flatpickr(this, config);
|
2452
|
+
};
|
2453
|
+
HTMLElement.prototype.flatpickr = function (config) {
|
2454
|
+
return _flatpickr([this], config);
|
2455
|
+
};
|
2133
2456
|
}
|
2134
|
-
|
2135
|
-
var flatpickr = function
|
2136
|
-
|
2137
|
-
|
2457
|
+
/* istanbul ignore next */
|
2458
|
+
var flatpickr = function (selector, config) {
|
2459
|
+
if (typeof selector === "string") {
|
2460
|
+
return _flatpickr(window.document.querySelectorAll(selector), config);
|
2461
|
+
}
|
2462
|
+
else if (selector instanceof Node) {
|
2463
|
+
return _flatpickr([selector], config);
|
2464
|
+
}
|
2465
|
+
else {
|
2466
|
+
return _flatpickr(selector, config);
|
2467
|
+
}
|
2138
2468
|
};
|
2139
|
-
|
2469
|
+
/* istanbul ignore next */
|
2140
2470
|
flatpickr.defaultConfig = defaults;
|
2141
2471
|
flatpickr.l10ns = {
|
2142
|
-
|
2143
|
-
|
2472
|
+
en: __assign({}, english),
|
2473
|
+
"default": __assign({}, english)
|
2144
2474
|
};
|
2145
|
-
|
2146
2475
|
flatpickr.localize = function (l10n) {
|
2147
|
-
|
2476
|
+
flatpickr.l10ns["default"] = __assign({}, flatpickr.l10ns["default"], l10n);
|
2148
2477
|
};
|
2149
|
-
|
2150
2478
|
flatpickr.setDefaults = function (config) {
|
2151
|
-
|
2479
|
+
flatpickr.defaultConfig = __assign({}, flatpickr.defaultConfig, config);
|
2152
2480
|
};
|
2153
|
-
|
2154
2481
|
flatpickr.parseDate = createDateParser({});
|
2155
2482
|
flatpickr.formatDate = createDateFormatter({});
|
2156
2483
|
flatpickr.compareDates = compareDates;
|
2157
|
-
|
2484
|
+
/* istanbul ignore next */
|
2158
2485
|
if (typeof jQuery !== "undefined") {
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2486
|
+
jQuery.fn.flatpickr = function (config) {
|
2487
|
+
return _flatpickr(this, config);
|
2488
|
+
};
|
2162
2489
|
}
|
2163
|
-
|
2164
2490
|
Date.prototype.fp_incr = function (days) {
|
2165
|
-
|
2491
|
+
return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
|
2166
2492
|
};
|
2167
|
-
|
2168
2493
|
if (typeof window !== "undefined") {
|
2169
|
-
|
2494
|
+
window.flatpickr = flatpickr;
|
2170
2495
|
}
|
2171
2496
|
|
2172
2497
|
return flatpickr;
|
2173
2498
|
|
2174
|
-
}))
|
2499
|
+
}));
|