Publish eventLabs 0.5.0

This commit is contained in:
josh
2026-11-11 21:30:20 -05:00
parent 31a327d16f
commit 258aee939c
41 changed files with 6737 additions and 0 deletions

63
assets/event-editor.js Normal file
View File

@@ -0,0 +1,63 @@
(() => {
const editorSelector = '[data-be-event-editor]';
function showFields(group, visible) {
group.hidden = !visible;
for (const control of group.querySelectorAll('input, select')) {
control.disabled = !visible;
}
}
function updateSchedule(editor) {
const allDay = editor.querySelector('[name="be[all_day]"]').checked;
for (const time of editor.querySelectorAll('[data-be-time]')) {
showFields(time, !allDay);
}
const repeat = editor.querySelector('[name="be[repeat]"]');
for (const group of editor.querySelectorAll('[data-be-repeat]')) {
const mode = group.dataset.beRepeat;
showFields(group, mode === repeat.value || (mode === 'enabled' && repeat.value !== 'none'));
}
editor.querySelector('[data-be-frequency]').textContent = repeat.selectedOptions[0].textContent;
}
function updateSelection(picker) {
const summary = picker.querySelector('[data-be-picker-selection]');
const labels = [...picker.querySelectorAll('[data-be-picker-option] input:checked')]
.map(input => input.nextElementSibling.textContent);
summary.textContent = labels.join(', ') || summary.dataset.beEmpty;
}
function initialize() {
for (const editor of document.querySelectorAll(editorSelector)) updateSchedule(editor);
}
document.addEventListener('change', event => {
const editor = event.target.closest(editorSelector);
if (!editor) return;
if (event.target.name === 'be[all_day]' || event.target.name === 'be[repeat]') {
updateSchedule(editor);
} else if (event.target.closest('[data-be-picker-option]')) {
updateSelection(event.target.closest('[data-be-picker]'));
}
});
document.addEventListener('input', event => {
if (!event.target.matches('[data-be-picker-search]')) return;
const picker = event.target.closest('[data-be-picker]');
const search = event.target.value.trim().toLocaleLowerCase();
let found = false;
for (const option of picker.querySelectorAll('[data-be-picker-option]')) {
option.hidden = !option.textContent.toLocaleLowerCase().includes(search);
found = found || !option.hidden;
}
picker.querySelector('[data-be-no-options]').hidden = found;
});
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initialize, {once: true});
} else {
initialize();
}
})();