JS: Check collapsible containers for unique collapsible-id

This commit is contained in:
Florian Strohmaier 2019-01-07 16:07:52 +01:00 committed by Johannes Meyer
parent e375822ef1
commit b73a608742
1 changed files with 28 additions and 22 deletions

View File

@ -34,16 +34,18 @@
$(event.target).find('.collapsible-container').each(function() {
var $this = $(this);
if ($this.find('.collapsible').length > 0) {
$this.addClass('has-collapsible');
if ($this.find('.collapsible').innerHeight() > ($this.data('height') || defaultHeight)) {
$this.append($('#collapsible-control-ghost').clone().removeAttr('id'));
$this.addClass('can-collapse');
}
} else {
if ($this.innerHeight() > ($this.data('height') || defaultHeight)) {
$this.append($('#collapsible-control-ghost').clone().removeAttr('id'));
$this.addClass('can-collapse');
if ($this.data('collapsible-id') && $('[data-collapsible-id=' + $this.data('collapsible-id') + ']').length < 2) {
if ($this.find('.collapsible').length > 0) {
$this.addClass('has-collapsible');
if ($this.find('.collapsible').innerHeight() > ($this.data('height') || defaultHeight)) {
$this.append($('#collapsible-control-ghost').clone().removeAttr('id'));
$this.addClass('can-collapse');
}
} else {
if ($this.innerHeight() > ($this.data('height') || defaultHeight)) {
$this.append($('#collapsible-control-ghost').clone().removeAttr('id'));
$this.addClass('can-collapse');
}
}
}
updateCollapsedState($this);
@ -52,16 +54,18 @@
$(event.target).find('.collapsible-table-container').each(function() {
var $this = $(this);
if ($this.find('.collapsible').length > 0) {
$this.addClass('has-collapsible');
if ($this.find('tr').length > ($this.attr('data-numofrows') || defaultNumOfRows)) {
$this.append($('#collapsible-control-ghost').clone().removeAttr('id'));
$this.addClass('can-collapse');
}
if ($this.data('collapsible-id') && $('[data-collapsible-id=' + $this.data('collapsible-id') + ']').length < 2) {
if ($this.find('.collapsible').length > 0) {
$this.addClass('has-collapsible');
if ($this.find('tr').length > ($this.attr('data-numofrows') || defaultNumOfRows)) {
$this.append($('#collapsible-control-ghost').clone().removeAttr('id'));
$this.addClass('can-collapse');
}
if ($this.find('li').length > ($this.attr('data-numofrows') || defaultNumOfRows)) {
$this.append($('#collapsible-control-ghost').clone().removeAttr('id'));
$this.addClass('can-collapse');
if ($this.find('li').length > ($this.attr('data-numofrows') || defaultNumOfRows)) {
$this.append($('#collapsible-control-ghost').clone().removeAttr('id'));
$this.addClass('can-collapse');
}
}
}
updateCollapsedState($this);
@ -81,11 +85,13 @@
if (expandedContainers.length > maxLength - 1) {
expandedContainers.shift();
}
expandedContainers.push($c.attr('id'));
expandedContainers.push($c.data('collapsible-id'));
} else {
expandedContainers.splice(expandedContainers.indexOf($c.attr('id')), 1);
expandedContainers.splice(expandedContainers.indexOf($c.data('collapsible-id')), 1);
}
console.log(expandedContainers);
updateCollapsedState($c);
};
@ -102,7 +108,7 @@
} else {
$collapsible = $container;
}
if (expandedContainers.indexOf($container.attr('id')) > -1) {
if (expandedContainers.indexOf($container.data('collapsible-id')) > -1) {
$container.removeClass('collapsed');
$collapsible.css({ maxHeight: 'none' });
} else {