js: Support custom collapsible controls in place of the default one

This commit is contained in:
Johannes Meyer 2021-05-05 17:59:12 +02:00
parent c8497c8e6f
commit f50c095e15
1 changed files with 8 additions and 1 deletions
public/js/icinga/behavior

View File

@ -48,6 +48,10 @@
var toggleSelector = collapsible.dataset.toggleElement;
if (!! toggleSelector) {
var toggle = $(collapsible).children(toggleSelector)[0];
if (! toggle && $(collapsible.nextSibling).is(toggleSelector)) {
toggle = collapsible.nextSibling;
}
if (! toggle) {
_this.icinga.logger.error(
'[Collapsible] Control `' + toggleSelector + '` not found in .collapsible', collapsible);
@ -281,7 +285,10 @@
height += parseFloat(window.getComputedStyle(collapsible).getPropertyValue('padding-top'));
if (!! collapsible.dataset.toggleElement) {
if (
!! collapsible.dataset.toggleElement
&& ! $(collapsible.nextSibling).is(collapsible.dataset.toggleElement)
) {
var toggle = $(collapsible).children(collapsible.dataset.toggleElement)[0];
height += toggle.offsetHeight; // TODO: Very expensive at times. (50ms+) Check why!
height += parseFloat(window.getComputedStyle(toggle).getPropertyValue('margin-top'));