From f50c095e155161235295c4309c171af1e86cf4ef Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 5 May 2021 17:59:12 +0200 Subject: [PATCH] js: Support custom collapsible controls in place of the default one --- public/js/icinga/behavior/collapsible.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/js/icinga/behavior/collapsible.js b/public/js/icinga/behavior/collapsible.js index 64265f5a6..507ad59f3 100644 --- a/public/js/icinga/behavior/collapsible.js +++ b/public/js/icinga/behavior/collapsible.js @@ -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'));