Working "tous" filter for places

This commit is contained in:
Théo Marchal 2021-03-06 12:30:44 +01:00
parent 4effbe657e
commit 34e8fe9b12

View File

@ -284,11 +284,7 @@ jQuery(document).ready(function($)
{ {
$('input[name="' + name + 's"]').change(function() $('input[name="' + name + 's"]').change(function()
{ {
// set back array with original available params[name] = []; // remove filter
if (this.checked)
params[name] = originalAvailableOptions[name + "s"];
else
params[name] = []
selectedOptions = gatherURLdata(); selectedOptions = gatherURLdata();
data = originalData; data = originalData;
@ -330,14 +326,33 @@ jQuery(document).ready(function($)
}); });
} }
function visualFilterListItem(name, param) function visualFilterListItem(name)
{ {
$('input[name="' + name + 's"]').change(function()
{
params[name] = []; // remove filter
if (this.checked)
{
$('select[name="' + name + '"] option[value=""]').prop('selected', true);
$('select[name="' + name + '"]').attr('disabled', 'disabled');
}
else
$('select[name="' + name + '"]').removeAttr('disabled');
selectedOptions = gatherURLdata();
data = originalData;
filterData(selectedOptions);
availableOptions = [];
availableOptions = gatherData();
updateMenu(availableOptions);
});
$('select[name="' + name + '"]').change(function() $('select[name="' + name + '"]').change(function()
{ {
if (this.value == "" && name == "place") if (this.value == "" && name == "place")
param.pop(); params[name].pop();
else else
param.push(this.value); params[name].push(this.value);
selectedOptions = gatherURLdata(); selectedOptions = gatherURLdata();
data = originalData; data = originalData;
@ -355,7 +370,8 @@ jQuery(document).ready(function($)
visualFilterCheckboxItem("theme"); visualFilterCheckboxItem("theme");
visualFilterCheckboxItem("dimension"); visualFilterCheckboxItem("dimension");
visualFilterCheckboxItem("help"); visualFilterCheckboxItem("help");
visualFilterListItem("place", paramPlace);
visualFilterListItem("place");
}); });
/*********************/ /*********************/