diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 7d30e4bca..5be90dcfe 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -86,17 +86,13 @@ $.fn.position = function( options ) { // make a copy, we don't want to modify arguments options = $.extend( {}, options ); - var target = $( options.of ), + var atOffset, targetWidth, targetHeight, targetOffset, basePosition, + target = $( options.of ), within = $.position.getWithinInfo( options.within ), scrollInfo = $.position.getScrollInfo( within ), targetElem = target[0], collision = ( options.collision || "flip" ).split( " " ), - offsets = {}, - atOffset, - targetWidth, - targetHeight, - targetOffset, - basePosition; + offsets = {}; if ( targetElem.nodeType === 9 ) { targetWidth = target.width(); @@ -173,7 +169,8 @@ $.fn.position = function( options ) { basePosition.top += atOffset[ 1 ]; return this.each(function() { - var elem = $( this ), + var collisionPosition, using, + elem = $( this ), elemWidth = elem.outerWidth(), elemHeight = elem.outerHeight(), marginLeft = parseCss( this, "marginLeft" ), @@ -181,9 +178,7 @@ $.fn.position = function( options ) { collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width, collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height, position = $.extend( {}, basePosition ), - myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ), - collisionPosition, - using; + myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); if ( options.my[ 0 ] === "right" ) { position.left -= elemWidth;