2010-01-07 03:19:50 +00:00
|
|
|
/*
|
|
|
|
* jQuery UI Position @VERSION
|
|
|
|
*
|
2011-01-17 14:13:18 +00:00
|
|
|
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
2010-07-09 13:01:04 +00:00
|
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
|
|
* http://jquery.org/license
|
2010-01-07 03:19:50 +00:00
|
|
|
*
|
|
|
|
* http://docs.jquery.com/UI/Position
|
|
|
|
*/
|
2010-07-13 13:57:58 +00:00
|
|
|
(function( $, undefined ) {
|
2010-01-07 03:19:50 +00:00
|
|
|
|
|
|
|
$.ui = $.ui || {};
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
var rhorizontal = /left|center|right/,
|
|
|
|
rvertical = /top|center|bottom/,
|
2011-03-22 16:25:25 +00:00
|
|
|
roffset = /[+-]\d+%?/,
|
|
|
|
rposition = /^\w+/,
|
|
|
|
rpercent = /%$/,
|
2010-08-27 17:19:51 +00:00
|
|
|
center = "center",
|
2011-05-26 14:22:12 +00:00
|
|
|
_position = $.fn.position;
|
|
|
|
|
|
|
|
$.position = {
|
2011-06-10 20:07:03 +00:00
|
|
|
scrollbarWidth: function() {
|
|
|
|
var w1, w2,
|
|
|
|
div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
|
|
|
|
innerDiv = div.children()[0];
|
|
|
|
|
|
|
|
$( "body" ).append( div );
|
|
|
|
w1 = innerDiv.offsetWidth;
|
|
|
|
div.css( "overflow", "scroll" );
|
|
|
|
|
|
|
|
w2 = innerDiv.offsetWidth;
|
|
|
|
|
2011-05-26 00:53:16 +00:00
|
|
|
if ( w1 === w2 ) {
|
|
|
|
w2 = div[0].clientWidth;
|
|
|
|
}
|
|
|
|
|
2011-06-10 20:07:03 +00:00
|
|
|
div.remove();
|
|
|
|
|
|
|
|
return w1 - w2;
|
2011-05-26 00:53:16 +00:00
|
|
|
},
|
2011-06-10 20:07:03 +00:00
|
|
|
getScrollInfo: function( within ) {
|
2011-05-26 00:53:16 +00:00
|
|
|
var that = within[0],
|
|
|
|
scrollHeight = within.height() < that.scrollHeight,
|
|
|
|
scrollWidth = within.width() < that.scrollWidth,
|
2011-05-26 14:22:12 +00:00
|
|
|
scrollbarWidth = $.position.scrollbarWidth();
|
2011-06-10 20:07:03 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
height: scrollHeight ? scrollbarWidth : 0,
|
|
|
|
width : scrollWidth ? scrollbarWidth : 0
|
|
|
|
};
|
2011-05-26 14:22:12 +00:00
|
|
|
}
|
|
|
|
};
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2010-02-14 18:15:32 +00:00
|
|
|
$.fn.position = function( options ) {
|
|
|
|
if ( !options || !options.of ) {
|
|
|
|
return _position.apply( this, arguments );
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
2010-02-14 18:15:32 +00:00
|
|
|
|
2010-01-07 03:19:50 +00:00
|
|
|
// make a copy, we don't want to modify arguments
|
2010-02-14 18:15:32 +00:00
|
|
|
options = $.extend( {}, options );
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2010-02-14 18:15:32 +00:00
|
|
|
var target = $( options.of ),
|
2011-05-11 23:30:21 +00:00
|
|
|
within = $( options.within || window ),
|
2010-08-27 17:34:14 +00:00
|
|
|
targetElem = target[0],
|
2010-02-14 18:15:32 +00:00
|
|
|
collision = ( options.collision || "flip" ).split( " " ),
|
2011-03-22 16:25:25 +00:00
|
|
|
offsets = {},
|
|
|
|
atOffset,
|
2010-01-07 03:19:50 +00:00
|
|
|
targetWidth,
|
|
|
|
targetHeight,
|
|
|
|
basePosition;
|
|
|
|
|
2010-08-27 17:34:14 +00:00
|
|
|
if ( targetElem.nodeType === 9 ) {
|
2010-01-07 03:19:50 +00:00
|
|
|
targetWidth = target.width();
|
|
|
|
targetHeight = target.height();
|
|
|
|
basePosition = { top: 0, left: 0 };
|
2010-12-10 19:34:21 +00:00
|
|
|
} else if ( $.isWindow( targetElem ) ) {
|
2010-01-07 03:19:50 +00:00
|
|
|
targetWidth = target.width();
|
|
|
|
targetHeight = target.height();
|
|
|
|
basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
|
2010-08-27 17:34:14 +00:00
|
|
|
} else if ( targetElem.preventDefault ) {
|
2010-01-07 03:19:50 +00:00
|
|
|
// force left top to allow flipping
|
2010-02-14 18:15:32 +00:00
|
|
|
options.at = "left top";
|
2010-01-07 03:19:50 +00:00
|
|
|
targetWidth = targetHeight = 0;
|
|
|
|
basePosition = { top: options.of.pageY, left: options.of.pageX };
|
|
|
|
} else {
|
|
|
|
targetWidth = target.outerWidth();
|
|
|
|
targetHeight = target.outerHeight();
|
|
|
|
basePosition = target.offset();
|
|
|
|
}
|
|
|
|
|
2011-03-21 18:02:00 +00:00
|
|
|
// force my and at to have valid horizontal and vertical positions
|
2011-06-10 20:07:03 +00:00
|
|
|
// if a value is missing or invalid, it will be converted to center
|
2010-02-14 18:15:32 +00:00
|
|
|
$.each( [ "my", "at" ], function() {
|
2011-03-22 17:12:03 +00:00
|
|
|
var pos = ( options[ this ] || "" ).split( " " ),
|
2011-03-22 16:25:25 +00:00
|
|
|
horizontalOffset,
|
|
|
|
verticalOffset;
|
|
|
|
|
2010-02-14 18:15:32 +00:00
|
|
|
if ( pos.length === 1) {
|
2011-03-22 17:12:03 +00:00
|
|
|
pos = rhorizontal.test( pos[ 0 ] ) ?
|
|
|
|
pos.concat( [ center ] ) :
|
|
|
|
rvertical.test( pos[ 0 ] ) ?
|
2010-08-27 17:19:51 +00:00
|
|
|
[ center ].concat( pos ) :
|
|
|
|
[ center, center ];
|
2010-02-14 18:15:32 +00:00
|
|
|
}
|
2011-03-22 17:12:03 +00:00
|
|
|
pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : center;
|
|
|
|
pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : center;
|
2011-03-22 16:25:25 +00:00
|
|
|
|
|
|
|
// calculate offsets
|
|
|
|
horizontalOffset = roffset.exec( pos[ 0 ] );
|
2011-03-22 17:12:03 +00:00
|
|
|
verticalOffset = roffset.exec( pos[ 1 ] );
|
2011-03-22 16:25:25 +00:00
|
|
|
offsets[ this ] = [
|
|
|
|
horizontalOffset ? horizontalOffset[ 0 ] : 0,
|
|
|
|
verticalOffset ? verticalOffset[ 0 ] : 0
|
|
|
|
];
|
|
|
|
|
|
|
|
// reduce to just the positions without the offsets
|
|
|
|
options[ this ] = [
|
|
|
|
rposition.exec( pos[ 0 ] )[ 0 ],
|
|
|
|
rposition.exec( pos[ 1 ] )[ 0 ]
|
|
|
|
];
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// normalize collision option
|
2010-02-14 18:15:32 +00:00
|
|
|
if ( collision.length === 1 ) {
|
|
|
|
collision[ 1 ] = collision[ 0 ];
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
if ( options.at[ 0 ] === "right" ) {
|
2010-02-14 18:15:32 +00:00
|
|
|
basePosition.left += targetWidth;
|
2011-03-22 17:12:03 +00:00
|
|
|
} else if ( options.at[ 0 ] === center ) {
|
2010-02-14 18:15:32 +00:00
|
|
|
basePosition.left += targetWidth / 2;
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
if ( options.at[ 1 ] === "bottom" ) {
|
2010-02-14 18:15:32 +00:00
|
|
|
basePosition.top += targetHeight;
|
2011-03-22 17:12:03 +00:00
|
|
|
} else if ( options.at[ 1 ] === center ) {
|
2010-02-14 18:15:32 +00:00
|
|
|
basePosition.top += targetHeight / 2;
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 16:25:25 +00:00
|
|
|
atOffset = [
|
|
|
|
parseInt( offsets.at[ 0 ], 10 ) *
|
|
|
|
( rpercent.test( offsets.at[ 0 ] ) ? targetWidth / 100 : 1 ),
|
|
|
|
parseInt( offsets.at[ 1 ], 10 ) *
|
|
|
|
( rpercent.test( offsets.at[ 1 ] ) ? targetHeight / 100 : 1 )
|
|
|
|
];
|
2011-05-12 13:28:01 +00:00
|
|
|
basePosition.left += atOffset[ 0 ];
|
2011-03-22 16:25:25 +00:00
|
|
|
basePosition.top += atOffset[ 1 ];
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2011-05-26 01:15:05 +00:00
|
|
|
return this.each(function() {
|
2010-02-14 18:15:32 +00:00
|
|
|
var elem = $( this ),
|
2010-01-07 03:19:50 +00:00
|
|
|
elemWidth = elem.outerWidth(),
|
|
|
|
elemHeight = elem.outerHeight(),
|
2010-09-03 14:38:44 +00:00
|
|
|
marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
|
|
|
|
marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
|
2011-05-26 14:22:12 +00:00
|
|
|
scrollInfo = $.position.getScrollInfo( within ),
|
2010-09-03 14:38:44 +00:00
|
|
|
collisionWidth = elemWidth + marginLeft +
|
2011-05-26 00:53:16 +00:00
|
|
|
( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ) + scrollInfo.width,
|
2010-09-03 14:38:44 +00:00
|
|
|
collisionHeight = elemHeight + marginTop +
|
2011-05-26 00:53:16 +00:00
|
|
|
( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ) + scrollInfo.height,
|
2010-09-03 14:38:44 +00:00
|
|
|
position = $.extend( {}, basePosition ),
|
2011-03-22 16:25:25 +00:00
|
|
|
myOffset = [
|
|
|
|
parseInt( offsets.my[ 0 ], 10 ) *
|
|
|
|
( rpercent.test( offsets.my[ 0 ] ) ? elem.outerWidth() / 100 : 1 ),
|
|
|
|
parseInt( offsets.my[ 1 ], 10 ) *
|
|
|
|
( rpercent.test( offsets.my[ 1 ] ) ? elem.outerHeight() / 100 : 1 )
|
|
|
|
],
|
2010-09-03 14:38:44 +00:00
|
|
|
collisionPosition;
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
if ( options.my[ 0 ] === "right" ) {
|
2010-02-14 18:15:32 +00:00
|
|
|
position.left -= elemWidth;
|
2011-03-22 17:12:03 +00:00
|
|
|
} else if ( options.my[ 0 ] === center ) {
|
2010-02-14 18:15:32 +00:00
|
|
|
position.left -= elemWidth / 2;
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 17:12:03 +00:00
|
|
|
if ( options.my[ 1 ] === "bottom" ) {
|
2010-02-14 18:15:32 +00:00
|
|
|
position.top -= elemHeight;
|
2011-03-22 17:12:03 +00:00
|
|
|
} else if ( options.my[ 1 ] === center ) {
|
2010-02-14 18:15:32 +00:00
|
|
|
position.top -= elemHeight / 2;
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 16:25:25 +00:00
|
|
|
position.left += myOffset[ 0 ];
|
|
|
|
position.top += myOffset[ 1 ];
|
|
|
|
|
2010-03-26 23:53:43 +00:00
|
|
|
// prevent fractions (see #5280)
|
2010-12-01 16:23:06 +00:00
|
|
|
position.left = Math.round( position.left );
|
|
|
|
position.top = Math.round( position.top );
|
2010-03-26 23:53:43 +00:00
|
|
|
|
2010-09-03 14:38:44 +00:00
|
|
|
collisionPosition = {
|
|
|
|
left: position.left - marginLeft,
|
|
|
|
top: position.top - marginTop
|
|
|
|
};
|
|
|
|
|
2010-02-14 18:15:32 +00:00
|
|
|
$.each( [ "left", "top" ], function( i, dir ) {
|
2011-03-22 17:12:03 +00:00
|
|
|
if ( $.ui.position[ collision[ i ] ] ) {
|
|
|
|
$.ui.position[ collision[ i ] ][ dir ]( position, {
|
2010-01-07 03:19:50 +00:00
|
|
|
targetWidth: targetWidth,
|
|
|
|
targetHeight: targetHeight,
|
|
|
|
elemWidth: elemWidth,
|
|
|
|
elemHeight: elemHeight,
|
2010-09-03 14:38:44 +00:00
|
|
|
collisionPosition: collisionPosition,
|
|
|
|
collisionWidth: collisionWidth,
|
|
|
|
collisionHeight: collisionHeight,
|
2011-03-22 16:25:25 +00:00
|
|
|
offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
|
2010-01-07 03:19:50 +00:00
|
|
|
my: options.my,
|
2011-05-11 23:30:21 +00:00
|
|
|
at: options.at,
|
2011-07-11 23:49:56 +00:00
|
|
|
within: within,
|
|
|
|
elem : elem
|
2010-02-14 18:15:32 +00:00
|
|
|
});
|
|
|
|
}
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
|
2010-02-14 18:15:32 +00:00
|
|
|
if ( $.fn.bgiframe ) {
|
|
|
|
elem.bgiframe();
|
|
|
|
}
|
|
|
|
elem.offset( $.extend( position, { using: options.using } ) );
|
2010-01-07 03:19:50 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
$.ui.position = {
|
|
|
|
fit: {
|
2010-02-14 18:15:32 +00:00
|
|
|
left: function( position, data ) {
|
2011-05-13 19:17:42 +00:00
|
|
|
var within = data.within,
|
2011-05-13 20:54:25 +00:00
|
|
|
win = $( window ),
|
2011-05-11 23:52:43 +00:00
|
|
|
isWindow = $.isWindow( data.within[0] ),
|
2011-05-13 21:57:16 +00:00
|
|
|
withinOffset = isWindow ? win.scrollLeft() : within.offset().left,
|
|
|
|
outerWidth = isWindow ? win.width() : within.outerWidth(),
|
|
|
|
overLeft = withinOffset - data.collisionPosition.left,
|
2011-05-16 23:46:21 +00:00
|
|
|
overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - withinOffset;
|
2011-05-03 08:38:17 +00:00
|
|
|
|
|
|
|
// element is wider than window or too far left -> align with left edge
|
2011-05-11 23:30:21 +00:00
|
|
|
if ( data.collisionWidth > outerWidth || overLeft > 0 ) {
|
2011-05-16 23:46:21 +00:00
|
|
|
position.left += overLeft;
|
2011-05-03 08:38:17 +00:00
|
|
|
// too far right -> align with right edge
|
|
|
|
} else if ( overRight > 0 ) {
|
2011-05-16 23:46:21 +00:00
|
|
|
position.left -= overRight;
|
2011-05-03 08:38:17 +00:00
|
|
|
// adjust based on position and margin
|
|
|
|
} else {
|
2011-05-16 23:46:21 +00:00
|
|
|
position.left = Math.max( position.left - data.collisionPosition.left, position.left );
|
2011-05-03 08:38:17 +00:00
|
|
|
}
|
2010-01-07 03:19:50 +00:00
|
|
|
},
|
2010-02-14 18:15:32 +00:00
|
|
|
top: function( position, data ) {
|
2011-05-13 19:17:42 +00:00
|
|
|
var within = data.within,
|
2011-05-13 20:54:25 +00:00
|
|
|
win = $( window ),
|
2011-05-11 23:52:43 +00:00
|
|
|
isWindow = $.isWindow( data.within[0] ),
|
2011-05-13 21:57:16 +00:00
|
|
|
withinOffset = isWindow ? win.scrollTop() : within.offset().top,
|
|
|
|
outerHeight = isWindow ? win.height() : within.outerHeight(),
|
|
|
|
overTop = withinOffset - data.collisionPosition.top,
|
2011-05-16 23:46:21 +00:00
|
|
|
overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - withinOffset;
|
2011-05-03 08:38:17 +00:00
|
|
|
|
|
|
|
// element is taller than window or too far up -> align with top edge
|
2011-05-11 23:30:21 +00:00
|
|
|
if ( data.collisionHeight > outerHeight || overTop > 0 ) {
|
2011-05-16 23:46:21 +00:00
|
|
|
position.top += overTop;
|
2011-05-03 08:38:17 +00:00
|
|
|
// too far down -> align with bottom edge
|
|
|
|
} else if ( overBottom > 0 ) {
|
2011-05-16 23:46:21 +00:00
|
|
|
position.top -= overBottom;
|
2011-05-03 08:38:17 +00:00
|
|
|
// adjust based on position and margin
|
|
|
|
} else {
|
2011-05-16 23:46:21 +00:00
|
|
|
position.top = Math.max( position.top - data.collisionPosition.top, position.top );
|
2011-05-03 08:38:17 +00:00
|
|
|
}
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
flip: {
|
2010-02-14 18:15:32 +00:00
|
|
|
left: function( position, data ) {
|
2011-03-22 17:12:03 +00:00
|
|
|
if ( data.at[ 0 ] === center ) {
|
2010-01-07 03:19:50 +00:00
|
|
|
return;
|
2010-02-14 18:15:32 +00:00
|
|
|
}
|
2011-05-11 23:52:43 +00:00
|
|
|
|
2011-07-11 23:49:56 +00:00
|
|
|
data.elem
|
|
|
|
.removeClass( "ui-flipped-left ui-flipped-right" );
|
|
|
|
|
2011-05-13 19:17:42 +00:00
|
|
|
var within = data.within,
|
2011-05-13 20:54:25 +00:00
|
|
|
win = $( window ),
|
2011-05-11 23:52:43 +00:00
|
|
|
isWindow = $.isWindow( data.within[0] ),
|
2011-05-13 19:17:42 +00:00
|
|
|
withinOffset = isWindow ? 0 : within.offset().left,
|
|
|
|
outerWidth = isWindow ? within.width() : within.outerWidth(),
|
|
|
|
overLeft = data.collisionPosition.left - withinOffset,
|
2011-05-13 20:54:25 +00:00
|
|
|
overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - withinOffset,
|
2011-05-11 23:30:21 +00:00
|
|
|
left = data.my[ 0 ] === "left",
|
2010-02-14 18:15:32 +00:00
|
|
|
myOffset = data.my[ 0 ] === "left" ?
|
|
|
|
-data.elemWidth :
|
|
|
|
data.my[ 0 ] === "right" ?
|
|
|
|
data.elemWidth :
|
|
|
|
0,
|
2010-08-05 06:57:19 +00:00
|
|
|
atOffset = data.at[ 0 ] === "left" ?
|
|
|
|
data.targetWidth :
|
|
|
|
-data.targetWidth,
|
2010-02-14 18:15:32 +00:00
|
|
|
offset = -2 * data.offset[ 0 ];
|
2011-05-11 23:30:21 +00:00
|
|
|
if ( overLeft < 0 || overRight > 0 ) {
|
2011-07-11 23:49:56 +00:00
|
|
|
|
|
|
|
data.elem
|
|
|
|
.addClass( "ui-flipped-" + ( overLeft < 0 ? "right" : "left" ) );
|
|
|
|
|
2011-05-11 23:30:21 +00:00
|
|
|
position.left += myOffset + atOffset + offset;
|
|
|
|
}
|
2010-01-07 03:19:50 +00:00
|
|
|
},
|
2010-02-14 18:15:32 +00:00
|
|
|
top: function( position, data ) {
|
2011-03-22 17:12:03 +00:00
|
|
|
if ( data.at[ 1 ] === center ) {
|
2010-01-07 03:19:50 +00:00
|
|
|
return;
|
2010-02-14 18:15:32 +00:00
|
|
|
}
|
2011-07-11 23:49:56 +00:00
|
|
|
|
|
|
|
data.elem
|
|
|
|
.removeClass( "ui-flipped-top ui-flipped-bottom" );
|
|
|
|
|
2011-05-13 19:17:42 +00:00
|
|
|
var within = data.within,
|
2011-05-13 20:54:25 +00:00
|
|
|
win = $( window ),
|
2011-05-11 23:52:43 +00:00
|
|
|
isWindow = $.isWindow( data.within[0] ),
|
2011-05-13 19:17:42 +00:00
|
|
|
withinOffset = isWindow ? 0 : within.offset().top,
|
|
|
|
outerHeight = isWindow ? within.height() : within.outerHeight(),
|
|
|
|
overTop = data.collisionPosition.top - withinOffset,
|
2011-05-13 20:54:25 +00:00
|
|
|
overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - withinOffset,
|
2011-05-11 23:30:21 +00:00
|
|
|
top = data.my[ 1 ] === "top",
|
|
|
|
myOffset = top ?
|
2010-02-14 18:15:32 +00:00
|
|
|
-data.elemHeight :
|
|
|
|
data.my[ 1 ] === "bottom" ?
|
|
|
|
data.elemHeight :
|
|
|
|
0,
|
|
|
|
atOffset = data.at[ 1 ] === "top" ?
|
|
|
|
data.targetHeight :
|
|
|
|
-data.targetHeight,
|
|
|
|
offset = -2 * data.offset[ 1 ];
|
2011-06-10 20:07:03 +00:00
|
|
|
if ( overTop < 0 || overBottom > 0 ) {
|
2011-07-11 23:49:56 +00:00
|
|
|
|
|
|
|
data.elem
|
|
|
|
.addClass( "ui-flipped-" + ( overTop < 0 ? "bottom" : "top" ) );
|
|
|
|
|
2011-05-11 23:30:21 +00:00
|
|
|
position.top += myOffset + atOffset + offset;
|
|
|
|
}
|
2010-01-07 03:19:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-03-22 16:25:25 +00:00
|
|
|
// DEPRECATED
|
|
|
|
if ( $.uiBackCompat !== false ) {
|
|
|
|
// offset option
|
|
|
|
(function( $ ) {
|
|
|
|
var _position = $.fn.position;
|
|
|
|
$.fn.position = function( options ) {
|
2011-06-10 01:04:51 +00:00
|
|
|
if ( !options || !options.offset ) {
|
2011-03-22 16:25:25 +00:00
|
|
|
return _position.call( this, options );
|
|
|
|
}
|
|
|
|
var offset = options.offset.split( " " ),
|
|
|
|
at = options.at.split( " " );
|
|
|
|
if ( offset.length === 1 ) {
|
|
|
|
offset[ 1 ] = offset[ 0 ];
|
|
|
|
}
|
|
|
|
if ( /^\d/.test( offset[ 0 ] ) ) {
|
|
|
|
offset[ 0 ] = "+" + offset[ 0 ];
|
|
|
|
}
|
|
|
|
if ( /^\d/.test( offset[ 1 ] ) ) {
|
|
|
|
offset[ 1 ] = "+" + offset[ 1 ];
|
|
|
|
}
|
|
|
|
if ( at.length === 1 ) {
|
|
|
|
if ( /left|center|right/.test( at[ 0 ] ) ) {
|
|
|
|
at[ 1 ] = "center";
|
|
|
|
} else {
|
|
|
|
at[ 1 ] = at[ 0 ];
|
|
|
|
at[ 0 ] = "center";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _position.call( this, $.extend( options, {
|
|
|
|
at: at[ 0 ] + offset[ 0 ] + " " + at[ 1 ] + offset[ 1 ],
|
|
|
|
offset: undefined
|
|
|
|
} ) );
|
|
|
|
}
|
2011-03-22 17:12:03 +00:00
|
|
|
}( jQuery ) );
|
2011-03-22 16:25:25 +00:00
|
|
|
}
|
|
|
|
|
2011-06-10 20:07:03 +00:00
|
|
|
}( jQuery ) );
|