aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
authorAnanya Sen2012-06-07 11:59:32 -0700
committerAnanya Sen2012-06-07 11:59:32 -0700
commit7378b6846f140106490f10c02cd7cec6a19023aa (patch)
tree90b60c007696b4a73c29abbae82562f69f15c11a /js/controllers/elements
parentaea0e6879abfef02a827ed239ef091c3b96d6eb2 (diff)
parentb75fe9369f7caec0351d298f7106c8d59572b440 (diff)
downloadninja-7378b6846f140106490f10c02cd7cec6a19023aa.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-xjs/controllers/elements/body-controller.js4
-rwxr-xr-xjs/controllers/elements/component-controller.js4
-rwxr-xr-xjs/controllers/elements/element-controller.js102
-rwxr-xr-xjs/controllers/elements/shapes-controller.js103
4 files changed, 162 insertions, 51 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
index 7a3a66f5..9c427c62 100755
--- a/js/controllers/elements/body-controller.js
+++ b/js/controllers/elements/body-controller.js
@@ -71,7 +71,7 @@ exports.BodyController = Montage.create(ElementController, {
71 71
72 getPerspectiveDist: { 72 getPerspectiveDist: {
73 value: function(el) { 73 value: function(el) {
74 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { 74 if(el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) {
75 return el.elementModel.props3D.perspectiveDist; 75 return el.elementModel.props3D.perspectiveDist;
76 } else { 76 } else {
77 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true); 77 var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true);
@@ -83,7 +83,7 @@ exports.BodyController = Montage.create(ElementController, {
83 83
84 getMatrix: { 84 getMatrix: {
85 value: function(el) { 85 value: function(el) {
86 if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) 86 if(el.elementModel.props3D && el.elementModel.props3D.matrix3d)
87 { 87 {
88 return el.elementModel.props3D.matrix3d.slice(0); 88 return el.elementModel.props3D.matrix3d.slice(0);
89 } 89 }
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/element-controller.js b/js/controllers/elements/element-controller.js
index 01e132d7..4a02e9a3 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -5,7 +5,8 @@ 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
@@ -36,7 +37,7 @@ exports.ElementController = Montage.create(Component, {
36 // Remove the element from the DOM and clear the GLWord. 37 // Remove the element from the DOM and clear the GLWord.
37 removeElement: { 38 removeElement: {
38 value: function(el) { 39 value: function(el) {
39 if(el.elementModel && el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { 40 if(el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) {
40 el.elementModel.shapeModel.GLWorld.clearTree(); 41 el.elementModel.shapeModel.GLWorld.clearTree();
41 } 42 }
42 el.parentNode.removeChild(el); 43 el.parentNode.removeChild(el);
@@ -162,28 +163,12 @@ exports.ElementController = Montage.create(Component, {
162 el.elementModel.stroke = null; 163 el.elementModel.stroke = null;
163 return; 164 return;
164 case 'gradient': 165 case 'gradient':
165 if(color.borderInfo) {
166 if(color.borderInfo.borderWidth) {
167 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits);
168 }
169 if(color.borderInfo.borderStyle) {
170 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
171 }
172 }
173 this.setGradientBorder(el, color.color.gradientMode, color.color.css); 166 this.setGradientBorder(el, color.color.gradientMode, color.color.css);
174 break; 167 break;
175 default: 168 default:
176 this.setProperty(el, "border-image", "none"); 169 this.setProperty(el, "border-image", "none");
177 this.setProperty(el, "border-image-slice", ""); 170 this.setProperty(el, "border-image-slice", "");
178 this.setProperty(el, "border-color", color.color.css); 171 this.setProperty(el, "border-color", color.color.css);
179 if(color.borderInfo) {
180 if(color.borderInfo.borderWidth) {
181 this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits);
182 }
183 if(color.borderInfo.borderStyle) {
184 this.setProperty(el, "border-style", color.borderInfo.borderStyle);
185 }
186 }
187 } 172 }
188 } 173 }
189 el.elementModel.stroke = color; 174 el.elementModel.stroke = color;
@@ -211,25 +196,88 @@ exports.ElementController = Montage.create(Component, {
211 }, 196 },
212 197
213 getStroke: { 198 getStroke: {
214 value: function(el) { 199 value: function(el, stroke) {
215 // TODO - Need to figure out which border side user wants 200 var strokeInfo = {},
216 return this.application.ninja.stylesController.getElementStyle(el, "border"); 201 color,
202 borderWidth,
203 border;
204 if(stroke.colorInfo) {
205 strokeInfo.colorInfo = {};
206 color = this.getColor(el, false);
207 if(color && color.color) {
208 strokeInfo.colorInfo.mode = color.mode;
209 strokeInfo.colorInfo.color = color.color;
210 } else {
211 strokeInfo.colorInfo.mode = "nocolor";
212 strokeInfo.colorInfo.color = null;
213 }
214 }
215 if(stroke.borderInfo) {
216 // TODO - Need to figure out which border side user wants
217 strokeInfo.borderInfo = {};
218 if(stroke.borderInfo.borderWidth) {
219 borderWidth = this.getProperty(el, "border-width");
220 if(borderWidth) {
221 border = njModule.NJUtils.getValueAndUnits(borderWidth);
222 strokeInfo.borderInfo.borderWidth = border[0];
223 strokeInfo.borderInfo.borderUnits = border[1];
224 }
225 }
226 if(stroke.borderInfo.borderStyle) {
227 strokeInfo.borderInfo.borderStyle = this.getProperty(el, "border-style");
228 }
229 }
230 return strokeInfo;
217 } 231 }
218 }, 232 },
219 233
220 setStroke: { 234 setStroke: {
221 value: function(el, stroke) { 235 value: function(el, stroke) {
222 this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderWidth + stroke.borderUnits); 236 if(stroke.borderInfo) {
223 this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderStyle); 237 if(stroke.borderInfo.borderWidth) {
224 this.setColor(el, stroke.color, false); 238 this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderInfo.borderWidth + stroke.borderInfo.borderUnits);
239 }
240 if(stroke.borderInfo.borderStyle) {
241 this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderInfo.borderStyle);
242 }
243 }
244 if(stroke.colorInfo) {
245 this.setColor(el, stroke.colorInfo, false);
246 }
225 } 247 }
226 }, 248 },
227 249
250 getFill: {
251 value: function(el, fill) {
252 var fillInfo = {},
253 color;
254 if(fill.colorInfo) {
255 fillInfo.colorInfo = {};
256 color = this.getColor(el, true);
257 if(color && color.color) {
258 fillInfo.colorInfo.mode = color.mode;
259 fillInfo.colorInfo.color = color.color;
260 } else {
261 fillInfo.colorInfo.mode = "nocolor";
262 fillInfo.colorInfo.color = null;
263 }
264 }
265 return fillInfo;
266 }
267 },
268
269 setFill: {
270 value: function(el, fill) {
271 if(fill.colorInfo) {
272 this.setColor(el, fill.colorInfo, true);
273 }
274 }
275 },
228 //-------------------------------------------------------------------------------------------------------- 276 //--------------------------------------------------------------------------------------------------------
229 // Routines to get/set 3D properties 277 // Routines to get/set 3D properties
230 get3DProperty: { 278 get3DProperty: {
231 value: function(el, prop) { 279 value: function(el, prop) {<