jquery-ui/ui/tests/autodrag.html
2008-05-26 14:30:37 +00:00

100 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<title>Draggable - Automated Test Page</title>
<script type="text/javascript" src="../../jquery/jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../ui/source/ui.core.js"></script>
<script type="text/javascript" src="../../ui/source/ui.draggable.js"></script>
<script type="text/javascript" src="ui.testmouse.js"></script>
<style type="text/css">
html, body { height: 100%; }
#main { height: 100%; }
.drag { position: relative; margin: 10px; padding: 10px; border: 3px solid black; cursor: move; width: 200px; height: 40px; background: #eef; }
</style>
<script type="text/javascript">
</script>
<script type="text/javascript">
$(function() {
$(".drag").draggable().testMouse({
speed: "fast"
});
var queue;
var start = function() {
queue = tests.slice(); // clone
$("#status").text("Running...");
nextTest();
}
var stop = function() {
$("#status").text("Ready");
}
var tests = [];
var nextTest = function() {
if (queue.length) {
queue.pop().apply();
} else {
stop();
}
}
var addTest = function(fn) {
tests.unshift(fn);
}
addTest(function() {
$("#d1").testMouse("drag", 100, 0, nextTest);
});
addTest(function() {
$("#d2").testMouse("drag", 100, 0, nextTest);
});
addTest(function() {
$("#d3").testMouse("drag", 100, 0, nextTest);
});
$('#begin').click(function(e) {
start();
});
});
</script>
</head>
<body>
<div id="main">
<h1>jQuery UI Draggable - Automated Test</h1>
Status: <span id="status">Ready</span>
<div style="height: 3em;"><button id="begin">Run Test</button></div>
<div class="drag" id="d1">
Drag 1
</div>
<div class="drag" id="d2">
Drag 2
</div>
<div class="drag" id="d3">
Drag 3
</div>
</div>
</body>
</html>