aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
authorKruti Shah2012-06-12 13:09:11 -0700
committerKruti Shah2012-06-12 13:09:11 -0700
commitd648c842905c7c53e0f89b943982493d2b79f56e (patch)
treeeb5585f92061975215f6d19305a8d1b76262e2fc /js/controllers/elements
parentbedb38e14887b29eae3cdf1c8d435259c920257c (diff)
parentcf3b96822665751dae7a64644db3cb3960733c3d (diff)
downloadninja-d648c842905c7c53e0f89b943982493d2b79f56e.tar.gz
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts: js/controllers/elements/element-controller.js js/document/_toDelete/html-document.js js/panels/Timeline/Layer.reel/Layer.js Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/body-controller.js9
-rwxr-xr-xjs/controllers/elements/component-controller.js4
-rwxr-xr-xjs/controllers/elements/controller-factory.js4
-rwxr-xr-xjs/controllers/elements/element-controller.js136
-rwxr-xr-xjs/controllers/elements/element-controller.js.orig393
-rwxr-xr-xjs/controllers/elements/shapes-controller.js107
6 files changed, 588 insertions, 65 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
index 7a3a66f5..0dc11b82 100755
--- a/js/controllers/elements/body-controller.js
+++ b/js/controllers/elements/body-controller.js
@@ -30,7 +30,8 @@ exports.BodyController = Montage.create(ElementController, {
30 value: function(el, p) { 30 value: function(el, p) {
31 switch(p) { 31 switch(p) {
32 case "background" : 32 case "background" :
33 return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", false, true)); 33 case "background-color":
34 return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color"));
34 case "border": 35 case "border":
35 return 0; 36 return 0;
36 case "height": 37 case "height":
@@ -47,8 +48,8 @@ exports.BodyController = Montage.create(ElementController, {
47 setProperty: { 48 setProperty: {
48 value: function(el, p, value) { 49 value: function(el, p, value) {
49 switch(p) { 50 switch(p) {
50 case "body-background":
51 case "background": 51 case "background":
52 case "background-color":
52 this.application.ninja.stylesController.setElementStyle(el, "background-color", value); 53 this.application.ninja.stylesController.setElementStyle(el, "background-color", value);
53 break; 54 break;
54 case "overflow": 55 case "overflow":
@@ -71,7 +72,7 @@ exports.BodyController = Montage.create(ElementController, {
71 72
72 getPerspectiveDist: { 73 getPerspectiveDist: {
73 value: function(el) { 74 value: function(el) {
74 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { 75 if(el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) {
75 return el.elementModel.props3D.perspectiveDist; 76 return el.elementModel.props3D.perspectiveDist;
76 } else { 77 } else {
77 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true); 78 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true);
@@ -83,7 +84,7 @@ exports.BodyController = Montage.create(ElementController, {
83 84
84 getMatrix: { 85 getMatrix: {
85 value: function(el) { 86 value: function(el) {
86 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) 87 if(el.elementModel.props3D && el.elementModel.props3D.matrix3d)
87 { 88 {
88 return el.elementModel.props3D.matrix3d.slice(0); 89 return el.elementModel.props3D.matrix3d.slice(0);
89 } 90 }
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 5b0aaeac..dd0766df 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -11,7 +11,7 @@ exports.ComponentController = Montage.create(ElementController, {
11 11
12 getProperty: { 12 getProperty: {
13 value: function(el, prop) { 13 value: function(el, prop) {
14 var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); 14 var component = el.controller;
15 15
16 switch(prop) { 16 switch(prop) {
17 case "id": 17 case "id":
@@ -34,7 +34,7 @@ exports.ComponentController = Montage.create(ElementController, {
34 34
35 setProperty: { 35 setProperty: {
36 value: function(el, p, value) { 36 value: function(el, p, value) {
37 var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); 37 var component = el.controller;
38 38
39 switch(p) { 39 switch(p) {
40 case "id": 40 case "id":
diff --git a/js/controllers/elements/controller-factory.js b/js/controllers/elements/controller-factory.js
index 3ac3fe14..2d2a5cd1 100755
--- a/js/controllers/elements/controller-factory.js
+++ b/js/controllers/elements/controller-factory.js
@@ -8,7 +8,6 @@ var Montage = require("montage/core/core").Montage;
8 8
9var BodyController = require("js/controllers/elements/body-controller").BodyController, 9var BodyController = require("js/controllers/elements/body-controller").BodyController,
10 BlockController = require("js/controllers/elements/block-controller").BlockController, 10 BlockController = require("js/controllers/elements/block-controller").BlockController,
11 StageController = require("js/controllers/elements/stage-controller").StageController,
12 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, 11 ShapesController = require("js/controllers/elements/shapes-controller").ShapesController,
13 ImageController = require("js/controllers/elements/image-controller").ImageController, 12 ImageController = require("js/controllers/elements/image-controller").ImageController,
14 VideoController = require("js/controllers/elements/video-controller").VideoController, 13 VideoController = require("js/controllers/elements/video-controller").VideoController,
@@ -27,7 +26,8 @@ exports.ControllerFactory = Montage.create(Montage, {
27 if(value.indexOf("block") !== -1) { 26 if(value.indexOf("block") !== -1) {
28 return BlockController; 27 return BlockController;
29 } else if(value.indexOf("stage") !== -1) { 28 } else if(value.indexOf("stage") !== -1) {
30 return StageController; 29// return StageController;
30 alert("Calling the stage controller. Should not be calling this object");
31 } else if(value.indexOf("body") !== -1) { 31 } else if(value.indexOf("body") !== -1) {
32 return BodyController; 32 return BodyController;
33 } else if(value.indexOf("shape") !== -1) { 33 } else if(value.indexOf("shape") !== -1) {
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index da8afbaa..3d71c52d 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -5,12 +5,16 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component,
9 njModule = require("js/lib/NJUtils");
9 10
10exports.ElementController = Montage.create(Component, { 11exports.ElementController = Montage.create(Component, {
11 12
12 addElement: { 13 addElement: {
13 value: function(el, styles) { 14 value: function(el, styles) {
15
16 if (el.getAttribute) el.setAttribute('data-ninja-node', 'true');
17
14 // Updated to use new methods in TimelinePanel. JR. 18 // Updated to use new methods in TimelinePanel. JR.
15 var insertionIndex = this.application.ninja.timeline.getInsertionIndex(); 19 var insertionIndex = this.application.ninja.timeline.getInsertionIndex();
16 if (insertionIndex === false) { 20 if (insertionIndex === false) {
@@ -53,7 +57,7 @@ exports.ElementController = Montage.create(Component, {
53 // Remove the element from the DOM and clear the GLWord. 57 // Remove the element from the DOM and clear the GLWord.
54 removeElement: { 58 removeElement: {
55 value: function(el) { 59 value: function(el) {
56 if(el.elementModel && el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { 60 if(el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) {
57 el.elementModel.shapeModel.GLWorld.clearTree(); 61 el.elementModel.shapeModel.GLWorld.clearTree();
58 } 62 }
59 el.parentNode.removeChild(el); 63 el.parentNode.removeChild(el);
@@ -179,32 +183,12 @@ exports.ElementController = Montage.create(Component, {
179 el.elementModel.stroke = null; 183 el.elementModel.stroke = null;
180 return; 184 return;
181 case 'gradient': 185 case 'gradient':
182 this.setProperty(el, "border-image", color.color.css); 186 this.setGradientBorder(el, color.color.gradientMode, color.color.css);
183 this.setProperty(el, "border-color", "none");
184 if(color.borderInfo) {
185 if(color.borderInfo.borderWidth) {
186 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits);
187 }
188 if(color.borderInfo.borderStyle) {
189 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
190 }
191 }
192 break; 187 break;
193 default: 188 default:
194 if(borderSide){ 189 this.setProperty(el, "border-image", "none");
195 this.setProperty(el,"border-"+borderSide+"-color",color.color.css); 190 this.setProperty(el, "border-image-slice", "");
196 }else{ 191 this.setProperty(el, "border-color", color.color.css);
197 this.setProperty(el, "border-image", "none");
198 this.setProperty(el, "border-color", color.color.css);
199 }
200 if(color.borderInfo) {
201 if(color.borderInfo.borderWidth) {
202 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits);
203 }
204 if(color.borderInfo.borderStyle) {
205 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
206 }
207 }
208 } 192 }
209 } 193 }
210 el.elementModel.stroke = color; 194 el.elementModel.stroke = color;
@@ -212,26 +196,108 @@ exports.ElementController = Montage.create(Component, {
212 } 196 }
213 }, 197 },
214 198
199 setGradientBorder: {
200 value: function(el, gradientMode, css) {
201 if(gradientMode === "radial") {
202 this.setProperty(el, "border-image", css.replace("ellipse", "circle"));
203 } else {
204 this.setProperty(el, "border-image", css);
205 }
206 this.setProperty(el, "border-color", "none");
207 // gradient slice = borderWidth/totalWidth
208 var b = parseInt(this.getProperty(el, "border-left-width", true)),
209 w = parseInt(this.getProperty(el, "width", true)),
210 h = parseInt(this.getProperty(el, "height", true));
211 if(h > w) {
212 w = h;
213 }
214 this.setProperty(el, "border-image-slice", Math.floor(b/(w+b+b) * 100) + "%");
215 }
216 },
217