aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnanya Sen2012-06-11 17:13:31 -0700
committerAnanya Sen2012-06-11 17:13:31 -0700
commit609ad21e56623827c5ca203cf6062f70d3067764 (patch)
tree9b7a00dd4219ef5250c5a297df5e47a538fa14a0
parent19d9da2ae655f0b531aa0e348a15bcf9d673a776 (diff)
downloadninja-609ad21e56623827c5ca203cf6062f70d3067764.tar.gz
- removed extra selection change event,
- displace element after adding it to the document Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
-rw-r--r--js/controllers/clipboard-controller.js55
-rw-r--r--js/panels/css-panel/styles-view-container.reel/styles-view-container.js2
-rwxr-xr-xjs/stage/stage.reel/stage.js2
3 files changed, 34 insertions, 25 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
diff --git a/js/panels/css-panel/styles-view-container.reel/styles-view-container.js b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
index 157d99de..4a09d5f3 100644
--- a/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
+++ b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
@@ -110,7 +110,7 @@ exports.StylesViewContainer = Montage.create(Component, {
110 } 110 }
111 }, 111 },
112 handleSelectionChange: { 112 handleSelectionChange: {
113 value: function() { 113 value: function(e) {
114 var elements = this.application.ninja.selectedElements, 114 var elements = this.application.ninja.selectedElements,
115 elementsCopy = this._copy(elements); 115 elementsCopy = this._copy(elements);
116 116
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 30ee1e40..2177616d 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -634,7 +634,7 @@ exports.Stage = Montage.create(Component, {
634 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop)); 634 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop));
635 element = this.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop); 635 element = this.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop);
636 636
637 if(!element) debugger; 637// if(!element) debugger;
638 // workaround Chrome 3d bug 638 // workaround Chrome 3d bug
639 if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.currentDocument.inExclusion(element) !== -1) { 639 if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.currentDocument.inExclusion(element) !== -1) {
640 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY)); 640 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY));