Position: Fix style issues

Closes gh-1499
This commit is contained in:
Jörn Zaefferer 2015-03-14 12:33:03 +01:00
parent 62e0092156
commit 6b34ae952b

View File

@ -15,7 +15,7 @@
//>>docs: http://api.jqueryui.com/position/ //>>docs: http://api.jqueryui.com/position/
//>>demos: http://jqueryui.com/position/ //>>demos: http://jqueryui.com/position/
(function( factory ) { ( function( factory ) {
if ( typeof define === "function" && define.amd ) { if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module. // AMD. Register as an anonymous module.
@ -25,8 +25,8 @@
// Browser globals // Browser globals
factory( jQuery ); factory( jQuery );
} }
}(function( $ ) { }( function( $ ) {
(function() { ( function() {
$.ui = $.ui || {}; $.ui = $.ui || {};
@ -53,7 +53,7 @@ function parseCss( element, property ) {
} }
function getDimensions( elem ) { function getDimensions( elem ) {
var raw = elem[0]; var raw = elem[ 0 ];
if ( raw.nodeType === 9 ) { if ( raw.nodeType === 9 ) {
return { return {
width: elem.width(), width: elem.width(),
@ -89,7 +89,7 @@ $.position = {
} }
var w1, w2, var w1, w2,
div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ), div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
innerDiv = div.children()[0]; innerDiv = div.children()[ 0 ];
$( "body" ).append( div ); $( "body" ).append( div );
w1 = innerDiv.offsetWidth; w1 = innerDiv.offsetWidth;
@ -98,12 +98,12 @@ $.position = {
w2 = innerDiv.offsetWidth; w2 = innerDiv.offsetWidth;
if ( w1 === w2 ) { if ( w1 === w2 ) {
w2 = div[0].clientWidth; w2 = div[ 0 ].clientWidth;
} }
div.remove(); div.remove();
return (cachedScrollbarWidth = w1 - w2); return ( cachedScrollbarWidth = w1 - w2 );
}, },
getScrollInfo: function( within ) { getScrollInfo: function( within ) {
var overflowX = within.isWindow || within.isDocument ? "" : var overflowX = within.isWindow || within.isDocument ? "" :
@ -111,9 +111,9 @@ $.position = {
overflowY = within.isWindow || within.isDocument ? "" : overflowY = within.isWindow || within.isDocument ? "" :
within.element.css( "overflow-y" ), within.element.css( "overflow-y" ),
hasOverflowX = overflowX === "scroll" || hasOverflowX = overflowX === "scroll" ||
( overflowX === "auto" && within.width < within.element[0].scrollWidth ), ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
hasOverflowY = overflowY === "scroll" || hasOverflowY = overflowY === "scroll" ||
( overflowY === "auto" && within.height < within.element[0].scrollHeight ); ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
return { return {
width: hasOverflowY ? $.position.scrollbarWidth() : 0, width: hasOverflowY ? $.position.scrollbarWidth() : 0,
height: hasOverflowX ? $.position.scrollbarWidth() : 0 height: hasOverflowX ? $.position.scrollbarWidth() : 0
@ -121,7 +121,7 @@ $.position = {
}, },
getWithinInfo: function( element ) { getWithinInfo: function( element ) {
var withinElement = $( element || window ), var withinElement = $( element || window ),
isWindow = $.isWindow( withinElement[0] ), isWindow = $.isWindow( withinElement[ 0 ] ),
isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9; isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
return { return {
element: withinElement, element: withinElement,
@ -152,7 +152,7 @@ $.fn.position = function( options ) {
offsets = {}; offsets = {};
dimensions = getDimensions( target ); dimensions = getDimensions( target );
if ( target[0].preventDefault ) { if ( target[ 0 ].preventDefault ) {
// force left top to allow flipping // force left top to allow flipping
options.at = "left top"; options.at = "left top";
} }
@ -169,7 +169,7 @@ $.fn.position = function( options ) {
horizontalOffset, horizontalOffset,
verticalOffset; verticalOffset;
if ( pos.length === 1) { if ( pos.length === 1 ) {
pos = rhorizontal.test( pos[ 0 ] ) ? pos = rhorizontal.test( pos[ 0 ] ) ?
pos.concat( [ "center" ] ) : pos.concat( [ "center" ] ) :
rvertical.test( pos[ 0 ] ) ? rvertical.test( pos[ 0 ] ) ?
@ -192,7 +192,7 @@ $.fn.position = function( options ) {
rposition.exec( pos[ 0 ] )[ 0 ], rposition.exec( pos[ 0 ] )[ 0 ],
rposition.exec( pos[ 1 ] )[ 0 ] rposition.exec( pos[ 1 ] )[ 0 ]
]; ];
}); } );
// normalize collision option // normalize collision option
if ( collision.length === 1 ) { if ( collision.length === 1 ) {
@ -215,7 +215,7 @@ $.fn.position = function( options ) {
basePosition.left += atOffset[ 0 ]; basePosition.left += atOffset[ 0 ];
basePosition.top += atOffset[ 1 ]; basePosition.top += atOffset[ 1 ];
return this.each(function() { return this.each( function() {
var collisionPosition, using, var collisionPosition, using,
elem = $( this ), elem = $( this ),
elemWidth = elem.outerWidth(), elemWidth = elem.outerWidth(),
@ -268,9 +268,9 @@ $.fn.position = function( options ) {
at: options.at, at: options.at,
within: within, within: within,
elem: elem elem: elem
}); } );
} }
}); } );
if ( options.using ) { if ( options.using ) {
// adds feedback as second argument to using callback, if present // adds feedback as second argument to using callback, if present
@ -313,7 +313,7 @@ $.fn.position = function( options ) {
} }
elem.offset( $.extend( position, { using: using } ) ); elem.offset( $.extend( position, { using: using } ) );
}); } );
}; };
$.ui.position = { $.ui.position = {
@ -476,7 +476,7 @@ $.ui.position = {
}; };
// fraction support test // fraction support test
(function() { ( function() {
var testElement, testElementParent, testElementStyle, offsetLeft, i, var testElement, testElementParent, testElementStyle, offsetLeft, i,
body = document.getElementsByTagName( "body" )[ 0 ], body = document.getElementsByTagName( "body" )[ 0 ],
div = document.createElement( "div" ); div = document.createElement( "div" );
@ -496,7 +496,7 @@ $.ui.position = {
position: "absolute", position: "absolute",
left: "-1000px", left: "-1000px",
top: "-1000px" top: "-1000px"
}); } );
} }
for ( i in testElementStyle ) { for ( i in testElementStyle ) {
testElement.style[ i ] = testElementStyle[ i ]; testElement.style[ i ] = testElementStyle[ i ];
@ -512,10 +512,10 @@ $.ui.position = {
testElement.innerHTML = ""; testElement.innerHTML = "";
testElementParent.removeChild( testElement ); testElementParent.removeChild( testElement );
})(); } )();
})(); } )();
return $.ui.position; return $.ui.position;
})); } ) );