Adds further dropdown position checks for overlay dropdowns
authorMatthias Schmidt <gravatronics@live.com>
Fri, 2 Aug 2013 13:16:47 +0000 (15:16 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 2 Aug 2013 13:16:47 +0000 (15:16 +0200)
wcfsetup/install/files/js/WCF.js

index b91a5d3e8140b513f721a3bea26a377e3ef11452..98a6982e16cf9a715e3cbe1397236b89c75e8b59 100755 (executable)
@@ -749,14 +749,28 @@ WCF.Dropdown = {
                var $dialogContent = $(event.currentTarget);
                $dialogContent.find('.dropdown.dropdownOpen').each(function(index, element) {
                        var $dropdown = $(element);
-                       var $scrollTolerance = $(element).height() / 2;
+                       var $dropdownID = $dropdown.wcfIdentify();
+                       var $dropdownOffset = $dropdown.offset();
+                       var $dialogContentOffset = $dialogContent.offset();
+                       
+                       var $verticalScrollTolerance = $(element).height() / 2;
                        
                        // check if dropdown toggle is still (partially) visible 
-                       if ($dropdown.offset().top + $scrollTolerance <= $dialogContent.offset().top) { // top check
-                               WCF.Dropdown.toggleDropdown($dropdown.wcfIdentify());
+                       if ($dropdownOffset.top + $verticalScrollTolerance <= $dialogContentOffset.top) {
+                               // top check
+                               WCF.Dropdown.toggleDropdown($dropdownID);
+                       }
+                       else if ($dropdownOffset.top >= $dialogContentOffset.top + $dialogContent.height()) {
+                               // bottom check
+                               WCF.Dropdown.toggleDropdown($dropdownID);
+                       }
+                       else if ($dropdownOffset.left <= $dialogContentOffset.left) {
+                               // left check
+                               WCF.Dropdown.toggleDropdown($dropdownID);
                        }
-                       else if ($dropdown.offset().top >= $dialogContent.offset().top + $dialogContent.height()) { // bottom check
-                               WCF.Dropdown.toggleDropdown($dropdown.wcfIdentify());
+                       else if ($dropdownOffset.left >= $dialogContentOffset.left + $dialogContent.width()) {
+                               // right check
+                               WCF.Dropdown.toggleDropdown($dropdownID);
                        }
                        else {
                                WCF.Dropdown.setAlignmentByID($dropdown.wcfIdentify());