Commit 744aa223 authored by David Stutz's avatar David Stutz

Merge pull request #395 from ehouais/filtering-&-optgroups

Correct filtering with optgroups.
parents 40bbecbf e36c14c0
...@@ -730,6 +730,7 @@ ...@@ -730,6 +730,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;
$.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();
...@@ -757,11 +758,18 @@ ...@@ -757,11 +758,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);
} // 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