aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-05-07 10:38:04 -0700
committerJose Antonio Marquez2012-05-07 10:38:04 -0700
commit5293ede5f3493900df93da33197416d853f8d907 (patch)
tree3155deaea5616fa09fc96c84567419fec5f288a2 /js/controllers/elements
parent9c0bda09a502472768f6dd5090a882d11be58d23 (diff)
parent30e837ade2da7cb20caf7c5a69faf0888736bb9a (diff)
downloadninja-5293ede5f3493900df93da33197416d853f8d907.tar.gz
Merge branch 'refs/heads/Ninja-DOM-Architecture' into Document
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/body-controller.js28
-rwxr-xr-xjs/controllers/elements/controller-factory.js2
-rwxr-xr-xjs/controllers/elements/element-controller.js7
-rwxr-xr-xjs/controllers/elements/shapes-controller.js2
4 files changed, 34 insertions, 5 deletions
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, {
28 28
29 getProperty: { 29 getProperty: {
30 value: function(el, p) { 30 value: function(el, p) {
31 switch(p) {
32 case "background" :
33 return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", true, true));
34 case "border":
35 return 0;
36 case "height":
37 case "width":
38 case "-webkit-transform-style":
39 return this.application.ninja.stylesController.getElementStyle(el, p, true, true);
40 default:
41 return ElementController.getProperty(el, p, true, true);
42 //console.log("Undefined Stage property ", p);
43 }
31 } 44 }
32 }, 45 },
33 46
34 setProperty: { 47 setProperty: {
35 value: function(el, p, value) { 48 value: function(el, p, value) {
49 switch(p) {
50 case "body-background":
51 case "background":
52 this.application.ninja.stylesController.setElementStyle(el, "background-color", value, true);
53 break;
54 case "overflow":
55 case "width":
56 case "height":
57 case "-webkit-transform-style":
58 this.application.ninja.stylesController.setElementStyle(el, p, value, true);
59 this.application.ninja.stage.updatedStage = true;
60 break;
61 default:
62 console.log("Undefined property ", p, "for the Body Controller");
63 }
36 } 64 }
37 }, 65 },
38 66
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, {
42 return ImageController; 42 return ImageController;
43 } else if(value.indexOf("video") !== -1) { 43 } else if(value.indexOf("video") !== -1) {
44 return VideoController; 44 return VideoController;
45 } else {
46 return BlockController;
45 } 47 }
46 } catch (err) { 48 } catch (err) {
47 console.log("Could not create Controller Factory " + err); 49 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 ea5fe4af..20225c61 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -15,16 +15,15 @@ exports.ElementController = Montage.create(Component, {
15 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); 15 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID);
16 16
17 if(selectedLayerIndex === 0) { 17 if(selectedLayerIndex === 0) {
18 this.application.ninja.currentDocument.documentRoot.appendChild(el); 18 this.application.ninja.currentSelectedContainer.appendChild(el);
19 } else { 19 } else {
20 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0]; 20 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0];
21 element.parentNode.insertBefore(el, element.nextSibling); 21 element.parentNode.insertBefore(el, element.nextSibling);
22 } 22 }
23 } else { 23 } else {
24 this.application.ninja.currentDocument.documentRoot.appendChild(el); 24 this.application.ninja.currentSelectedContainer.appendChild(el);
25 } 25 }
26 // Nested elements - TODO make sure the CSS is correct before nesting elements 26
27 // this.application.ninja.currentSelectedContainer.appendChild(el);
28 if(styles) { 27 if(styles) {
29 this.application.ninja.stylesController.setElementStyles(el, styles); 28 this.application.ninja.stylesController.setElementStyles(el, styles);
30 } 29 }
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, {
129 el.elementModel.shapeModel.GLWorld.render(); 129 el.elementModel.shapeModel.GLWorld.render();
130 break; 130 break;
131 case "useWebGl": 131 case "useWebGl":
132 canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); 132 canvas = njModule.NJUtils.make("canvas", el.className, this.application.ninja.currentDocument);
133 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); 133 canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom());
134 canvas.width = el.width; 134 canvas.width = el.width;
135 canvas.height = el.height; 135 canvas.height = el.height;