use now static js helper for datepicker
This commit is contained in:
parent
1277982449
commit
515ad0fac7
@ -1,8 +1,5 @@
|
|||||||
document.addEventListener('setup', function(e) {
|
function setupDatepicker(wrapper) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
if (e.detail.module && e.detail.module !== 'datepicker')
|
|
||||||
return;
|
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
dtLocal: {
|
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);
|
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);
|
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);
|
flatpickr(el, config.dtLocal);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
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 });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user