aboutsummaryrefslogtreecommitdiff
path: root/js/panels/components-panel.reel
diff options
context:
space:
mode:
authorKruti Shah2012-06-27 09:25:42 -0700
committerKruti Shah2012-06-27 09:25:42 -0700
commitd6bffa2450f68bdf9bfff0f4e155778f59f3624a (patch)
treec37300f67a3fb502d7f4e277600944739d48fd82 /js/panels/components-panel.reel
parentb52747edbeba7d210fca98acccb2d2df52134bca (diff)
parent46174eb0ce93d660c8d2e9276fbdc4f9a03f056a (diff)
downloadninja-d6bffa2450f68bdf9bfff0f4e155778f59f3624a.tar.gz
Merge branch 'refs/heads/ninjainternalmaster' into Timeline-local-kruti
Diffstat (limited to 'js/panels/components-panel.reel')
-rwxr-xr-xjs/panels/components-panel.reel/components-panel.js36
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