Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a03612dc9c | |||
| b525f37862 | |||
| 1b477c24da | |||
| 85b669d214 |
@@ -1,32 +1,50 @@
|
|||||||
<div id="eventfilters" data-eventlist-id="{{ targetEventListId|default('eventlist')|e('html_attr') }}">
|
<div id="eventfilters" data-eventlist-id="{{ targetEventListId|default('eventlist')|e('html_attr') }}">
|
||||||
<button type="button" data-filter-tag="all" class="active">Alle</button>
|
<div class="tag-buttons">
|
||||||
|
<button type="button" data-filter-tag="all" class="active" aria-pressed="true">Alle</button>
|
||||||
|
|
||||||
{% for tag in tagButtons|default([]) %}
|
{% for tag in tagButtons|default([]) %}
|
||||||
<button type="button" data-filter-tag="{{ tag.id }}">{{ tag.title }} ({{ tag.count }})</button>
|
<button type="button" data-filter-tag="{{ tag.id }}" aria-pressed="false">{{ tag.title }} ({{ tag.count }})</button>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<div class="widget-select places">
|
|
||||||
<label for="location-filter">Orte:</label>
|
|
||||||
<select id="location-filter">
|
|
||||||
<option value="all">Orte</option>
|
|
||||||
{% for location in locations|default([]) %}
|
|
||||||
<option value="location-{{ location.id }}">{{ location.title }} ({{ location.count }})</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="widget-select org">
|
<div class="select-filters">
|
||||||
<label for="org-filter">Veranstalter:</label>
|
<div class="widget-select places">
|
||||||
<select id="org-filter">
|
<label for="location-filter" class="visually-hidden">Orte:</label>
|
||||||
<option value="all">Veranstalter</option>
|
<select id="location-filter">
|
||||||
{% for organization in organizations|default([]) %}
|
<option value="all">Orte</option>
|
||||||
<option value="org-{{ organization.id }}">{{ organization.title }} ({{ organization.count }})</option>
|
{% for location in locations|default([]) %}
|
||||||
{% endfor %}
|
<option value="location-{{ location.id }}">{{ location.title }} ({{ location.count }})</option>
|
||||||
</select>
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="widget-select org">
|
||||||
|
<label for="org-filter" class="visually-hidden">Veranstalter:</label>
|
||||||
|
<select id="org-filter">
|
||||||
|
<option value="all">Veranstalter</option>
|
||||||
|
{% for organization in organizations|default([]) %}
|
||||||
|
<option value="org-{{ organization.id }}">{{ organization.title }} ({{ organization.count }})</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p id="eventfilter-status" class="visually-hidden" aria-live="polite"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.visually-hidden {
|
||||||
|
position: absolute;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
padding: 0;
|
||||||
|
margin: -1px;
|
||||||
|
overflow: hidden;
|
||||||
|
clip: rect(0, 0, 0, 0);
|
||||||
|
white-space: nowrap;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.event-filter-target-list {
|
.event-filter-target-list {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||||
@@ -51,6 +69,12 @@
|
|||||||
outline: 2px solid currentColor;
|
outline: 2px solid currentColor;
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#eventfilters button:focus-visible,
|
||||||
|
#eventfilters select:focus-visible {
|
||||||
|
outline: 2px solid currentColor;
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
@@ -73,6 +97,9 @@
|
|||||||
const tagButtons = Array.from(filters.querySelectorAll('button[data-filter-tag]'));
|
const tagButtons = Array.from(filters.querySelectorAll('button[data-filter-tag]'));
|
||||||
const locationSelect = filters.querySelector('#location-filter');
|
const locationSelect = filters.querySelector('#location-filter');
|
||||||
const orgSelect = filters.querySelector('#org-filter');
|
const orgSelect = filters.querySelector('#org-filter');
|
||||||
|
const locationWidget = locationSelect?.closest('.widget-select');
|
||||||
|
const orgWidget = orgSelect?.closest('.widget-select');
|
||||||
|
const status = filters.querySelector('#eventfilter-status');
|
||||||
|
|
||||||
const animationMs = 220;
|
const animationMs = 220;
|
||||||
let hideTimers = new WeakMap();
|
let hideTimers = new WeakMap();
|
||||||
@@ -110,15 +137,19 @@
|
|||||||
|
|
||||||
const setActiveControl = ({ type, value }) => {
|
const setActiveControl = ({ type, value }) => {
|
||||||
tagButtons.forEach((button) => {
|
tagButtons.forEach((button) => {
|
||||||
button.classList.toggle('active', type === 'tag' && button.dataset.filterTag === value);
|
const isActive = type === 'tag' && button.dataset.filterTag === value;
|
||||||
|
button.classList.toggle('active', isActive);
|
||||||
|
button.setAttribute('aria-pressed', isActive ? 'true' : 'false');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (locationSelect) {
|
if (locationSelect) {
|
||||||
locationSelect.classList.toggle('active', type === 'location');
|
locationSelect.classList.toggle('active', type === 'location');
|
||||||
|
locationWidget?.classList.toggle('active', type === 'location');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orgSelect) {
|
if (orgSelect) {
|
||||||
orgSelect.classList.toggle('active', type === 'org');
|
orgSelect.classList.toggle('active', type === 'org');
|
||||||
|
orgWidget?.classList.toggle('active', type === 'org');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -147,6 +178,32 @@
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateStatus = (filterState) => {
|
||||||
|
if (!status) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const visibleCount = events.filter((eventItem) => !eventItem.hidden).length;
|
||||||
|
let filterText = 'alle';
|
||||||
|
|
||||||
|
if (filterState.type === 'tag' && filterState.value !== 'all') {
|
||||||
|
const activeButton = tagButtons.find((button) => button.dataset.filterTag === filterState.value);
|
||||||
|
filterText = activeButton ? activeButton.textContent.trim() : `Tag ${filterState.value}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filterState.type === 'location' && locationSelect) {
|
||||||
|
const option = locationSelect.options[locationSelect.selectedIndex];
|
||||||
|
filterText = option ? option.textContent.trim() : 'Ort';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filterState.type === 'org' && orgSelect) {
|
||||||
|
const option = orgSelect.options[orgSelect.selectedIndex];
|
||||||
|
filterText = option ? option.textContent.trim() : 'Veranstalter';
|
||||||
|
}
|
||||||
|
|
||||||
|
status.textContent = `${visibleCount} Veranstaltungen angezeigt, Filter: ${filterText}.`;
|
||||||
|
};
|
||||||
|
|
||||||
const applyFilter = (filterState) => {
|
const applyFilter = (filterState) => {
|
||||||
currentFilter = filterState;
|
currentFilter = filterState;
|
||||||
setActiveControl(filterState);
|
setActiveControl(filterState);
|
||||||
@@ -158,6 +215,8 @@
|
|||||||
hideEvent(eventItem);
|
hideEvent(eventItem);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateStatus(filterState);
|
||||||
};
|
};
|
||||||
|
|
||||||
tagButtons.forEach((button) => {
|
tagButtons.forEach((button) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user