flatpickr 2.4.8.0 → 2.4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flatpickr/version.rb +1 -1
- data/vendor/assets/javascripts/flatpickr.js +307 -230
- data/vendor/assets/javascripts/flatpickr/l10n/gr.js +31 -0
- data/vendor/assets/javascripts/flatpickr/l10n/nl.js +4 -4
- data/vendor/assets/stylesheets/flatpickr.css +4 -4
- data/vendor/assets/stylesheets/flatpickr/rtl/flatpickr.min.css +13 -0
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/airbnb.rtl.css +332 -49
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/base16_flat.rtl.css +291 -36
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/confetti.rtl.css +294 -38
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/dark.rtl.css +294 -39
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/material_blue.rtl.css +301 -45
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/material_green.rtl.css +301 -45
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/material_orange.rtl.css +301 -45
- data/vendor/assets/stylesheets/flatpickr/rtl/themes/material_red.rtl.css +301 -45
- data/vendor/assets/stylesheets/flatpickr/themes/airbnb.css +308 -72
- data/vendor/assets/stylesheets/flatpickr/themes/base16_flat.css +267 -59
- data/vendor/assets/stylesheets/flatpickr/themes/confetti.css +270 -61
- data/vendor/assets/stylesheets/flatpickr/themes/dark.css +270 -62
- data/vendor/assets/stylesheets/flatpickr/themes/material_blue.css +277 -68
- data/vendor/assets/stylesheets/flatpickr/themes/material_green.css +277 -68
- data/vendor/assets/stylesheets/flatpickr/themes/material_orange.css +277 -68
- data/vendor/assets/stylesheets/flatpickr/themes/material_red.css +277 -68
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33093b7a0d2abc52114461f6fbb3938ae69fb5f9
|
4
|
+
data.tar.gz: 73449d002ee949526b352c3c43391fad49f88652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34589fe924dba58d1897abe91072bbc9028cea557b3f23a1f8528bf02577f07f35d2e256f4515eb6607bd925706ce907349b8d098fdd23b9c6e59bee90ddb4b4
|
7
|
+
data.tar.gz: dbbcbe66b55fc4eae32da2d24e797e9b51b2c15b9b79781332608cade9f29fc120720bad1bd2ca3f5909d7f2d3e409e5c93907eeaba4a968072be971aac6b151
|
data/lib/flatpickr/version.rb
CHANGED
@@ -2,10 +2,12 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
|
|
2
2
|
|
3
3
|
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
4
4
|
|
5
|
-
/*! flatpickr v2.4.
|
5
|
+
/*! flatpickr v2.4.9, @license MIT */
|
6
6
|
function Flatpickr(element, config) {
|
7
7
|
var self = this;
|
8
8
|
|
9
|
+
self._ = {};
|
10
|
+
self._.afterDayAnim = afterDayAnim;
|
9
11
|
self.changeMonth = changeMonth;
|
10
12
|
self.changeYear = changeYear;
|
11
13
|
self.clear = clear;
|
@@ -37,7 +39,7 @@ function Flatpickr(element, config) {
|
|
37
39
|
setupDates();
|
38
40
|
setupHelperFunctions();
|
39
41
|
|
40
|
-
self.isOpen =
|
42
|
+
self.isOpen = false;
|
41
43
|
|
42
44
|
self.isMobile = !self.config.disableMobile && !self.config.inline && self.config.mode === "single" && !self.config.disable.length && !self.config.enable.length && !self.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
43
45
|
|
@@ -53,18 +55,18 @@ function Flatpickr(element, config) {
|
|
53
55
|
}
|
54
56
|
|
55
57
|
if (self.config.weekNumbers) {
|
56
|
-
self.calendarContainer.style.width = self.
|
58
|
+
self.calendarContainer.style.width = self.daysContainer.clientWidth + self.weekWrapper.clientWidth + "px";
|
57
59
|
}
|
58
60
|
|
59
61
|
self.showTimeInput = self.selectedDates.length > 0 || self.config.noCalendar;
|
60
62
|
|
61
63
|
if (!self.isMobile) positionCalendar();
|
64
|
+
|
62
65
|
triggerEvent("Ready");
|
63
66
|
}
|
64
67
|
|
65
68
|
function bindToInstance(fn) {
|
66
|
-
|
67
|
-
return fn;
|
69
|
+
return fn.bind(self);
|
68
70
|
}
|
69
71
|
|
70
72
|
function updateTime(e) {
|
@@ -142,11 +144,6 @@ function Flatpickr(element, config) {
|
|
142
144
|
}
|
143
145
|
}
|
144
146
|
|
145
|
-
function onMonthScroll(e) {
|
146
|
-
e.preventDefault();
|
147
|
-
self.changeMonth(Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY)));
|
148
|
-
}
|
149
|
-
|
150
147
|
function bind() {
|
151
148
|
if (self.config.wrap) {
|
152
149
|
["open", "close", "toggle", "clear"].forEach(function (el) {
|
@@ -170,9 +167,11 @@ function Flatpickr(element, config) {
|
|
170
167
|
};
|
171
168
|
self.debouncedChange = debounce(self.triggerChange, 300);
|
172
169
|
|
173
|
-
if (self.config.mode === "range" && self.
|
170
|
+
if (self.config.mode === "range" && self.daysContainer) self.daysContainer.addEventListener("mouseover", function (e) {
|
171
|
+
return onMouseOver(e.target);
|
172
|
+
});
|
174
173
|
|
175
|
-
|
174
|
+
document.body.addEventListener("keydown", onKeyDown);
|
176
175
|
|
177
176
|
if (!self.config.static) (self.altInput || self.input).addEventListener("keydown", onKeyDown);
|
178
177
|
|
@@ -193,12 +192,13 @@ function Flatpickr(element, config) {
|
|
193
192
|
return changeMonth(1);
|
194
193
|
});
|
195
194
|
|
196
|
-
self.
|
197
|
-
|
198
|
-
});
|
199
|
-
self.currentYearElement.addEventListener("wheel", function (e) {
|
200
|
-
return debounce(yearScroll(e), 50);
|
195
|
+
self.monthNav.addEventListener("wheel", function (e) {
|
196
|
+
e.preventDefault();
|
201
197
|
});
|
198
|
+
|
199
|
+
self.monthNav.addEventListener("wheel", debounce(onMonthNavScroll, 10));
|
200
|
+
self.monthNav.addEventListener("click", onMonthNavClick);
|
201
|
+
|
202
202
|
self.currentYearElement.addEventListener("focus", function () {
|
203
203
|
self.currentYearElement.select();
|
204
204
|
});
|
@@ -206,14 +206,21 @@ function Flatpickr(element, config) {
|
|
206
206
|
self.currentYearElement.addEventListener("input", onYearInput);
|
207
207
|
self.currentYearElement.addEventListener("increment", onYearInput);
|
208
208
|
|
209
|
-
self.
|
209
|
+
self.daysContainer.addEventListener("click", selectDate);
|
210
|
+
|
211
|
+
if (self.config.animate) {
|
212
|
+
self.daysContainer.addEventListener("animationend", animateDays);
|
213
|
+
self.monthNav.addEventListener("animationend", animateMonths);
|
214
|
+
|
215
|
+
self.daysContainer.addEventListener("webkitAnimationEnd", animateDays);
|
216
|
+
self.monthNav.addEventListener("webkitAnimationEnd", animateMonths);
|
217
|
+
}
|
210
218
|
}
|
211
219
|
|
212
220
|
if (self.config.enableTime) {
|
213
|
-
self.timeContainer.addEventListener("
|
214
|
-
|
215
|
-
|
216
|
-
});
|
221
|
+
self.timeContainer.addEventListener("wheel", updateTime);
|
222
|
+
|
223
|
+
self.timeContainer.addEventListener("click", timeIncrement);
|
217
224
|
self.timeContainer.addEventListener("input", updateTime);
|
218
225
|
self.timeContainer.addEventListener("increment", updateTime);
|
219
226
|
self.timeContainer.addEventListener("increment", self.debouncedChange);
|
@@ -243,6 +250,41 @@ function Flatpickr(element, config) {
|
|
243
250
|
}
|
244
251
|
}
|
245
252
|
|
253
|
+
function animateDays(e) {
|
254
|
+
if (self.daysContainer.childNodes.length > 1) {
|
255
|
+
switch (e.animationName) {
|
256
|
+
case "slideLeft":
|
257
|
+
self.daysContainer.lastChild.classList.remove("slideLeftNew");
|
258
|
+
self.daysContainer.removeChild(self.daysContainer.firstChild);
|
259
|
+
self.days = self.daysContainer.firstChild;
|
260
|
+
|
261
|
+
break;
|
262
|
+
|
263
|
+
case "slideRight":
|
264
|
+
self.daysContainer.firstChild.classList.remove("slideRightNew");
|
265
|
+
self.daysContainer.removeChild(self.daysContainer.lastChild);
|
266
|
+
self.days = self.daysContainer.firstChild;
|
267
|
+
|
268
|
+
break;
|
269
|
+
|
270
|
+
default:
|
271
|
+
break;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}
|
275
|
+
|
276
|
+
function animateMonths(e) {
|
277
|
+
switch (e.animationName) {
|
278
|
+
case "slideLeft":
|
279
|
+
case "slideRight":
|
280
|
+
self.navigationCurrentMonth.classList.remove("slideLeftNew");
|
281
|
+
self.navigationCurrentMonth.classList.remove("slideRightNew");
|
282
|
+
self.monthNav.removeChild(self.oldCurMonth);
|
283
|
+
self.oldCurMonth = null;
|
284
|
+
break;
|
285
|
+
}
|
286
|
+
}
|
287
|
+
|
246
288
|
function jumpToDate(jumpDate) {
|
247
289
|
jumpDate = jumpDate ? self.parseDate(jumpDate) : self.latestSelectedDateObj || (self.config.minDate > self.now ? self.config.minDate : self.config.maxDate && self.config.maxDate < self.now ? self.config.maxDate : self.now);
|
248
290
|
|
@@ -259,6 +301,10 @@ function Flatpickr(element, config) {
|
|
259
301
|
self.redraw();
|
260
302
|
}
|
261
303
|
|
304
|
+
function timeIncrement(e) {
|
305
|
+
if (~e.target.className.indexOf("arrow")) incrementNumInput(e, e.target.classList.contains("arrowUp") ? 1 : -1);
|
306
|
+
}
|
307
|
+
|
262
308
|
function incrementNumInput(e, delta, inputElem) {
|
263
309
|
var input = inputElem || e.target.parentNode.childNodes[0];
|
264
310
|
var ev = void 0;
|
@@ -282,22 +328,18 @@ function Flatpickr(element, config) {
|
|
282
328
|
|
283
329
|
numInput.type = "text";
|
284
330
|
numInput.pattern = "\\d*";
|
331
|
+
|
285
332
|
wrapper.appendChild(numInput);
|
286
333
|
wrapper.appendChild(arrowUp);
|
287
334
|
wrapper.appendChild(arrowDown);
|
288
335
|
|
289
|
-
arrowUp.addEventListener("click", function (e) {
|
290
|
-
return incrementNumInput(e, 1);
|
291
|
-
});
|
292
|
-
arrowDown.addEventListener("click", function (e) {
|
293
|
-
return incrementNumInput(e, -1);
|
294
|
-
});
|
295
336
|
return wrapper;
|
296
337
|
}
|
297
338
|
|
298
339
|
function build() {
|
299
340
|
var fragment = window.document.createDocumentFragment();
|
300
341
|
self.calendarContainer = createElement("div", "flatpickr-calendar");
|
342
|
+
self.calendarContainer.tabIndex = -1;
|
301
343
|
self.numInputType = navigator.userAgent.indexOf("MSIE 9.0") > 0 ? "text" : "number";
|
302
344
|
|
303
345
|
if (!self.config.noCalendar) {
|
@@ -309,13 +351,13 @@ function Flatpickr(element, config) {
|
|
309
351
|
self.rContainer = createElement("div", "flatpickr-rContainer");
|
310
352
|
self.rContainer.appendChild(buildWeekdays());
|
311
353
|
|
312
|
-
if (!self.
|
313
|
-
self.
|
314
|
-
self.
|
354
|
+
if (!self.daysContainer) {
|
355
|
+
self.daysContainer = createElement("div", "flatpickr-days");
|
356
|
+
self.daysContainer.tabIndex = -1;
|
315
357
|
}
|
316
358
|
|
317
359
|
buildDays();
|
318
|
-
self.rContainer.appendChild(self.
|
360
|
+
self.rContainer.appendChild(self.daysContainer);
|
319
361
|
|
320
362
|
self.innerContainer.appendChild(self.rContainer);
|
321
363
|
fragment.appendChild(self.innerContainer);
|
@@ -323,7 +365,8 @@ function Flatpickr(element, config) {
|
|
323
365
|
|
324
366
|
if (self.config.enableTime) fragment.appendChild(buildTime());
|
325
367
|
|
326
|
-
|
368
|
+
toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
|
369
|
+
toggleClass(self.calendarContainer, "animate", self.config.animate);
|
327
370
|
|
328
371
|
self.calendarContainer.appendChild(fragment);
|
329
372
|
|
@@ -396,26 +439,42 @@ function Flatpickr(element, config) {
|
|
396
439
|
}
|
397
440
|
|
398
441
|
function focusOnDay(currentIndex, offset) {
|
399
|
-
if (currentIndex === undefined) return (self.todayDateElem || self.days.childNodes[0]).focus();
|
400
|
-
|
401
442
|
var newIndex = currentIndex + offset || 0,
|
402
|
-
targetNode = self.days.childNodes[newIndex]
|
443
|
+
targetNode = currentIndex !== undefined ? self.days.childNodes[newIndex] : self.selectedDateElem || self.todayDateElem || self.days.childNodes[0],
|
444
|
+
focus = function focus() {
|
445
|
+
targetNode = targetNode || self.days.childNodes[newIndex];
|
446
|
+
targetNode.focus();
|
403
447
|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
448
|
+
if (self.config.mode === "range") onMouseOver(targetNode);
|
449
|
+
};
|
450
|
+
|
451
|
+
if (targetNode === undefined && offset !== 0) {
|
452
|
+
if (offset > 0) {
|
453
|
+
self.changeMonth(1);
|
454
|
+
newIndex = newIndex % 42;
|
455
|
+
} else if (offset < 0) {
|
456
|
+
self.changeMonth(-1);
|
457
|
+
newIndex += 42;
|
458
|
+
}
|
459
|
+
|
460
|
+
return afterDayAnim(focus);
|
410
461
|
}
|
462
|
+
|
463
|
+
focus();
|
411
464
|
}
|
412
465
|
|
413
|
-
function
|
466
|
+
function afterDayAnim(fn) {
|
467
|
+
if (self.config.animate) return setTimeout(fn, self._.daysAnimDuration + 1);
|
468
|
+
fn();
|
469
|
+
}
|
470
|
+
|
471
|
+
function buildDays(delta) {
|
414
472
|
var firstOfMonth = (new Date(self.currentYear, self.currentMonth, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7,
|
415
473
|
isRangeMode = self.config.mode === "range";
|
416
474
|
|
417
475
|
self.prevMonthDays = self.utils.getDaysinMonth((self.currentMonth - 1 + 12) % 12);
|
418
|
-
self.
|
476
|
+
self.selectedDateElem = undefined;
|
477
|
+
self.todayDateElem = undefined;
|
419
478
|
|
420
479
|
var daysInMonth = self.utils.getDaysinMonth(),
|
421
480
|
days = window.document.createDocumentFragment();
|
@@ -431,8 +490,6 @@ function Flatpickr(element, config) {
|
|
431
490
|
self.maxRangeDate = new Date(self.currentYear, self.currentMonth + 1, (42 - firstOfMonth) % daysInMonth);
|
432
491
|
}
|
433
492
|
|
434
|
-
if (self.days.firstChild) self.days.textContent = "";
|
435
|
-
|
436
493
|
// prepend days from the ending of previous month
|
437
494
|
for (; dayNumber <= self.prevMonthDays; dayNumber++, dayIndex++) {
|
438
495
|
days.appendChild(createDay("prevMonthDay", new Date(self.currentYear, self.currentMonth - 1, dayNumber), dayNumber, dayIndex));
|
@@ -454,8 +511,25 @@ function Flatpickr(element, config) {
|
|
454
511
|
self._hideNextMonthArrow = self._hideNextMonthArrow || self.maxRangeDate < new Date(self.currentYear, self.currentMonth + 1, 1);
|
455
512
|
} else updateNavigationCurrentMonth();
|
456
513
|
|
457
|
-
|
458
|
-
|
514
|
+
var dayContainer = createElement("div", "dayContainer");
|
515
|
+
dayContainer.appendChild(days);
|
516
|
+
|
517
|
+
if (!self.config.animate || delta === undefined) clearNode(self.daysContainer);else {
|
518
|
+
while (self.daysContainer.childNodes.length > 1) {
|
519
|
+
self.daysContainer.removeChild(self.daysContainer.firstChild);
|
520
|
+
}
|
521
|
+
}
|
522
|
+
|
523
|
+
if (delta >= 0) self.daysContainer.appendChild(dayContainer);else self.daysContainer.insertBefore(dayContainer, self.daysContainer.firstChild);
|
524
|
+
|
525
|
+
self.days = self.daysContainer.firstChild;
|
526
|
+
return self.daysContainer;
|
527
|
+
}
|
528
|
+
|
529
|
+
function clearNode(node) {
|
530
|
+
while (node.firstChild) {
|
531
|
+
node.removeChild(node.firstChild);
|
532
|
+
}
|
459
533
|
}
|
460
534
|
|
461
535
|
function buildMonthNav() {
|
@@ -606,9 +680,10 @@ function Flatpickr(element, config) {
|
|
606
680
|
return self.weekWrapper;
|
607
681
|
}
|
608
682
|
|
609
|
-
function changeMonth(value, is_offset) {
|
610
|
-
is_offset =
|
683
|
+
function changeMonth(value, is_offset, animate) {
|
684
|
+
is_offset = is_offset === undefined || is_offset;
|
611
685
|
var delta = is_offset ? value : value - self.currentMonth;
|
686
|
+
var skipAnimations = !self.config.animate || animate === false;
|
612
687
|
|
613
688
|
if (delta < 0 && self._hidePrevMonthArrow || delta > 0 && self._hideNextMonthArrow) return;
|
614
689
|
|
@@ -621,10 +696,43 @@ function Flatpickr(element, config) {
|
|
621
696
|
triggerEvent("YearChange");
|
622
697
|
}
|
623
698
|
|
699
|
+
buildDays(!skipAnimations ? delta : undefined);
|
700
|
+
|
701
|
+
if (skipAnimations) {
|
702
|
+
triggerEvent("MonthChange");
|
703
|
+
return updateNavigationCurrentMonth();
|
704
|
+
}
|
705
|
+
|
706
|
+
self.oldCurMonth = self.navigationCurrentMonth;
|
707
|
+
self.navigationCurrentMonth = self.monthNav.insertBefore(self.oldCurMonth.cloneNode(true), delta > 0 ? self.oldCurMonth.nextSibling : self.oldCurMonth);
|
708
|
+
|
709
|
+
if (delta > 0) {
|
710
|
+
self.daysContainer.firstChild.classList.add("slideLeft");
|
711
|
+
self.daysContainer.lastChild.classList.add("slideLeftNew");
|
712
|
+
|
713
|
+
self.oldCurMonth.classList.add("slideLeft");
|
714
|
+
self.navigationCurrentMonth.classList.add("slideLeftNew");
|
715
|
+
} else if (delta < 0) {
|
716
|
+
self.daysContainer.firstChild.classList.add("slideRightNew");
|
717
|
+
self.daysContainer.lastChild.classList.add("slideRight");
|
718
|
+
|
719
|
+
self.oldCurMonth.classList.add("slideRight");
|
720
|
+
self.navigationCurrentMonth.classList.add("slideRightNew");
|
721
|
+
}
|
722
|
+
|
723
|
+
self.currentMonthElement = self.navigationCurrentMonth.firstChild;
|
724
|
+
self.currentYearElement = self.navigationCurrentMonth.lastChild.childNodes[0];
|
725
|
+
|
624
726
|
updateNavigationCurrentMonth();
|
625
|
-
|
727
|
+
self.oldCurMonth.firstChild.textContent = self.utils.monthToStr(self.currentMonth - delta);
|
728
|
+
|
729
|
+
if (self._.daysAnimDuration === undefined) {
|
730
|
+
var compStyle = window.getComputedStyle(self.daysContainer.lastChild);
|
731
|
+
|
732
|
+
var duration = compStyle.getPropertyValue("animation-duration") || compStyle.getPropertyValue("-webkit-animation-duration");
|
626
733
|
|
627
|
-
|
734
|
+
self._.daysAnimDuration = parseInt(/(\d+)s/.exec(duration)[1]);
|
735
|
+
}
|
628
736
|
}
|
629
737
|
|
630
738
|
function clear(triggerChangeEvent) {
|
@@ -666,8 +774,6 @@ function Flatpickr(element, config) {
|
|
666
774
|
window.document.removeEventListener("touchstart", documentClick);
|
667
775
|
window.document.removeEventListener("blur", documentClick);
|
668
776
|
|
669
|
-
if (instance.timeContainer) instance.timeContainer.removeEventListener("transitionend", positionCalendar);
|
670
|
-
|
671
777
|
if (instance.mobileInput) {
|
672
778
|
if (instance.mobileInput.parentNode) instance.mobileInput.parentNode.removeChild(instance.mobileInput);
|
673
779
|
delete instance.mobileInput;
|
@@ -735,14 +841,11 @@ function Flatpickr(element, config) {
|
|
735
841
|
}
|
736
842
|
|
737
843
|
function isEnabled(date, timeless) {
|
738
|
-
|
739
|
-
var gtmax = compareDates(date, self.config.maxDate, typeof timeless !== "undefined" ? timeless : !self.maxDateHasTime) > 0;
|
740
|
-
|
741
|
-
if (ltmin || gtmax) return false;
|
844
|
+
if (self.config.minDate && compareDates(date, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0 || self.config.maxDate && compareDates(date, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0) return false;
|
742
845
|
|
743
846
|
if (!self.config.enable.length && !self.config.disable.length) return true;
|
744
847
|
|
745
|
-
var dateToCheck = self.parseDate(date, true); // timeless
|
848
|
+
var dateToCheck = self.parseDate(date, null, true); // timeless
|
746
849
|
|
747
850
|
var bool = self.config.enable.length > 0,
|
748
851
|
array = bool ? self.config.enable : self.config.disable;
|
@@ -753,7 +856,7 @@ function Flatpickr(element, config) {
|
|
753
856
|
if (d instanceof Function && d(dateToCheck)) // disabled by function
|
754
857
|
return bool;else if (d instanceof Date && d.getTime() === dateToCheck.getTime())
|
755
858
|
// disabled by date
|
756
|
-
return bool;else if (typeof d === "string" && self.parseDate(d, true).getTime() === dateToCheck.getTime())
|
859
|
+
return bool;else if (typeof d === "string" && self.parseDate(d, null, true).getTime() === dateToCheck.getTime())
|
757
860
|
// disabled by date string
|
758
861
|
return bool;else if ( // disabled by range
|
759
862
|
(typeof d === "undefined" ? "undefined" : _typeof(d)) === "object" && d.from && d.to && dateToCheck >= d.from && dateToCheck <= d.to) return bool;
|
@@ -763,10 +866,17 @@ function Flatpickr(element, config) {
|
|
763
866
|
}
|
764
867
|
|
765
868
|
function onKeyDown(e) {
|
766
|
-
|
869
|
+
var isInput = e.target === (self.altInput || self.input);
|
870
|
+
var calendarElem = isCalendarElem(e.target);
|
871
|
+
|
872
|
+
if (e.key === "Enter" && self.config.allowInput && isInput) {
|
873
|
+
self.setDate((self.altInput || self.input).value, true, e.target === self.altInput ? self.config.altFormat : self.config.dateFormat);
|
874
|
+
return e.target.blur();
|
875
|
+
} else if (self.isOpen || self.config.inline && (isInput || calendarElem)) {
|
876
|
+
var isTimeObj = self.timeContainer && self.timeContainer.contains(e.target);
|
767
877
|
switch (e.key) {
|
768
878
|
case "Enter":
|
769
|
-
if (
|
879
|
+
if (isTimeObj) updateValue();else selectDate(e);
|
770
880
|
|
771
881
|
break;
|
772
882
|
|
@@ -777,38 +887,36 @@ function Flatpickr(element, config) {
|
|
777
887
|
break;
|
778
888
|
|
779
889
|
case "ArrowLeft":
|
780
|
-
e.preventDefault();
|
781
|
-
if (!e.ctrlKey) focusOnDay(e.target.$i, -1);else {
|
782
|
-
changeMonth(-1, true);
|
783
|
-
focusOnDay(e.target.$i, 0);
|
784
|
-
}
|
785
|
-
|
786
|
-
break;
|
787
|
-
|
788
890
|
case "ArrowRight":
|
789
891
|
e.preventDefault();
|
790
|
-
if (!e.ctrlKey) focusOnDay(e.target.$i, 1);else {
|
791
|
-
changeMonth(1, true);
|
792
|
-
focusOnDay(e.target.$i, 0);
|
793
|
-
}
|
794
892
|
|
795
|
-
|
893
|
+
if (self.daysContainer) {
|
894
|
+
var _delta = e.key === "ArrowRight" ? 1 : -1;
|
796
895
|
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
896
|
+
if (!e.ctrlKey) focusOnDay(e.target.$i, _delta);else {
|
897
|
+
changeMonth(_delta, true);
|
898
|
+
afterDayAnim(function () {
|
899
|
+
focusOnDay(e.target.$i, 0);
|
900
|
+
});
|
901
|
+
}
|
902
|
+
} else if (self.config.enableTime && !isTimeObj) self.hourElement.focus();
|
803
903
|
|
804
904
|
break;
|
805
905
|
|
906
|
+
case "ArrowUp":
|
806
907
|
case "ArrowDown":
|
807
908
|
e.preventDefault();
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
909
|
+
var delta = e.key === "ArrowDown" ? 1 : -1;
|
910
|
+
|
911
|
+
if (self.daysContainer) {
|
912
|
+
if (e.ctrlKey) {
|
913
|
+
changeYear(self.currentYear - delta);
|
914
|
+
focusOnDay(e.target.$i, 0);
|
915
|
+
} else if (!isTimeObj) focusOnDay(e.target.$i, delta * 7);
|
916
|
+
} else if (self.config.enableTime) {
|
917
|
+
if (!isTimeObj) self.hourElement.focus();
|
918
|
+
updateTime(e);
|
919
|
+
}
|
812
920
|
|
813
921
|
break;
|
814
922
|
|
@@ -848,11 +956,11 @@ function Flatpickr(element, config) {
|
|
848
956
|
}
|
849
957
|
}
|
850
958
|
|
851
|
-
function onMouseOver(
|
852
|
-
if (self.selectedDates.length !== 1 || !
|
959
|
+
function onMouseOver(elem) {
|
960
|
+
if (self.selectedDates.length !== 1 || !elem.classList.contains("flatpickr-day")) return;
|
853
961
|
|
854
|
-
var hoverDate =
|
855
|
-
initialDate = self.parseDate(self.selectedDates[0], true),
|
962
|
+
var hoverDate = elem.dateObj,
|
963
|
+
initialDate = self.parseDate(self.selectedDates[0], null, true),
|
856
964
|
rangeStartDate = Math.min(hoverDate.getTime(), self.selectedDates[0].getTime()),
|
857
965
|
rangeEndDate = Math.max(hoverDate.getTime(), self.selectedDates[0].getTime()),
|
858
966
|
containsDisabled = false;
|
@@ -865,26 +973,29 @@ function Flatpickr(element, config) {
|
|
865
973
|
}
|
866
974
|
|
867
975
|
var _loop = function _loop(timestamp, i) {
|
868
|
-
var outOfRange = timestamp < self.minRangeDate.getTime() || timestamp > self.maxRangeDate.getTime()
|
976
|
+
var outOfRange = timestamp < self.minRangeDate.getTime() || timestamp > self.maxRangeDate.getTime(),
|
977
|
+
dayElem = self.days.childNodes[i];
|
869
978
|
|
870
979
|
if (outOfRange) {
|
871
980
|
self.days.childNodes[i].classList.add("notAllowed");
|
872
981
|
["inRange", "startRange", "endRange"].forEach(function (c) {
|
873
|
-
|
982
|
+
dayElem.classList.remove(c);
|
874
983
|
});
|
875
984
|
return "continue";
|
876
985
|
} else if (containsDisabled && !outOfRange) return "continue";
|
877
986
|
|
878
987
|
["startRange", "inRange", "endRange", "notAllowed"].forEach(function (c) {
|
879
|
-
|
988
|
+
dayElem.classList.remove(c);
|
880
989
|
});
|
881
990
|
|
882
991
|
var minRangeDate = Math.max(self.minRangeDate.getTime(), rangeStartDate),
|
883
992
|
maxRangeDate = Math.min(self.maxRangeDate.getTime(), rangeEndDate);
|
884
993
|
|
885
|
-
|
994
|
+
elem.classList.add(hoverDate < self.selectedDates[0] ? "startRange" : "endRange");
|
886
995
|
|
887
|
-
if (initialDate
|
996
|
+
if (initialDate < hoverDate && timestamp === initialDate.getTime()) dayElem.classList.add("startRange");else if (initialDate > hoverDate && timestamp === initialDate.getTime()) dayElem.classList.add("endRange");
|
997
|
+
|
998
|
+
if (timestamp >= minRangeDate && timestamp <= maxRangeDate) dayElem.classList.add("inRange");
|
888
999
|
};
|
889
1000
|
|
890
1001
|
for (var timestamp = self.days.childNodes[0].dateObj.getTime(), i = 0; i < 42; i++, timestamp += self.utils.duration.DAY) {
|
@@ -942,7 +1053,7 @@ function Flatpickr(element, config) {
|
|
942
1053
|
updateValue();
|
943
1054
|
}
|
944
1055
|
|
945
|
-
if (self.
|
1056
|
+
if (self.daysContainer) {
|
946
1057
|
redraw();
|
947
1058
|
|
948
1059
|
if (isValidDate) self.currentYearElement[type] = dateObj.getFullYear();else self.currentYearElement.removeAttribute(type);
|
@@ -999,7 +1110,7 @@ function Flatpickr(element, config) {
|
|
999
1110
|
var pluginConf = self.config.plugins[_i2](self) || {};
|
1000
1111
|
for (var key in pluginConf) {
|
1001
1112
|
|
1002
|
-
if (
|
1113
|
+
if ((self.config[key] || ~hooks.indexOf(key)) instanceof Array) {
|
1003
1114
|
self.config[key] = arrayify(pluginConf[key]).map(bindToInstance).concat(self.config[key]);
|
1004
1115
|
} else if (typeof userConfig[key] === "undefined") self.config[key] = pluginConf[key];
|
1005
1116
|
}
|
@@ -1014,8 +1125,8 @@ function Flatpickr(element, config) {
|
|
1014
1125
|
self.l10n = _extends(Object.create(Flatpickr.l10ns.default), _typeof(self.config.locale) === "object" ? self.config.locale : self.config.locale !== "default" ? Flatpickr.l10ns[self.config.locale] || {} : {});
|
1015
1126
|
}
|
1016
1127
|
|
1017
|
-
function positionCalendar(
|
1018
|
-
if (
|
1128
|
+
function positionCalendar() {
|
1129
|
+
if (self.calendarContainer === undefined) return;
|
1019
1130
|
|
1020
1131
|
var calendarHeight = self.calendarContainer.offsetHeight,
|
1021
1132
|
calendarWidth = self.calendarContainer.offsetWidth,
|
@@ -1063,15 +1174,12 @@ function Flatpickr(element, config) {
|
|
1063
1174
|
e.preventDefault();
|
1064
1175
|
e.stopPropagation();
|
1065
1176
|
|
1066
|
-
if (self.config.allowInput && e.key === "Enter" && e.target === (self.altInput || self.input)) {
|
1067
|
-
self.setDate((self.altInput || self.input).value, true, e.target === self.altInput ? self.config.altFormat : self.config.dateFormat);
|
1068
|
-
return e.target.blur();
|
1069
|
-
}
|
1070
|
-
|
1071
1177
|
if (!e.target.classList.contains("flatpickr-day") || e.target.classList.contains("disabled") || e.target.classList.contains("notAllowed")) return;
|
1072
1178
|
|
1073
1179
|
var selectedDate = self.latestSelectedDateObj = new Date(e.target.dateObj.getTime());
|
1074
1180
|
|
1181
|
+
var shouldChangeMonth = selectedDate.getMonth() !== self.currentMonth && self.config.mode !== "range";
|
1182
|
+
|
1075
1183
|
self.selectedDateElem = e.target;
|
1076
1184
|
|
1077
1185
|
if (self.config.mode === "single") self.selectedDates = [selectedDate];else if (self.config.mode === "multiple") {
|
@@ -1090,7 +1198,7 @@ function Flatpickr(element, config) {
|
|
1090
1198
|
|
1091
1199
|
setHoursFromInputs();
|
1092
1200
|
|
1093
|
-
if (
|
1201
|
+
if (shouldChangeMonth) {
|
1094
1202
|
var isNewYear = self.currentYear !== selectedDate.getFullYear();
|
1095
1203
|
self.currentYear = selectedDate.getFullYear();
|
1096
1204
|
self.currentMonth = selectedDate.getMonth();
|
@@ -1106,13 +1214,13 @@ function Flatpickr(element, config) {
|
|
1106
1214
|
|
1107
1215
|
updateValue();
|
1108
1216
|
|
1109
|
-
setTimeout(function () {
|
1217
|
+
if (self.config.enableTime) setTimeout(function () {
|
1110
1218
|
return self.showTimeInput = true;
|
1111
1219
|
}, 50);
|
1112
1220
|
|
1113
1221
|
if (self.config.mode === "range") {
|
1114
1222
|
if (self.selectedDates.length === 1) {
|
1115
|
-
onMouseOver(e);
|
1223
|
+
onMouseOver(e.target);
|
1116
1224
|
|
1117
1225
|
self._hidePrevMonthArrow = self._hidePrevMonthArrow || self.minRangeDate > self.days.childNodes[0].dateObj;
|
1118
1226
|
|
@@ -1123,13 +1231,18 @@ function Flatpickr(element, config) {
|
|
1123
1231
|
}
|
1124
1232
|
}
|
1125
1233
|
|
1234
|
+
triggerEvent("Change");
|
1235
|
+
|
1236
|
+
// maintain focus
|
1237
|
+
if (!shouldChangeMonth) focusOnDay(e.target.$i, 0);else afterDayAnim(function () {
|
1238
|
+
return self.selectedDateElem.focus();
|
1239
|
+
});
|
1240
|
+
|
1126
1241
|
if (self.config.enableTime) setTimeout(function () {
|
1127
1242
|
return self.hourElement.select();
|
1128
1243
|
}, 451);
|
1129
1244
|
|
1130
1245
|
if (self.config.mode === "single" && !self.config.enableTime) self.close();
|
1131
|
-
|
1132
|
-
triggerEvent("Change");
|
1133
1246
|
}
|
1134
1247
|
|
1135
1248
|
function set(option, value) {
|
@@ -1139,23 +1252,23 @@ function Flatpickr(element, config) {
|
|
1139
1252
|
}
|
1140
1253
|
|
1141
1254
|
function setSelectedDate(inputDate, format) {
|
1142
|
-
if (Array
|
1143
|
-
return self.parseDate(d,
|
1144
|
-
});else if (inputDate instanceof Date || !isNaN(inputDate)) self.selectedDates = [self.parseDate(inputDate)];else if (inputDate && inputDate.substring) {
|
1255
|
+
if (inputDate instanceof Array) self.selectedDates = inputDate.map(function (d) {
|
1256
|
+
return self.parseDate(d, format);
|
1257
|
+
});else if (inputDate instanceof Date || !isNaN(inputDate)) self.selectedDates = [self.parseDate(inputDate, format)];else if (inputDate && inputDate.substring) {
|
1145
1258
|
switch (self.config.mode) {
|
1146
1259
|
case "single":
|
1147
|
-
self.selectedDates = [self.parseDate(inputDate,
|
1260
|
+
self.selectedDates = [self.parseDate(inputDate, format)];
|
1148
1261
|
break;
|
1149
1262
|
|
1150
1263
|
case "multiple":
|
1151
1264
|
self.selectedDates = inputDate.split("; ").map(function (date) {
|
1152
|
-
return self.parseDate(date,
|
1265
|
+
return self.parseDate(date, format);
|
1153
1266
|
});
|
1154
1267
|
break;
|
1155
1268
|
|
1156
1269
|
case "range":
|
1157
1270
|
self.selectedDates = inputDate.split(self.l10n.rangeSeparator).map(function (date) {
|
1158
|
-
return self.parseDate(date,
|
1271
|
+
return self.parseDate(date, format);
|
1159
1272
|
});
|
1160
1273
|
|
1161
1274
|
break;
|
@@ -1194,7 +1307,7 @@ function Flatpickr(element, config) {
|
|
1194
1307
|
function setupDates() {
|
1195
1308
|
function parseDateRules(arr) {
|
1196
1309
|
for (var i = arr.length; i--;) {
|
1197
|
-
if (typeof arr[i] === "string" || +arr[i]) arr[i] = self.parseDate(arr[i], true);else if (arr[i] && arr[i].from && arr[i].to) {
|
1310
|
+
if (typeof arr[i] === "string" || +arr[i]) arr[i] = self.parseDate(arr[i], null, true);else if (arr[i] && arr[i].from && arr[i].to) {
|
1198
1311
|
arr[i].from = self.parseDate(arr[i].from);
|
1199
1312
|
arr[i].to = self.parseDate(arr[i].to);
|
1200
1313
|
}
|
@@ -1212,7 +1325,8 @@ function Flatpickr(element, config) {
|
|
1212
1325
|
|
1213
1326
|
if (self.config.enable.length) self.config.enable = parseDateRules(self.config.enable);
|
1214
1327
|
|
1215
|
-
|
1328
|
+
var preloadedDate = self.config.defaultDate || self.input.value;
|
1329
|
+
if (preloadedDate) setSelectedDate(preloadedDate, self.config.dateFormat);
|
1216
1330
|
|
1217
1331
|
var initialDate = self.selectedDates.length ? self.selectedDates[0] : self.config.minDate && self.config.minDate.getTime() > self.now ? self.config.minDate : self.config.maxDate && self.config.maxDate.getTime() < self.now ? self.config.maxDate : self.now;
|
1218
1332
|
|
@@ -1242,6 +1356,7 @@ function Flatpickr(element, config) {
|
|
1242
1356
|
set: function set(bool) {
|
1243
1357
|
self._showTimeInput = bool;
|
1244
1358
|
if (self.calendarContainer) toggleClass(self.calendarContainer, "showTimeInput", bool);
|
1359
|
+
positionCalendar();
|
1245
1360
|
}
|
1246
1361
|
});
|
1247
1362
|
}
|
@@ -1332,15 +1447,15 @@ function Flatpickr(element, config) {
|
|
1332
1447
|
}
|
1333
1448
|
|
1334
1449
|
self.mobileInput.addEventListener("change", function (e) {
|
1335
|
-
self.
|
1336
|
-
self.setDate(self.latestSelectedDateObj);
|
1450
|
+
self.setDate(e.target.value, false, self.mobileFormatStr);
|
1337
1451
|
triggerEvent("Change");
|
1338
1452
|
triggerEvent("Close");
|
1339
1453
|
});
|
1340
1454
|
}
|
1341
1455
|
|
1342
1456
|
function toggle() {
|
1343
|
-
if (self.isOpen) self.close();
|
1457
|
+
if (self.isOpen) return self.close();
|
1458
|
+
self.open();
|
1344
1459
|
}
|
1345
1460
|
|
1346
1461
|
function triggerEvent(event, data) {
|
@@ -1415,14 +1530,27 @@ function Flatpickr(element, config) {
|
|
1415
1530
|
triggerEvent("ValueUpdate");
|
1416
1531
|
}
|
1417
1532
|
|
1418
|
-
function
|
1533
|
+
function mouseDelta(e) {
|
1534
|
+
return Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY));
|
1535
|
+
}
|
1536
|
+
|
1537
|
+
function onMonthNavScroll(e) {
|
1419
1538
|
e.preventDefault();
|
1539
|
+
var isYear = self.currentYearElement.parentNode.contains(e.target);
|
1540
|
+
|
1541
|
+
if (e.target === self.currentMonthElement || isYear) {
|
1420
1542
|
|
1421
|
-
|
1422
|
-
newYear = parseInt(e.target.value, 10) + delta;
|
1543
|
+
var delta = mouseDelta(e);
|
1423
1544
|
|
1424
|
-
|
1425
|
-
|
1545
|
+
if (isYear) {
|
1546
|
+
changeYear(self.currentYear + delta);
|
1547
|
+
e.target.value = self.currentYear;
|
1548
|
+
} else self.changeMonth(delta, true, false);
|
1549
|
+
}
|
1550
|
+
}
|
1551
|
+
|
1552
|
+
function onMonthNavClick(e) {
|
1553
|
+
if (e.target.className === "arrowUp") self.changeYear(self.currentYear + 1);else if (e.target.className === "arrowDown") self.changeYear(self.currentYear - 1);
|
1426
1554
|
}
|
1427
1555
|
|
1428
1556
|
function createElement(tag, className, content) {
|
@@ -1438,7 +1566,7 @@ function Flatpickr(element, config) {
|
|
1438
1566
|
}
|
1439
1567
|
|
1440
1568
|
function arrayify(obj) {
|
1441
|
-
if (Array
|
1569
|
+
if (obj instanceof Array) return obj;
|
1442
1570
|
return [obj];
|
1443
1571
|
}
|
1444
1572
|
|
@@ -1480,12 +1608,6 @@ function Flatpickr(element, config) {
|
|
1480
1608
|
isIncrement = e.type === "increment",
|
1481
1609
|
input = e.target;
|
1482
1610
|
|
1483
|
-
if (e.type !== "input" && !isKeyDown && (e.target.value || e.target.textContent).length >= 2 // typed two digits
|
1484
|
-
) {
|
1485
|
-
e.target.focus();
|
1486
|
-
e.target.blur();
|
1487
|
-
}
|
1488
|
-
|
1489
1611
|
if (self.amPM && e.target === self.amPM) return e.target.textContent = ["AM", "PM"][e.target.textContent === "AM" | 0];
|
1490
1612
|
|
1491
1613
|
var min = Number(input.min),
|
@@ -1522,10 +1644,11 @@ function Flatpickr(element, config) {
|
|
1522
1644
|
|
1523
1645
|
/* istanbul ignore next */
|
1524
1646
|
Flatpickr.defaultConfig = {
|
1525
|
-
|
1526
1647
|
mode: "single",
|
1527
1648
|
|
1528
|
-
position: "
|
1649
|
+
position: "auto",
|
1650
|
+
|
1651
|
+
animate: window.navigator.userAgent.indexOf("MSIE") === -1,
|
1529
1652
|
|
1530
1653
|
/* if true, dates will be parsed, formatted, and displayed in UTC.
|
1531
1654
|
preloading date strings w/ timezones is recommended but not necessary */
|
@@ -1822,15 +1945,7 @@ Flatpickr.prototype = {
|
|
1822
1945
|
formatDate: function formatDate(dateObj, frmt) {
|
1823
1946
|
var _this = this;
|
1824
1947
|
|
1825
|
-
if (this.config.formatDate)
|
1826
|
-
try {
|
1827
|
-
return this.config.formatDate(dateObj, frmt);
|
1828
|
-
} catch (e) {
|
1829
|
-
console.warn("Please swap the format string and the date object parameters in your formatDate option", "\nThe old signature will be deprecated by v2.5");
|
1830
|
-
|
1831
|
-
return this.config.formatDate(frmt, dateObj);
|
1832
|
-
}
|
1833
|
-
}
|
1948
|
+
if (this.config.formatDate) return this.config.formatDate(dateObj, frmt);
|
1834
1949
|
|
1835
1950
|
return frmt.split("").map(function (c, i, arr) {
|
1836
1951
|
return _this.formats[c] && arr[i - 1] !== "\\" ? _this.formats[c](dateObj) : c !== "\\" ? c : "";
|
@@ -1844,10 +1959,10 @@ Flatpickr.prototype = {
|
|
1844
1959
|
dateObj.setMonth(this.l10n.months.longhand.indexOf(monthName));
|
1845
1960
|
},
|
1846
1961
|
H: function H(dateObj, hour) {
|
1847
|
-
|
1962
|
+
dateObj.setHours(parseFloat(hour));
|
1848
1963
|
},
|
1849
1964
|
J: function J(dateObj, day) {
|
1850
|
-
|
1965
|
+
dateObj.setDate(parseFloat(day));
|
1851
1966
|
},
|
1852
1967
|
K: function K(dateObj, amPM) {
|
1853
1968
|
var hours = dateObj.getHours();
|
@@ -1858,41 +1973,45 @@ Flatpickr.prototype = {
|
|
1858
1973
|
dateObj.setMonth(this.l10n.months.shorthand.indexOf(shortMonth));
|
1859
1974
|
},
|
1860
1975
|
S: function S(dateObj, seconds) {
|
1861
|
-
|
1976
|
+
dateObj.setSeconds(seconds);
|
1862
1977
|
},
|
1978
|
+
U: function U(dateObj, unixSeconds) {
|
1979
|
+
return new Date(parseFloat(unixSeconds) * 1000);
|
1980
|
+
},
|
1981
|
+
|
1863
1982
|
W: function W() {},
|
1864
1983
|
Y: function Y(dateObj, year) {
|
1865
|
-
|
1984
|
+
dateObj.setFullYear(year);
|
1866
1985
|
},
|
1867
1986
|
Z: function Z(dateObj, ISODate) {
|
1868
|
-
return
|
1987
|
+
return new Date(ISODate);
|
1869
1988
|
},
|
1870
1989
|
|
1871
1990
|
d: function d(dateObj, day) {
|
1872
|
-
|
1991
|
+
dateObj.setDate(parseFloat(day));
|
1873
1992
|
},
|
1874
1993
|
h: function h(dateObj, hour) {
|
1875
|
-
|
1994
|
+
dateObj.setHours(parseFloat(hour));
|
1876
1995
|
},
|
1877
1996
|
i: function i(dateObj, minutes) {
|
1878
|
-
|
1997
|
+
dateObj.setMinutes(parseFloat(minutes));
|
1879
1998
|
},
|
1880
1999
|
j: function j(dateObj, day) {
|
1881
|
-
|
2000
|
+
dateObj.setDate(parseFloat(day));
|
1882
2001
|
},
|
1883
2002
|
l: function l() {},
|
1884
2003
|
m: function m(dateObj, month) {
|
1885
|
-
|
2004
|
+
dateObj.setMonth(parseFloat(month) - 1);
|
1886
2005
|
},
|
1887
2006
|
n: function n(dateObj, month) {
|
1888
|
-
|
2007
|
+
dateObj.setMonth(parseFloat(month) - 1);
|
1889
2008
|
},
|
1890
2009
|
s: function s(dateObj, seconds) {
|
1891
|
-
|
2010
|
+
dateObj.setSeconds(parseFloat(seconds));
|
1892
2011
|
},
|
1893
2012
|
w: function w() {},
|
1894
2013
|
y: function y(dateObj, year) {
|
1895
|
-
|
2014
|
+
dateObj.setFullYear(2000 + parseFloat(year));
|
1896
2015
|
}
|
1897
2016
|
},
|
1898
2017
|
|
@@ -1904,6 +2023,7 @@ Flatpickr.prototype = {
|
|
1904
2023
|
K: "(\\w+)",
|
1905
2024
|
M: "(\\w+)",
|
1906
2025
|
S: "(\\d\\d|\\d)",
|
2026
|
+
U: "(.+)",
|
1907
2027
|
Y: "(\\d{4})",
|
1908
2028
|
Z: "(.+)",
|
1909
2029
|
d: "(\\d\\d|\\d)",
|
@@ -1922,39 +2042,45 @@ Flatpickr.prototype = {
|
|
1922
2042
|
return ("0" + number).slice(-2);
|
1923
2043
|
},
|
1924
2044
|
|
1925
|
-
parseDate: function parseDate(date,
|
2045
|
+
parseDate: function parseDate(date, givenFormat, timeless) {
|
1926
2046
|
if (!date) return null;
|
1927
2047
|
|
1928
2048
|
var date_orig = date;
|
1929
2049
|
|
1930
|
-
if (date
|
1931
|
-
date = new Date(parseInt(date, 10));else if (typeof date === "string") {
|
1932
|
-
var format = typeof givenFormat === "string" ? givenFormat : this.config.dateFormat;
|
1933
|
-
date = date.trim();
|
2050
|
+
if (date instanceof Date) date = new Date(date.getTime()); // create a copy
|
1934
2051
|
|
1935
|
-
|
1936
|
-
date = new Date();
|
1937
|
-
timeless = true;
|
1938
|
-
} else if (this.config && this.config.parseDate) date = this.config.parseDate(date);else if (/Z$/.test(date) || /GMT$/.test(date)) // datestrings w/ timezone
|
2052
|
+
else if (date.toFixed !== undefined) // timestamp
|
1939
2053
|
date = new Date(date);else {
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
if (this.
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
2054
|
+
// date string
|
2055
|
+
var format = givenFormat || this.config.dateFormat;
|
2056
|
+
date = String(date).trim();
|
2057
|
+
|
2058
|
+
if (date === "today") {
|
2059
|
+
date = new Date();
|
2060
|
+
timeless = true;
|
2061
|
+
} else if (/Z$/.test(date) || /GMT$/.test(date)) // datestrings w/ timezone
|
2062
|
+
date = new Date(date);else if (this.config.parseDate) date = this.config.parseDate(date, format);else {
|
2063
|
+
var parsedDate = this.config.noCalendar ? new Date(new Date().setHours(0, 0, 0, 0)) : new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0);
|
2064
|
+
|
2065
|
+
var matched = void 0;
|
2066
|
+
|
2067
|
+
for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
|
2068
|
+
var token = format[i];
|
2069
|
+
var isBackSlash = token === "\\";
|
2070
|
+
var escaped = format[i - 1] === "\\" || isBackSlash;
|
2071
|
+
|
2072
|
+
if (this.tokenRegex[token] && !escaped) {
|
2073
|
+
regexStr += this.tokenRegex[token];
|
2074
|
+
var match = new RegExp(regexStr).exec(date);
|
2075
|
+
if (match && (matched = true)) {
|
2076
|
+
parsedDate = this.revFormat[token](parsedDate, match[++matchIndex]) || parsedDate;
|
2077
|
+
}
|
2078
|
+
} else if (!isBackSlash) regexStr += "."; // don't really care
|
2079
|
+
}
|
1954
2080
|
|
1955
|
-
|
2081
|
+
date = matched ? parsedDate : null;
|
2082
|
+
}
|
1956
2083
|
}
|
1957
|
-
} else if (date instanceof Date) date = new Date(date.getTime()); // create a copy
|
1958
2084
|
|
1959
2085
|
/* istanbul ignore next */
|
1960
2086
|
if (!(date instanceof Date)) {
|
@@ -2023,53 +2149,4 @@ Date.prototype.fp_toUTC = function () {
|
|
2023
2149
|
return newDate;
|
2024
2150
|
};
|
2025
2151
|
|
2026
|
-
|
2027
|
-
/* istanbul ignore next */
|
2028
|
-
if (!window.document.documentElement.classList && Object.defineProperty && typeof HTMLElement !== "undefined") {
|
2029
|
-
Object.defineProperty(HTMLElement.prototype, "classList", {
|
2030
|
-
get: function get() {
|
2031
|
-
var self = this;
|
2032
|
-
function update(fn) {
|
2033
|
-
return function (value) {
|
2034
|
-
var classes = self.className.split(/\s+/),
|
2035
|
-
index = classes.indexOf(value);
|
2036
|
-
|
2037
|
-
fn(classes, index, value);
|
2038
|
-
self.className = classes.join(" ");
|
2039
|
-
};
|
2040
|
-
}
|
2041
|
-
|
2042
|
-
var ret = {
|
2043
|
-
add: update(function (classes, index, value) {
|
2044
|
-
if (!~index) classes.push(value);
|
2045
|
-
}),
|
2046
|
-
|
2047
|
-
remove: update(function (classes, index) {
|
2048
|
-
if (~index) classes.splice(index, 1);
|
2049
|
-
}),
|
2050
|
-
|
2051
|
-
toggle: update(function (classes, index, value) {
|
2052
|
-
if (~index) classes.splice(index, 1);else classes.push(value);
|
2053
|
-
}),
|
2054
|
-
|
2055
|
-
contains: function contains(value) {
|
2056
|
-
return !!~self.className.split(/\s+/).indexOf(value);
|
2057
|
-
},
|
2058
|
-
|
2059
|
-
item: function item(i) {
|
2060
|
-
return self.className.split(/\s+/)[i] || null;
|
2061
|
-
}
|
2062
|
-
};
|
2063
|
-
|
2064
|
-
Object.defineProperty(ret, "length", {
|
2065
|
-
get: function get() {
|
2066
|
-
return self.className.split(/\s+/).length;
|
2067
|
-
}
|
2068
|
-
});
|
2069
|
-
|
2070
|
-
return ret;
|
2071
|
-
}
|
2072
|
-
});
|
2073
|
-
}
|
2074
|
-
|
2075
|
-
if (typeof module !== "undefined") module.exports = Flatpickr;
|
2152
|
+
if (typeof module !== "undefined") module.exports = Flatpickr;
|