From d3dc637b657b9e491c24a5d1ccd278178f102844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 18 Apr 2012 16:43:25 +0200 Subject: [PATCH] Position: Cleanup variable definitions, move undefined vars to the top --- ui/jquery.ui.position.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) 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;