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/controllers/elements/element-controller.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 452d09f1..a7d99466 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -11,7 +11,19 @@ exports.ElementController = Montage.create(Component, { addElement: { value: function(el, styles) { - this.application.ninja.currentDocument.documentRoot.appendChild(el); + if(this.application.ninja.timeline.currentLayerSelected){ + var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); + + if(selectedLayerIndex==0){ + this.application.ninja.currentDocument.documentRoot.appendChild(el); + }else{ + var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0]; + element.parentNode.insertBefore(el,element.nextSibling); + } + + }else{ + this.application.ninja.currentDocument.documentRoot.appendChild(el); + } // Nested elements - TODO make sure the CSS is correct before nesting elements // this.application.ninja.currentSelectedContainer.appendChild(el); if(styles) { -- cgit v1.2.3