Skip to content

Commit 32baf68

Browse files
committed
Adding BoundingBoxController
1 parent cba0aba commit 32baf68

8 files changed

+408
-0
lines changed

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>dojox-dnd</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

tests/.tmp_test_selector.html.30537~

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
<head>
4+
<title>Dojox DnD selector test</title>
5+
<style type="text/css">
6+
@import "../../../dojo/resources/dojo.css";
7+
@import "../../../dojo/tests/dnd/dndDefault.css";
8+
body { padding: 20px; }
9+
</style>
10+
<style title="text/css">
11+
#boundingBox {
12+
background:#999;
13+
border:1px solid #2B2B2B;
14+
opacity:0.6;
15+
position:absolute;
16+
z-index:19999;
17+
}
18+
</style>
19+
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
20+
<script type="text/javascript">
21+
dojo.require("dojox.dnd.Selector");
22+
dojo.require("dojox.dnd.BoundingBoxController");
23+
var albums, bb;
24+
var init = function() {
25+
albums = new dojox.dnd.Selector(dojo.byId("albums"));
26+
dojo.connect(dojo.doc, "onkeydown", dojo.hitch(this, function(evt) {
27+
// would usually use dojo.keys.UP_ARROW/dojo.keys.DOWN_ARROW
28+
// but can't seem to get that working with doh. Instead, I'm using
29+
// 'u' as an indicator for up and 'd' as an indicator for down.
30+
if(evt.keyCode == 85) {
31+
albums.shift(-1, evt.shiftKey);
32+
}
33+
if(evt.keyCode == 68) {
34+
albums.shift(1, evt.shiftKey);
35+
}
36+
}));
37+
bb = new dojox.dnd.BoundingBoxController({domNode: dojo.byId("boundingBox"), sources: [albums]});
38+
};
39+
dojo.addOnLoad(init);
40+
</script>
41+
</head>
42+
<body>
43+
<h1 id="header">Dojox DnD selector test</h1>
44+
<p>Use the up/down arrows to iterate through the list after selecting one.</p>
45+
<div id="albums" class="container">
46+
<div id="blonde" class="dojoDndItem">Blonde on Blonde</div>
47+
<div id="highway" class="dojoDndItem">Highway 61 Revisited</div>
48+
<div id="tracks" class="dojoDndItem">Blood on the Tracks</div>
49+
</div>
50+
<div id="boundingBox" style="display:none;"></div>
51+
</body>
52+
</html>

tests/.tmp_test_selector.html.45679~

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
<head>
4+
<title>Dojox DnD selector test</title>
5+
<style type="text/css">
6+
@import "../../../dojo/resources/dojo.css";
7+
@import "../../../dojo/tests/dnd/dndDefault.css";
8+
body { padding: 20px; }
9+
</style>
10+
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
11+
<script type="text/javascript">
12+
dojo.require("dojox.dnd.Selector");
13+
var albums;
14+
var init = function() {
15+
albums = new dojox.dnd.Selector(dojo.byId("albums"));
16+
dojo.connect(dojo.doc, "onkeydown", dojo.hitch(this, function(evt) {
17+
// would usually use dojo.keys.UP_ARROW/dojo.keys.DOWN_ARROW
18+
// but can't seem to get that working with doh. Instead, I'm using
19+
// 'u' as an indicator for up and 'd' as an indicator for down.
20+
if(evt.keyCode == 85) {
21+
albums.shift(-1, evt.shiftKey);
22+
}
23+
if(evt.keyCode == 68) {
24+
albums.shift(1, evt.shiftKey);
25+
}
26+
}));
27+
};
28+
dojo.addOnLoad(init);
29+
</script>
30+
</head>
31+
<body>
32+
<h1 id="header">Dojox DnD selector test</h1>
33+
<p>Use the up/down arrows to iterate through the list after selecting one.</p>
34+
<div id="albums" class="container">
35+
<div id="blonde" class="dojoDndItem">Blonde on Blonde</div>
36+
<div id="highway" class="dojoDndItem">Highway 61 Revisited</div>
37+
<div id="tracks" class="dojoDndItem">Blood on the Tracks</div>
38+
</div>
39+
</body>
40+
</html>

