From 29b786becf5ef9f27617bee99668b946582d5af3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 6 Jan 2017 17:31:13 +0100 Subject: [PATCH] Fixed recognition of matching control buttons --- .../js/WoltLabSuite/Core/Bbcode/Collapsible.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Collapsible.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Collapsible.js index a2e4994cfc..a30b3d25ab 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Collapsible.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/Collapsible.js @@ -20,8 +20,16 @@ define([], function() { while (_containers.length) { container = _containers[0]; - toggleButton = elBySelAll('.toggleButton', container)[0]; - if (toggleButton && toggleButton.closest('.jsCollapsibleBbcode') === container) { + // find the matching toggle button + toggleButton = null; + elBySelAll('.toggleButton:not(.jsToggleButtonEnabled)', container, function (button) { + //noinspection JSReferencingMutableVariableFromClosure + if (button.closest('.jsCollapsibleBbcode') === container) { + toggleButton = button; + } + }); + + if (toggleButton) { (function (container, toggleButton) { var toggle = function (event) { if (container.classList.toggle('collapsed')) { @@ -42,6 +50,7 @@ define([], function() { } }; + toggleButton.classList.add('jsToggleButtonEnabled'); toggleButton.addEventListener(WCF_CLICK_EVENT, toggle); // expand boxes that are initially scrolled -- 2.20.1