2011-06-09 15:14:21 +00:00
|
|
|
<!doctype html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Position Visual Test: Containing Element</title>
|
|
|
|
|
2011-05-12 14:27:29 +00:00
|
|
|
<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" />
|
2011-06-09 15:14:21 +00:00
|
|
|
|
2011-07-27 13:40:53 +00:00
|
|
|
<script src="../../../jquery-1.6.2.js"></script>
|
|
|
|
<script src="../../../ui/jquery.ui.core.js"></script>
|
|
|
|
<script src="../../../ui/jquery.ui.widget.js"></script>
|
|
|
|
<script src="../../../ui/jquery.ui.mouse.js"></script>
|
|
|
|
<script src="../../../ui/jquery.ui.draggable.js"></script>
|
|
|
|
<script src="../../../ui/jquery.ui.position.js"></script>
|
2011-06-09 15:14:21 +00:00
|
|
|
|
|
|
|
<style>
|
2011-05-12 14:27:29 +00:00
|
|
|
html, body {
|
|
|
|
height:100%;
|
|
|
|
width:100%;
|
|
|
|
margin:0;
|
2011-05-13 20:53:25 +00:00
|
|
|
/* force scroll bar*/
|
|
|
|
min-height:800px;
|
|
|
|
min-width:800px;
|
2011-06-09 15:14:21 +00:00
|
|
|
|
2011-05-26 14:22:12 +00:00
|
|
|
/* IE6 needs this */
|
|
|
|
text-align:center;
|
2011-05-12 14:27:29 +00:00
|
|
|
}
|
|
|
|
.demo-description {
|
|
|
|
text-align:center;
|
|
|
|
padding:1.5em;
|
|
|
|
}
|
|
|
|
.demo-container {
|
|
|
|
background:#aaa;
|
2011-06-09 15:14:21 +00:00
|
|
|
width:80%;
|
2011-05-12 14:27:29 +00:00
|
|
|
height:80%;
|
2011-06-09 15:14:21 +00:00
|
|
|
|
2011-05-26 14:22:12 +00:00
|
|
|
text-align:left;
|
2011-05-12 14:27:29 +00:00
|
|
|
margin:0 auto;
|
|
|
|
position:relative;
|
|
|
|
padding:10px;
|
|
|
|
}
|
|
|
|
.demo {
|
|
|
|
background:#eee;
|
|
|
|
overflow:hidden;
|
|
|
|
position:relative;
|
|
|
|
height:100%;
|
2011-05-26 14:22:12 +00:00
|
|
|
/* IE6 needs this */
|
|
|
|
width:100%;
|
2011-05-12 14:27:29 +00:00
|
|
|
}
|
|
|
|
#parent {
|
|
|
|
width: 60%;
|
|
|
|
margin: 10px auto;
|
|
|
|
padding: 5px;
|
|
|
|
border: 1px solid #777;
|
|
|
|
background-color: #fbca93;
|
|
|
|
text-align: center;
|
|
|
|
cursor:move;
|
|
|
|
}
|
|
|
|
.positionable {
|
|
|
|
width: 75px;
|
|
|
|
height: 75px;
|
|
|
|
position: absolute;
|
|
|
|
display: block;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
background-color: #bcd5e6;
|
|
|
|
text-align: center;
|
|
|
|
cursor:move;
|
|
|
|
}
|
2011-07-12 15:15:33 +00:00
|
|
|
.ui-flipped-top {
|
|
|
|
border-top: 3px solid #000000;
|
|
|
|
}
|
|
|
|
.ui-flipped-bottom {
|
|
|
|
border-bottom: 3px solid #000000;
|
|
|
|
}
|
|
|
|
.ui-flipped-left {
|
|
|
|
border-left: 3px solid #000000;
|
|
|
|
}
|
|
|
|
.ui-flipped-right {
|
|
|
|
border-right: 3px solid #000000;
|
|
|
|
}
|
2011-05-12 14:27:29 +00:00
|
|
|
select, input {
|
|
|
|
margin-left: 15px;
|
|
|
|
}
|
2011-06-09 15:14:21 +00:00
|
|
|
</style>
|
|
|
|
<script>
|
2011-05-12 14:27:29 +00:00
|
|
|
$(function() {
|
|
|
|
function position( using ) {
|
|
|
|
$( ".positionable" ).position({
|
|
|
|
of: $( "#parent" ),
|
|
|
|
my: $( "#my_horizontal" ).val() + " " + $( "#my_vertical" ).val(),
|
|
|
|
at: $( "#at_horizontal" ).val() + " " + $( "#at_vertical" ).val(),
|
|
|
|
offset: $( "#offset" ).val(),
|
|
|
|
using: using,
|
|
|
|
within: $( ".demo" ),
|
|
|
|
collision: $( "#collision_horizontal" ).val() + " " + $( "#collision_vertical" ).val()
|
|
|
|
});
|
|
|
|
}
|
2011-05-13 20:53:25 +00:00
|
|
|
$( ".demo" ).append("<div style='width:5000px;height:5000px;' />").css("overflow","auto");
|
2011-05-12 14:27:29 +00:00
|
|
|
|
|
|
|
$( ".positionable" ).css( "opacity", 0.5 );
|
|
|
|
|
|
|
|
$( ":input" ).bind( "click keyup change", function() { position(); } );
|
|
|
|
|
|
|
|
$( "#parent" ).draggable({
|
|
|
|
drag: function() { position(); }
|
|
|
|
});
|
|
|
|
|
|
|
|
$( ".positionable" ).draggable({
|
|
|
|
drag: function( event, ui ) {
|
|
|
|
// reset offset before calculating it
|
|
|
|
$( "#offset" ).val( "0" );
|
|
|
|
position(function( result ) {
|
2011-05-13 20:53:25 +00:00
|
|
|
var demo = $( ".demo" );
|
|
|
|
$( "#offset" ).val( "" + ( ui.offset.left - result.left - demo.offset().left + demo.scrollLeft() ) +
|
|
|
|
" " + ( ui.offset.top - result.top - demo.offset().top + demo.scrollTop() ) );
|
2011-05-12 14:27:29 +00:00
|
|
|
position();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
position();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
2011-06-09 15:14:21 +00:00
|
|
|
|
2011-05-12 14:27:29 +00:00
|
|
|
<div class="demo-description">
|
|
|
|
Use the form controls to configure the positioning, or drag the positioned element to modify its offset.
|
|
|
|
<br/>Drag around the parent element to see collision detection in action.
|
|
|
|
</div><!-- End demo-description -->
|
|
|
|
|
|
|
|
<div class="demo-container">
|
|
|
|
<div class="demo">
|
|
|
|
|
|
|
|
<div id="parent">
|
|
|
|
<p>This is the position parent element.</p>
|
|
|
|
</div>
|
2011-06-09 15:14:21 +00:00
|
|
|
|
2011-05-12 14:27:29 +00:00
|
|
|
<div class="positionable">
|
|
|
|
<p>to position</p>
|
|
|
|
</div>
|
2011-06-09 15:14:21 +00:00
|
|
|
|
2011-05-12 14:27:29 +00:00
|
|
|
<div class="positionable" style="width:120px; height: 40px;">
|
|
|
|
<p>to position 2</p>
|
|
|
|
</div>
|
2011-06-09 15:14:21 +00:00
|
|
|
|
2011-05-12 14:27:29 +00:00
|
|
|
<div style="padding: 20px; margin-top: 75px;">
|
|
|
|
position...
|
|
|
|
<div style="padding-bottom: 20px;">
|
|
|
|
<b>my:</b>
|
|
|
|
<select id="my_horizontal">
|
|
|
|
<option value="left">left</option>
|
|
|
|
<option value="center">center</option>
|
2011-06-09 15:14:21 +00:00
|
|
|
<option value="right" selected="selected">right</option>
|
2011-05-12 14:27:29 +00:00
|
|
|
</select>
|
|
|
|
<select id="my_vertical">
|
|
|
|
<option value="top">top</option>
|
|
|
|
<option value="middle">center</option>
|
|
|
|
<option value="bottom">bottom</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div style="padding-bottom: 20px;">
|
|
|
|
<b>at:</b>
|
|
|
|
<select id="at_horizontal">
|
|
|
|
<option value="left">left</option>
|
|
|
|
<option value="center">center</option>
|
2011-06-09 15:14:21 +00:00
|
|
|
<option value="right" selected="selected">right</option>
|
2011-05-12 14:27:29 +00:00
|
|
|
</select>
|
|
|
|
<select id="at_vertical">
|
|
|
|
<option value="top">top</option>
|
|
|
|
<option value="middle">center</option>
|
|
|
|
<option value="bottom">bottom</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div style="padding-bottom: 20px;">
|
|
|
|
<b>offset:</b>
|
|
|
|
<input id="offset" type="text" size="15"/>
|
|
|
|
</div>
|
|
|
|
<div style="padding-bottom: 20px;">
|
|
|
|
<b>collision:</b>
|
|
|
|
<select id="collision_horizontal">
|
|
|
|
<option value="flip">flip</option>
|
|
|
|
<option value="fit">fit</option>
|
|
|
|
<option value="none">none</option>
|
|
|
|
</select>
|
|
|
|
<select id="collision_vertical">
|
|
|
|
<option value="flip">flip</option>
|
|
|
|
<option value="fit">fit</option>
|
|
|
|
<option value="none">none</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
2011-06-09 15:14:21 +00:00
|
|
|
|
|
|
|
</div><!-- End demo -->
|
2011-05-12 14:27:29 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
2011-06-09 15:14:21 +00:00
|
|
|
</html>
|