Hiding mobile navigation if there are no available options
authorAlexander Ebert <ebert@woltlab.com>
Wed, 26 Oct 2016 09:24:24 +0000 (11:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 26 Oct 2016 09:28:03 +0000 (11:28 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js

index 9c08fe0a902dbcd1d974f433ab3ccd48d42c64a3..48102151bd81a1ee0af290a7197387c02b3df733 100644 (file)
@@ -159,6 +159,12 @@ define(
                                if (navigation.classList.contains('jsMobileButtonGroupNavigation')) continue;
                                else navigation.classList.add('jsMobileButtonGroupNavigation');
                                
+                               var list = elBySel('.buttonList', navigation);
+                               if (list.childElementCount === 0) {
+                                       // ignore objects without options
+                                       continue;
+                               }
+                               
                                navigation.parentNode.classList.add('hasMobileNavigation');
                                
                                var button = elCreate('a');
@@ -168,7 +174,7 @@ define(
                                span.className = 'icon icon24 fa-ellipsis-v';
                                button.appendChild(span);
                                
-                               (function(navigation, button) {
+                               (function(navigation, button, list) {
                                        button.addEventListener(WCF_CLICK_EVENT, function(event) {
                                                event.preventDefault();
                                                event.stopPropagation();
@@ -176,13 +182,12 @@ define(
                                                navigation.classList.toggle('open');
                                        });
                                        
-                                       var list = elBySel('.buttonList', navigation);
                                        list.addEventListener(WCF_CLICK_EVENT, function(event) {
                                                event.stopPropagation();
                                                
                                                navigation.classList.remove('open');
                                        });
-                               })(navigation, button);
+                               })(navigation, button, list);
                                
                                navigation.insertBefore(button, navigation.firstChild);
                        }