From 6c4f58ab9dd2f60d509d3e1c1ba0c94a6995691d Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Fri, 18 May 2012 15:05:50 -0700 Subject: Timeline: Fix element insertion to use new TimelinePanel properties and multiselect. Fix Property Panel so changing an ID there will actually change an ID on the element (broken by switch from id to data-montage-id change). --- js/controllers/elements/element-controller.js | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index eecf319e..925fc959 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -11,6 +11,33 @@ exports.ElementController = Montage.create(Component, { addElement: { value: function(el, styles) { + // Updated to use new methods in TimelinePanel. JR. + var insertionIndex = this.application.ninja.timeline.getInsertionIndex(); + console.log("elementcontroller.addElement, insertionIndex = ", insertionIndex); + //debugger; + if (insertionIndex === false) { + this.application.ninja.currentSelectedContainer.appendChild(el); + } else { + if (insertionIndex === 0) { + this.application.ninja.currentSelectedContainer.appendChild(el); + } else { + /* + if (insertionIndex === this.application.ninja.timeline.arrLayers.length-1) { + this.application.ninja.currentSelectedContainer.appendChild(el); + } else { + */ + var element = this.application.ninja.timeline.arrLayers[insertionIndex].layerData.stageElement; + element.parentNode.insertBefore(el, element.nextSibling); + //} + } + } + + if(styles) { + this.application.ninja.stylesController.setElementStyles(el, styles); + } + + /* + // Old methods. Kept for reference. Delete if not needed. JR. if(this.application.ninja.timeline.currentLayerSelected) { var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); @@ -27,6 +54,7 @@ exports.ElementController = Montage.create(Component, { if(styles) { this.application.ninja.stylesController.setElementStyles(el, styles); } + */ } }, -- cgit v1.2.3