Project

General

Profile

Revision 7b885e22

ID7b885e2211d160857f1e3fe438a874059575c07e
Parent 2dbc5942
Child 268f526d

Added by Francois POIROTTE about 14 years ago

Fichier manquant lors du précédent commit.

git-svn-id: https://vigilo-dev.si.c-s.fr/svn@3601 b22e2e97-25c9-44ff-b637-2e5ceca36478

View differences:

vigiboard/public/js/tree.js
1
/**
2
 * VigiBoard, composant de Vigilo.
3
 * (c) CSSI 2009-2010 <contact@projet-vigilo.org>
4
 * Licence : GNU GPL v2 ou superieure
5
 * 
6
 */
7

  
8
/*
9
 * Affichage en arbre des groupes.
10
 */
11
var TreeGroup = new Class({
12
    Implements: [Options, Events],
13

  
14
    initialize: function(options) {
15
        this.setOptions(options);
16

  
17
        /* L'objet tree se réfère à un élément div*/
18
        var container = new Element('div')
19
        this.tree = new Jx.Tree({parent: container});
20

  
21
        this.dlg = new Jx.Dialog({
22
            label: this.options.title,
23
            modal: true,
24
            content: container,
25
        });
26

  
27
        var req = new Request.JSON({
28
            method: "get",
29
            url: this.options.url,
30
            onSuccess: function(groups) {
31
                groups = new Hash(groups.groups);
32
                $each(groups, function(item, key) {
33
                    this.addItem(key, item, this.tree);
34
                }, this);
35
            }.bind(this)
36
        });
37
        req.send();
38
    },
39

  
40
    /* Ajout d'un element à l'arbre */
41
    addItem: function(idgroup, data, parent) {
42
        var subfolder;
43
        var children = new Hash(data.children);
44
        if (children.getLength()) {
45
            subfolder = new Jx.TreeFolder({
46
                label: data.name,
47
                data: idgroup,
48
                image: this.options.app_path+"images/map-list.png",
49
            });
50
        }
51
        else {
52
            subfolder = new Jx.TreeItem({
53
                label: data.name,
54
                data: idgroup,
55
                image: this.options.app_path+"images/map.png",
56
            });
57
        }
58

  
59
        subfolder.addEvent("click", function() {
60
            this.fireEvent('select', [subfolder]);
61
            this.dlg.close();
62
            return false;
63
        }.bind(this));
64
        parent.append(subfolder);
65

  
66
        $each(children, function(item, key) {
67
            this.addItem(key, item, subfolder);
68
        }, this);
69
    },
70

  
71
    selectGroup: function() {
72
        this.dlg.open();
73
    }
74
});
75

  

Also available in: Unified diff