diff options
Diffstat (limited to 'js/controllers')
-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 | } |