aboutsummaryrefslogtreecommitdiff
path: root/js/panels/components-panel.reel/components-panel.js
diff options
context:
space:
mode:
authorJonathan Duran2012-06-26 13:28:59 -0700
committerJonathan Duran2012-06-26 13:28:59 -0700
commit42ea74de49cc9f06d8231b99c2ee6c65b0f8a61a (patch)
treead15f365ffae331ae76060a1ebdfc0f0f029725a /js/panels/components-panel.reel/components-panel.js
parentcdb5af99be5fca15265e4940dd22870f4c5fef4b (diff)
parent87a8b62f71bb72274c3dd1fa389e88c12d482ebb (diff)
downloadninja-42ea74de49cc9f06d8231b99c2ee6c65b0f8a61a.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Diffstat (limited to 'js/panels/components-panel.reel/components-panel.js')
-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