From: Alexander Ebert Date: Thu, 21 Nov 2013 14:23:00 +0000 (+0100) Subject: Fixed width calculation of flexible menu X-Git-Tag: 2.0.0_RC_2~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8960a2357726ef223eb7a6f1ea09d9c0bc9446be;p=GitHub%2FWoltLab%2FWCF.git Fixed width calculation of flexible menu --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 864f6feff7..d769d55f03 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -6113,7 +6113,7 @@ WCF.System.FlexibleMenu = { this._dropdowns[containerID].detach(); } - var $maximumWidth = $container.parent().innerWidth() - $dropdownWidth; + var $maximumWidth = $container.parent().innerWidth(); // substract padding from the parent element $maximumWidth -= parseInt($container.parent().css('padding-left').replace(/px$/, '')) + parseInt($container.parent().css('padding-right').replace(/px$/, '')); @@ -6124,8 +6124,11 @@ WCF.System.FlexibleMenu = { // substract paddings from the actual list $maximumWidth -= parseInt($container.children('ul:eq(0)').css('padding-left').replace(/px$/, '')) + parseInt($container.children('ul:eq(0)').css('padding-right').replace(/px$/, '')); - if ($currentWidth > $maximumWidth) { - var $menuItems = $menuItems.filter(':not(.active):not(.ui-state-active)'); + if ($currentWidth > $maximumWidth || (this._hasHiddenItems[containerID] && ($currentWidth > $maximumWidth - $dropdownWidth))) { + var $menuItems = $menuItems.filter(':not(.active):not(.ui-state-active):visible'); + + // substract dropdown width from maximum width + $maximumWidth -= $dropdownWidth; // hide items starting with the last in list (ignores active item) for (var $i = ($menuItems.length - 1); $i >= 0; $i--) { @@ -6149,10 +6152,18 @@ WCF.System.FlexibleMenu = { else if (this._hasHiddenItems[containerID] && $currentWidth < $maximumWidth) { var $hiddenItems = this._menuItems[containerID].filter(':not(:visible)'); + // substract dropdown width from maximum width unless it is the last item + $maximumWidth -= $dropdownWidth; + // reverts items starting with the first hidden one for (var $i = 0, $length = $hiddenItems.length; $i < $length; $i++) { var $item = $($hiddenItems[$i]); $currentWidth += $item.outerWidth(); + + if ($i + 1 == $length) { + $maximumWidth += $dropdownWidth; + } + if ($currentWidth < $maximumWidth) { // enough space, show item $item.css('display', '');