From 92e7297c153b432ede5b95d86cd934c990ebe768 Mon Sep 17 00:00:00 2001 From: Kruti Shah Date: Thu, 3 May 2012 10:57:45 -0700 Subject: Dom Manipulation Signed-off-by: Kruti Shah --- js/mediators/element-mediator.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 919aaec1..49a8e369 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -514,7 +514,35 @@ exports.ElementMediator = Montage.create(Component, { var str = this.getProperty(el, "-webkit-transform"); return str && str.length; } - } + }, + + reArrangeDOM:{ + value:function(layersDraggedArray , layerDroppedAfter){ + + var documentRoot,length; + + documentRoot = this.application.ninja.currentDocument.documentRoot; + length = layersDraggedArray.length; + + for(i=0;documentRoot.children[i];i++){ + if(documentRoot.children[i]===layerDroppedAfter.layerData.elementsList[0]){ + if(length >0){ + documentRoot.children[i].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0],documentRoot.children[i]); + } + /* Will require for Multiple Drag n Drop */ + // length = length-1; + // index=i; + // if(length>0){ + // while(layersDraggedArray[length]){ + // documentRoot.children[index].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0],documentRoot.children[k].nextSibling); + // length--; + // index++; + // } + // } + } + } + } + } -- cgit v1.2.3 From 602240c38e0f2c3937d3c7246247e0b59bccab2b Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 3 May 2012 13:35:37 -0700 Subject: minor formatting Signed-off-by: Valerio Virgillito --- js/mediators/element-mediator.js | 46 +++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 26 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 49a8e369..06514076 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -517,36 +517,30 @@ exports.ElementMediator = Montage.create(Component, { }, reArrangeDOM:{ - value:function(layersDraggedArray , layerDroppedAfter){ + value: function(layersDraggedArray, layerDroppedAfter) { + var documentRoot,length; - var documentRoot,length; + documentRoot = this.application.ninja.currentDocument.documentRoot; + length = layersDraggedArray.length; - documentRoot = this.application.ninja.currentDocument.documentRoot; - length = layersDraggedArray.length; - - for(i=0;documentRoot.children[i];i++){ - if(documentRoot.children[i]===layerDroppedAfter.layerData.elementsList[0]){ - if(length >0){ - documentRoot.children[i].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0],documentRoot.children[i]); - } - /* Will require for Multiple Drag n Drop */ - // length = length-1; - // index=i; - // if(length>0){ - // while(layersDraggedArray[length]){ - // documentRoot.children[index].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0],documentRoot.children[k].nextSibling); - // length--; - // index++; - // } - // } + for(var i=0; documentRoot.children[i]; i++) { + if(documentRoot.children[i] === layerDroppedAfter.layerData.elementsList[0]) { + if(length >0){ + documentRoot.children[i].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0], documentRoot.children[i]); } + + /* Will require for Multiple Drag n Drop */ + //length = length-1; + //index = i; + //if(length>0) { + //while(layersDraggedArray[length]) { + //documentRoot.children[index].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0],documentRoot.children[k].nextSibling); + //length--; + //index++; + //} + //} } } } - - - - - //-------------------------------------------------------------------------------------------------------- - + } }); \ No newline at end of file -- cgit v1.2.3 From 2078bfa96afaef40acb4edac99848ba55e808ef1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 3 May 2012 15:15:21 -0700 Subject: Refactor creating elements. Removed makeNJElement and separated the model creation Signed-off-by: Valerio Virgillito --- js/mediators/drag-drop-mediator.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index b0aba5b6..59086ef6 100755 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js @@ -114,11 +114,13 @@ exports.DragDropMediator = Montage.create(Component, { var self = this; // if (e.currentTarget.fileType.indexOf('svg') !== -1) { - element = NJUtils.makeNJElement('embed', 'SVG', 'block');//TODO: Verify this is proper + element = NJUtils.make('embed', null, this.application.ninja.currentDocument);//TODO: Verify this is proper + NJUtils.createModelWithSelection(element, "SVG"); element.type = 'image/svg+xml'; element.src = url+'/'+fileName; } else { - element = NJUtils.makeNJElement('image', 'image', 'image'); + element = NJUtils.make('image', null, this.application.ninja.currentDocument); + NJUtils.createModel(element); element.src = url+'/'+fileName; } //Adding element once it is loaded -- cgit v1.2.3