From d2a5fcbaed6b3c3377edecbc27e6a2818b79be40 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 2 May 2012 15:34:49 -0700 Subject: Nesting absolute element in the Tag tool. Refactoring element creation and element models Signed-off-by: Valerio Virgillito --- js/controllers/elements/controller-factory.js | 2 ++ js/controllers/elements/element-controller.js | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/controller-factory.js b/js/controllers/elements/controller-factory.js index 1bbbbce0..3ac3fe14 100755 --- a/js/controllers/elements/controller-factory.js +++ b/js/controllers/elements/controller-factory.js @@ -42,6 +42,8 @@ exports.ControllerFactory = Montage.create(Montage, { return ImageController; } else if(value.indexOf("video") !== -1) { return VideoController; + } else { + return BlockController; } } catch (err) { console.log("Could not create Controller Factory " + err); diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 452d09f1..7f553551 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -11,9 +11,8 @@ exports.ElementController = Montage.create(Component, { addElement: { value: function(el, styles) { - 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); + this.application.ninja.currentSelectedContainer.appendChild(el); + if(styles) { this.application.ninja.stylesController.setElementStyles(el, styles); } -- cgit v1.2.3 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/elements') 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 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/controllers/elements/element-controller.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index a7d99466..ea5fe4af 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -11,17 +11,16 @@ exports.ElementController = Montage.create(Component, { addElement: { value: function(el, styles) { - if(this.application.ninja.timeline.currentLayerSelected){ + if(this.application.ninja.timeline.currentLayerSelected) { var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); - if(selectedLayerIndex==0){ + 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 { + var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0]; + element.parentNode.insertBefore(el, element.nextSibling); } - - }else{ + } else { this.application.ninja.currentDocument.documentRoot.appendChild(el); } // Nested elements - TODO make sure the CSS is correct before nesting elements -- 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/controllers/elements/shapes-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 8d7b74f0..e9a5f865 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -129,7 +129,7 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLWorld.render(); break; case "useWebGl": - canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); + canvas = njModule.NJUtils.make("canvas", el.className, this.application.ninja.currentDocument); canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); canvas.width = el.width; canvas.height = el.height; -- cgit v1.2.3 From b96dd7bbf61e84be51a7e011a85d1f09f493d1e5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 3 May 2012 23:15:17 -0700 Subject: fixing the currentContainer Signed-off-by: Valerio Virgillito --- js/controllers/elements/element-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 45d78b33..20225c61 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -15,13 +15,13 @@ exports.ElementController = Montage.create(Component, { var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); if(selectedLayerIndex === 0) { - this.application.ninja.currentDocument.currentSelectedContainer.appendChild(el); + this.application.ninja.currentSelectedContainer.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.currentSelectedContainer.appendChild(el); + this.application.ninja.currentSelectedContainer.appendChild(el); } if(styles) { -- cgit v1.2.3 From 8f8f7f9a36fb9abadea2a9f25aef0084946bebc9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:42:00 -0700 Subject: Removed special-casing for new template workflow. Instead, we will enforce a width and height on the body in order to do 3d. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/body-controller.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'js/controllers/elements') diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 14aeae24..943594f2 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -28,11 +28,39 @@ exports.BodyController = Montage.create(ElementController, { getProperty: { value: function(el, p) { + switch(p) { + case "background" : + return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", true, true)); + case "border": + return 0; + case "height": + case "width": + case "-webkit-transform-style": + return this.application.ninja.stylesController.getElementStyle(el, p, true, true); + default: + return ElementController.getProperty(el, p, true, true); + //console.log("Undefined Stage property ", p); + } } }, setProperty: { value: function(el, p, value) { + switch(p) { + case "body-background": + case "background": + this.application.ninja.stylesController.setElementStyle(el, "background-color", value, true); + break; + case "overflow": + case "width": + case "height": + case "-webkit-transform-style": + this.application.ninja.stylesController.setElementStyle(el, p, value, true); + this.application.ninja.stage.updatedStage = true; + break; + default: + console.log("Undefined property ", p, "for the Body Controller"); + } } }, -- cgit v1.2.3