1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../ui/ui.draggable.js"></script>
<script type="text/javascript" src="../../ui/ui.droppable.js"></script>
<script type="text/javascript" src="../../ui/ui.resizable.js"></script>
<script type="text/javascript" src="../../ui/ui.sortable.js"></script>
<script>
$(document).ready(function(){
$.widget("ui.tree", {
init: function() {
var self = this;
this.element.sortable({
items: this.options.sortOn,
placeholder: "ui-tree-placeholder",
start: function() {
$(this).data("sortable").placeholder.hide();
$(this).data("sortable").refreshPositions(true);
},
stop: function() {
var self = $(this).data("sortable");
$(self.options.items, self.element).css("border-top", "0").css("border-bottom", "0");
},
sortIndicator: function(e, item, append, hardRefresh) {
append ? append[0].appendChild(this.placeholder[0]) : item.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? item.item[0] : item.item[0].nextSibling));
$(this.options.items, this.element).css("border-top", "0").css("border-bottom", "0");
item.item.css("border-"+(this.direction == "down" ? "top" : "bottom"), "2px solid black");
}
});
//Make certain nodes droppable
$(this.options.dropOn, this.element).droppable({
accept: this.options.sortOn,
hoverClass: this.options.hoverClass,
//tolerance: "pointer",
over: function() {
$(self.options.sortOn, self.element).css("border-top", "0").css("border-bottom", "0");
},
drop: function(e, ui) {
$(this).parent().find("ul").append(ui.draggable);
self.element.data("sortable")._noFinalSort = true;
}
});
}
});
$.extend($.ui.tree, {
defaults: {
sortOn: "*",
dropOn: "div",
hoverClass: "ui-tree-hover"
}
});
$("ul.sortable").tree({
sortOn: "li",
dropOn: "div",
hoverClass: "hover"
});
});
</script>
<style type="text/css">
body {
background:#fff;
color:#333;
font-size:11px;
font-family:"lucida grande", tahoma, verdana, arial, sans-serif;
}
.hover {
background: green;
color: #fff;
}
.placeholder {
display: none;
}
</style>
</head>
<body>
<ul class="sortable">
<li>Item 1</li>
<li><div>Item 2</div>
<ul>
<li>Sub Item 1</li>
<li>Sub Item 3</li>
<li>Sub Item 4</li>
<li>Sub Item 5</li>
</ul>
</li>
<li>Item 3</li>
<li>Item 4</li>
<li><div>Item 2</div>
<ul>
<li>Sub Item 1</li>
<li>Sub Item 3</li>
<li>Sub Item 4</li>
<li>Sub Item 5</li>
</ul>
</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
</ul>
</body>
</html>
|