vendor: 2,756 bytes, lines 1-79
1/* flatpickr v4.5.0, @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.rangePlugin = factory()); 6}(this, (function () { 'use strict'; 7 8 function rangePlugin(config) { 9 if (config === void 0) { 10 config = {}; 11 } 12 13 return function (fp) { 14 var dateFormat = "", 15 secondInput, 16 _secondInputFocused, 17 _prevDates; 18 19 var createSecondInput = function createSecondInput() { 20 if (config.input) { 21 secondInput = config.input instanceof Element ? config.input : window.document.querySelector(config.input); 22 } else { 23 secondInput = fp._input.cloneNode(); 24 secondInput.removeAttribute("id"); 25 secondInput._flatpickr = undefined; 26 } 27 28 if (secondInput.value) { 29 var parsedDate = fp.parseDate(secondInput.value); 30 if (parsedDate) fp.selectedDates.push(parsedDate); 31 } 32 33 secondInput.setAttribute("data-fp-omit", ""); 34 35 fp._bind(secondInput, ["focus", "click"], function () { 36 if (fp.selectedDates[1]) { 37 fp.latestSelectedDateObj = fp.selectedDates[1]; 38 39 fp._setHoursFromDate(fp.selectedDates[1]); 40 41 fp.jumpToDate(fp.selectedDates[1]); 42 } 43 _secondInputFocused = true; 44 fp.isOpen = false; 45 fp.open(undefined, secondInput); 46 }); 47 48 fp._bind(fp._input, ["focus", "click"], function (e) { 49 e.preventDefault(); 50 fp.isOpen = false; 51 fp.open(); 52 }); 53 54 if (fp.config.allowInput) fp._bind(secondInput, "keydown", function (e) { 55 if (e.key === "Enter") { 56 fp.setDate([fp.selectedDates[0], secondInput.value], true, dateFormat); 57 secondInput.click(); 58 } 59 }); 60 if (!config.input) fp._input.parentNode && fp._input.parentNode.insertBefore(secondInput, fp._input.nextSibling); 61 }; 62 63 var plugin = { 64 onParseConfig: function onParseConfig() { 65 fp.config.mode = "range"; 66 dateFormat = fp.config.altInput ? fp.config.altFormat : fp.config.dateFormat; 67 }, 68 onReady: function onReady() { 69 createSecondInput(); 70 fp.config.ignoredFocusElements.push(secondInput); 71 72 if (fp.config.allowInput) { 73 fp._input.removeAttribute("readonly"); 74 75 secondInput.removeAttribute("readonly"); 76 } else { 77 secondInput.setAttribute("readonly", "readonly"); 78 } 79
80 fp._bind(fp._input, "focus", function () { 81 fp.latestSelectedDateObj = fp.selectedDates[0]; 82 83 fp._setHoursFromDate(fp.selectedDates[0]); 84 _secondInputFocused = false; 85 fp.jumpToDate(fp.selectedDates[0]); 86 }); 87 88 if (fp.config.allowInput) fp._bind(fp._input, "keydown", function (e) { 89 if (e.key === "Enter") fp.setDate([fp._input.value, fp.selectedDates[1]], true, dateFormat); 90 }); 91 fp.setDate(fp.selectedDates, false); 92 plugin.onValueUpdate(fp.selectedDates); 93 }, 94 onPreCalendarPosition: function onPreCalendarPosition() { 95 if (_secondInputFocused) { 96 fp._positionElement = secondInput; 97 setTimeout(function () { 98 fp._positionElement = fp._input; 99 }, 0); 100 } 101 }, 102 onChange: function onChange() { 103 if (!fp.selectedDates.length) { 104 setTimeout(function () { 105 if (fp.selectedDates.length) return; 106 secondInput.value = ""; 107 _prevDates = []; 108 }, 10); 109 } 110 111 if (_secondInputFocused) { 112 setTimeout(function () { 113 secondInput.focus(); 114 }, 0); 115 } 116 }, 117 onDestroy: function onDestroy() { 118 if (!config.input) secondInput.parentNode && secondInput.parentNode.removeChild(secondInput); 119 }, 120 onValueUpdate: function onValueUpdate(selDates) { 121 if (!secondInput) return; 122 _prevDates = !_prevDates || selDates.length >= _prevDates.length ? selDates.concat() : _prevDates; 123 124 if (_prevDates.length > selDates.length) { 125 var newSelectedDate = selDates[0]; 126 var newDates = _secondInputFocused ? [_prevDates[0], newSelectedDate] : [newSelectedDate, _prevDates[1]]; 127 fp.setDate(newDates, false); 128 _prevDates = newDates.concat(); 129 } 130 131 var _fp$selectedDates$map = fp.selectedDates.map(function (d) { 132 return fp.formatDate(d, dateFormat); 133 }); 134 135 var _fp$selectedDates$map2 = _fp$selectedDates$map[0]; 136 fp._input.value = _fp$selectedDates$map2 === void 0 ? "" : _fp$selectedDates$map2; 137 var _fp$selectedDates$map3 = _fp$selectedDates$map[1]; 138 secondInput.value = _fp$selectedDates$map3 === void 0 ? "" : _fp$selectedDates$map3; 139 } 140 }; 141 return plugin; 142 }; 143 } 144 145 return rangePlugin; 146 147})));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.