aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/clipboard-controller.js55
1 files changed, 32 insertions, 23 deletions
diff --git a/js/controllers/clipboard-controller.js b/js/controllers/clipboard-controller.js
index e7b772d4..57ee5c64 100644
--- a/js/controllers/clipboard-controller.js
+++ b/js/controllers/clipboard-controller.js
@@ -76,7 +76,11 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
76 76
77 handleCopy:{ 77 handleCopy:{
78 value:function(clipboardEvent){ 78 value:function(clipboardEvent){
79 if(this.application.ninja.currentDocument.currentView === "code") return; 79 if(!this.application.ninja.currentDocument
80 || (this.application.ninja.currentDocument && this.application.ninja.currentDocument.currentView === "code")){
81
82 return;
83 }//for design view only
80 84
81 this.copy(clipboardEvent); 85 this.copy(clipboardEvent);
82 86
@@ -96,7 +100,11 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
96 100
97 handlePaste:{ 101 handlePaste:{
98 value:function(clipboardEvent){ 102 value:function(clipboardEvent){
99 if(this.application.ninja.currentDocument.currentView === "code") return;//for design view only 103 if(!this.application.ninja.currentDocument
104 || (this.application.ninja.currentDocument && this.application.ninja.currentDocument.currentView === "code")){
105
106 return;
107 }//for design view only
100 108
101 //TODO: return if stage is not focussed 109 //TODO: return if stage is not focussed
102 110
@@ -173,11 +181,6 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
173 181
174 //TODO: cleanse HTML 182 //TODO: cleanse HTML
175 183
176 //clear previous selections
177 this.application.ninja.selectedElements.length = 0;
178 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": true} );
179
180
181 for(j=0; j< this.copiedObjects.copy.length; j++){ 184 for(j=0; j< this.copiedObjects.copy.length; j++){
182 copiedElement = this.copiedObjects.copy[j]; 185 copiedElement = this.copiedObjects.copy[j];
183 styles = null; 186 styles = null;
@@ -280,16 +283,9 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
280 //can't paste external canvas for lack of all metadata 283 //can't paste external canvas for lack of all metadata
281 clipboardHelper.removeChild(clipboardHelper.lastChild); 284 clipboardHelper.removeChild(clipboardHelper.lastChild);
282 } 285 }
283 else if((clipboardHelper.lastChild.nodeType === 3) || (clipboardHelper.lastChild.tagName === "A")){//TextNode 286 else if((clipboardHelper.lastChild.nodeType === 3) || (clipboardHelper.lastChild.tagName === "A")){
284 node = clipboardHelper.removeChild(clipboardHelper.lastChild); 287 node = clipboardHelper.removeChild(clipboardHelper.lastChild);
285 288
286 //todo : not working - USE styles controller to create the styles of the div and span
287// var doc = this.application.ninja.currentDocument ? this.application.ninja.currentDocument._document : document;
288// var aspan = doc.createElement("span");
289// aspan.appendChild(node);
290// var adiv = doc.createElement("div");
291// adiv.appendChild(aspan);
292
293 divWrapper = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); 289 divWrapper = document.application.njUtils.make("div", null, this.application.ninja.currentDocument);
294 spanWrapper = document.application.njUtils.make("span", null, this.application.ninja.currentDocument); 290 spanWrapper = document.application.njUtils.make("span", null, this.application.ninja.currentDocument);
295 spanWrapper.appendChild(node); 291 spanWrapper.appendChild(node);
@@ -298,6 +294,15 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
298 //end - todo : not working 294 //end - todo : not working
299 295
300 this.pastePositioned(divWrapper, styles); 296 this.pastePositioned(divWrapper, styles);
297 }else if(clipboardHelper.lastChild.tagName === "SPAN"){
298 node = clipboardHelper.removeChild(clipboardHelper.lastChild);
299
300 divWrapper = document.application.njUtils.make("div", null, this.application.ninja.currentDocument);
301 divWrapper.appendChild(node);
302 styles = null;
303 //end - todo : not working
304
305 this.pastePositioned(divWrapper, styles);
301 } 306 }
302 else { 307 else {
303 node = clipboardHelper.removeChild(clipboardHelper.lastChild); 308 node = clipboardHelper.removeChild(clipboardHelper.lastChild);
@@ -536,16 +541,20 @@ var ClipboardController = exports.ClipboardController = Montage.create(Component
536 newX = styles ? ("" + (styles.left + (25 * this.pasteCounter)) + "px") : "100px"; 541 newX = styles ? ("" + (styles.left + (25 * this.pasteCounter)) + "px") : "100px";
537 newY = styles ? ("" + (styles.top + (25 * this.pasteCounter)) + "px") : "100px"; 542 newY = styles ? ("" + (styles.top + (25 * this.pasteCounter)) + "px") : "100px";
538 543
539 translation = {"left": newX, "top": newY};
540 //add the pasted object on top of the copied object
541 this.application.ninja.elementMediator.addElements(element, translation);
542 544
543// //move the pasted object to make it visible to user 545
544// modObject.push({element:element, properties:{left: newX, top:newY}, previousProperties: {left: x, top:y}}); 546// //add pasted object with new position
545// this.application.ninja.elementMediator.setProperties(modObject, "Change", "clipboard-controller" ); 547// translation = {"left": newX, "top": newY};
548// this.application.ninja.elementMediator.addElements(element, translation);
546// 549//
547// element.elementModel.setProperty("x", this.application.ninja.elementMediator.getProperty(element, "left")); 550
548// element.elementModel.setProperty("y", this.application.ninja.elementMediator.getProperty(element, "top")); 551
552 //first paste on top and then move the pasted object to make it visible to user
553 this.application.ninja.elementMediator.addElements(element, null, false);
554 modObject.push({element:element, properties:{left: newX, top:newY}, previousProperties: {left: x, top:y}});
555 this.application.ninja.elementMediator.setProperties(modObject, "Change", "clipboard-controller" );
556 NJevent("elementAdded", element);
557
549 } 558 }
550 }, 559 },
551 560