From f4fab54f568efcce9bae0a5948ea1b44622b66de Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 12 Jul 2018 19:32:49 +0200 Subject: [PATCH] Add radioButton support for WoltLabSuite/Core/Ui/ItemList/Filter Close #2696 --- .../WoltLabSuite/Core/Ui/ItemList/Filter.js | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Filter.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Filter.js index 800b7cafaf..da95befb73 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Filter.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Filter.js @@ -285,12 +285,28 @@ define(['Core', 'EventKey', 'Language', 'List', 'StringUtil', 'Dom/Util', 'Ui/Si elBySelAll('li', this._element, function(li) { var checkbox = elBySel('input[type="checkbox"]', li); - if (checkbox.checked) li.classList.add('active'); - - checkbox.addEventListener('change', function() { - li.classList[(checkbox.checked ? 'add' : 'remove')]('active'); - }); - }); + if (checkbox) { + if (checkbox.checked) li.classList.add('active'); + + checkbox.addEventListener('change', function() { + li.classList[(checkbox.checked ? 'add' : 'remove')]('active'); + }); + } + else { + var radioButton = elBySel('input[type="radio"]', li); + if (radioButton) { + if (radioButton.checked) li.classList.add('active'); + + radioButton.addEventListener('change', function() { + elBySelAll('li', this._element, function(everyLi) { + everyLi.classList.remove('active'); + }); + + li.classList[(radioButton.checked ? 'add' : 'remove')]('active'); + }.bind(this)); + } + } + }.bind(this)); // re-insert the modified DOM parent.insertBefore(this._element, nextSibling); -- 2.20.1