mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
260261255b
Also rename the demo file to match the variables names, 'feedback', instead of 'notification'
141 lines
3.2 KiB
HTML
141 lines
3.2 KiB
HTML
<!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.7.2.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" src="../../../ui/jquery.ui.menu.js"></script>
|
|
<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
function using( position, feedback ) {
|
|
$(this).offset( position );
|
|
$(this).text(feedback.horizontal + " " + feedback.vertical + " " + feedback.important)
|
|
$(this)
|
|
.removeClass("left right top bottom center middle vertical horizontal")
|
|
.addClass(feedback.horizontal)
|
|
.addClass(feedback.vertical)
|
|
.addClass(feedback.important);
|
|
}
|
|
var target = $("#target").position({
|
|
my: "center",
|
|
at: "center",
|
|
of: window
|
|
});
|
|
var element = $(".element");
|
|
$.each([
|
|
"center top-100",
|
|
"right+25 top-50",
|
|
"right+75 top",
|
|
"right+75 center",
|
|
"right+75 bottom",
|
|
"right+25 bottom+50",
|
|
"center bottom+100",
|
|
"left-25 bottom+50",
|
|
"left-75 bottom",
|
|
"left-75 center",
|
|
"left-75 top",
|
|
"left-25 top-50"
|
|
], function(index, direction) {
|
|
element.clone().insertAfter(target).position({
|
|
my: "center",
|
|
at: direction,
|
|
of: target,
|
|
using: using
|
|
})
|
|
});
|
|
|
|
var targetOffset = target.offset();
|
|
var oppositeElement = element.clone().width(50).appendTo('body');
|
|
element.width(150);
|
|
$(document).on( "mousemove", function(event) {
|
|
element.position({
|
|
my: "left top",
|
|
at: "left top",
|
|
of: target,
|
|
offset: (event.pageX - targetOffset.left) + " " + (event.pageY - targetOffset.top),
|
|
using: using
|
|
});
|
|
oppositeElement.position({
|
|
my: "left top",
|
|
at: "left top",
|
|
of: target,
|
|
offset: (-1 * (event.pageX - targetOffset.left)) + " " + (-1 * (event.pageY - targetOffset.top)),
|
|
using: using
|
|
});
|
|
} )
|
|
});
|
|
</script>
|
|
<style>
|
|
#target, .element {
|
|
position: absolute;
|
|
border: 1px solid black;
|
|
border-radius: 5px;
|
|
width: 75px;
|
|
height: 25px;
|
|
padding: 5px;
|
|
}
|
|
#target {
|
|
height: 75px;
|
|
}
|
|
.element:before {
|
|
font-size: 12pt;
|
|
content: "↑";
|
|
position: absolute;
|
|
top: -19px;
|
|
left: 5px;
|
|
}
|
|
.right:before {
|
|
left: auto;
|
|
right: 5px;
|
|
}
|
|
.bottom:before {
|
|
content: "↓";
|
|
top: auto;
|
|
bottom: -19px;
|
|
}
|
|
.center:before {
|
|
left: 50%;
|
|
right: auto;
|
|
}
|
|
.middle:before {
|
|
top: 50%;
|
|
bottom: auto;
|
|
}
|
|
.horizontal:before {
|
|
height: 10px;
|
|
top: 50%;
|
|
margin-top: -8px;
|
|
bottom: auto;
|
|
left: -18px;
|
|
right: auto;
|
|
content: "←";
|
|
}
|
|
.right.horizontal:before {
|
|
left: auto;
|
|
right: -18px;
|
|
content: "→";
|
|
}
|
|
.bottom.horizontal:before {
|
|
top: auto;
|
|
bottom: 5px;
|
|
}
|
|
.top.horizontal:before {
|
|
top: 5px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="target">all around me</div>
|
|
|
|
<div class="element"></div>
|
|
|
|
</body>
|
|
</html>
|