MCPcopy
hub / github.com/flatpickr/flatpickr / open

Function open

src/index.ts:1905–1951  ·  view source on GitHub ↗
(
    e?: FocusEvent | MouseEvent,
    positionElement = self._positionElement
  )

Source from the content-addressed store, hash-verified

1903 }
1904
1905 function open(
1906 e?: FocusEvent | MouseEvent,
1907 positionElement = self._positionElement
1908 ) {
1909 if (self.isMobile === true) {
1910 if (e) {
1911 e.preventDefault();
1912 const eventTarget = getEventTarget(e);
1913 if (eventTarget) {
1914 (eventTarget as HTMLInputElement).blur();
1915 }
1916 }
1917
1918 if (self.mobileInput !== undefined) {
1919 self.mobileInput.focus();
1920 self.mobileInput.click();
1921 }
1922
1923 triggerEvent("onOpen");
1924 return;
1925 } else if (self._input.disabled || self.config.inline) {
1926 return;
1927 }
1928
1929 const wasOpen = self.isOpen;
1930
1931 self.isOpen = true;
1932
1933 if (!wasOpen) {
1934 self.calendarContainer.classList.add("open");
1935 self._input.classList.add("active");
1936 triggerEvent("onOpen");
1937 positionCalendar(positionElement);
1938 }
1939
1940 if (self.config.enableTime === true && self.config.noCalendar === true) {
1941 if (
1942 self.config.allowInput === false &&
1943 (e === undefined ||
1944 !(self.timeContainer as HTMLDivElement).contains(
1945 e.relatedTarget as Node
1946 ))
1947 ) {
1948 setTimeout(() => (self.hourElement as HTMLInputElement).select(), 50);
1949 }
1950 }
1951 }
1952
1953 function minMaxDateSetter(type: "min" | "max") {
1954 return (date: DateOption) => {

Callers

nothing calls this directly

Calls 3

getEventTargetFunction · 0.90
triggerEventFunction · 0.85
positionCalendarFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…