Skip to content

Commit

Permalink
Merge pull request #4869 from Rawi01/patch-4868
Browse files Browse the repository at this point in the history
Fix #4868: Hide/Show all items at once
  • Loading branch information
tandraschko committed Jun 25, 2019
2 parents a5cf035 + 8ad413b commit 4ad4339
Showing 1 changed file with 18 additions and 7 deletions.
Expand Up @@ -877,40 +877,51 @@ PrimeFaces.widget.SelectOneMenu = PrimeFaces.widget.DeferredWidget.extend({
this.itemsContainer.children('.ui-selectonemenu-item-group').show();
}
else {
var hide = [];
var show = [];

for(var i = 0; i < this.options.length; i++) {
var option = this.options.eq(i),
itemLabel = this.cfg.caseSensitive ? option.text() : option.text().toLowerCase(),
item = this.items.eq(i);

if(item.hasClass('ui-noselection-option')) {
item.hide();
hide.push(item);
}
else {
if(this.filterMatcher(itemLabel, filterValue))
item.show();
show.push(item);
else
item.hide();
hide.push(item);
}
}

$.each(hide, function(i, o) { o.hide() });
$.each(show, function(i, o) { o.show() });
hide = [];
show = [];

//Toggle groups
var groups = this.itemsContainer.children('.ui-selectonemenu-item-group');
for(var g = 0; g < groups.length; g++) {
var group = groups.eq(g);

if(g === (groups.length - 1)) {
if(group.nextAll().filter(':visible').length === 0)
group.hide();
hide.push(group);
else
group.show();
show.push(group);
}
else {
if(group.nextUntil('.ui-selectonemenu-item-group').filter(':visible').length === 0)
group.hide();
hide.push(group);
else
group.show();
show.push(group);
}
}

$.each(hide, function(i, o) { o.hide() });
$.each(show, function(i, o) { o.show() });
}

var firstVisibleItem = this.items.filter(':visible:not(.ui-state-disabled):first');
Expand Down

0 comments on commit 4ad4339

Please sign in to comment.