From ec4825f6bf5e330853cc9f74dcc7d326e5da1dd8 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 11 Mar 2014 17:06:00 +0100 Subject: [PATCH] Added proper support for dropdown menus in RTL --- wcfsetup/install/files/js/WCF.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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')) { -- 2.20.1