Skip to content

Ticket 6981 - Merge offset options into my and at options #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions tests/unit/position/position_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,41 @@ test('of', function() {
}, 'event - left top, right bottom');
});

test('offset', function() {
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: 50, left: 50 }, 'offsets in my');

$('#elx').position({
my: 'left top',
at: 'left+50% bottom-10%',
of: '#parentx',
collision: 'none'
});
same($('#elx').offset(), { top: 54, left: 60 }, 'percentage offsets in at');

$('#elx').position({
my: 'left+30% top-50%',
at: 'left bottom',
of: '#parentx',
collision: 'none'
});
same($('#elx').offset(), { top: 90, left: 28 }, 'percentage offsets in my');
});

test('offset - deprecated', function() {
$('#elx').position({
my: 'left top',
at: 'left bottom',
Expand All @@ -216,7 +250,7 @@ test('offset', function() {
collision: 'none'
});
same($('#elx').offset(), { top: 70, left: 50 }, 'single value');

$('#elx').position({
my: 'left top',
at: 'left bottom',
Expand Down
47 changes: 47 additions & 0 deletions tests/visual/position/position_offset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Position Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
<script type="text/javascript" src="../../../jquery-1.4.4.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript">
$(function() {
$( "#my" ).position({
my: "left top",
at: "right+100 bottom-10%",
of: '#at'
});
});
</script>
<style>
#my {
background-color: blue;
height: 50px;
width: 50px;
margin: 0;
padding: 0;
display: inline-block;
}
#at {
background-color: red;
position: absolute;
left: 100px;
top: 50px;
height: 50px;
width: 50px;
margin: 0;
padding: 0;
}
</style>
</head>
<body>

<div id="my"></div>
<div id="at"></div>
</body>
</html>
48 changes: 48 additions & 0 deletions tests/visual/position/position_old_offset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Position Visual Test: Default</title>
<link rel="stylesheet" href="../visual.css" type="text/css" />
<link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" />
<script type="text/javascript" src="../../../jquery-1.4.4.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.position.js"></script>
<script type="text/javascript">
$(function() {
$( "#my" ).position({
my: "left top",
at: "right bottom",
of: "#at",
offset: "100 100"
});
});
</script>
<style>
#my {
background-color: blue;
height: 50px;
width: 50px;
margin: 0;
padding: 0;
display: inline-block;
}
#at {
background-color: red;
position: absolute;
left: 100px;
top: 50px;
height: 50px;
width: 50px;
margin: 0;
padding: 0;
}
</style>
</head>
<body>

<div id="my"></div>
<div id="at"></div>
</body>
</html>
Loading