From 9db77c5dd2d04b931ab204005cba35dfe77fb0a3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 10 Sep 2013 12:44:17 +0200 Subject: [PATCH] Dropdown menus now use the proper vertical direction --- wcfsetup/install/files/js/WCF.js | 29 ++++++++++++++++++++-- wcfsetup/install/files/style/dropdown.less | 18 ++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 2530d2289f..a98278f859 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -1017,7 +1017,7 @@ WCF.Dropdown = { var $left = 'auto'; var $right = 'auto'; if ($align === 'left') { - dropdownMenu.removeClass('dropdownArrorRight'); + dropdownMenu.removeClass('dropdownArrowRight'); $left = $dropdownOffsets.left + 'px'; } @@ -1027,10 +1027,35 @@ WCF.Dropdown = { $right = ($windowWidth - ($dropdownOffsets.left + $dropdownDimensions.width)) + 'px'; } + // calculate vertical offset + var $wasHidden = true; + if (dropdownMenu.hasClass('dropdownOpen')) { + $wasHidden = false; + dropdownMenu.removeClass('dropdownOpen'); + } + + var $bottom = 'auto'; + var $top = $dropdownOffsets.top + $dropdownDimensions.height + 7; + var $documentHeight = $(document).height(); + if ($top + $menuDimensions.height > $documentHeight) { + $bottom = $(window).height() - $dropdownOffsets.top + 10; + $top = 'auto'; + + dropdownMenu.addClass('dropdownArrowBottom'); + } + else { + dropdownMenu.removeClass('dropdownArrowBottom'); + } + + if (!$wasHidden) { + dropdownMenu.addClass('dropdownOpen'); + } + dropdownMenu.css({ + bottom: $bottom, left: $left, right: $right, - top: $dropdownOffsets.top + $dropdownDimensions.height + 7 + 'px' + top: $top }); }, diff --git a/wcfsetup/install/files/style/dropdown.less b/wcfsetup/install/files/style/dropdown.less index b67d306f9e..c2486a418c 100644 --- a/wcfsetup/install/files/style/dropdown.less +++ b/wcfsetup/install/files/style/dropdown.less @@ -142,6 +142,24 @@ } } + &.dropdownArrowBottom { + &:after { + border: 7px transparent solid; + border-top-color: @wcfDropdownBorderColor; + border-bottom-width: 0; + bottom: -7px; + top: auto; + } + + &:before { + border: 6px transparent solid; + border-top-color: @wcfDropdownBackgroundColor; + border-bottom-width: 0; + bottom: -6px; + top: auto; + } + } + &.dropdownOpen { display: block; } -- 2.20.1