diff options
author | Armen Kesablyan | 2012-06-13 11:37:11 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-13 11:37:11 -0700 |
commit | d2e2a39feeba51e976d139eddf6f1cf331457f4f (patch) | |
tree | 7616fb59b5210d0d0128f1fd5dde34a43eb13f11 /js/controllers | |
parent | cfa2d42f6ca65eb3ce1bea92db5f4af87dd68bb5 (diff) | |
parent | d57ab6509805ba4e97d6c74be913a2c1b324af3a (diff) | |
download | ninja-d2e2a39feeba51e976d139eddf6f1cf331457f4f.tar.gz |
Merge pull request #12 from ericguzman/binding
Binding Panel update
Diffstat (limited to 'js/controllers')
-rw-r--r-- | js/controllers/objects-controller.js | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js index fd9b12f4..386ef683 100644 --- a/js/controllers/objects-controller.js +++ b/js/controllers/objects-controller.js | |||
@@ -7,6 +7,10 @@ | |||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | var CATEGORIES = { | ||
11 | |||
12 | }; | ||
13 | |||
10 | var objectsController = exports.ObjectsController = Montage.create(Component, { | 14 | var objectsController = exports.ObjectsController = Montage.create(Component, { |
11 | 15 | ||
12 | _currentDocument : { | 16 | _currentDocument : { |
@@ -62,6 +66,7 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { | |||
62 | if(!bindingArgs.sourceObject || !bindingArgs.sourceObjectPropertyPath || !bindingArgs) { return; } | 66 | if(!bindingArgs.sourceObject || !bindingArgs.sourceObjectPropertyPath || !bindingArgs) { return; } |
63 | 67 | ||
64 | Object.defineBinding(bindingArgs.sourceObject, bindingArgs.sourceObjectPropertyPath, bindingArgs); | 68 | Object.defineBinding(bindingArgs.sourceObject, bindingArgs.sourceObjectPropertyPath, bindingArgs); |
69 | this.currentObjectBindings = this.getObjectBindings(value); | ||
65 | } | 70 | } |
66 | }, | 71 | }, |
67 | 72 | ||
@@ -72,6 +77,7 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { | |||
72 | 77 | ||
73 | 78 | ||
74 | Object.deleteBinding(bindingArgs.sourceObject, bindingArgs.sourceObjectPropertyPath); | 79 | Object.deleteBinding(bindingArgs.sourceObject, bindingArgs.sourceObjectPropertyPath); |
80 | this.currentObjectBindings = this.getObjectBindings(value); | ||
75 | } | 81 | } |
76 | }, | 82 | }, |
77 | 83 | ||
@@ -88,6 +94,7 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { | |||
88 | } | 94 | } |
89 | 95 | ||
90 | this.addBinding(bindingArgs); | 96 | this.addBinding(bindingArgs); |
97 | |||
91 | } | 98 | } |
92 | }, | 99 | }, |
93 | 100 | ||
@@ -119,20 +126,11 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { | |||
119 | } | 126 | } |
120 | }, | 127 | }, |
121 | 128 | ||
122 | /* ---- Bindable Properties ---- */ | 129 | /* ---- Get Bindable Properties ---- */ |
123 | 130 | ||
124 | getPropertyList : { | 131 | getPropertyList : { |
125 | value: function(object, excludeUnderscoreProperties) { | 132 | value: function(object, excludeUnderscoreProperties) { |
126 | var object_i = object, | 133 | return this.getPrototypes(object).map(function(proto) { |
127 | prototypes = [object_i]; | ||
128 | |||
129 | ///// Collect prototypes | ||
130 | while(Object.getPrototypeOf(object_i)) { | ||
131 | object_i = Object.getPrototypeOf(object_i); | ||
132 | prototypes.push(object_i); | ||
133 | } | ||
134 | |||
135 | return prototypes.map(function(proto) { | ||
136 | 134 | ||
137 | var metadata = proto._montage_metadata, | 135 | var metadata = proto._montage_metadata, |
138 | objectName = (metadata) ? metadata.objectName : "Object"; | 136 | objectName = (metadata) ? metadata.objectName : "Object"; |
@@ -166,6 +164,44 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { | |||
166 | } | 164 | } |
167 | }, | 165 | }, |
168 | 166 | ||
167 | getPrototypes : { | ||
168 | value: function(object) { | ||
169 | var object_i = object, | ||
170 | prototypes = [object_i]; | ||
171 | |||
172 | ///// Collect prototypes | ||
173 | while(Object.getPrototypeOf(object_i)) { | ||
174 | object_i = Object.getPrototypeOf(object_i); | ||
175 | prototypes.push(object_i); | ||
176 | } | ||
177 | |||
178 | return prototypes; | ||
179 | } | ||
180 | }, | ||
181 | |||
182 | /* ----- Category properties ----- */ | ||
183 | |||
184 | getObjectCategory : { | ||
185 | value: function(object) { | ||
186 | if(this._hasPrototype(object, 'Component')) { | ||
187 | return 'Component'; | ||
188 | } | ||
189 | |||
190 | return null; | ||
191 | } | ||
192 | }, | ||
193 | |||
194 | _hasPrototype : { | ||
195 | value: function(object, prototypeName) { | ||
196 | var prototypes = this.getPrototypes(object).map(function(proto) { | ||
197 | var metadata = proto._montage_metadata; | ||
198 | return (metadata) ? metadata.objectName : "Object"; | ||
199 | }); | ||
200 | |||
201 | return prototypes.indexOf(prototypeName) !== -1; | ||
202 | } | ||
203 | }, | ||
204 | |||
169 | /* ---- Bindable controller properties ---- */ | 205 | /* ---- Bindable controller properties ---- */ |
170 | 206 | ||
171 | currentObjectBindings : { | 207 | currentObjectBindings : { |