79 lines
2.1 KiB
Plaintext
79 lines
2.1 KiB
Plaintext
function setupDatepicker(wrapper) {
|
|
"use strict";
|
|
|
|
var config = {
|
|
dtLocal: {
|
|
enableTime: true,
|
|
altInput: true,
|
|
altFormat: "j. F Y, H:i", // maybe interpolate these formats for locale
|
|
dateFormat: "Y-m-dTH:i",
|
|
time_24hr: true
|
|
},
|
|
d: {
|
|
altFormat: "j. F Y",
|
|
dateFormat: "Y-m-d",
|
|
altInput: true
|
|
},
|
|
t: {
|
|
enableTime: true,
|
|
noCalendar: true,
|
|
altFormat: "H:i",
|
|
dateFormat: "H:i",
|
|
altInput: true,
|
|
time_24hr: true
|
|
}
|
|
};
|
|
|
|
Array.from(wrapper.querySelectorAll('input[type="date"]')).forEach(function(el) {
|
|
flatpickr(el, config.d);
|
|
});
|
|
Array.from(wrapper.querySelectorAll('input[type="time"]')).forEach(function(el) {
|
|
flatpickr(el, config.t);
|
|
});
|
|
Array.from(wrapper.querySelectorAll('input[type="datetime-local"]')).forEach(function(el) {
|
|
flatpickr(el, config.dtLocal);
|
|
});
|
|
}
|
|
|
|
if (I18n) {
|
|
I18n.addMany({
|
|
filesSelected: 'Dateien ausgewählt',
|
|
selectFile: 'Datei auswählen',
|
|
selectFiles: 'Datei(en) auswählen',
|
|
asyncFormFailure: 'Da ist etwas schief gelaufen, das tut uns Leid. Falls das erneut passiert schicke uns gerne eine kurze Beschreibung dieses Ereignisses über das Hilfe-Widget rechts oben. Vielen Dank für deine Hilfe!',
|
|
});
|
|
} else {
|
|
throw new Error('I18n JavaScript service is missing!');
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
setupDatepicker(document.body);
|
|
});
|
|
|
|
/**
|
|
* The following code should be moved to profile.julius as soon as the widget file is actually used.
|
|
*/
|
|
(function() {
|
|
'use strict';
|
|
|
|
var DEFAULT_THEME = 'theme--default';
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
var themeSwitcher = document.querySelector('#theme-select');
|
|
var currentTheme = DEFAULT_THEME;
|
|
|
|
if (themeSwitcher) {
|
|
currentTheme = 'theme--' + themeSwitcher.value;
|
|
themeSwitcher.addEventListener('input', function() {
|
|
|
|
var desiredTheme = 'theme--' + themeSwitcher.value;
|
|
document.body.classList.remove(currentTheme);
|
|
document.body.classList.add(desiredTheme);
|
|
currentTheme = desiredTheme;
|
|
});
|
|
}
|
|
});
|
|
|
|
})();
|