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