MCPcopy
hub / github.com/flatpickr/flatpickr / setupMobile

Function setupMobile

src/index.ts:2662–2722  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2660 }
2661
2662 function setupMobile() {
2663 const inputType = self.config.enableTime
2664 ? self.config.noCalendar
2665 ? "time"
2666 : "datetime-local"
2667 : "date";
2668
2669 self.mobileInput = createElement<HTMLInputElement>(
2670 "input",
2671 self.input.className + " flatpickr-mobile"
2672 );
2673 self.mobileInput.tabIndex = 1;
2674 self.mobileInput.type = inputType;
2675 self.mobileInput.disabled = self.input.disabled;
2676 self.mobileInput.required = self.input.required;
2677 self.mobileInput.placeholder = self.input.placeholder;
2678
2679 self.mobileFormatStr =
2680 inputType === "datetime-local"
2681 ? "Y-m-d\\TH:i:S"
2682 : inputType === "date"
2683 ? "Y-m-d"
2684 : "H:i:S";
2685
2686 if (self.selectedDates.length > 0) {
2687 self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(
2688 self.selectedDates[0],
2689 self.mobileFormatStr
2690 );
2691 }
2692
2693 if (self.config.minDate)
2694 self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
2695
2696 if (self.config.maxDate)
2697 self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
2698
2699 if (self.input.getAttribute("step"))
2700 self.mobileInput.step = String(self.input.getAttribute("step"));
2701
2702 self.input.type = "hidden";
2703 if (self.altInput !== undefined) self.altInput.type = "hidden";
2704
2705 try {
2706 if (self.input.parentNode)
2707 self.input.parentNode.insertBefore(
2708 self.mobileInput,
2709 self.input.nextSibling
2710 );
2711 } catch {}
2712
2713 bind(self.mobileInput, "change", (e: KeyboardEvent) => {
2714 self.setDate(
2715 (getEventTarget(e) as HTMLInputElement).value,
2716 false,
2717 self.mobileFormatStr
2718 );
2719 triggerEvent("onChange");

Callers 1

bindEventsFunction · 0.85

Calls 4

createElementFunction · 0.90
getEventTargetFunction · 0.90
bindFunction · 0.85
triggerEventFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…