From: Alexander Ebert Date: Tue, 11 Mar 2014 16:06:00 +0000 (+0100) Subject: Added proper support for dropdown menus in RTL X-Git-Tag: 2.0.4~21^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ec4825f6bf5e330853cc9f74dcc7d326e5da1dd8;p=GitHub%2FWoltLab%2FWCF.git Added proper support for dropdown menus in RTL --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index edb5653308..fcc7901a83 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -1080,14 +1080,40 @@ WCF.Dropdown = { if ($align === 'left') { dropdownMenu.removeClass('dropdownArrowRight'); - $left = $dropdownOffsets.left + 'px'; + $left = $dropdownOffsets.left; } else { dropdownMenu.addClass('dropdownArrowRight'); - $right = ($windowWidth - ($dropdownOffsets.left + $dropdownDimensions.width)) + 'px'; + $right = ($windowWidth - ($dropdownOffsets.left + $dropdownDimensions.width)); } + // rtl works the same with the exception that we need to offset it with the right boundary + if (WCF.Language.get('wcf.global.pageDirection') == 'rtl') { + var $oldLeft = $left; + var $oldRight = $right; + + // use reverse positioning + if ($left == 'auto') { + dropdownMenu.removeClass('dropdownArrowRight'); + } + else { + $right = $windowWidth - ($dropdownOffsets.left + $dropdownDimensions.width); + $left = 'auto'; + + if ($right + $menuDimensions.width > $windowWidth) { + // exceeded window width, restore ltr values + $left = $oldLeft; + $right = $oldRight; + + dropdownMenu.addClass('dropdownArrowRight'); + } + } + } + + if ($left == 'auto') $right += 'px'; + else $left += 'px'; + // calculate vertical offset var $wasHidden = true; if (dropdownMenu.hasClass('dropdownOpen')) {