1 |
13151
|
antonis.le
|
var tree;
|
2 |
|
|
var tt, contextElements = [];
|
3 |
|
|
|
4 |
|
|
var editedCollectionResourceId;
|
5 |
|
|
|
6 |
|
|
// load dojo RPC
|
7 |
|
|
dojo.require("dojo.rpc.*");
|
8 |
|
|
|
9 |
|
|
dojo.hostenv.writeIncludes();
|
10 |
|
|
dojo.require();
|
11 |
|
|
|
12 |
|
|
var roarQueue;
|
13 |
|
|
// define as global
|
14 |
|
|
|
15 |
|
|
window.addEvent('domready', function() {
|
16 |
|
|
roarQueue = new Roar( {
|
17 |
|
|
position :'upperRight',
|
18 |
|
|
container :$('roarQueue_container'),
|
19 |
|
|
duration :5000
|
20 |
|
|
});
|
21 |
|
|
});
|
22 |
|
|
|
23 |
|
|
// create service object(proxy) using SMD (generated by the json result)
|
24 |
|
|
var service = new dojo.rpc.JsonService("CollectionInfo");
|
25 |
|
|
|
26 |
|
|
function formTree() {
|
27 |
|
|
var treeDiv = document.getElementById('treeDiv1');
|
28 |
|
|
|
29 |
|
|
treeInit();
|
30 |
|
|
|
31 |
|
|
tt = new YAHOO.widget.Tooltip("tt", {
|
32 |
|
|
context :contextElements
|
33 |
|
|
});
|
34 |
|
|
|
35 |
|
|
// handler for expanding all nodes
|
36 |
|
|
YAHOO.util.Event.on("expand", "click", function(e) {
|
37 |
|
|
YAHOO.log("Expanding all TreeView nodes.", "info", "example");
|
38 |
|
|
tree.destroy();
|
39 |
|
|
tree = new YAHOO.widget.TreeView("treeDiv1");
|
40 |
|
|
tree.setDynamicLoad(loadDataForTree);
|
41 |
|
|
var root = tree.getRoot();
|
42 |
|
|
var tmpNode = new YAHOO.widget.TextNode( {
|
43 |
|
|
label :"Collections",
|
44 |
|
|
id :"InfoSpace",
|
45 |
|
|
expanded :true
|
46 |
|
|
}, root);
|
47 |
|
|
|
48 |
|
|
tree.render();
|
49 |
|
|
|
50 |
|
|
});
|
51 |
|
|
|
52 |
|
|
// handler for collapsing all nodes
|
53 |
|
|
YAHOO.util.Event.on("collapse", "click", function(e) {
|
54 |
|
|
YAHOO.log("Collapsing all TreeView nodes.", "info", "example");
|
55 |
|
|
tree.collapseAll();
|
56 |
|
|
YAHOO.util.Event.preventDefault(e);
|
57 |
|
|
});
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
function treeInit() {
|
61 |
|
|
tree = new YAHOO.widget.TreeView("treeDiv1");
|
62 |
|
|
tree.setDynamicLoad(loadDataForNode);
|
63 |
|
|
|
64 |
|
|
var root = tree.getRoot();
|
65 |
|
|
|
66 |
|
|
var tmpNode = new YAHOO.widget.TextNode( {
|
67 |
|
|
label :"Collections",
|
68 |
|
|
id :"InfoSpace",
|
69 |
|
|
expanded :false,
|
70 |
|
|
enableHighlight :false
|
71 |
|
|
}, root);
|
72 |
|
|
|
73 |
|
|
tmpNode.expand();
|
74 |
|
|
|
75 |
|
|
tmpNode.highlight(false);
|
76 |
|
|
tmpNode.renderHidden = true;
|
77 |
|
|
contextElements.push(tmpNode.labelElId);
|
78 |
|
|
|
79 |
|
|
tree.setNodesProperty('enableHighlight', 'false');
|
80 |
|
|
// The tree is not created in the DOM until this method is called:
|
81 |
|
|
tree.render();
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
function loadDataForNode(node, onCompleteCallback) {
|
85 |
|
|
// -- code to get your data, possibly using Connect --
|
86 |
|
|
getChildren(node, onCompleteCallback);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
function loadDataForTree(node, onCompleteCallback) {
|
90 |
|
|
getAllChildren(node, onCompleteCallback);
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
function getAllChildren(node, onCompleteCallback) {
|
94 |
|
|
// load dojo RPC
|
95 |
|
|
dojo.require("dojo.rpc.*");
|
96 |
|
|
|
97 |
|
|
dojo.hostenv.writeIncludes();
|
98 |
|
|
dojo.require();
|
99 |
|
|
|
100 |
|
|
// create service object(proxy) using SMD (generated by the json result)
|
101 |
|
|
var service = new dojo.rpc.JsonService("CollectionInfo");
|
102 |
|
|
|
103 |
|
|
var callback = function(bean) {
|
104 |
|
|
|
105 |
|
|
for ( var i = 0; i < bean.length; i++) {
|
106 |
|
|
|
107 |
|
|
var collectionLabel;
|
108 |
|
|
if (bean[i].visible)
|
109 |
|
|
collectionLabel = bean[i].name;
|
110 |
|
|
else
|
111 |
|
|
collectionLabel = "<i>" + bean[i].name + "</i>";
|
112 |
|
|
|
113 |
|
|
var myobj = {
|
114 |
|
|
label :collectionLabel,
|
115 |
|
|
id :bean[i].resourceId,
|
116 |
|
|
enableHighlight :false,
|
117 |
|
|
href :"javascript:fetchCollection('" + bean[i].resourceId
|
118 |
|
|
+ "');"
|
119 |
|
|
};
|
120 |
|
|
|
121 |
|
|
var tmpNode = new YAHOO.widget.TextNode(myobj, node, true);
|
122 |
|
|
if (bean[i].children.length == 0)
|
123 |
|
|
tmpNode.isLeaf = true;
|
124 |
|
|
contextElements.push(tmpNode.labelElId);
|
125 |
|
|
|
126 |
|
|
// fetch first root collection
|
127 |
|
|
if (bean[i].father == null && i == 0)
|
128 |
|
|
fetchCollection(bean[i].resourceId);
|
129 |
|
|
|
130 |
|
|
}
|
131 |
|
|
// Be sure to notify the TreeView component when the data load is
|
132 |
|
|
// complete
|
133 |
|
|
onCompleteCallback();
|
134 |
|
|
|
135 |
|
|
};
|
136 |
|
|
|
137 |
|
|
// execute remote method
|
138 |
|
|
var defered = service.getChildren(node.data.id);
|
139 |
|
|
defered.addCallback(callback);
|
140 |
|
|
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
function getChildren(node, onCompleteCallback) {
|
144 |
|
|
|
145 |
|
|
var callback = function(bean) {
|
146 |
|
|
|
147 |
|
|
for ( var i = 0; i < bean.length; i++) {
|
148 |
|
|
|
149 |
|
|
var collectionLabel;
|
150 |
|
|
if (bean[i].visible)
|
151 |
|
|
collectionLabel = bean[i].name;
|
152 |
|
|
else
|
153 |
|
|
collectionLabel = "<i>" + bean[i].name + "</i>";
|
154 |
|
|
|
155 |
|
|
var myobj = {
|
156 |
|
|
label :collectionLabel,
|
157 |
|
|
id :bean[i].resourceId,
|
158 |
|
|
enableHighlight :false,
|
159 |
|
|
href :"javascript:fetchCollection('" + bean[i].resourceId
|
160 |
|
|
+ "');"
|
161 |
|
|
};
|
162 |
|
|
|
163 |
|
|
var tmpNode = new YAHOO.widget.TextNode(myobj, node, false);
|
164 |
|
|
if (bean[i].children.length == 0) {
|
165 |
|
|
tmpNode.isLeaf = true;
|
166 |
|
|
}
|
167 |
|
|
contextElements.push(tmpNode.labelElId);
|
168 |
|
|
|
169 |
|
|
// fetch first root collection
|
170 |
|
|
if (bean[i].father == null && i == 0)
|
171 |
|
|
fetchCollection(bean[i].resourceId);
|
172 |
|
|
|
173 |
|
|
}
|
174 |
|
|
// Be sure to notify the TreeView component when the data load is
|
175 |
|
|
// complete
|
176 |
|
|
onCompleteCallback();
|
177 |
|
|
|
178 |
|
|
};
|
179 |
|
|
|
180 |
|
|
// execute remote method
|
181 |
|
|
var defered = service.getChildren(node.data.id);
|
182 |
|
|
defered.addCallback(callback);
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
function updateCollection() {
|
186 |
|
|
|
187 |
|
|
var name = document.getElementById('collectionName').value;
|
188 |
|
|
var description = document.getElementById('collectionDescription').value;
|
189 |
|
|
var subject = document.getElementById('collectionSubject').value;
|
190 |
|
|
var iconUrl = document.getElementById('collectionIconUrl').value;
|
191 |
|
|
var visible = false;
|
192 |
|
|
var tmpVisible = document.getElementById('collectionVisible');
|
193 |
|
|
if (tmpVisible.checked == true) {
|
194 |
|
|
visible = true;
|
195 |
|
|
}
|
196 |
|
|
var frozen = false;
|
197 |
|
|
var tmpFrozen = document.getElementById('collectionFrozen');
|
198 |
13396
|
katerina.i
|
if (tmpFrozen.checked == true) {
|
199 |
13151
|
antonis.le
|
frozen = true;
|
200 |
13396
|
katerina.i
|
}
|
201 |
|
|
var privatevar = false;
|
202 |
13151
|
antonis.le
|
var tmpPrivate = document.getElementById('collectionPrivateTrue');
|
203 |
|
|
if (tmpPrivate.checked == true) {
|
204 |
13396
|
katerina.i
|
privatevar = true;
|
205 |
13151
|
antonis.le
|
}
|
206 |
|
|
|
207 |
|
|
var callback = function(bean) {
|
208 |
|
|
if (bean.name != null) {
|
209 |
|
|
|
210 |
|
|
document.getElementById('collectionLastUpdateDate').innerHTML = dateFormat(
|
211 |
|
|
Date(bean.lastUpdateDate), "mmmm dd, yyyy");
|
212 |
|
|
document.getElementById('collectionTitle').value = bean.name;
|
213 |
|
|
|
214 |
|
|
if (bean.iconUrl != "")
|
215 |
|
|
document.getElementById('collectionImage').src = bean.iconUrl;
|
216 |
|
|
else
|
217 |
13396
|
katerina.i
|
document.getElementById('collectionImage').src = "static-content/images/logo_driver.png";
|
218 |
13151
|
antonis.le
|
|
219 |
|
|
var node = tree.getNodeByProperty("id", bean.resourceId);
|
220 |
|
|
if (bean.visible) {
|
221 |
|
|
|
222 |
|
|
node.label = bean.name;
|
223 |
|
|
} else
|
224 |
|
|
node.label = "<i>" + bean.name + "</i>";
|
225 |
|
|
|
226 |
|
|
tree.render();
|
227 |
|
|
roarQueue
|
228 |
|
|
.alert('<p>Collection has been updated successfully.</p><p></p>');
|
229 |
|
|
|
230 |
|
|
} else
|
231 |
|
|
alert("A problem occured while updating collection");
|
232 |
|
|
|
233 |
|
|
};
|
234 |
|
|
|
235 |
|
|
// execute remote method
|
236 |
|
|
|
237 |
|
|
var collectionBean = {
|
238 |
|
|
"resourceId" :editedCollectionResourceId,
|
239 |
|
|
"name" :name,
|
240 |
|
|
"description" : [ description ],
|
241 |
|
|
"visible" :visible,
|
242 |
13396
|
katerina.i
|
"private" :privatevar,
|
243 |
13151
|
antonis.le
|
"frozen" :frozen,
|
244 |
|
|
"subject" :subject,
|
245 |
|
|
"iconUrl" :iconUrl
|
246 |
|
|
};
|
247 |
|
|
|
248 |
|
|
var defered = service.updateCollection(collectionBean);
|
249 |
|
|
|
250 |
|
|
// attach callback to defered object
|
251 |
|
|
defered.addCallback(callback);
|
252 |
|
|
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
function fetchCollection(collectionId) {
|
256 |
|
|
squeezeBoxLoading.open($('collection_loading'));
|
257 |
|
|
// function called when remote method returns
|
258 |
|
|
|
259 |
|
|
var callback = function(bean) {
|
260 |
|
|
if (bean.isFatherPrivate != null) {
|
261 |
|
|
|
262 |
|
|
document.getElementById('maincolumn2').style.display = 'block';
|
263 |
|
|
document.getElementById('collectionID').value = collectionId;
|
264 |
|
|
|
265 |
|
|
document.getElementById('collectionTitle').value = bean.collection.name;
|
266 |
|
|
document.getElementById('collectionName').value = bean.collection.name;
|
267 |
|
|
|
268 |
|
|
document.getElementById('collectionDescription').value = bean.collection.description;
|
269 |
|
|
document.getElementById('collectionSubject').value = bean.collection.subject;
|
270 |
|
|
document.getElementById('collectionQueryCriteria').innerHTML = "<i>No query defined</i>";
|
271 |
|
|
document.getElementById('collectionItemsInBasket').innerHTML = bean.collection.documentsInBasket.length;
|
272 |
|
|
|
273 |
|
|
if (bean.collection.query && bean.collection.query != "")
|
274 |
|
|
document.getElementById('collectionQueryCriteria').innerHTML = bean.collection.query;
|
275 |
|
|
|
276 |
|
|
if (bean.ownerEmail && bean.ownerEmail != "")
|
277 |
|
|
document.getElementById('collectionOwnerEmail').innerHTML = bean.ownerEmail;
|
278 |
|
|
else
|
279 |
|
|
document.getElementById('collectionOwnerEmail').innerHTML = "<i>Not specified.</i>";
|
280 |
|
|
|
281 |
|
|
if (bean.collection.iconUrl != "") {
|
282 |
|
|
document.getElementById('collectionImage').src = bean.collection.iconUrl;
|
283 |
|
|
} else
|
284 |
13396
|
katerina.i
|
document.getElementById('collectionImage').src = "static-content/images/logo_driver.png";
|
285 |
13151
|
antonis.le
|
|
286 |
|
|
document.getElementById('collectionIconUrl').value = bean.collection.iconUrl;
|
287 |
|
|
if (bean.collection.visible)
|
288 |
|
|
document.getElementById('collectionVisible').checked = true;
|
289 |
|
|
else
|
290 |
|
|
document.getElementById('collectionVisible').checked = false;
|
291 |
|
|
|
292 |
|
|
if (bean.collection.frozen)
|
293 |
|
|
document.getElementById('collectionFrozen').checked = true;
|
294 |
|
|
else
|
295 |
|
|
document.getElementById('collectionFrozen').checked = false;
|
296 |
|
|
|
297 |
|
|
document.getElementById('collectionPrivateTrue').disabled = false;
|
298 |
|
|
document.getElementById('collectionPrivateFalse').disabled = false;
|
299 |
|
|
|
300 |
|
|
if (bean.collection.private) {
|
301 |
|
|
|
302 |
|
|
document.getElementById('collectionPrivateTrue').checked = true;
|
303 |
|
|
// if father is private you cannot turn to public
|
304 |
|
|
if (bean.isFatherPrivate) {
|
305 |
|
|
document.getElementById('collectionPrivateTrue').disabled = true;
|
306 |
|
|
document.getElementById('collectionPrivateFalse').disabled = true;
|
307 |
|
|
}
|
308 |
|
|
|
309 |
|
|
} else {
|
310 |
|
|
|
311 |
|
|
document.getElementById('collectionPrivateFalse').checked = true;
|
312 |
|
|
// if you have children you cannot turn to private
|
313 |
|
|
if (bean.collection.children.length > 0) {
|
314 |
|
|
document.getElementById('collectionPrivateTrue').disabled = true;
|
315 |
|
|
document.getElementById('collectionPrivateFalse').disabled = true;
|
316 |
|
|
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
}
|
320 |
|
|
|
321 |
|
|
document.getElementById('collectionLastUpdateDate').innerHTML = dateFormat(
|
322 |
|
|
Date(bean.collection.lastUpdateDate), "mmmm dd, yyyy");
|
323 |
|
|
|
324 |
|
|
document.getElementById('collectionDocumentCount').innerHTML = bean.collection.documentCount;
|
325 |
|
|
|
326 |
|
|
editedCollectionResourceId = bean.collection.resourceId;
|
327 |
|
|
|
328 |
|
|
if (bean.basketDocuments != null) {
|
329 |
|
|
document.getElementById('collectionsDocumentList').innerHTML = "";
|
330 |
|
|
for ( var i = 0; i < bean.basketDocuments.length; i++)
|
331 |
|
|
addDocumentDiv(i, bean.basketDocuments[i].title,
|
332 |
|
|
bean.basketDocuments[i].documentId,
|
333 |
|
|
bean.basketDocuments[i].summaryFields,
|
334 |
|
|
'collectionsDocumentList');
|
335 |
13396
|
katerina.i
|
} else {
|
336 |
13151
|
antonis.le
|
document.getElementById('collectionsDocumentList').innerHTML = "<i>There are no documents in your basket.</i>";
|
337 |
13396
|
katerina.i
|
}
|
338 |
13151
|
antonis.le
|
|
339 |
13396
|
katerina.i
|
} else {
|
340 |
13151
|
antonis.le
|
alert("A problem occured while getting collection");
|
341 |
13396
|
katerina.i
|
}
|
342 |
13151
|
antonis.le
|
squeezeBoxLoading.close();
|
343 |
|
|
|
344 |
|
|
};
|
345 |
|
|
|
346 |
|
|
// execute remote method
|
347 |
|
|
var defered = service.getCollection(collectionId);
|
348 |
|
|
|
349 |
|
|
// attach callback to defered object
|
350 |
|
|
defered.addCallback(callback);
|
351 |
|
|
}
|
352 |
|
|
function addDocumentDiv(index, title, documentId, summaryFields, targetDiv) {
|
353 |
|
|
var documentListDiv = document.getElementById(targetDiv);
|
354 |
|
|
|
355 |
|
|
var documentDiv = document.createElement('div');
|
356 |
|
|
|
357 |
|
|
documentDiv.setAttribute('id', "document" + index);
|
358 |
|
|
|
359 |
|
|
var mydriveritemDiv = document.createElement('div');
|
360 |
|
|
mydriveritemDiv.setAttribute('class', "mydriveritem");
|
361 |
|
|
|
362 |
|
|
var contentDiv = document.createElement('div');
|
363 |
|
|
contentDiv.setAttribute('class', "content");
|
364 |
|
|
|
365 |
|
|
var rightDiv = document.createElement('div');
|
366 |
|
|
rightDiv.setAttribute('class', "right");
|
367 |
|
|
|
368 |
|
|
rightDiv.innerHTML = "<h2>" + "<input type=\"checkbox\" name=\""
|
369 |
|
|
+ documentId + "\" value=\"true\" id=\"" + documentId + " />"
|
370 |
|
|
+ "</h2>";
|
371 |
|
|
contentDiv.appendChild(rightDiv);
|
372 |
|
|
|
373 |
|
|
var titleDiv = document.createElement('div');
|
374 |
13396
|
katerina.i
|
titleDiv.innerHTML = "<h2><img src=\"static-content/images/icons/document_pdf.png\" alt=\"PDF\" width=\"25\" height=\"25\" align=\"absmiddle\" />"
|
375 |
13151
|
antonis.le
|
+ title + "</h2>";
|
376 |
|
|
|
377 |
|
|
var document_detailsDiv = document.createElement('div');
|
378 |
|
|
document_detailsDiv.setAttribute('class', "document_details");
|
379 |
|
|
|
380 |
|
|
for ( var key in summaryFields) {
|
381 |
|
|
var summaryFieldDiv = document.createElement('div');
|
382 |
|
|
summaryFieldDiv.setAttribute('class', "resultsField")
|
383 |
|
|
summaryFieldDiv.innerHTML = '<span class="resultsFieldNm">' + key + ': </span>' + summaryFields[key];
|
384 |
|
|
document_detailsDiv.appendChild(summaryFieldDiv);
|
385 |
|
|
}
|
386 |
|
|
|
387 |
|
|
var document_infoDiv = document.createElement('div');
|
388 |
|
|
document_infoDiv.setAttribute('class', "document_info");
|
389 |
|
|
|
390 |
|
|
var document_moreDiv = document.createElement('div');
|
391 |
|
|
document_moreDiv.setAttribute('class', "document_more");
|
392 |
|
|
document_moreDiv.innerHTML = "Show document details";
|
393 |
|
|
|
394 |
|
|
var document_fewerDiv = document.createElement('div');
|
395 |
|
|
document_fewerDiv.setAttribute('class', "document_fewer");
|
396 |
|
|
document_fewerDiv.innerHTML = "Hide document details";
|
397 |
|
|
document_infoDiv.appendChild(document_moreDiv);
|
398 |
|
|
document_infoDiv.appendChild(document_fewerDiv);
|
399 |
|
|
|
400 |
|
|
contentDiv.appendChild(titleDiv);
|
401 |
|
|
contentDiv.appendChild(document_detailsDiv);
|
402 |
|
|
contentDiv.appendChild(document_infoDiv);
|
403 |
|
|
|
404 |
|
|
mydriveritemDiv.appendChild(contentDiv);
|
405 |
|
|
documentDiv.appendChild(mydriveritemDiv);
|
406 |
|
|
documentListDiv.appendChild(documentDiv);
|
407 |
|
|
|
408 |
|
|
// implement the more/fewer options sliders on ALL dropbox items on
|
409 |
|
|
// the page
|
410 |
|
|
$$('.mydriveritem').each(
|
411 |
|
|
function(item) {
|
412 |
|
|
if (item.getElement('.document_details')) {
|
413 |
|
|
var document_details = new Fx.Slide(item
|
414 |
|
|
.getElement('.document_details')).hide();
|
415 |
|
|
item.getElement('.document_fewer').hide();
|
416 |
|
|
item.getElement('.document_more').addEvent('click',
|
417 |
|
|
function(e) {
|
418 |
|
|
e.stop();
|
419 |
|
|
document_details.slideIn();
|
420 |
|
|
});
|
421 |
|
|
item.getElement('.document_fewer').addEvent('click',
|
422 |
|
|
function(e) {
|
423 |
|
|
e.stop();
|
424 |
|
|
document_details.slideOut();
|
425 |
|
|
});
|
426 |
|
|
document_details.addEvent('complete', function() {
|
427 |
|
|
if (this.open) {
|
428 |
|
|
item.getElement('.document_more').hide();
|
429 |
|
|
item.getElement('.document_fewer').show();
|
430 |
|
|
} else {
|
431 |
|
|
item.getElement('.document_more').show();
|
432 |
|
|
item.getElement('.document_fewer').hide();
|
433 |
|
|
}
|
434 |
|
|
});
|
435 |
|
|
}
|
436 |
|
|
});
|
437 |
|
|
}
|