aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.position.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2012-04-12 17:10:51 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2012-04-12 17:10:51 +0200
commit58d5452a7cc58b160035376d9a4a136a4444c0c6 (patch)
treedeab2ea3f3db70b6904d65b56dcefa358a8670d6 /ui/jquery.ui.position.js
parente1a80d59003869f9078271b9b0df8c0e907e2f5b (diff)
downloadjquery-ui-58d5452a7cc58b160035376d9a4a136a4444c0c6.tar.gz
jquery-ui-58d5452a7cc58b160035376d9a4a136a4444c0c6.zip
Position: Refactor css parse calls
Diffstat (limited to 'ui/jquery.ui.position.js')
-rw-r--r--ui/jquery.ui.position.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index bdc23eaec..c87e1d105 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -56,6 +56,9 @@ $.position = {
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;
}
};
@@ -157,12 +160,10 @@ $.fn.position = function( options ) {
var elem = $( this ),
elemWidth = elem.outerWidth(),
elemHeight = elem.outerHeight(),
- marginLeft = parseInt( $.css( this, "marginLeft" ), 10 ) || 0,
- marginTop = parseInt( $.css( this, "marginTop" ), 10 ) || 0,
- collisionWidth = elemWidth + marginLeft +
- ( parseInt( $.css( this, "marginRight" ), 10 ) || 0 ) + scrollInfo.width,
- collisionHeight = elemHeight + marginTop +
- ( parseInt( $.css( this, "marginBottom" ), 10 ) || 0 ) + scrollInfo.height,
+ 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,
position = $.extend( {}, basePosition ),
myOffset = $.position.getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ),
collisionPosition,