From 515ad0fac7bd62e921b68cfa897a0a996ec542ae Mon Sep 17 00:00:00 2001 From: Felix Hamann Date: Sat, 16 Feb 2019 13:39:20 +0100 Subject: [PATCH] use now static js helper for datepicker --- templates/standalone/datepicker.julius | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/templates/standalone/datepicker.julius b/templates/standalone/datepicker.julius index a7e956af4..9bf21c071 100644 --- a/templates/standalone/datepicker.julius +++ b/templates/standalone/datepicker.julius @@ -1,8 +1,5 @@ -document.addEventListener('setup', function(e) { +function setupDatepicker(wrapper) { "use strict"; - - if (e.detail.module && e.detail.module !== 'datepicker') - return; var config = { dtLocal: { @@ -27,17 +24,17 @@ document.addEventListener('setup', function(e) { } }; - Array.from(e.detail.scope.querySelectorAll('input[type="date"]')).forEach(function(el) { + Array.from(wrapper.querySelectorAll('input[type="date"]')).forEach(function(el) { flatpickr(el, config.d); }); - Array.from(e.detail.scope.querySelectorAll('input[type="time"]')).forEach(function(el) { + Array.from(wrapper.querySelectorAll('input[type="time"]')).forEach(function(el) { flatpickr(el, config.t); }); - Array.from(e.detail.scope.querySelectorAll('input[type="datetime-local"]')).forEach(function(el) { + Array.from(wrapper.querySelectorAll('input[type="datetime-local"]')).forEach(function(el) { flatpickr(el, config.dtLocal); }); -}); +} document.addEventListener('DOMContentLoaded', function() { - document.dispatchEvent(new CustomEvent('setup', { detail: { scope: document.body, module: 'datepicker' }, bubbles: true, cancelable: true })); + window.utils.setup('flatpickr', document.body, { setupFunction: setupDatepicker }); });