aboutsummaryrefslogtreecommitdiff
path: root/js/mediators
diff options
context:
space:
mode:
authorJon Reid2012-06-19 18:04:06 -0700
committerJon Reid2012-06-19 18:04:06 -0700
commit0da75e4de7373ed361b5d76be4ee192453146dde (patch)
treeb1ffd39b63e0934e55c38543830546ae619af3d5 /js/mediators
parent53a49f49ce5cd72fbb21e2840bb9622d5952d953 (diff)
downloadninja-0da75e4de7373ed361b5d76be4ee192453146dde.tar.gz
Timeline: Re-enable drag-and-drop of layers, now with bonus DOM
manipulation!
Diffstat (limited to 'js/mediators')
-rwxr-xr-xjs/mediators/element-mediator.js43
1 files changed, 19 insertions, 24 deletions
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js
index bd0ae3cb..99d2f822 100755
--- a/js/mediators/element-mediator.js
+++ b/js/mediators/element-mediator.js
@@ -483,30 +483,25 @@ exports.ElementMediator = Montage.create(Component, {
483 }, 483 },
484 484
485 reArrangeDOM:{ 485 reArrangeDOM:{
486 value: function(layersDraggedArray, layerDroppedAfter) { 486 value: function(arrLayersDragged, dropTargetElement) {
487 var documentRoot,length; 487 var i = 0,
488 488 arrLayersDraggedLength = arrLayersDragged.length,
489 documentRoot = this.application.ninja.currentDocument.model.documentRoot; 489 targetParentNode,
490 length = layersDraggedArray.length; 490 targetElement;
491 491
492 for(var i=0; documentRoot.children[i]; i++) { 492 if (arrLayersDraggedLength === 0) {
493 if(documentRoot.children[i] === layerDroppedAfter.layerData.stageElement) { 493 // Nothing was dragged, so return.
494 if(length >0){ 494 return;
495 documentRoot.children[i].parentNode.insertBefore(layersDraggedArray[length-1].layerData.stageElement, documentRoot.children[i]); 495 }
496 } 496
497 497 // Get the target parent node (this will be the parentNode of any of the dragging items)
498 /* Will require for Multiple Drag n Drop */ 498 targetParentNode = arrLayersDragged[0].parentNode;
499 //length = length-1; 499
500 //index = i; 500
501 //if(length>0) { 501 // Loop through arrLayersDragged and insertBefore the drop target element
502 //while(layersDraggedArray[length]) { 502 for (i = 0; i < arrLayersDraggedLength; i++) {
503 //documentRoot.children[index].parentNode.insertBefore(layersDraggedArray[length-1].layerData.elementsList[0],documentRoot.children[k].nextSibling); 503 targetParentNode.insertBefore(arrLayersDragged[i], dropTargetElement);
504 //length--; 504 }
505 //index++;
506 //}
507 //}
508 }
509 }
510 } 505 }
511 } 506 }
512}); \ No newline at end of file 507}); \ No newline at end of file