From b583b2f3afb4721e1ca4c582663639668e70430c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 26 Oct 2016 11:24:24 +0200 Subject: [PATCH] Hiding mobile navigation if there are no available options --- .../install/files/js/WoltLabSuite/Core/Ui/Mobile.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js index 9c08fe0a90..48102151bd 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Mobile.js @@ -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); } -- 2.20.1