1322 |
alexandre_ |
1 |
var dojoConfig = {
|
|
|
2 |
isDebug: true
|
|
|
3 |
};
|
|
|
4 |
dojo.require("dojo.lang.*");
|
|
|
5 |
dojo.require("dojo.widget.*");
|
|
|
6 |
dojo.require("dojo.widget.Tree");
|
|
|
7 |
dojo.require("dojo.widget.TreeNode");
|
|
|
8 |
dojo.require("dojo.widget.TreeSelector");
|
|
|
9 |
dojo.require("dojo.widget.TreeLoadingController");
|
|
|
10 |
dojo.require("dojo.event.*");
|
|
|
11 |
dojo.require("dojo.io.*");
|
|
|
12 |
|
|
|
13 |
function treeSelectFired() {
|
|
|
14 |
|
|
|
15 |
// une reference vers treeSelector et vers le noeud selectionne
|
|
|
16 |
var treeSelector = dojo.widget.manager.getWidgetById('treeSelector');
|
|
|
17 |
var treeNode = treeSelector.selectedNode;
|
|
|
18 |
|
|
|
19 |
// le noeud est il un repertoire
|
|
|
20 |
var isFolder = treeNode['isFolder'];
|
|
|
21 |
|
|
|
22 |
// Si non on dirige vers le document
|
|
|
23 |
if ( !isFolder) {
|
|
|
24 |
var link = treeNode['link'];
|
1471 |
alexandre_ |
25 |
document.location.href= link;
|
|
|
26 |
} else {
|
|
|
27 |
var repertoire = dojo.widget.manager.getWidgetById('treeController');
|
|
|
28 |
repertoire.expand(treeNode);
|
1322 |
alexandre_ |
29 |
}
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
function init() {
|
|
|
33 |
// une reference vers treeSelector
|
|
|
34 |
var treeSelector = dojo.widget.manager.getWidgetById('treeSelector');
|
|
|
35 |
|
1471 |
alexandre_ |
36 |
// on connecte le select event a la fonction treeSelectFired()
|
1322 |
alexandre_ |
37 |
dojo.event.connect(treeSelector,'select','treeSelectFired');
|
|
|
38 |
|
1471 |
alexandre_ |
39 |
var rootNode = dojo.widget.manager.getWidgetById('rootNode');
|
|
|
40 |
var loadingController = dojo.widget.manager.getWidgetById('treeController');
|
|
|
41 |
|
|
|
42 |
// L appel ci-dessous permet de charger les donnees du noeud racine
|
|
|
43 |
loadingController.loadRemote(rootNode);
|
|
|
44 |
|
|
|
45 |
// On ouvre le noeud racine
|
|
|
46 |
rootNode.expand();
|
|
|
47 |
//ajout d'un listener a la suppression d'un noeud
|
1322 |
alexandre_ |
48 |
dojo.event.topic.subscribe("nodeRemoved", ioDeplaceFichier) ;
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
// envoie une requete asynchrone pour deplacer un fichier
|
|
|
52 |
|
|
|
53 |
function ioDeplaceFichier (message) {
|
|
|
54 |
var url = window.location.href ;
|
|
|
55 |
|
|
|
56 |
var arguments = {
|
|
|
57 |
url : url + "&service=serviceDeplacementFichier&enfant=" + message.child.objectId + "&parent=" + message.newParent.objectId,
|
|
|
58 |
mimetype: "text/json",
|
|
|
59 |
error : function (type, errObj) { alert ('erreur'); },
|
|
|
60 |
load : function (type, data, evt) {}
|
|
|
61 |
};
|
|
|
62 |
//var treeLoadingController = dojo.widget.manager.getWidgetById('treeController');
|
|
|
63 |
dojo.io.bind (arguments) ;
|
|
|
64 |
}
|
|
|
65 |
dojo.addOnLoad(init);
|