Fixed calculation for position aligned to the right boundary
authorAlexander Ebert <ebert@woltlab.com>
Wed, 4 Feb 2015 10:35:30 +0000 (11:35 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 4 Feb 2015 10:35:30 +0000 (11:35 +0100)
wcfsetup/install/files/js/WCF.js

index 7383d003b43f42aa774ff1c11adb33a9d96297b7..30c0bc96c20223da6c25fddccedb05af689d63f3 100755 (executable)
@@ -1623,7 +1623,7 @@ WCF.Dropdown.Interactive.Instance = Class.extend({
                        $left = this._getPositionLeft($elementOffsets, $dropdownDimensions, $pageWidth);
                        
                        if (!$left.result) {
-                               $right = this._getPositionRight($elementOffsets, $dropdownDimensions, $elementDimensions);
+                               $right = this._getPositionRight($elementOffsets, $dropdownDimensions, $elementDimensions, $pageWidth);
                                
                                if ($right.result) {
                                        $left = null;
@@ -1634,7 +1634,7 @@ WCF.Dropdown.Interactive.Instance = Class.extend({
                        }
                }
                else {
-                       $right = this._getPositionRight($elementOffsets, $dropdownDimensions, $elementDimensions);
+                       $right = this._getPositionRight($elementOffsets, $dropdownDimensions, $elementDimensions, $pageWidth);
                        
                        if (!$right.result) {
                                $left = this._getPositionLeft($elementOffsets, $dropdownDimensions, $pageWidth);
@@ -1695,11 +1695,12 @@ WCF.Dropdown.Interactive.Instance = Class.extend({
         * @param       object          elementOffsets
         * @param       object          dropdownDimensions
         * @param       object          elementDimensions
+        * @param       integer         pageWidth
         * @return      object
         */
-       _getPositionRight: function(elementOffsets, dropdownDimensions, elementDimensions) {
+       _getPositionRight: function(elementOffsets, dropdownDimensions, elementDimensions, pageWidth) {
                var $left = (elementOffsets.left + elementDimensions.width) - dropdownDimensions.width;
-               var $right = elementOffsets.right;
+               var $right = pageWidth - (elementOffsets.left + elementDimensions.width);
                
                return {
                        result: ($left > 0),