jquery.suggestions: Use document width instead of <body> width for position calculation
authorMatmaRex <matma.rex@gmail.com>
Wed, 10 Jul 2013 13:10:19 +0000 (15:10 +0200)
committerMatmaRex <matma.rex@gmail.com>
Wed, 10 Jul 2013 13:10:27 +0000 (15:10 +0200)
Almost always, $( 'body' ).width() == $( document ).width(). (This is
the case for all core skins, for example.) However, it is technically
possible to give <body> a width or large margins and break that
assumption, so one of these should be used consistently.

Document width is better here because we're using it to do absolute
positioning, and usually it's relative to the viewport (ie., document
width). This will still break if someone decides to give their <body>
a position: absolute, but that would be quite insane, so let's not
bother.

Bug: 45668
Change-Id: Ib96d1c5c3591495623933e1aa4266b0f13432610

resources/jquery/jquery.suggestions.js

index 44382f0..93fba49 100644 (file)
@@ -220,7 +220,7 @@ $.suggestions = {
                                                } else {
                                                        // Expand from right
                                                        newCSS.left = 'auto';
-                                                       newCSS.right = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() );
+                                                       newCSS.right = $( document ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() );
                                                }
 
                                                context.data.$container.css( newCSS );