tests/.tmp_test_selector.html.67693~

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
<head>
4+
<title>Dojox DnD selector test</title>
5+
<style type="text/css">
6+
@import "../../../dojo/resources/dojo.css";
7+
@import "../../../dojo/tests/dnd/dndDefault.css";
8+
body { padding: 20px; }
9+
</style>
10+
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
11+
<script type="text/javascript">
12+
dojo.require("dojox.dnd.Selector");
13+
var albums;
14+
var init = function() {
15+
albums = new dojox.dnd.Selector(dojo.byId("albums"));
16+
dojo.connect(dojo.doc, "onkeydown", dojo.hitch(this, function(evt) {
17+
// would usually use dojo.keys.UP_ARROW/dojo.keys.DOWN_ARROW
18+
// but can't seem to get that working with doh. Instead, I'm using
19+
// 'u' as an indicator for up and 'd' as an indicator for down.
20+
if(evt.keyCode == 85) {
21+
albums.shift(-1, evt.shiftKey);
22+
}
23+
if(evt.keyCode == 68) {
24+
albums.shift(1, evt.shiftKey);
25+
}
26+
}));
27+
};
28+
dojo.addOnLoad(init);
29+
</script>
30+
</head>
31+
<body>
32+
<h1 id="header">Dojox DnD selector test</h1>
33+
<p>Use the up/down arrows to iterate through the list after selecting one.</p>
34+
<div id="albums" class="container">
35+
<div id="blonde" class="dojoDndItem">Blonde on Blonde</div>
36+
<div id="highway" class="dojoDndItem">Highway 61 Revisited</div>
37+
<div id="tracks" class="dojoDndItem">Blood on the Tracks</div>
38+
</div>
39+
</body>
40+
</html>

