mirror of
https://github.com/torproject/community.git
synced 2024-11-27 03:30:33 +00:00
Add "clear filters" button
This commit is contained in:
parent
05b4fa1107
commit
806ba76922
@ -10,6 +10,7 @@ let resources = document.querySelectorAll('#resource-list > .resource-list-entry
|
||||
let topic_dropdown_button = document.getElementById('topicDropdownMenuButton');
|
||||
let lang_dropdown_button = document.getElementById('languageDropdownMenuButton');
|
||||
let author_dropdown_button = document.getElementById('authorDropdownMenuButton');
|
||||
let filterClearButton = document.getElementById('filterClearButton');
|
||||
|
||||
const translatedTopic = document.currentScript.getAttribute('topic');
|
||||
const translatedTopicColon = document.currentScript.getAttribute('topic-colon');
|
||||
@ -54,6 +55,14 @@ Array.from(document.getElementsByClassName('onclick-setAuthor'))
|
||||
applyFilters(resourceFilters.topic, resourceFilters.lang, resourceFilters.author)
|
||||
}));
|
||||
|
||||
filterClearButton.addEventListener('click', ev => {
|
||||
ev.preventDefault();
|
||||
setTopic('none', 'none');
|
||||
setLang('none', 'none');
|
||||
setAuthor('none', 'none');
|
||||
applyFilters(null, null, null);
|
||||
});
|
||||
|
||||
function setTopic(topic, topicReadable) {
|
||||
let newText = `${translatedTopicColon} ${topicReadable}`;
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
{%- endif -%}
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="authorDropdownMenuButton">
|
||||
<a class="d-block onclick-setAuthor" data-author="none" href="{{ get_new_link(this, new_author=none) }}">{{ _('None') }}</a>
|
||||
<a class="d-block onclick-setAuthor" data-author="none" href="{{ get_new_link(this, new_author='none') }}">{{ _('None') }}</a>
|
||||
{% for author in get_authors()|sort(case_sensitive=False) if author != 'none' %}
|
||||
<a
|
||||
class="d-block onclick-setAuthor"
|
||||
@ -75,4 +75,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ get_new_link(this, new_topic='none', new_lang='none', new_author='none') }}" id="filterClearButton" class="btn btn-primary font-weight-600">{{ _('Clear filters') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user