aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAnanya Sen2012-06-20 11:24:24 -0700
committerAnanya Sen2012-06-20 11:24:24 -0700
commitd852ea28dad399e84e8d5e69c0293500c30b59f1 (patch)
tree9b3a4bc0b0a12aec1cd33622e8373cbe00ae1c1a /js
parent7ebdf28143306c0e3eca08846114179f0e037c1e (diff)
downloadninja-d852ea28dad399e84e8d5e69c0293500c30b59f1.tar.gz
Notify for adding multiple elements together, to fix IKNINJA-1775 [Drawing a different type of object after performing copy-paste on an existing object throws error on console]
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js')
-rw-r--r--js/controllers/clipboard-controller.js26
1 files changed, 12 insertions, 14 deletions
diff --git a/js/controllers/clipboard-controller.js b/js/controllers/clipboard-controller.js
index 129e1f89..afa9cbdb 100644
--- a/js/controllers/clipboard-controller.js
+++ b/js/controllers/clipboard-controller.js
@@ -233,7 +233,6 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
233 if (copiedElement.tagName === "CANVAS"){ 233 if (copiedElement.tagName === "CANVAS"){
234 //clone copied canvas 234 //clone copied canvas
235 var canvas = this.cloneCanvas(copiedElement); 235 var canvas = this.cloneCanvas(copiedElement);
236 NJevent("elementAdded", canvas);
237 pastedElements.push(canvas); 236 pastedElements.push(canvas);
238 } 237 }
239 else { 238 else {
@@ -247,13 +246,13 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
247 }else{ 246 }else{
248 styles = null; 247 styles = null;
249 } 248 }
250 this.pastePositioned(node, styles, true/*notify*/); 249 this.pastePositioned(node, styles);
251 pastedElements.push(node); 250 pastedElements.push(node);
252 } 251 }
253 252
254 } 253 }
255 254
256 this.application.ninja.selectionController.selectElements(pastedElements); 255 NJevent("elementAdded", pastedElements);
257 256
258 this.application.ninja.currentDocument.model.needsSave = true; 257 this.application.ninja.currentDocument.model.needsSave = true;
259 } 258 }
@@ -272,7 +271,6 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
272 if (node.tagName === "CANVAS"){ 271 if (node.tagName === "CANVAS"){
273 //paste canvas 272 //paste canvas
274 canvas = this.generateNewCanvas(this.copiedObjects.cut[j].outerhtml, this.copiedObjects.cut[j].styles, this.copiedObjects.cut[j].className, this.copiedObjects.cut[j].worldJson); 273 canvas = this.generateNewCanvas(this.copiedObjects.cut[j].outerhtml, this.copiedObjects.cut[j].styles, this.copiedObjects.cut[j].className, this.copiedObjects.cut[j].worldJson);
275 NJevent("elementAdded", canvas);
276 pastedElements.push(canvas); 274 pastedElements.push(canvas);
277 node = null; 275 node = null;
278 } 276 }
@@ -281,12 +279,12 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
281 node = null; 279 node = null;
282 } 280 }
283 else { 281 else {
284 this.pastePositioned(node, this.copiedObjects.cut[j].styles, true/*notify*/, false/*fromCopy*/); 282 this.pastePositioned(node, this.copiedObjects.cut[j].styles, false/*fromCopy*/);
285 pastedElements.push(node); 283 pastedElements.push(node);
286 } 284 }
287 } 285 }
288 286
289 this.application.ninja.selectionController.selectElements(pastedElements); 287 NJevent("elementAdded", pastedElements);
290 this.application.ninja.currentDocument.model.needsSave = true; 288 this.application.ninja.currentDocument.model.needsSave = true;
291 } 289 }
292 }, 290 },
@@ -337,7 +335,7 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
337 divWrapper.appendChild(spanWrapper); 335 divWrapper.appendChild(spanWrapper);
338 styles = {"position":"absolute", "top":"100px", "left":"100px"}; 336 styles = {"position":"absolute", "top":"100px", "left":"100px"};
339 337
340 this.pastePositioned(divWrapper, styles, true/*notify*/); 338 this.pastePositioned(divWrapper, styles);
341 339
342 nodeList[i] = null; 340 nodeList[i] = null;
343 341
@@ -348,7 +346,7 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
348 divWrapper.appendChild(node); 346 divWrapper.appendChild(node);
349 styles = {"position":"absolute", "top":"100px", "left":"100px"}; 347 styles = {"position":"absolute", "top":"100px", "left":"100px"};
350 348
351 this.pastePositioned(divWrapper, styles, true/*notify*/); 349 this.pastePositioned(divWrapper, styles);
352 350
353 nodeList[i] = null; 351 nodeList[i] = null;
354 } 352 }
@@ -358,7 +356,7 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
358 //get class string while copying .... generate styles from class 356 //get class string while copying .... generate styles from class
359 styles = {"position":"absolute", "top":"100px", "left":"100px"}; 357 styles = {"position":"absolute", "top":"100px", "left":"100px"};
360 358
361 this.pastePositioned(node, styles, true/*notify*/); 359 this.pastePositioned(node, styles);
362 360
363 nodeList[i] = null; 361 nodeList[i] = null;
364 } 362 }
@@ -371,7 +369,7 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
371 }else if(textData){ 369 }else if(textData){
372 node = self.deserializeHtmlString("<div><span>"+ textData +"</span></div>")[0]; 370 node = self.deserializeHtmlString("<div><span>"+ textData +"</span></div>")[0];
373 styles = {"position":"absolute", "top":"100px", "left":"100px"}; 371 styles = {"position":"absolute", "top":"100px", "left":"100px"};
374 this.pastePositioned(node, styles, true/*notify*/); 372 this.pastePositioned(node, styles);
375 } 373 }
376 374
377 } 375 }
@@ -519,7 +517,7 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
519 517
520 if (!canvas.getAttribute( "data-RDGE-id" )) canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); 518 if (!canvas.getAttribute( "data-RDGE-id" )) canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() );
521 519
522 this.pastePositioned(canvas, styles, false/*notify*/, false/*from copy*/); 520 this.pastePositioned(canvas, styles, false/*from copy*/);
523 521
524 worldData = worldJson; 522 worldData = worldJson;
525 523
@@ -583,7 +581,7 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
583 581
584 582
585 pastePositioned:{ 583 pastePositioned:{
586 value: function(element, styles, notify, fromCopy){// for now can wok for both in-place and centered paste 584 value: function(element, styles, fromCopy){// for now can wok for both in-place and centered paste
587 var modObject = [], x,y, newX, newY, counter; 585 var modObject = [], x,y, newX, newY, counter;
588 586
589 if((typeof fromCopy === "undefined") || (fromCopy && fromCopy === true)){ 587 if((typeof fromCopy === "undefined") || (fromCopy && fromCopy === true)){
@@ -598,9 +596,9 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
598 newY = styles ? ("" + (styles.top + (25 * counter)) + "px") : "100px"; 596 newY = styles ? ("" + (styles.top + (25 * counter)) + "px") : "100px";
599 597
600 if(!styles || (styles && !styles.position)){ 598 if(!styles || (styles && !styles.position)){
601 this.application.ninja.elementMediator.addElements(element, null, notify); 599 this.application.ninja.elementMediator.addElements(element, null, false);
602 }else if(styles && (styles.position === "absolute")){ 600 }else if(styles && (styles.position === "absolute")){
603 this.application.ninja.elementMediator.addElements(element, {"top" : newY, "left" : newX}, notify);//displace 601 this.application.ninja.elementMediator.addElements(element, {"top" : newY, "left" : newX}, false);//displace
604 } 602 }
605 } 603 }
606 }, 604 },