diff options
author | Armen Kesablyan | 2012-06-05 12:55:10 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-05 12:55:10 -0700 |
commit | 9db979373f80162d463e23d400e97f37c75267d1 (patch) | |
tree | 3c33002b57e254cbeb2c581b7994d94384cbce40 /js/controllers/objects-controller.js | |
parent | cd5be45e6787929905daafbda79bdb258dca5473 (diff) | |
parent | 9274b3959384d21809c992f6f2e7860eb1682e06 (diff) | |
download | ninja-9db979373f80162d463e23d400e97f37c75267d1.tar.gz |
Merge pull request #9 from ericguzman/binding
Binding
Diffstat (limited to 'js/controllers/objects-controller.js')
-rw-r--r-- | js/controllers/objects-controller.js | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js index 2c9f2d66..32f24d5c 100644 --- a/js/controllers/objects-controller.js +++ b/js/controllers/objects-controller.js | |||
@@ -113,12 +113,38 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { | |||
113 | 113 | ||
114 | /* ---- Bindable Properties ---- */ | 114 | /* ---- Bindable Properties ---- */ |
115 | 115 | ||
116 | getEnumerableProperties : { | 116 | getPropertyList : { |
117 | value: function(object, excludeUnderscoreProperties) { | 117 | value: function(object, excludeUnderscoreProperties) { |
118 | var object_i = object, | ||
119 | prototypes = [object_i]; | ||
120 | |||
121 | ///// Collect prototypes | ||
122 | while(Object.getPrototypeOf(object_i)) { | ||
123 | object_i = Object.getPrototypeOf(object_i); | ||
124 | prototypes.push(object_i); | ||
125 | } | ||
126 | |||
127 | return prototypes.map(function(proto) { | ||
128 | var metadata = proto._montage_metadata, | ||
129 | objectName = (metadata) ? metadata.objectName : "Object"; | ||
130 | |||
131 | return { | ||
132 | category : objectName, | ||
133 | properties : this.getPropertiesFromObject(proto) | ||
134 | }; | ||
135 | }, this); | ||
136 | |||
137 | } | ||
138 | }, | ||
139 | |||
140 | getPropertiesFromObject : { | ||
141 | value: function (object, excludeUnderscoreProperties) { | ||
118 | var properties = []; | 142 | var properties = []; |
119 | 143 | ||
120 | for(var key in object) { | 144 | for(var key in object) { |
121 | properties.push(key); | 145 | if(object.hasOwnProperty(key)) { |
146 | properties.push(key); | ||
147 | } | ||
122 | } | 148 | } |
123 | 149 | ||
124 | if(excludeUnderscoreProperties) { | 150 | if(excludeUnderscoreProperties) { |
@@ -146,7 +172,12 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { | |||
146 | set: function(value) { | 172 | set: function(value) { |
147 | if(value === this._currentObject) { return; } | 173 | if(value === this._currentObject) { return; } |
148 | 174 | ||
149 | this.currentObjectBindings = this.getObjectBindings(value); | 175 | if(value) { |
176 | this.currentObjectBindings = this.getObjectBindings(value); | ||
177 | console.log("Property list", this.getPropertyList(value, true)); | ||
178 | } else { | ||
179 | this.currentObjectBindings = []; | ||
180 | } | ||
150 | 181 | ||
151 | this._currentObject = value; | 182 | this._currentObject = value; |
152 | } | 183 | } |