From 7e1de5b5574bf09cdc9c4f83f6f0acd916c6d6cf Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 17 Jul 2024 15:08:58 +0100 Subject: [PATCH] Bug 37371: Move Maskito instantiation to onReady Signed-off-by: Owen Leonard Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- .../prog/en/includes/calendar.inc | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 3eae704b50..6dc58c4059 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -85,39 +85,39 @@ instance.set('allowInput',false); } }); - }, - onChange: function( selectedDates, dateText, instance) { - var thisInput = instance.input; - let accepts_time = $(thisInput).data('flatpickr-enable-time'); - let accepts_period = $(thisInput).data('flatpickr-period'); - if ( !accepts_period ) { - if ( accepts_time ) { - let parsedDate = flatpickr.parseDate(dateText, instance.config.dateFormat); - if ( !parsedDate.getHours() ) { - instance.setDate(selectedDates[0].setHours(23, 59, 0, 0)); - } - } - } - }, - onOpen: function( selectedDates, dateText, instance ) { + + /* When flatpickr instance is ready, add maskito input mask */ var thisInput = instance.input; let accepts_time = $(thisInput).data('flatpickr-enable-time'); let accepts_period = $(thisInput).data('flatpickr-period'); - let options = {}; + let maskitoOptions = {}; if ( !accepts_period ) { if ( accepts_time ) { - options = maskitoDateTimeOptionsGenerator({ + maskitoOptions = maskitoDateTimeOptionsGenerator({ dateMode: altinput_dateformat, timeMode: 'HH:MM', dateSeparator: delimiter, }); } else { - options = maskitoDateOptionsGenerator({ + maskitoOptions = maskitoDateOptionsGenerator({ mode: altinput_dateformat, separator: delimiter, }); } - new Maskito( instance.altInput, options ); + } + new Maskito( instance.altInput, maskitoOptions ); + }, + onChange: function( selectedDates, dateText, instance) { + var thisInput = instance.input; + let accepts_time = $(thisInput).data('flatpickr-enable-time'); + let accepts_period = $(thisInput).data('flatpickr-period'); + if ( !accepts_period ) { + if ( accepts_time ) { + let parsedDate = flatpickr.parseDate(dateText, instance.config.dateFormat); + if ( !parsedDate.getHours() ) { + instance.setDate(selectedDates[0].setHours(23, 59, 0, 0)); + } + } } }, onClose: function( selectedDates, dateText, instance) { -- 2.39.5