aboutsummaryrefslogtreecommitdiff
path: root/js/components/treeview/tree-node.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-06 14:09:29 -0800
committerValerio Virgillito2012-02-06 14:09:29 -0800
commit07e5839e0ec6da2eb71056ff18b90226af213eef (patch)
treebfc93091f03f2c2383ccfe3ec73dd85bf0a0ccf3 /js/components/treeview/tree-node.js
parent671a27069db6a121507c2b342653aede685cff67 (diff)
parentc83b0d9bf3f37ae8569e8afc51dbcba9ed003929 (diff)
downloadninja-07e5839e0ec6da2eb71056ff18b90226af213eef.tar.gz
Merge pull request #16 from ericguzman/TreeComponents
Tree components
Diffstat (limited to 'js/components/treeview/tree-node.js')
-rw-r--r--js/components/treeview/tree-node.js103
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>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component;
9
10exports.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});