diff options
author | Armen Kesablyan | 2012-06-25 14:05:38 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-25 14:05:38 -0700 |
commit | b73e0aa2cffa3ffd2b574645f6ec88dc34726caa (patch) | |
tree | 7b84872cf02096ee46e5a8537cd2299bf2d5f046 /js/panels/components-panel.reel | |
parent | 446f475c35e3d0d5d6cb6ca35346e548de6c36f9 (diff) | |
download | ninja-b73e0aa2cffa3ffd2b574645f6ec88dc34726caa.tar.gz |
Can bind Multiple instance
Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/panels/components-panel.reel')
-rwxr-xr-x | js/panels/components-panel.reel/components-panel.js | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index a57c9efc..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 | }, |
@@ -388,5 +392,28 @@ exports.ComponentsPanel = Montage.create(Component, { | |||
388 | 392 | ||
389 | //return this.centerStage; | 393 | //return this.centerStage; |
390 | } | 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 | } | ||
391 | } | 418 | } |
392 | }); \ No newline at end of file | 419 | }); \ No newline at end of file |