1function confirmDatePlugin(pluginConfig) { 2 var defaultConfig = { 3 confirmIcon: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='17' height='17' viewBox='0 0 17 17'> <g> </g> <path d='M15.418 1.774l-8.833 13.485-4.918-4.386 0.666-0.746 4.051 3.614 8.198-12.515 0.836 0.548z' fill='#000000' /> </svg>", 4 confirmText: "OK ", 5 showAlways: false, 6 theme: "light" 7 }; 8 9 var config = {}; 10 for (var key in defaultConfig) { 11 config[key] = pluginConfig && pluginConfig[key] !== undefined ? pluginConfig[key] : defaultConfig[key]; 12 } 13 14 return function (fp) { 15 var hooks = { 16 onKeyDown: function onKeyDown(_, __, ___, e) { 17 if (fp.config.enableTime && e.key === "Tab" && e.target === fp.amPM) { 18 e.preventDefault(); 19 fp.confirmContainer.focus(); 20 } else if (e.key === "Enter" && e.target === fp.confirmContainer) fp.close(); 21 }, 22 onReady: function onReady() { 23 if (fp.calendarContainer === undefined) return; 24 25 fp.confirmContainer = fp._createElement("div", "flatpickr-confirm " + (config.showAlways ? "visible" : "") + " " + config.theme + "Theme", config.confirmText); 26 27 fp.confirmContainer.tabIndex = -1; 28 fp.confirmContainer.innerHTML += config.confirmIcon; 29 30 fp.confirmContainer.addEventListener("click", fp.close); 31 fp.calendarContainer.appendChild(fp.confirmContainer); 32 } 33 }; 34 35 if (!config.showAlways) { 36 hooks.onChange = function (dateObj, dateStr) { 37 var showCondition = fp.config.enableTime || fp.config.mode === "multiple"; 38 if (dateStr && !fp.config.inline && showCondition) return fp.confirmContainer.classList.add("visible"); 39 fp.confirmContainer.classList.remove("visible"); 40 }; 41 } 42 43 return hooks; 44 }; 45} 46 47if (typeof module !== "undefined") module.exports = confirmDatePlugin;
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.