From: Alexander Ebert Date: Fri, 25 Nov 2016 17:00:52 +0000 (+0100) Subject: Fixed nested collapsible bbcode X-Git-Tag: 3.0.0_RC_1~138 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=943ac7f5795a646be261f4051221b5e5b1e31cf5;p=GitHub%2FWoltLab%2FWCF.git Fixed nested collapsible bbcode --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Collapsible.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Collapsible.js index c351868d2b..3a86bf88da 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Collapsible.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Collapsible.js @@ -19,40 +19,43 @@ define([], function() { var container, toggleButton; while (_containers.length) { container = _containers[0]; - container.classList.remove('jsCollapsibleBbcode'); - toggleButton = elBySel('.toggleButton', container); - if (toggleButton === null) { + toggleButton = elBySelAll('.toggleButton', container)[0]; + if (toggleButton === undefined) { continue; } - (function(container, toggleButton) { - var toggle = function(event) { - if (container.classList.toggle('collapsed')) { - toggleButton.textContent = elData(toggleButton, 'title-expand'); - - if (event instanceof Event) { - // negative top value means the upper boundary is not within the viewport - var top = container.getBoundingClientRect().top; - if (top < 0) { - var y = window.pageYOffset + (top - 100); - if (y < 0) y = 0; - window.scrollTo(window.pageXOffset, y); + if (toggleButton.closest('.jsCollapsibleBbcode') === container) { + (function (container, toggleButton) { + var toggle = function (event) { + if (container.classList.toggle('collapsed')) { + toggleButton.textContent = elData(toggleButton, 'title-expand'); + + if (event instanceof Event) { + // negative top value means the upper boundary is not within the viewport + var top = container.getBoundingClientRect().top; + if (top < 0) { + var y = window.pageYOffset + (top - 100); + if (y < 0) y = 0; + window.scrollTo(window.pageXOffset, y); + } } } + else { + toggleButton.textContent = elData(toggleButton, 'title-collapse'); + } + }; + + toggleButton.addEventListener(WCF_CLICK_EVENT, toggle); + + // expand boxes that are initially scrolled + if (container.scrollTop !== 0) { + toggle(); } - else { - toggleButton.textContent = elData(toggleButton, 'title-collapse'); - } - }; - - toggleButton.addEventListener(WCF_CLICK_EVENT, toggle); - - // expand boxes that are initially scrolled - if (container.scrollTop !== 0) { - toggle(); - } - })(container, toggleButton); + })(container, toggleButton); + } + + container.classList.remove('jsCollapsibleBbcode'); } } };