From 5a34cac9594d710f6e5675bee34dc16be1b4d8a0 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 16 Jul 2012 15:34:07 -0700 Subject: Fixed copy paste from external applications Signed-off-by: Ananya Sen --- .../internal-ops/elements-clipboard-agent.js | 24 ++++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'js/clipboard/internal-ops') diff --git a/js/clipboard/internal-ops/elements-clipboard-agent.js b/js/clipboard/internal-ops/elements-clipboard-agent.js index a6bce2ba..cfc75916 100644 --- a/js/clipboard/internal-ops/elements-clipboard-agent.js +++ b/js/clipboard/internal-ops/elements-clipboard-agent.js @@ -152,8 +152,6 @@ var ElementsClipboardAgent = exports.ElementsClipboardAgent = Montage.create(Com this.pasteCounter++; - //cleanse HTML - for(j=0; j< this.copiedObjects.copy.length; j++){ copiedElement = this.copiedObjects.copy[j]; styles = null; @@ -259,16 +257,13 @@ var ElementsClipboardAgent = exports.ElementsClipboardAgent = Montage.create(Com if(sourceCanvas.ownerDocument.defaultView.getComputedStyle(sourceCanvas).getPropertyValue("position") === "absolute"){ styles = canvas.elementModel.data || {}; - styles.top = "" + (this.application.ninja.elementMediator.getProperty(sourceCanvas, "top", parseInt) + (25 * this.pasteCounter))+"px"; - styles.left = "" + (this.application.ninja.elementMediator.getProperty(sourceCanvas, "left", parseInt) + (25 * this.pasteCounter)) + "px"; + styles.top = "" + (this.application.ninja.elementMediator.getProperty(sourceCanvas, "top", parseInt) + (10 * this.pasteCounter))+"px"; + styles.left = "" + (this.application.ninja.elementMediator.getProperty(sourceCanvas, "left", parseInt) + (10 * this.pasteCounter)) + "px"; }else{ styles = null; } - var addDelegate = this.application.ninja.elementMediator.addDelegate; - this.application.ninja.elementMediator.addDelegate = null; - this.application.ninja.elementMediator.addElements(canvas, styles, false); - this.application.ninja.elementMediator.addDelegate = addDelegate; + this.application.ninja.elementMediator.addElements(canvas, styles, false/*notify*/, false /*callAddDelegate*/); worldData = sourceCanvas.elementModel.shapeModel ? sourceCanvas.elementModel.shapeModel.GLWorld.exportJSON(): null; if(worldData) @@ -360,13 +355,11 @@ var ElementsClipboardAgent = exports.ElementsClipboardAgent = Montage.create(Com x = styles ? ("" + styles.left + "px") : "100px"; y = styles ? ("" + styles.top + "px") : "100px"; - newX = styles ? ("" + (styles.left + (25 * counter)) + "px") : "100px"; - newY = styles ? ("" + (styles.top + (25 * counter)) + "px") : "100px"; - - var addDelegate = this.application.ninja.elementMediator.addDelegate; - this.application.ninja.elementMediator.addDelegate = null; + newX = styles ? ("" + (styles.left + (10 * counter)) + "px") : "100px"; + newY = styles ? ("" + (styles.top + (10 * counter)) + "px") : "100px"; + if(!styles || (styles && !styles.position)){ - this.application.ninja.elementMediator.addElements(element, null, false); + this.application.ninja.elementMediator.addElements(element, null, false /*notify*/, false /*callAddDelegate*/); }else if(styles && (styles.position === "absolute")){ if((element.tagName === "IMG") || (element.getAttribute("type") === "image/svg+xml")){ element.onload = function(){ @@ -376,9 +369,8 @@ var ElementsClipboardAgent = exports.ElementsClipboardAgent = Montage.create(Com } } - this.application.ninja.elementMediator.addElements(element, {"top" : newY, "left" : newX}, false);//displace + this.application.ninja.elementMediator.addElements(element, {"top" : newY, "left" : newX}, false/*notify*/, false /*callAddDelegate*/);//displace } - this.application.ninja.elementMediator.addDelegate = addDelegate; } }, -- cgit v1.2.3