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 @@
if (this.query !== event.target.value) {
this.query = event.target.value;
var currentGroup, currentGroupVisible;
$.each($('li', this.$ul), $.proxy(function(index, element) {
var value = $('input', element).val();
var text = $('label', element).text();
......@@ -757,11 +758,18 @@
showElement = true;
}
if (showElement) {
$(element).show().removeClass("filter-hidden");
}
else {
$(element).hide().addClass("filter-hidden");
// Toggle current element (group or group item) according to showElement boolean
$(element).toggle(showElement).toggleClass('filter-hidden', !showElement);
// Differentiate groups and group items
if ($('label', element).hasClass('multiselect-group')) {
// 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));
......
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