aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.position.js
diff options
context:
space:
mode:
authorDavid Murdoch <musicisair@yahoo.com>2011-05-11 16:44:20 -0700
committerDavid Murdoch <musicisair@yahoo.com>2011-05-11 16:44:20 -0700
commitabf3a86c8b4220442d35c2da61544d5a0a529b77 (patch)
tree4f3adde39ece84060c7cb3177dfef217307c4c4c /ui/jquery.ui.position.js
parentc6afaa10727fdabefad129cf76cf8a4d2caafb60 (diff)
downloadjquery-ui-abf3a86c8b4220442d35c2da61544d5a0a529b77.tar.gz
jquery-ui-abf3a86c8b4220442d35c2da61544d5a0a529b77.zip
Fix issue when window is "within".
Diffstat (limited to 'ui/jquery.ui.position.js')
-rw-r--r--ui/jquery.ui.position.js46
1 files changed, 24 insertions, 22 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index 184571154..eb94a6457 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -37,8 +37,6 @@ $.fn.position = function( options ) {
targetHeight,
basePosition;
- options.within = within;
-
if ( targetElem.nodeType === 9 ) {
targetWidth = target.width();
targetHeight = target.height();
@@ -187,11 +185,12 @@ $.fn.position = function( options ) {
$.ui.position = {
fit: {
left: function( position, data ) {
- var win = $( data.within ),
- winOffset = win.offset(),
- outerWidth = win.outerWidth(),
- overLeft = win.scrollLeft() - data.collisionPosition.left + winOffset.left,
- overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - win.scrollLeft() - winOffset.left;
+ var win = data.within,
+ isWindow = $.isWindow(data.within[0]),
+ winOffset = isWindow ? 0 : win.offset().left,
+ outerWidth = isWindow ? win.width() : win.outerWidth(),
+ overLeft = win.scrollLeft() - data.collisionPosition.left + winOffset,
+ overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - win.scrollLeft() - winOffset;
// element is wider than window or too far left -> align with left edge
if ( data.collisionWidth > outerWidth || overLeft > 0 ) {
@@ -205,11 +204,12 @@ $.ui.position = {
}
},
top: function( position, data ) {
- var win = $( data.within ),
- winOffset = win.offset(),
- outerHeight = win.outerHeight(),
- overTop = win.scrollTop() - data.collisionPosition.top + winOffset.top,
- overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - win.scrollTop() - winOffset.top;
+ var win = data.within,
+ isWindow = $.isWindow(data.within[0]),
+ winOffset = isWindow ? 0 : win.offset().top,
+ outerHeight = isWindow ? win.height() : win.outerHeight(),
+ overTop = win.scrollTop() - data.collisionPosition.top + winOffset,
+ overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - win.scrollTop() - winOffset;
// element is taller than window or too far up -> align with top edge
if ( data.collisionHeight > outerHeight || overTop > 0 ) {
@@ -228,11 +228,12 @@ $.ui.position = {
if ( data.at[ 0 ] === center ) {
return;
}
- var win = $( data.within ),
- winOffset = win.offset(),
- outerWidth = win.outerWidth(),
- overLeft = data.collisionPosition.left - winOffset.left,
- overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - win.scrollLeft() - winOffset.left,
+ var win = data.within,
+ isWindow = $.isWindow(data.within[0]),
+ winOffset = isWindow ? 0 : win.offset().left,
+ outerWidth = isWindow ? win.width() : win.outerWidth(),
+ overLeft = data.collisionPosition.left - winOffset,
+ overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - win.scrollLeft() - winOffset
left = data.my[ 0 ] === "left",
myOffset = data.my[ 0 ] === "left" ?
-data.elemWidth :
@@ -251,11 +252,12 @@ $.ui.position = {
if ( data.at[ 1 ] === center ) {
return;
}
- var win = $( data.within ),
- winOffset = win.offset(),
- outerHeight = win.outerHeight(),
- overTop = data.collisionPosition.top - winOffset.top,
- overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - win.scrollTop() - winOffset.top,
+ var win = data.within,
+ isWindow = $.isWindow(data.within[0]),
+ winOffset = isWindow ? 0 : win.offset().top,
+ outerHeight = isWindow ? win.height() : win.outerHeight(),
+ overTop = data.collisionPosition.top - winOffset,
+ overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - win.scrollTop() - winOffset,
top = data.my[ 1 ] === "top",
myOffset = top ?
-data.elemHeight :