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