From 3ceb1282fa317023706e001bb4ec5ac61e40590f Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 12 Jun 2012 12:58:50 -0700 Subject: Components - Add object instance to model's objects array --- js/panels/components-panel.reel/components-panel.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/panels/components-panel.reel/components-panel.js') diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index e6b7a6e3..c8e5ac9a 100755 --- a/js/panels/components-panel.reel/components-panel.js +++ b/js/panels/components-panel.reel/components-panel.js @@ -302,6 +302,7 @@ exports.ComponentsPanel = Montage.create(Component, { componentInstanceOnFirstDraw: { value: function(instance) { this.application.ninja.elementMediator.addElements(instance.element); + this.application.ninja.currentDocument.model.mObjects.push(instance); } }, -- cgit v1.2.3 From b73e0aa2cffa3ffd2b574645f6ec88dc34726caa Mon Sep 17 00:00:00 2001 From: Armen Kesablyan Date: Mon, 25 Jun 2012 14:05:38 -0700 Subject: Can bind Multiple instance Signed-off-by: Armen Kesablyan --- .../components-panel.reel/components-panel.js | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'js/panels/components-panel.reel/components-panel.js') 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, { } that = this; element = this.makeComponent(component.component); - - this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, - {name: component.name, path: component.module, firstDraw: {cb: this.componentInstanceOnFirstDraw, ctx: this}}, + this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, { + identifier: this.CreateUniqueComponentName(component.name), + name: component.name, + path: component.module, + firstDraw: {cb: this.componentInstanceOnFirstDraw, ctx: this} + }, function(instance, element) { //var pos = that.getStageCenter(); @@ -289,7 +292,8 @@ exports.ComponentsPanel = Montage.create(Component, { //that.application.ninja.elementMediator.addElements(element, styles); ElementController.addElement(element, styles); - }); + } + ); } }, @@ -388,5 +392,28 @@ exports.ComponentsPanel = Montage.create(Component, { //return this.centerStage; } + }, + + CreateUniqueComponentName: { + value: function(name) { + for(var i=1; i < 1000; i++) { + if(!this.ComponentNameExists(name + i)) { + return name + i; + } + } + } + }, + + ComponentNameExists: { + value: function(name) { + var filteredList = this.application.ninja.currentDocument.model.mObjects.filter(function(obj){ + if(name === obj.identifier) return true; + }); + if (filteredList.length > 0) { + return true; + } else { + return false; + } + } } }); \ No newline at end of file -- cgit v1.2.3