Bienvenue sur PostGIS.fr

Bienvenue sur PostGIS.fr , le site de la communauté des utilisateurs francophones de PostGIS.

PostGIS ajoute le support d'objets géographique à la base de données PostgreSQL. En effet, PostGIS "spatialise" le serverur PostgreSQL, ce qui permet de l'utiliser comme une base de données SIG.

Maintenu à jour, en fonction de nos disponibilités et des diverses sorties des outils que nous testons, nous vous proposons l'ensemble de nos travaux publiés en langue française.

source: trunk/workshop-routing-foss4g/web/GeoExt/lib/GeoExt/plugins/TreeNodeRadioButton.js @ 76

Revision 76, 4.0 KB checked in by djay, 12 years ago (diff)

Ajout du répertoire web

  • Property svn:executable set to *
Line 
1/**
2 * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
3 *
4 * Published under the BSD license.
5 * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
6 * of the license.
7 */
8
9 /**
10  * @include GeoExt/widgets/tree/TreeNodeUIEventMixin.js
11  */
12Ext.namespace("GeoExt.plugins");
13
14/** api: (define)
15 *  module = GeoExt.plugins
16 *  class = TreeNodeRadioButton
17 */
18
19/** api: constructor
20 *  A plugin to create tree node UIs with radio buttons. Can be plugged into
21 *  any ``Ext.tree.TreePanel`` and will be applied to nodes that are extended
22 *  with the :class:`GeoExt.Tree.TreeNodeUIEventMixin`, in particular
23 *  :class:`GeoExt.tree.LayerNodeUI` nodes.
24 *
25 *  A tree with a ``GeoExt.plugins.TreeNodeRadioButton`` fires the additional
26 *  ``radiochange`` event when a node's radio button is clicked.
27 *
28 *  Only if a node is configured ``radioGroup`` attribute, it will be rendered
29 *  with a radio button next to its icon. The ``radioGroup`` works like a
30 *  HTML checkbox with its ``name`` attribute, and ``radioGroup`` is a string
31 *  that identifies the options group.
32 *
33 */
34
35/** api: example
36 *  Sample code to create a tree with a node that has a radio button:
37 *
38 *  .. code-block:: javascript
39 *
40 *      var UIClass = Ext.extend(
41 *          Ext.tree.TreeNodeUI,
42 *          GeoExt.tree.TreeNodeUIEventMixin
43 *      );
44 *      var tree = new Ext.tree.TreePanel({
45 *          plugins: [
46 *              new GeoExt.plugins.TreeNodeRadioButton({
47 *                  listeners: {
48 *                      "radiochange": function(node) {
49 *                          alert(node.text + "'s radio button was clicked.");
50 *                      }
51 *                  }
52 *              })
53 *          ],
54 *          root: {
55 *              nodeType: "node",
56 *              uiProvider: UIClass,
57 *              text: "My Node",
58 *              radioGroup: "myGroupId"
59 *          }
60 *      }
61 */
62
63GeoExt.plugins.TreeNodeRadioButton = Ext.extend(Ext.util.Observable, {
64   
65    /** private: method[constructor]
66     *  :param config: ``Object``
67     */
68    constructor: function(config) {
69        Ext.apply(this.initialConfig, Ext.apply({}, config));
70        Ext.apply(this, config);
71
72        this.addEvents(
73
74            /** api: event[radiochange]
75             *  Fires when a radio button is clicked.
76             *
77             *  Listener arguments:
78             * 
79             *  * node - ``Ext.TreeNode`` The node of the clicked radio button.
80             */
81            "radiochange"
82        );
83
84        GeoExt.plugins.TreeNodeRadioButton.superclass.constructor.apply(this, arguments);
85    },
86
87    /** private: method[init]
88     *  :param tree: ``Ext.tree.TreePanel`` The tree.
89     */
90    init: function(tree) {
91        tree.on({
92            "rendernode": this.onRenderNode,
93            "rawclicknode": this.onRawClickNode,
94            "beforedestroy": this.onBeforeDestroy,
95            scope: this
96        });
97    },
98   
99    /** private: method[onRenderNode]
100     *  :param node: ``Ext.tree.TreeNode``
101     */
102    onRenderNode: function(node) {
103        var a = node.attributes;
104        if(a.radioGroup && !a.radio) {
105            a.radio = Ext.DomHelper.insertBefore(node.ui.anchor,
106                ['<input type="radio" class="gx-tree-radio" name="',
107                a.radioGroup, '_radio"></input>'].join(""));
108        }
109    },
110   
111    /** private: method[onRawClickNode]
112     *  :param node: ``Ext.tree.TreeNode``
113     *  :param e: ``Ext.EventObject``
114     */
115    onRawClickNode: function(node, e) {
116        var el = e.getTarget('.gx-tree-radio', 1); 
117        if(el) {
118            el.defaultChecked = el.checked;
119            this.fireEvent("radiochange", node);
120            return false;
121        }
122    },
123   
124    /** private: method[onBeforeDestroy]
125     */
126    onBeforeDestroy: function(tree) {
127        tree.un("rendernode", this.onRenderNode, this);
128        tree.un("rawclicknode", this.onRenderNode, this);
129        tree.un("beforedestroy", this.onBeforeDestroy, this);
130    }
131
132});
133
134/** api: ptype = gx_treenoderadiobutton */
135Ext.preg("gx_treenoderadiobutton", GeoExt.plugins.TreeNodeRadioButton);
Note: See TracBrowser for help on using the repository browser.