-/*
- * position_core.js
- */
-(function($) {
-
-module("position");
-
-test('my, at, of', function() {
- $('#elx').position({
- my: 'left top',
- at: 'left top',
- of: '#parentx',
- collision: 'none'
+(function( $ ) {
+
+module( "position" );
+
+test( "my, at, of", function() {
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left top",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 40, left: 40 }, 'left top, left top');
+ same( $( "#elx" ).offset(), { top: 40, left: 40 }, "left top, left top" );
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: '#parentx',
- collision: 'none'
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left bottom",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 60, left: 40 }, 'left top, left bottom');
+ same( $( "#elx" ).offset(), { top: 60, left: 40 }, "left top, left bottom" );
- $('#elx').position({
- my: 'left',
- at: 'bottom',
- of: '#parentx',
- collision: 'none'
+ $( "#elx" ).position({
+ my: "left",
+ at: "bottom",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 55, left: 50 }, 'left, bottom');
+ same( $( "#elx" ).offset(), { top: 55, left: 50 }, "left, bottom" );
- $('#elx').position({
- my: 'left foo',
- at: 'bar baz',
- of: '#parentx',
- collision: 'none'
+ $( "#elx" ).position({
+ my: "left foo",
+ at: "bar baz",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 45, left: 50 }, 'left foo, bar baz');
+ same( $( "#elx" ).offset(), { top: 45, left: 50 }, "left foo, bar baz" );
});
-test('multiple elements', function() {
- var elements = $('#el1, #el2');
+test( "multiple elements", function() {
+ var elements = $( "#el1, #el2" );
var result = elements.position({
- my: 'left top',
- at: 'left bottom',
- of: '#parent',
- collision: 'none'
+ my: "left top",
+ at: "left bottom",
+ of: "#parent",
+ collision: "none"
});
- same(result, elements);
- var expected = {top: 10, left: 4};
+ same( result, elements );
+ var expected = { top: 10, left: 4 };
elements.each(function() {
- same($(this).offset(), expected);
+ same( $( this ).offset(), expected );
});
});
-test('positions', function() {
+test( "positions", function() {
var definitions = [];
var offsets = {
left: 0,
bottom: 6
};
var start = { left: 4, top: 4 };
- $.each([0, 1], function(my) {
- $.each(["top", "center", "bottom"], function(vindex, vertical) {
- $.each(["left", "center", "right"], function(hindex, horizontal) {
+ $.each( [ 0, 1 ], function( my ) {
+ $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) {
+ $.each( [ "left", "center", "right" ], function( hindex, horizontal ) {
definitions.push({
- my: my ? horizontal + " " + vertical : 'left top',
- at: !my ? horizontal + " " + vertical : 'left top',
+ my: my ? horizontal + " " + vertical : "left top",
+ at: !my ? horizontal + " " + vertical : "left top",
result: {
- top: my ? start.top - offsets[vertical] : start.top + offsets[vertical],
- left: my ? start.left - offsets[horizontal] : start.left + offsets[horizontal]
+ top: my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ],
+ left: my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ]
}
});
});
});
});
- var el = $("#el1");
- $.each(definitions, function(index, definition) {
+ var el = $( "#el1" );
+ $.each( definitions, function( index, definition ) {
el.position({
my: definition.my,
at: definition.at,
- of: '#parent',
- collision: 'none'
+ of: "#parent",
+ collision: "none"
});
- same(el.offset(), definition.result, "Position via " + QUnit.jsDump.parse({my:definition.my, at:definition.at}));
+ same( el.offset(), definition.result,
+ "Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) );
});
});
-test('of', function() {
- $('#elx').position({
- my: 'left top',
- at: 'left top',
- of: '#parentx',
- collision: 'none'
+test( "of", function() {
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left top",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 40, left: 40 }, 'selector');
-
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: $('#parentx'),
- collision: 'none'
+ same( $( "#elx" ).offset(), { top: 40, left: 40 }, "selector" );
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left bottom",
+ of: $( "#parentx"),
+ collision: "none"
});
- same($('#elx').offset(), { top: 60, left: 40 }, 'jQuery object');
-
- $('#elx').position({
- my: 'left top',
- at: 'left top',
- of: $('#parentx')[0],
- collision: 'none'
+ same( $( "#elx" ).offset(), { top: 60, left: 40 }, "jQuery object" );
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left top",
+ of: $( "#parentx" )[ 0 ],
+ collision: "none"
});
- same($('#elx').offset(), { top: 40, left: 40 }, 'DOM element');
-
- $('#elx').position({
- my: 'right bottom',
- at: 'right bottom',
+ same( $( "#elx" ).offset(), { top: 40, left: 40 }, "DOM element" );
+
+ $( "#elx" ).position({
+ my: "right bottom",
+ at: "right bottom",
of: document,
- collision: 'none'
+ collision: "none"
});
- same($('#elx').offset(), {
- top: $(document).height() - 10,
- left: $(document).width() - 10
- }, 'document');
-
- $('#elx').position({
- my: 'right bottom',
- at: 'right bottom',
- of: $(document),
- collision: 'none'
+ same( $( "#elx" ).offset(), {
+ top: $( document ).height() - 10,
+ left: $( document ).width() - 10
+ }, "document" );
+
+ $( "#elx" ).position({
+ my: "right bottom",
+ at: "right bottom",
+ of: $( document ),
+ collision: "none"
});
- same($('#elx').offset(), {
- top: $(document).height() - 10,
- left: $(document).width() - 10
- }, 'document');
-
- $(window).scrollTop(0);
-
- $('#elx').position({
- my: 'right bottom',
- at: 'right bottom',
+ same( $( "#elx" ).offset(), {
+ top: $( document ).height() - 10,
+ left: $( document ).width() - 10
+ }, "document as jQuery object" );
+
+ $( window ).scrollTop( 0 );
+
+ $( "#elx" ).position({
+ my: "right bottom",
+ at: "right bottom",
of: window,
- collision: 'none'
+ collision: "none"
});
- same($('#elx').offset(), {
- top: $(window).height() - 10,
- left: $(window).width() - 10
- }, 'window');
-
- $('#elx').position({
- my: 'right bottom',
- at: 'right bottom',
- of: $(window),
- collision: 'none'
+ same( $( "#elx" ).offset(), {
+ top: $( window ).height() - 10,
+ left: $( window ).width() - 10
+ }, "window" );
+
+ $( "#elx" ).position({
+ my: "right bottom",
+ at: "right bottom",
+ of: $( window ),
+ collision: "none"
});
- same($('#elx').offset(), {
- top: $(window).height() - 10,
- left: $(window).width() - 10
- }, 'window');
-
+ same( $( "#elx" ).offset(), {
+ top: $( window ).height() - 10,
+ left: $( window ).width() - 10
+ }, "window as jQuery object" );
+
var scrollTopSupport = (function() {
- $(window).scrollTop(1);
- return $(window).scrollTop() == 1;
- })();
- if (scrollTopSupport) {
- $(window).scrollTop(500).scrollLeft(200);
- $('#elx').position({
- my: 'right bottom',
- at: 'right bottom',
+ $( window ).scrollTop( 1 );
+ return $( window ).scrollTop() === 1;
+ }() );
+ if ( scrollTopSupport ) {
+ $( window ).scrollTop( 500 ).scrollLeft( 200 );
+ $( "#elx" ).position({
+ my: "right bottom",
+ at: "right bottom",
of: window,
- collision: 'none'
+ collision: "none"
});
- same($('#elx').offset(), {
- top: $(window).height() + 500 - 10,
- left: $(window).width() + 200 - 10
- }, 'window, scrolled');
- $(window).scrollTop(0).scrollLeft(0);
+ same( $( "#elx" ).offset(), {
+ top: $( window ).height() + 500 - 10,
+ left: $( window ).width() + 200 - 10
+ }, "window, scrolled" );
+ $( window ).scrollTop( 0 ).scrollLeft( 0 );
}
-
- var event = $.extend($.Event('someEvent'), { pageX: 200, pageY: 300 });
- $('#elx').position({
- my: 'left top',
- at: 'left top',
+
+ var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left top",
of: event,
- collision: 'none'
+ collision: "none"
});
- same($('#elx').offset(), {
+ same( $( "#elx" ).offset(), {
top: 300,
left: 200
- }, 'event - left top, left top');
-
- event = $.extend($.Event('someEvent'), { pageX: 400, pageY: 600 });
- $('#elx').position({
- my: 'left top',
- at: 'right bottom',
+ }, "event - left top, left top" );
+
+ event = $.extend( $.Event( "someEvent" ), { pageX: 400, pageY: 600 } );
+ $( "#elx" ).position({
+ my: "left top",
+ at: "right bottom",
of: event,
- collision: 'none'
+ collision: "none"
});
- same($('#elx').offset(), {
+ same( $( "#elx" ).offset(), {
top: 600,
left: 400
- }, 'event - left top, right bottom');
+ }, "event - left top, right bottom" );
});
-test('offsets', function() {
- $('#elx').position({
- my: 'left top',
- at: 'left+10 bottom+10',
- of: '#parentx',
- collision: 'none'
+test( "offsets", function() {
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left+10 bottom+10",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 70, left: 50 }, 'offsets in at');
-
- $('#elx').position({
- my: 'left+10 top-10',
- at: 'left bottom',
- of: '#parentx',
- collision: 'none'
+ same( $( "#elx" ).offset(), { top: 70, left: 50 }, "offsets in at" );
+
+ $( "#elx" ).position({
+ my: "left+10 top-10",
+ at: "left bottom",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 50, left: 50 }, 'offsets in my');
+ same( $( "#elx" ).offset(), { top: 50, left: 50 }, "offsets in my" );
- $('#elx').position({
- my: 'left top',
- at: 'left+50% bottom-10%',
- of: '#parentx',
- collision: 'none'
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left+50% bottom-10%",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 58, left: 50 }, 'percentage offsets in at');
+ same( $( "#elx" ).offset(), { top: 58, left: 50 }, "percentage offsets in at" );
- $('#elx').position({
- my: 'left-30% top+50%',
- at: 'left bottom',
- of: '#parentx',
- collision: 'none'
+ $( "#elx" ).position({
+ my: "left-30% top+50%",
+ at: "left bottom",
+ of: "#parentx",
+ collision: "none"
});
- same($('#elx').offset(), { top: 65, left: 37 }, 'percentage offsets in my');
+ same( $( "#elx" ).offset(), { top: 65, left: 37 }, "percentage offsets in my" );
});
-test('offset - deprecated', function() {
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: '#parentx',
- offset: '10',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 70, left: 50 }, 'single value');
-
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: '#parentx',
- offset: '5 -3',
- collision: 'none'
- });
- same($('#elx').offset(), { top: 57, left: 45 }, 'two values');
-
- $('#elx').position({
- my: 'left top',
- at: 'left bottom',
- of: '#parentx',
- offset: '5px -3px',
- collision: 'none'
+if ( $.uiBackCompat !== false ) {
+ test( "offset", function() {
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left bottom",
+ of: "#parentx",
+ offset: "10",
+ collision: "none"
+ });
+ same( $( "#elx" ).offset(), { top: 70, left: 50 }, "single value" );
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left bottom",
+ of: "#parentx",
+ offset: "5 -3",
+ collision: "none"
+ });
+ same( $( "#elx" ).offset(), { top: 57, left: 45 }, "two values" );
+
+ $( "#elx" ).position({
+ my: "left top",
+ at: "left bottom",
+ of: "#parentx",
+ offset: "5px -3px",
+ collision: "none"
+ });
+ same( $( "#elx" ).offset(), { top: 57, left: 45 }, "with units" );
});
- same($('#elx').offset(), { top: 57, left: 45 }, 'with units');
-});
+}
+
+test( "using", function() {
+ expect( 6 );
-test('using', function() {
- expect(6);
-
var count = 0,
- elems = $('#el1, #el2'),
+ elems = $( "#el1, #el2" ),
expectedPosition = { top: 40, left: 40 },
originalPosition = elems.position({
- my: 'right bottom',
- at: 'rigt bottom',
- of: '#parentx',
- collision: 'none'
+ my: "right bottom",
+ at: "rigt bottom",
+ of: "#parentx",
+ collision: "none"
}).offset();
-
+
elems.position({
- my: 'left top',
- at: 'left top',
- of: '#parentx',
- using: function(position) {
- same(this, elems[count], 'correct context for call #' + count);
- same(position, expectedPosition, 'correct position for call #' + count);
+ my: "left top",
+ at: "left top",
+ of: "#parentx",
+ using: function( position ) {
+ same( this, elems[ count ], "correct context for call #" + count );
+ same( position, expectedPosition, "correct position for call #" + count );
count++;
}
});
-
+
elems.each(function() {
- same($(this).offset(), originalPosition, 'elements not moved');
+ same( $( this ).offset(), originalPosition, "elements not moved" );
});
});
-function collisionTest(config, result, msg) {
- var elem = $("#elx").position($.extend({
+function collisionTest( config, result, msg ) {
+ var elem = $( "#elx" ).position( $.extend({
my: "left top",
at: "right bottom",
of: window
- }, config));
- same(elem.offset(), result, msg);
+ }, config ) );
+ same( elem.offset(), result, msg );
}
-function collisionTest2(config, result, msg) {
- collisionTest($.extend({
+function collisionTest2( config, result, msg ) {
+ collisionTest( $.extend({
my: "right bottom",
at: "left top"
- }, config), result, msg);
+ }, config ), result, msg );
}
-test("collision: fit, no offset", function() {
+test( "collision: fit, no offset", function() {
collisionTest({
collision: "fit"
- }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom");
-
+ }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" );
+
collisionTest2({
collision: "fit"
- }, { top: 0, left: 0 }, "left top");
+ }, { top: 0, left: 0 }, "left top" );
});
-test("collision: fit, with offset", function() {
+test( "collision: fit, with offset", function() {
collisionTest({
collision: "fit",
- offset: "2 3"
+ at: "right+2 bottom+3"
}, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom");
-
+
collisionTest2({
collision: "fit",
- offset: "2 3"
- }, { top: 0, left: 0 }, "left top, positive offset");
-
+ at: "left+2 top+3"
+ }, { top: 0, left: 0 }, "left top, positive offset" );
+
collisionTest2({
collision: "fit",
- offset: "-2 -3"
- }, { top: 0, left: 0 }, "left top, negative offset");
+ at: "left-2 top-3"
+ }, { top: 0, left: 0 }, "left top, negative offset" );
});
-test("collision: flip, no offset", function() {
+test( "collision: flip, no offset", function() {
collisionTest({
collision: "flip"
- }, { top: -10, left: -10 }, "left top");
-
+ }, { top: -10, left: -10 }, "left top" );
+
collisionTest2({
collision: "flip"
- }, { top: $(window).height(), left: $(window).width() }, "right bottom");
+ }, { top: $( window ).height(), left: $( window ).width() }, "right bottom" );
});
-test("collision: flip, with offset", function() {
+test( "collision: flip, with offset", function() {
collisionTest({
collision: "flip",
- offset: "2 3"
- }, { top: -13, left: -12 }, "left top, with offset added");
-
+ at: "right+2 bottom+3"
+ }, { top: -13, left: -12 }, "left top, with offset added" );
+
collisionTest2({
collision: "flip",
- offset: "2 3"
- }, { top: $(window).height() - 3, left: $(window).width() - 2 }, "bottom, positive offset");
-
+ at: "left+2 top+3"
+ }, { top: $( window ).height() - 3, left: $( window ).width() - 2 }, "bottom, positive offset" );
+
collisionTest2({
collision: "flip",
- offset: "-2 -3"
- }, { top: $(window).height() + 3, left: $(window).width() + 2 }, "right bottom, negative offset");
+ at: "left-2 top-3",
+ }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, negative offset" );
});
-test("collision: none, no offset", function() {
+test( "collision: none, no offset", function() {
collisionTest({
collision: "none"
- }, { top: $(window).height(), left: $(window).width() }, "left top");
-
+ }, { top: $( window ).height(), left: $( window ).width() }, "left top" );
+
collisionTest2({
collision: "none"
- }, { top: -10, left: -10 }, "moved to the right bottom");
+ }, { top: -10, left: -10 }, "moved to the right bottom" );
});
-test("collision: none, with offset", function() {
+test( "collision: none, with offset", function() {
collisionTest({
collision: "none",
- offset: "2 3"
- }, { top: $(window).height() + 3, left: $(window).width() + 2 }, "right bottom, with offset added");
-
+ at: "right+2 bottom+3"
+ }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, with offset added" );
+
collisionTest2({
collision: "none",
- offset: "2 3"
- }, { top: -7, left: -8 }, "left top, positive offset");
-
+ at: "left+2 top+3"
+ }, { top: -7, left: -8 }, "left top, positive offset" );
+
collisionTest2({
collision: "none",
- offset: "-2 -3"
- }, { top: -13, left: -12 }, "left top, negative offset");
+ at: "left-2 top-3"
+ }, { top: -13, left: -12 }, "left top, negative offset" );
});
-test("collision: fit, with margin", function() {
- $("#elx").css("margin", 10);
+test( "collision: fit, with margin", function() {
+ $( "#elx" ).css( "margin", 10 );
collisionTest({
collision: "fit"
- }, { top: $(window).height() - 20, left: $(window).width() - 20 }, "right bottom");
+ }, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" );
collisionTest2({
collision: "fit"
- }, { top: 10, left: 10 }, "left top");
+ }, { top: 10, left: 10 }, "left top" );
- $("#elx").css({
+ $( "#elx" ).css({
"margin-left": 5,
"margin-top": 5
});
collisionTest({
collision: "fit"
- }, { top: $(window).height() - 20, left: $(window).width() - 20 }, "right bottom");
+ }, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" );
collisionTest2({
collision: "fit"
- }, { top: 5, left: 5 }, "left top");
+ }, { top: 5, left: 5 }, "left top" );
- $("#elx").css({
+ $( "#elx" ).css({
"margin-right": 15,
"margin-bottom": 15
});
collisionTest({
collision: "fit"
- }, { top: $(window).height() - 25, left: $(window).width() - 25 }, "right bottom");
+ }, { top: $( window ).height() - 25, left: $( window ).width() - 25 }, "right bottom" );
collisionTest2({
collision: "fit"
- }, { top: 5, left: 5 }, "left top");
+ }, { top: 5, left: 5 }, "left top" );
});
-test("collision: flip, with margin", function() {
- $("#elx").css("margin", 10);
+test( "collision: flip, with margin", function() {
+ $( "#elx" ).css( "margin", 10 );
collisionTest({
collision: "flip",
at: "left top"
- }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "left top");
+ }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "left top" );
collisionTest2({
collision: "flip",
at: "right bottom"
- }, { top: 0, left: 0 }, "right bottom");
+ }, { top: 0, left: 0 }, "right bottom" );
});
-//test('bug #5280: consistent results (avoid fractional values)', function() {
-// var wrapper = $('#bug-5280'),
+//test( "bug #5280: consistent results (avoid fractional values)", function() {
+// var wrapper = $( "#bug-5280" ),
// elem = wrapper.children(),
// offset1 = elem.position({
-// my: 'center',
-// at: 'center',
+// my: "center",
+// at: "center",
// of: wrapper,
-// collision: 'none'
+// collision: "none"
// }).offset(),
// offset2 = elem.position({
-// my: 'center',
-// at: 'center',
+// my: "center",
+// at: "center",
// of: wrapper,
-// collision: 'none'
+// collision: "none"
// }).offset();
-// same(offset1, offset2);
+// same( offset1, offset2 );
//});
-})(jQuery);
+}( jQuery ) );
$.ui = $.ui || {};
-var horizontalPositions = /left|center|right/,
- verticalPositions = /top|center|bottom/,
+var rhorizontal = /left|center|right/,
+ rvertical = /top|center|bottom/,
roffset = /[+-]\d+%?/,
rposition = /^\w+/,
rpercent = /%$/,
// force my and at to have valid horizontal and vertical positions
// if a value is missing or invalid, it will be converted to center
$.each( [ "my", "at" ], function() {
- var pos = ( options[this] || "" ).split( " " ),
+ var pos = ( options[ this ] || "" ).split( " " ),
horizontalOffset,
verticalOffset;
if ( pos.length === 1) {
- pos = horizontalPositions.test( pos[0] ) ?
- pos.concat( [center] ) :
- verticalPositions.test( pos[0] ) ?
+ pos = rhorizontal.test( pos[ 0 ] ) ?
+ pos.concat( [ center ] ) :
+ rvertical.test( pos[ 0 ] ) ?
[ center ].concat( pos ) :
[ center, center ];
}
- pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
- pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
+ pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : center;
+ pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : center;
// calculate offsets
horizontalOffset = roffset.exec( pos[ 0 ] );
- verticalOffset = roffset.exec( pos [ 1 ] );
+ verticalOffset = roffset.exec( pos[ 1 ] );
offsets[ this ] = [
horizontalOffset ? horizontalOffset[ 0 ] : 0,
verticalOffset ? verticalOffset[ 0 ] : 0
collision[ 1 ] = collision[ 0 ];
}
- if ( options.at[0] === "right" ) {
+ if ( options.at[ 0 ] === "right" ) {
basePosition.left += targetWidth;
- } else if ( options.at[0] === center ) {
+ } else if ( options.at[ 0 ] === center ) {
basePosition.left += targetWidth / 2;
}
- if ( options.at[1] === "bottom" ) {
+ if ( options.at[ 1 ] === "bottom" ) {
basePosition.top += targetHeight;
- } else if ( options.at[1] === center ) {
+ } else if ( options.at[ 1 ] === center ) {
basePosition.top += targetHeight / 2;
}
],
collisionPosition;
- if ( options.my[0] === "right" ) {
+ if ( options.my[ 0 ] === "right" ) {
position.left -= elemWidth;
- } else if ( options.my[0] === center ) {
+ } else if ( options.my[ 0 ] === center ) {
position.left -= elemWidth / 2;
}
- if ( options.my[1] === "bottom" ) {
+ if ( options.my[ 1 ] === "bottom" ) {
position.top -= elemHeight;
- } else if ( options.my[1] === center ) {
+ } else if ( options.my[ 1 ] === center ) {
position.top -= elemHeight / 2;
}
};
$.each( [ "left", "top" ], function( i, dir ) {
- if ( $.ui.position[ collision[i] ] ) {
- $.ui.position[ collision[i] ][ dir ]( position, {
+ if ( $.ui.position[ collision[ i ] ] ) {
+ $.ui.position[ collision[ i ] ][ dir ]( position, {
targetWidth: targetWidth,
targetHeight: targetHeight,
elemWidth: elemWidth,
left: function( position, data ) {
var win = $( window ),
over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
- position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
+ position.left = over > 0 ?
+ position.left - over :
+ Math.max( position.left - data.collisionPosition.left, position.left );
},
top: function( position, data ) {
var win = $( window ),
over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
- position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
+ position.top = over > 0 ?
+ position.top - over :
+ Math.max( position.top - data.collisionPosition.top, position.top );
}
},
flip: {
left: function( position, data ) {
- if ( data.at[0] === center ) {
+ if ( data.at[ 0 ] === center ) {
return;
}
var win = $( window ),
0;
},
top: function( position, data ) {
- if ( data.at[1] === center ) {
+ if ( data.at[ 1 ] === center ) {
return;
}
var win = $( window ),
offset: undefined
} ) );
}
- }( jQuery ));
+ }( jQuery ) );
}
-}( jQuery ));
+}( jQuery ) );