1 |
efrain |
1 |
YUI.add('tree-labelable', function (Y, NAME) {
|
|
|
2 |
|
|
|
3 |
/*jshint expr:true, onevar:false */
|
|
|
4 |
|
|
|
5 |
/**
|
|
|
6 |
Extension for `Tree` that adds baked-in support for node labels like you might
|
|
|
7 |
see in a treeview or menu.
|
|
|
8 |
|
|
|
9 |
@module tree
|
|
|
10 |
@submodule tree-labelable
|
|
|
11 |
@main tree-labelable
|
|
|
12 |
**/
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
Extension for `Tree` that adds baked-in support for node labels like you might
|
|
|
16 |
see in a treeview or menu.
|
|
|
17 |
|
|
|
18 |
@class Tree.Labelable
|
|
|
19 |
@constructor
|
|
|
20 |
@extensionfor Tree
|
|
|
21 |
**/
|
|
|
22 |
|
|
|
23 |
function Labelable() {}
|
|
|
24 |
|
|
|
25 |
Labelable.prototype = {
|
|
|
26 |
initializer: function () {
|
|
|
27 |
this.nodeExtensions = this.nodeExtensions.concat(Y.Tree.Node.Labelable);
|
|
|
28 |
}
|
|
|
29 |
};
|
|
|
30 |
|
|
|
31 |
Y.Tree.Labelable = Labelable;
|
|
|
32 |
/**
|
|
|
33 |
@module tree
|
|
|
34 |
@submodule tree-labelable
|
|
|
35 |
**/
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
`Tree.Node` extension that adds baked in support for labels like you might see
|
|
|
39 |
in a treeview or menu.
|
|
|
40 |
|
|
|
41 |
**Security note:** The label is stored in raw, unescaped form. If you choose to
|
|
|
42 |
render the label as HTML, be sure to escape it first with `Y.Escape.html()`
|
|
|
43 |
unless you actually intend to render raw HTML contained in the label.
|
|
|
44 |
|
|
|
45 |
@class Tree.Node.Labelable
|
|
|
46 |
@constructor
|
|
|
47 |
@param {Tree} tree `Tree` instance with which this node should be associated.
|
|
|
48 |
@param {Object} [config] Configuration hash.
|
|
|
49 |
@param {String} [config.label=''] Label for this node.
|
|
|
50 |
@extensionfor Tree.Node
|
|
|
51 |
**/
|
|
|
52 |
|
|
|
53 |
function NodeLabelable(tree, config) {
|
|
|
54 |
this._serializable = this._serializable.concat('label');
|
|
|
55 |
|
|
|
56 |
if ('label' in config) {
|
|
|
57 |
this.label = config.label;
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
NodeLabelable.prototype = {
|
|
|
62 |
/**
|
|
|
63 |
Label for this node.
|
|
|
64 |
|
|
|
65 |
**Security note:** The label is stored in raw, unescaped form. If you choose
|
|
|
66 |
to render the label as HTML, be sure to escape it first with
|
|
|
67 |
`Y.Escape.html()` unless you actually intend to render raw HTML contained in
|
|
|
68 |
the label.
|
|
|
69 |
|
|
|
70 |
@property {String} label
|
|
|
71 |
@default ''
|
|
|
72 |
**/
|
|
|
73 |
label: ''
|
|
|
74 |
};
|
|
|
75 |
|
|
|
76 |
Y.Tree.Node.Labelable = NodeLabelable;
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
}, '3.18.1', {"requires": ["tree"]});
|