My favorites | Sign in
Project Home Downloads
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 264 attachment: _test-264.html (7.5 KB)

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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Dynatree - Issue 264</title>

<script src="../jquery/jquery.js" type="text/javascript"></script>
<script src="../jquery/jquery-ui.custom.js" type="text/javascript"></script>
<script src="../jquery/jquery.cookie.js" type="text/javascript"></script>

<link href="../src/skin/ui.dynatree.css" rel="stylesheet" type="text/css" id="skinSheet">
<script src="../src/jquery.dynatree.js" type="text/javascript"></script>

<style type="text/css">
#draggableSample, #droppableSample {
height:100px;
padding:0.5em;
width:150px;
border:1px solid #AAAAAA;
}
#draggableSample {
background-color: silver;
color:#222222;
}
#droppableSample {
background-color: maroon;
color: white;
}
#droppableSample.drophover {
border: 1px solid green;
}
</style>

<!-- Start_Exclude: This block is not part of the sample code -->
<link href="prettify.css" rel="stylesheet">
<script src="prettify.js" type="text/javascript"></script>
<link href="sample.css" rel="stylesheet" type="text/css">
<script src="sample.js" type="text/javascript"></script>
<!-- End_Exclude -->

<script type="text/javascript"><!--
$(function(){
// --- Initialize first Dynatree -------------------------------------------
$("#tree").dynatree({
initAjax: {
url: "sample-data3.json"
},
onLazyRead: function(node){
// Mockup a slow reqeuest ...
node.appendAjax({
url: "sample-data2.json",
debugLazyDelay: 750 // don't do thi in production code
});
},
onActivate: function(node) {
$("#echoActive").text(node.data.title + "(" + node.data.key + ")");
},
onDeactivate: function(node) {
$("#echoActive").text("-");
},
dnd: {
onDragStart: function(node) {
/** This function MUST be defined to enable dragging for the tree.
* Return false to cancel dragging of node.
*/
logMsg("tree.onDragStart(%o)", node);
if(node.data.isFolder)
return false;
return true;
},
onDragStop: function(node) {
logMsg("tree.onDragStop(%o)", node);
}
}
});
// --- Initialize second Dynatree ------------------------------------------
$("#tree2").dynatree({
initAjax: {
url: "sample-data3.json"
},
onLazyRead: function(node){
// Mockup a slow reqeuest ...
node.appendAjax({
url: "sample-data2.json",
debugLazyDelay: 750 // don't do thi in production code
});
},
onActivate: function(node) {
$("#echoActive2").text(node.data.title + "(" + node.data.key + ")");
},
onDeactivate: function(node) {
$("#echoActive2").text("-");
},
onLazyRead: function(node){
node.appendAjax({
url: "sample-data2.json"
});
},
dnd: {
autoExpandMS: 1000,
preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
onDragStart: function(node) {
/** This function MUST be defined to enable dragging for the tree.
* Return false to cancel dragging of node.
*/
logMsg("tree.onDragStart(%o)", node);
return true;
},
onDragEnter: function(node, sourceNode) {
/** sourceNode may be null for non-dynatree droppables.
* Return false to disallow dropping on node. In this case
* onDragOver and onDragLeave are not called.
* Return 'over', 'before, or 'after' to force a hitMode.
* Any other return value will calc the hitMode from the cursor position.
*/
logMsg("tree.onDragEnter(%o, %o)", node, sourceNode);
// if(node.data.isFolder)
// return false;
return true;
// return "over";
},
onDragOver: function(node, sourceNode, hitMode) {
/** Return false to disallow dropping this node.
*
*/
// if(node.data.isFolder){
// var dd = $.ui.ddmanager.current;
// dd.cancel();
// alert("folder");
// }
logMsg("tree.onDragOver(%o, %o, %o)", node, sourceNode, hitMode);
},
onDrop: function(node, sourceNode, hitMode, ui, draggable) {
/**This function MUST be defined to enable dropping of items on the tree.
* sourceNode may be null, if it is a non-Dynatree droppable.
*/
logMsg("tree.onDrop(%o, %o)", node, sourceNode);
var copynode;
if(sourceNode) {
copynode = sourceNode.toDict(true, function(dict){
dict.title = "Copy of " + dict.title;
delete dict.key; // Remove key, so a new one will be created
});
}else{
copynode = {title: "This node was dropped here (" + ui.helper + ")."};
}
if(hitMode == "over"){
// Append as child node
node.addChild(copynode);
// expand the drop target
node.expand(true);
}else if(hitMode == "before"){
// Add before this, i.e. as child of current parent
node.parent.addChild(copynode, node);
}else if(hitMode == "after"){
// Add after this, i.e. as child of current parent
node.parent.addChild(copynode, node.getNextSibling());
}
},
onDragLeave: function(node, sourceNode) {
/** Always called if onDragEnter was called.
*/
logMsg("tree.onDragLeave(%o, %o)", node, sourceNode);
}
}
});
// --- Initialize simple draggable sample ----------------------------------
$("#draggableSample").draggable({
revert: true,
connectToDynatree: true,
cursorAt: { top: -5, left:-5 },
helper: "clone"
});
// --- Initialize simple droppable sample ----------------------------------
$("#droppableSample").droppable({
hoverClass: "drophover",
addClasses: true,
over: function(event, ui) {
logMsg("droppable.over, %o, %o", event, ui);
},
drop: function(event, ui) {
var source = ui.helper.data("dtSourceNode") || ui.draggable;
$(this).addClass("ui-state-highlight").find("p").html("Dropped " + source);
// alert("dropped");
}
});
<!-- Start_Exclude: This block is not part of the sample code -->
$("#skinCombo")
.val(0) // set state to prevent caching
.change(function(){
var href = "../src/"
+ $(this).val()
+ "/ui.dynatree.css"
+ "?reload=" + new Date().getTime();
$("#skinSheet").attr("href", href);
});
<!-- End_Exclude -->
});
--></script>
</head>

<body class="example">
<h1>Issue 264</h1>
<p class="description">
The right tree accepts all kind of draggables.
</p>
<div>
Skin:
<select id="skinCombo" size="1">
<option value="skin">Standard ('/skin/')</option>
<option value="skin-vista">Vista ('/skin-vista/')</option>
</select>
</div>

<table>
<thead>
<tr>
<th>
<p>This tree allows dragging.</p>
</th>
<th>
<p>This tree allows dropping.</p>
</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td>
<div id="tree"> </div>
</td>
<td>
<div id="tree2"></div>
</td>
</tr>
<tr>
<td>
<div>Active node: <span id="echoActive">-</span></div>
</td>
<td>
<div>Active node: <span id="echoActive2">-</span></div>
</td>
</tr>
<tr>
<td>
<div id="draggableSample" class="ui-widget-content">
<p>Drag me around</p>
</div>
</td>
<td>
<div id="droppableSample" class="ui-widget-content">
<p>Drop something here</p>
</div>
</td>
</tr>
</tbody>
</table>

<!-- Start_Exclude: This block is not part of the sample code -->
<hr>
<p class="sample-links no_code">
<a class="hideInsideFS" href="http://dynatree.googlecode.com">jquery.dynatree.js project home</a>
<a class="hideOutsideFS" href="#">Link to this page</a>
<a class="hideInsideFS" href="samples.html">Example Browser</a>
<a href="#" id="codeExample">View source code</a>
</p>
<pre id="sourceCode" class="prettyprint" style="display:none"></pre>
<!-- End_Exclude -->
</body>
</html>
Powered by Google Project Hosting