From: Alexander Ebert Date: Wed, 26 Oct 2016 09:24:24 +0000 (+0200) Subject: Hiding mobile navigation if there are no available options X-Git-Tag: 3.0.0_Beta_4~11 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b583b2f3afb4721e1ca4c582663639668e70430c;p=GitHub%2FWoltLab%2FWCF.git Hiding mobile navigation if there are no available options --- 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); }