source:
trunk/workshop-routing-foss4g/web/GeoExt/lib/GeoExt/widgets/tree/TreeNodeUIEventMixin.js
@
76
Revision 76, 2.6 KB checked in by djay, 12 years ago (diff) | |
---|---|
|
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 | Ext.namespace("GeoExt.tree"); |
10 | |
11 | /** api: (define) |
12 | * module = GeoExt.tree |
13 | * class = TreeNodeUIEventMixin |
14 | */ |
15 | |
16 | /** api: constructor |
17 | * A mixin that adds events to TreeNodeUIs. With these events, tree plugins |
18 | * can modify the node ui's DOM when it is rendered, and react to raw click |
19 | * events on tree nodes. |
20 | */ |
21 | |
22 | /** api: example |
23 | * Sample code to create a tree with a node that uses the |
24 | * :class:`GeoExt.tree.TreeNodeUIEventMixin`: |
25 | * |
26 | * .. code-block:: javascript |
27 | * |
28 | * var UIClass = Ext.extend( |
29 | * Ext.tree.TreeNodeUI, |
30 | * GeoExt.tree.TreeNodeUIEventMixin |
31 | * ); |
32 | * var tree = new Ext.tree.TreePanel({ |
33 | * root: { |
34 | * nodeType: "node", |
35 | * uiProvider: UIClass, |
36 | * text: "My Node" |
37 | * } |
38 | * } |
39 | */ |
40 | |
41 | GeoExt.tree.TreeNodeUIEventMixin = function(){ |
42 | return { |
43 | |
44 | constructor: function(node) { |
45 | |
46 | node.addEvents( |
47 | |
48 | /** api: event[rendernode] |
49 | * Fires on the tree when a node is rendered. |
50 | * |
51 | * Listener arguments: |
52 | * |
53 | * * node - ``Ext.TreeNode`` The rendered node. |
54 | */ |
55 | "rendernode", |
56 | |
57 | /** api: event[rawclicknode] |
58 | * Fires on the tree when a node is clicked. |
59 | * |
60 | * Listener arguments: |
61 | * |
62 | * * node - ``Ext.TreeNode`` The clicked node. |
63 | * * event - ``Ext.EventObject`` The click event. |
64 | */ |
65 | "rawclicknode" |
66 | ); |
67 | this.superclass = arguments.callee.superclass; |
68 | this.superclass.constructor.apply(this, arguments); |
69 | |
70 | }, |
71 | |
72 | /** private: method[render] |
73 | * :param bulkRender: ``Boolean`` |
74 | */ |
75 | render: function(bulkRender) { |
76 | if(!this.rendered) { |
77 | this.superclass.render.apply(this, arguments); |
78 | this.fireEvent("rendernode", this.node); |
79 | } |
80 | }, |
81 | |
82 | /** private: method[onClick] |
83 | * :param e: ``Ext.EventObject`` |
84 | */ |
85 | onClick: function(e) { |
86 | if(this.fireEvent("rawclicknode", this.node, e) !== false) { |
87 | this.superclass.onClick.apply(this, arguments); |
88 | } |
89 | } |
90 | } |
91 | }; |
Note: See TracBrowser
for help on using the repository browser.