Position: Cleanup variable definitions, move undefined vars to the top

This commit is contained in:
Jörn Zaefferer 2012-04-18 16:43:25 +02:00
parent f594c0623a
commit d3dc637b65

View File

@ -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;