diff options
author | Armen Kesablyan | 2012-02-07 16:51:14 -0800 |
---|---|---|
committer | Armen Kesablyan | 2012-02-07 16:51:14 -0800 |
commit | 8110e01dc5093ac6baf621103dcaa5f769e5be92 (patch) | |
tree | ecf339e3097b6ba25d81cbe44d913ee67591bf4b /js/components/treeview/tree-node.js | |
parent | 5f506542d28e12b707c3bfa41b53383519838477 (diff) | |
parent | 668510892537eaaeb2e11520831d87b44b2489b7 (diff) | |
download | ninja-8110e01dc5093ac6baf621103dcaa5f769e5be92.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'js/components/treeview/tree-node.js')
-rw-r--r-- | js/components/treeview/tree-node.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/js/components/treeview/tree-node.js b/js/components/treeview/tree-node.js new file mode 100644 index 00000000..689fc233 --- /dev/null +++ b/js/components/treeview/tree-node.js | |||
@@ -0,0 +1,103 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.TreeNode = Montage.create(Component, { | ||
11 | _labelText: { | ||
12 | value: "Default" | ||
13 | }, | ||
14 | labelText : { | ||
15 | get: function() { return this._labelText; }, | ||
16 | set: function(text) { | ||
17 | this._labelText = text; | ||
18 | } | ||
19 | }, | ||
20 | treeView : { | ||
21 | value: null, | ||
22 | serializable: true | ||
23 | }, | ||
24 | leafComponent: { | ||
25 | value: null, | ||
26 | serializable: true | ||
27 | }, | ||
28 | branchKey : { | ||
29 | serializable: true, | ||
30 | value: null | ||
31 | }, | ||
32 | labelKey : { | ||
33 | serializable: true, | ||
34 | value: null | ||
35 | }, | ||
36 | _sourceObject : { | ||
37 | value : null | ||
38 | }, | ||
39 | sourceObject : { | ||
40 | get : function() { | ||
41 | return this._sourceObject; | ||
42 | }, | ||
43 | set : function(object) { | ||
44 | if(!object) { | ||
45 | return; | ||
46 | } | ||
47 | if(object[this.branchKey]) { | ||
48 | object[this.branchKey].forEach(function(node) { | ||
49 | this.childNodes.push(node); | ||
50 | }, this); | ||
51 | } | ||
52 | this._sourceObject = object; | ||
53 | } | ||
54 | }, | ||
55 | childNodes : { | ||
56 | distinct: true, | ||
57 | value: [] | ||
58 | }, | ||
59 | isExpanded : { | ||
60 | distinct: true, | ||
61 | value: true | ||
62 | }, | ||
63 | _needsToggle : { | ||
64 | value: null | ||
65 | }, | ||
66 | activationEvent : { | ||
67 | value: null | ||
68 | }, | ||
69 | toggleExpand : { | ||
70 | value: function() { | ||
71 | if(this.isExpanded) { | ||
72 | this.collapse(); | ||
73 | this.isExpanded = false; | ||
74 | } else { | ||
75 | this.expand(); | ||
76 | this.isExpanded = true; | ||
77 | } | ||
78 | } | ||
79 | }, | ||
80 | expand : { | ||
81 | value: function() { | ||
82 | if(this.collapseClass) { | ||
83 | this.branchList.classList.remove(this.collapseClass); | ||
84 | } else { | ||
85 | this.branchList.style.display = "block"; | ||
86 | } | ||
87 | |||
88 | } | ||
89 | }, | ||
90 | collapse : { | ||
91 | value: function() { | ||
92 | if(this.collapseClass) { | ||
93 | this.branchList.classList.add(this.collapseClass); | ||
94 | } else { | ||
95 | this.branchList.style.display = "none"; | ||
96 | } | ||
97 | |||
98 | } | ||
99 | } | ||
100 | |||
101 | |||
102 | |||
103 | }); | ||