tests/.tmp_test_selector.html.70073~

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
<head>
4+
<title>Dojox DnD selector test</title>
5+
<style type="text/css">
6+
@import "../../../dojo/resources/dojo.css";
7+
@import "../../../dojo/tests/dnd/dndDefault.css";
8+
body { padding: 20px; }
9+
</style>
10+
<style title="text/css">
11+
#boundingBox {
12+
background:#999;
13+
border:1px solid #2B2B2B;
14+
opacity:0.6;
15+
position:absolute;
16+
z-index:19999;
17+
}
18+
</style>
19+
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
20+
<script type="text/javascript">
21+
dojo.require("dojox.dnd.Selector");
22+
dojo.require("dojox.dnd.BoundingBoxController");
23+
var albums, bb;
24+
var init = function() {
25+
albums = new dojox.dnd.Selector(dojo.byId("albums"));
26+
dojo.connect(dojo.doc, "onkeydown", dojo.hitch(this, function(evt) {
27+
// would usually use dojo.keys.UP_ARROW/dojo.keys.DOWN_ARROW
28+
// but can't seem to get that working with doh. Instead, I'm using
29+
// 'u' as an indicator for up and 'd' as an indicator for down.
30+
if(evt.keyCode == 85) {
31+
albums.shift(-1, evt.shiftKey);
32+
}
33+
if(evt.keyCode == 68) {
34+
albums.shift(1, evt.shiftKey);
35+
}
36+
}));
37+
bb = new dojox.dnd.BoundingBoxController({domNode: dojo.byId("boundingBox"), sources: [albums]});
38+
};
39+
dojo.addOnLoad(init);
40+
</script>
41+
</head>
42+
<body>
43+
<h1 id="header">Dojox DnD selector test</h1>
44+
<p>Use the up/down arrows to iterate through the list after selecting one.</p>
45+
<div id="albums" class="container">
46+
<div id="blonde" class="dojoDndItem">Blonde on Blonde</div>
47+
<div id="highway" class="dojoDndItem">Highway 61 Revisited</div>
48+
<div id="tracks" class="dojoDndItem">Blood on the Tracks</div>
49+
</div>
50+
<div id="boundingBox" style="display:none;"></div>
51+
</body>
52+
</html>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
<head>
4+
<title>doh.robot dojox DnD Test</title>
5+
6+
<style>
7+
@import "../../../../util/doh/robot/robot.css";
8+
</style>
9+
10+
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
11+
<script type="text/javascript">
12+
dojo.require("dojo.robotx");
13+
14+
dojo.addOnLoad(function() {
15+
16+
doh.robot.initRobot('../test_selector.html');
17+
18+
doh.register('dojox.robot.DndSelectorTest', [
19+
{
20+
name: 'dojox dnd shift down test',
21+
timeout: 10000,
22+
runTest: function() {
23+
var d = new doh.Deferred();
24+
doh.robot.mouseMoveAt('blonde', 1000);
25+
doh.robot.mouseClick({left:true, middle:false, right:false}, 100);
26+
doh.robot.mouseClick({left:true, middle:false, right:false}, 100);
27+
doh.robot.mouseMoveAt('header', 250);
28+
doh.robot.mouseClick({left:true, middle:false, right:false}, 100);
29+
doh.robot.typeKeys("d", 100);
30+
doh.robot.sequence(function() {
31+
dojo.query("> div", dojo.byId('albums')).forEach(function(item, index, array) {
32+
if(index == 1) {
33+
if(dojo.hasClass(item, "dojoDndItemSelected") && item.id == "highway") {
34+
d.callback(true);
35+
} else {
36+
d.errback(new Error("Second item in the album list was not selected"));
37+
}
38+
} else {
39+
doh.assertFalse(dojo.hasClass(item, "dojoDndItemSelected"));
40+
}
41+
});
42+
}, 3000);
43+
return d;
44+
}
45+
},
46+
{
47+
name: 'dojox dnd shift up test',
48+
timeout: 10000,
49+
runTest: function() {
50+
var d = new doh.Deferred();
51+
doh.robot.typeKeys("u", 100);
52+
doh.robot.sequence(function() {
53+
dojo.query("> div", dojo.byId('albums')).forEach(function(item, index, array) {
54+
if(index == 0) {
55+
if(dojo.hasClass(item, "dojoDndItemSelected") && item.id == "blonde") {
56+
d.callback(true);
57+
} else {
58+
d.errback(new Error("First item in the album list was not selected"));
59+
}
60+
}
61+
});
62+
}, 1000);
63+
return d;
64+
}
65+
}
66+
]);
67+
doh.run();
68+
});
69+
</script>
70+
</head>
71+
</html>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2+
<html>
3+
<head>
4+
<title>doh.robot dojox DnD Test</title>
5+
6+
<style>
7+
@import "../../../../util/doh/robot/robot.css";
8+
</style>
9+
10+
<script type="text/javascript" src="../../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true"></script>
11+
<script type="text/javascript">
12+
dojo.require("dojo.robotx");
13+
14+
dojo.addOnLoad(function() {
15+
16+
doh.robot.initRobot('../test_selector.html');
17+
18+
doh.register('dojox.robot.DndSelectorTest', [
19+
{
20+
name: 'dojox dnd shift down test',
21+
timeout: 10000,
22+
runTest: function() {
23+
var d = new doh.Deferred();
24+
doh.robot.mouseMoveAt('blonde', 1000);
25+
doh.robot.mouseClick({left:true, middle:false, right:false}, 100);
26+
doh.robot.mouseClick({left:true, middle:false, right:false}, 100);
27+
doh.robot.mouseMoveAt('header', 250);
28+
doh.robot.mouseClick({left:true, middle:false, right:false}, 100);
29+
doh.robot.typeKeys("d", 100);
30+
doh.robot.sequence(function() {
31+
dojo.query("> div", dojo.byId('albums')).forEach(function(item, index, array) {
32+
if(index == 1) {
33+
if(dojo.hasClass(item, "dojoDndItemSelected") && item.id == "highway") {
34+
d.callback(true);
35+
} else {
36+
d.errback(new Error("Second item in the album list was not selected"));
37+
}
38+
} else {
39+
doh.assertFalse(dojo.hasClass(item, "dojoDndItemSelected"));
40+
}
41+
});
42+
}, 3000);
43+
return d;
44+
}
45+
},
46+
{
47+
name: 'dojox dnd shift up test',
48+
timeout: 10000,
49+
runTest: function() {
50+
var d = new doh.Deferred();
51+
doh.robot.typeKeys("u", 100);
52+
doh.robot.sequence(function() {
53+
dojo.query("> div", dojo.byId('albums')).forEach(function(item, index, array) {
54+
if(index == 0) {
55+
if(dojo.hasClass(item, "dojoDndItemSelected") && item.id == "blonde") {
56+
d.callback(true);
57+
} else {
58+
d.errback(new Error("First item in the album list was not selected"));
59+
}
60+
}
61+
});
62+
}, 1000);
63+
return d;
64+
}
65+
}
66+
]);
67+
doh.run();
68+
});
69+
</script>
70+
</head>
71+
</html>

0 commit comments

Comments
 (0)