Commit 5bcf70c0 authored by Philippe Deschaseaux's avatar Philippe Deschaseaux

Alter filtering rules for optgroups

Altered filtering rules for optgroups
* Optgoup header is visible if at least one of its item is visible
* All optgroups items are visible if optgroup name satisfies filter
The resulting behaviour seems more consistent to me.
parent 8b42b6a9
...@@ -686,6 +686,7 @@ ...@@ -686,6 +686,7 @@
if (this.query !== event.target.value) { if (this.query !== event.target.value) {
this.query = event.target.value; this.query = event.target.value;
var currentGroup, currentGroupVisible; // PDX
$.each($('li', this.$ul), $.proxy(function(index, element) { $.each($('li', this.$ul), $.proxy(function(index, element) {
var value = $('input', element).val(); var value = $('input', element).val();
var text = $('label', element).text(); var text = $('label', element).text();
...@@ -713,11 +714,18 @@ ...@@ -713,11 +714,18 @@
showElement = true; showElement = true;
} }
if (showElement) { // Toggle current element (group or group item) according to showElement boolean
$(element).show().removeClass("filter-hidden"); $(element).toggle(showElement).toggleClass('filter-hidden', !showElement); // PDX
} // Differentiate groups and group items
else { if ($('label', element).hasClass('multiselect-group')) {
$(element).hide().addClass("filter-hidden"); // Remember group status
currentGroup = element;
currentGroupVisible = showElement;
} else {
// show group name when at least one of its items is visible
if (showElement) $(currentGroup).show().removeClass('filter-hidden');
// show all group items when group name satisfies filter
if (!showElement && currentGroupVisible) $(element).show().removeClass('filter-hidden');
} }
} }
}, this)); }, this));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment