diff --git a/src/js/Framework/DateTimePicker/DatePicker.js b/src/js/Framework/DateTimePicker/DatePicker.js index 1d200d7..3f9f913 100644 --- a/src/js/Framework/DateTimePicker/DatePicker.js +++ b/src/js/Framework/DateTimePicker/DatePicker.js @@ -21,7 +21,7 @@ import { Spanish } from 'flatpickr/dist/l10n/es.js' import { Slovenian } from 'flatpickr/dist/l10n/sl.js' export class DatePicker { - constructor (element) { + constructor (element, enableTime = false, noCalendar = false) { this.element = element let locale = document.documentElement.lang @@ -31,7 +31,9 @@ export class DatePicker { try { this.element._flatpickr = flatpickr(this.element, { - locale: locale + locale: locale, + enableTime: enableTime, + noCalendar: noCalendar }) } catch (ex) { console.log('No translation found for ' + locale) diff --git a/src/js/Framework/DateTimePicker/DateTimePicker.js b/src/js/Framework/DateTimePicker/DateTimePicker.js index 9594b5b..13aaa97 100644 --- a/src/js/Framework/DateTimePicker/DateTimePicker.js +++ b/src/js/Framework/DateTimePicker/DateTimePicker.js @@ -2,8 +2,6 @@ import { DatePicker } from './DatePicker.js' export class DateTimePicker extends DatePicker { constructor (element) { - super(element) - - this.element._flatpickr.config.enableTime = true + super(element, true) } } diff --git a/src/js/Framework/DateTimePicker/TimePicker.js b/src/js/Framework/DateTimePicker/TimePicker.js index 01ff679..67b1a55 100644 --- a/src/js/Framework/DateTimePicker/TimePicker.js +++ b/src/js/Framework/DateTimePicker/TimePicker.js @@ -2,10 +2,7 @@ import { DatePicker } from './DatePicker.js' export class TimePicker extends DatePicker { constructor (element) { - super(element) - - this.element._flatpickr.config.enableTime = true - this.element._flatpickr.config.noCalendar = true + super(element, true, true) element.parentNode.querySelector('[data-flatpicker-clear]').addEventListener('click', event => this.element._flatpickr.clear()) }