Add radioButton support for WoltLabSuite/Core/Ui/ItemList/Filter
authorMatthias Schmidt <gravatronics@live.com>
Thu, 12 Jul 2018 17:32:49 +0000 (19:32 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 12 Jul 2018 17:32:49 +0000 (19:32 +0200)
Close #2696

wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList/Filter.js

index 800b7cafafaad511d19b3970b7e095490e0de12e..da95befb7345315456fe95fd33086325e89980cf 100644 (file)
@@ -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);