From 211c5f879049f5a4980167c9aae650e530209aba Mon Sep 17 00:00:00 2001 From: Sascha Karnatz <122262394+sascha-karnatz@users.noreply.github.com> Date: Mon, 3 Jul 2023 10:07:43 +0200 Subject: [PATCH] Remove iOS switch for data pickers This is no necessary anymore, because flatpicker is doing that on its own. Also the Alchemy.isiOS - field was removed (Commit #80fc0d7a6a66137e1f52bdbc63b0ef88e9632566). --- app/javascript/alchemy_admin/datepicker.js | 47 +++++++++------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/app/javascript/alchemy_admin/datepicker.js b/app/javascript/alchemy_admin/datepicker.js index 2e80507a84..50b6bc4c66 100644 --- a/app/javascript/alchemy_admin/datepicker.js +++ b/app/javascript/alchemy_admin/datepicker.js @@ -9,32 +9,25 @@ export default function Datepicker(scope = document) { const datepickerInputs = scope.querySelectorAll("input[data-datepicker-type]") - // Initializes the datepickers on the text inputs and sets the proper type - // to enable browsers default datepicker if the current OS is iOS. - if (Alchemy.isiOS) { - datepickerInputs.forEach((input) => { - input.attributes.type = input.dataset.datepickerType - }) - } else { - datepickerInputs.forEach((input) => { - const type = input.dataset.datepickerType - const options = { - // alchemy_i18n supports `zh_CN` etc., but flatpickr only has two-letter codes (`zh`) - locale: Alchemy.locale.slice(0, 2), - altInput: true, - altFormat: Alchemy.t(`formats.${type}`), - altInputClass: "flatpickr-input", - dateFormat: "Z", - enableTime: /time/.test(type), - noCalendar: type === "time", - time_24hr: Alchemy.t("formats.time_24hr"), - onValueUpdate(_selectedDates, _dateStr, instance) { - return Alchemy.setElementDirty( - instance.element.closest(".element-editor") - ) - } + // Initializes the datepickers + datepickerInputs.forEach((input) => { + const type = input.dataset.datepickerType + const options = { + // alchemy_i18n supports `zh_CN` etc., but flatpickr only has two-letter codes (`zh`) + locale: Alchemy.locale.slice(0, 2), + altInput: true, + altFormat: Alchemy.t(`formats.${type}`), + altInputClass: "flatpickr-input", + dateFormat: "Z", + enableTime: /time/.test(type), + noCalendar: type === "time", + time_24hr: Alchemy.t("formats.time_24hr"), + onValueUpdate(_selectedDates, _dateStr, instance) { + return Alchemy.setElementDirty( + instance.element.closest(".element-editor") + ) } - flatpickr(input, options) - }) - } + } + flatpickr(input, options) + }) }