From f594c0623ae096165df88160575ef55952be92c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=CC=88rn=20Zaefferer?= Date: Wed, 18 Apr 2012 00:30:47 +0200 Subject: [PATCH] Position: Make getOffsets and parseCss helpers local functions, no need to expose those --- ui/jquery.ui.position.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 17d43b2a4..7d30e4bca 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -19,6 +19,16 @@ var rhorizontal = /left|center|right/, _position = $.fn.position, cachedScrollbarWidth; +function getOffsets( offsets, width, height ) { + return [ + parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), + parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) + ]; +} +function parseCss( element, property ) { + return parseInt( $.css( element, property ), 10 ) || 0; +} + $.position = { scrollbarWidth: function() { if ( cachedScrollbarWidth !== undefined ) { @@ -65,15 +75,6 @@ $.position = { width: isWindow ? withinElement.width() : withinElement.outerWidth(), height: isWindow ? withinElement.height() : withinElement.outerHeight() }; - }, - getOffsets: function( offsets, width, height ) { - return [ - parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), - parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) - ]; - }, - parseCss: function( element, property ) { - return parseInt( $.css( element, property ), 10 ) || 0; } }; @@ -167,7 +168,7 @@ $.fn.position = function( options ) { basePosition.top += targetHeight / 2; } - atOffset = $.position.getOffsets( offsets.at, targetWidth, targetHeight ); + atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); basePosition.left += atOffset[ 0 ]; basePosition.top += atOffset[ 1 ]; @@ -175,12 +176,12 @@ $.fn.position = function( options ) { var elem = $( this ), elemWidth = elem.outerWidth(), elemHeight = elem.outerHeight(), - marginLeft = $.position.parseCss( this, "marginLeft" ), - marginTop = $.position.parseCss( this, "marginTop" ), - collisionWidth = elemWidth + marginLeft + $.position.parseCss( this, "marginRight" ) + scrollInfo.width, - collisionHeight = elemHeight + marginTop + $.position.parseCss( this, "marginBottom" ) + scrollInfo.height, + marginLeft = parseCss( this, "marginLeft" ), + marginTop = parseCss( this, "marginTop" ), + collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width, + collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height, position = $.extend( {}, basePosition ), - myOffset = $.position.getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ), + myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ), collisionPosition, using; -- 2.39.5