diff options
author | Valerio Virgillito | 2012-06-26 13:15:26 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-06-26 13:15:26 -0700 |
commit | 87a8b62f71bb72274c3dd1fa389e88c12d482ebb (patch) | |
tree | bf9f995e2972c0a61355f24e64231cdf0b2c86b5 /js/panels/components-panel.reel | |
parent | 8821e662484aedb027e26a873883e6ca3fb55a51 (diff) | |
parent | a95bba25c3ba6e31784a452e9b94748cc870ba5d (diff) | |
download | ninja-87a8b62f71bb72274c3dd1fa389e88c12d482ebb.tar.gz |
Merge pull request #323 from dhg637/binding
Binding View - Binding Tool & Binding Panel
Diffstat (limited to 'js/panels/components-panel.reel')
-rwxr-xr-x | js/panels/components-panel.reel/components-panel.js | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 46f91410..ab033433 100755 --- a/js/panels/components-panel.reel/components-panel.js +++ b/js/panels/components-panel.reel/components-panel.js | |||
@@ -267,9 +267,12 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
267 | } | 267 | } |
268 | that = this; | 268 | that = this; |
269 | element = this.makeComponent(component.component); | 269 | element = this.makeComponent(component.component); |
270 | 270 | this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, { | |
271 | this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, | 271 | identifier: this.CreateUniqueComponentName(component.name), |
272 | {name: component.name, path: component.module, firstDraw: {cb: this.componentInstanceOnFirstDraw, ctx: this}}, | 272 | name: component.name, |
273 | path: component.module, | ||
274 | firstDraw: {cb: this.componentInstanceOnFirstDraw, ctx: this} | ||
275 | }, | ||
273 | function(instance, element) { | 276 | function(instance, element) { |
274 | 277 | ||
275 | //var pos = that.getStageCenter(); | 278 | //var pos = that.getStageCenter(); |
@@ -289,7 +292,8 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
289 | 292 | ||
290 | //that.application.ninja.elementMediator.addElements(element, styles); | 293 | //that.application.ninja.elementMediator.addElements(element, styles); |
291 | ElementController.addElement(element, styles); | 294 | ElementController.addElement(element, styles); |
292 | }); | 295 | } |
296 | ); | ||
293 | 297 | ||
294 | } | 298 | } |
295 | }, | 299 | }, |
@@ -297,6 +301,7 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
297 | componentInstanceOnFirstDraw: { | 301 | componentInstanceOnFirstDraw: { |
298 | value: function(instance) { | 302 | value: function(instance) { |
299 | this.application.ninja.elementMediator.addElements(instance.element); | 303 | this.application.ninja.elementMediator.addElements(instance.element); |
304 | this.application.ninja.currentDocument.model.mObjects.push(instance); | ||
300 | } | 305 | } |
301 | }, | 306 | }, |
302 | 307 | ||
@@ -387,5 +392,28 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
387 | 392 | ||
388 | //return this.centerStage; | 393 | //return this.centerStage; |
389 | } | 394 | } |
395 | }, | ||
396 | |||
397 | CreateUniqueComponentName: { | ||
398 | value: function(name) { | ||
399 | for(var i=1; i < 1000; i++) { | ||
400 | if(!this.ComponentNameExists(name + i)) { | ||
401 | return name + i; | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | }, | ||
406 | |||
407 | ComponentNameExists: { | ||
408 | value: function(name) { | ||
409 | var filteredList = this.application.ninja.currentDocument.model.mObjects.filter(function(obj){ | ||
410 | if(name === obj.identifier) return true; | ||
411 | }); | ||
412 | if (filteredList.length > 0) { | ||
413 | return true; | ||
414 | } else { | ||
415 | return false; | ||
416 | } | ||
417 | } | ||
390 | } | 418 | } |
391 | }); \ No newline at end of file | 419 | }); \ No newline at end of file |