Skip to content

Commit be4d904

Browse files
committed
fix taxon filter list
1 parent 65a9b7e commit be4d904

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

atlas/static/listeEspeces.js

+26-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
$(".lazy").lazy({
2-
effect: "fadeIn",
3-
effectTime: 2000,
4-
threshold: 0,
5-
appendScroll: $("#taxonList")
6-
});
2+
effect: "fadeIn",
3+
effectTime: 2000,
4+
threshold: 0,
5+
appendScroll: $("#taxonList")
6+
});
77
$('[data-toggle="tooltip"]').tooltip();
8+
9+
var taxonDomElem = Array.from(document.querySelectorAll("#taxonList li"))
10+
811
$(document).ready(function(){
9-
function filterListeEspèces() {
10-
let name = document.querySelector("#taxonInput").value.toLowerCase();
11-
let onlyProtégées = document.querySelector("#filtreProtégées").checked;
12-
let onlyPatrimoniales = document.querySelector("#filtrePatrimoniales").checked;
13-
$("#taxonList li").each(function() {
14-
let matched = $(this).text().toLowerCase().indexOf(name) > -1
15-
&& (!onlyProtégées || "data-protégée" in this.attributes)
16-
&& (!onlyPatrimoniales || "data-patrimoniale" in this.attributes);
17-
$(this).toggle(matched);
18-
});
19-
}
12+
function filterListeEspèces() {
13+
let name = document.querySelector("#taxonInput").value.toLowerCase();
14+
let onlyProtégées = document.querySelector("#filtreProtégées").checked;
15+
let onlyPatrimoniales = document.querySelector("#filtrePatrimoniales").checked;
2016

21-
document.querySelectorAll("#filtresListeEspèces input").forEach(
22-
(element) => element.addEventListener("input", filterListeEspèces)
23-
)
17+
const filteredTaxonDomElem = taxonDomElem.filter(elem => {
18+
let matched = elem.innerText.toLowerCase().indexOf(name) > -1
19+
&& (!onlyProtégées || "data-protégée" in elem.attributes)
20+
&& (!onlyPatrimoniales || "data-patrimoniale" in elem.attributes);
21+
if (matched) {
22+
return true;
23+
}
24+
})
25+
document.querySelectorAll("#taxonList li").forEach(e => e.remove());
26+
document.querySelector("#taxonList ul").append(...filteredTaxonDomElem)
27+
}
28+
document.querySelectorAll("#filtresListeEspèces input").forEach(
29+
(element) => element.addEventListener("input", filterListeEspèces)
30+
)
2431
});

atlas/templates/core/listTaxons.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{% if config.DISPLAY_PATRIMONIALITE %}
3737
<div class="custom-control custom-switch">
3838
<input id="filtrePatrimoniales" name="filtrePatrimoniales" type="checkbox" class="custom-control-input" />
39-
<label for="filtrePatrimoniales" class="custom-control-label">{{ _("espèces.%(label_patrimonialite)s.uniquement", label_patrimonialite=config.PATRIMONIALITE.label) }}</label>
39+
<label for="filtrePatrimoniales" class="custom-control-label">{{ _("espèces.%(label_patrimonialite)s.uniquement", label_patrimonialite=config.PATRIMONIALITE.label_pluriel)|lower }}</label>
4040
</div>
4141
{% endif %}
4242
</div>

0 commit comments

Comments
 (0)