1
|
dojo.require("dojo.rpc.*");
|
2
|
dojo.hostenv.writeIncludes();
|
3
|
var service = new dojo.rpc.JsonService("CollectionInfo");
|
4
|
|
5
|
var tree = null;
|
6
|
var roarQueue;
|
7
|
|
8
|
window.addEvent('domready', function() {
|
9
|
roarQueue = new Roar( {
|
10
|
position :'upperRight',
|
11
|
container :$('roarQueue_container'),
|
12
|
duration :5000
|
13
|
});
|
14
|
});
|
15
|
|
16
|
function formTree() {
|
17
|
var treeDiv = document.getElementById('treeDiv1');
|
18
|
treeInit();
|
19
|
|
20
|
// handler for expanding all nodes
|
21
|
YAHOO.util.Event.on("expand", "click", function(e) {
|
22
|
tree.destroy();
|
23
|
tree = new YAHOO.widget.TreeView("treeDiv1");
|
24
|
|
25
|
tree.setDynamicLoad(loadDataForContainerTree);
|
26
|
|
27
|
var root = tree.getRoot();
|
28
|
var tmpNode = new YAHOO.widget.TextNode( {
|
29
|
label :"My collections",
|
30
|
id :"InfoSpace",
|
31
|
expanded :true,
|
32
|
href :"javascript:addFather('InfoSpace','InfoSpace',false);" },
|
33
|
root);
|
34
|
|
35
|
tree.render();
|
36
|
});
|
37
|
|
38
|
// handler for collapsing all nodes
|
39
|
YAHOO.util.Event.on("collapse", "click", function(e) {
|
40
|
tree.collapseAll();
|
41
|
YAHOO.util.Event.preventDefault(e);
|
42
|
});
|
43
|
}
|
44
|
|
45
|
function hideTree() {
|
46
|
SqueezeBox.close();
|
47
|
}
|
48
|
|
49
|
function treeInit() {
|
50
|
tree = new YAHOO.widget.TreeView("treeDiv1");
|
51
|
|
52
|
tree.setDynamicLoad(loadDataForContainerNode);
|
53
|
|
54
|
var root = tree.getRoot();
|
55
|
var tmpNode = new YAHOO.widget.TextNode( {
|
56
|
label :"My Collections",
|
57
|
id :"InfoSpace",
|
58
|
enableHighlight :false,
|
59
|
href :"javascript:addFather('InfoSpace','InfoSpace',false);" },
|
60
|
root);
|
61
|
|
62
|
tmpNode.expand();
|
63
|
tmpNode.renderHidden = true;
|
64
|
tree.setNodesProperty('enableHighlight', 'false');
|
65
|
|
66
|
document.getElementById('expandcontractdiv').style.display = 'block';
|
67
|
|
68
|
tree.render();
|
69
|
}
|
70
|
|
71
|
function loadDataForContainerNode(node, onCompleteCallback) {
|
72
|
getContainerChildren(node, onCompleteCallback);
|
73
|
}
|
74
|
|
75
|
function loadDataForContainerTree(node, onCompleteCallback) {
|
76
|
getAllContainerChildren(node, onCompleteCallback);
|
77
|
}
|
78
|
|
79
|
function getAllContainerChildren(node, onCompleteCallback) {
|
80
|
var callback = function(bean) {
|
81
|
for ( var i = 0; i < bean.length; i++) {
|
82
|
var myobj = {
|
83
|
label :bean[i].collection.name,
|
84
|
id :bean[i].collection.resourceId,
|
85
|
enableHighlight :false,
|
86
|
href :"javascript:addFather('" + bean[i].collection.resourceId + "','" + bean[i].collection.name + "');"
|
87
|
};
|
88
|
|
89
|
if (bean[i].collection.private)
|
90
|
myobj.label = myobj.label + ' *';
|
91
|
|
92
|
var tmpNode = new YAHOO.widget.TextNode(myobj, node, true);
|
93
|
|
94
|
if (!bean[i].hasContainerChildren) {
|
95
|
tmpNode.isLeaf = true;
|
96
|
}
|
97
|
|
98
|
tmpNode.expand();
|
99
|
}
|
100
|
onCompleteCallback();
|
101
|
};
|
102
|
|
103
|
var defered = service.getUserFolderChildren(node.data.id);
|
104
|
defered.addCallback(callback);
|
105
|
}
|
106
|
|
107
|
function getContainerChildren(node, onCompleteCallback) {
|
108
|
var callback = function(bean) {
|
109
|
for ( var i = 0; i < bean.length; i++) {
|
110
|
var myobj = {
|
111
|
label :bean[i].collection.name,
|
112
|
id :bean[i].collection.resourceId,
|
113
|
enableHighlight :false,
|
114
|
href :"javascript:addFather('" + bean[i].collection.resourceId + "','" + bean[i].collection.name + "');"
|
115
|
};
|
116
|
|
117
|
if (bean[i].collection.private)
|
118
|
myobj.label = myobj.label + ' *';
|
119
|
|
120
|
var tmpNode = new YAHOO.widget.TextNode(myobj, node, false);
|
121
|
|
122
|
if (!bean[i].hasContainerChildren) {
|
123
|
tmpNode.isLeaf = true;
|
124
|
}
|
125
|
}
|
126
|
onCompleteCallback();
|
127
|
};
|
128
|
|
129
|
var defered = service.getUserFolderChildren(node.data.id);
|
130
|
defered.addCallback(callback);
|
131
|
}
|