aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements/element-controller.js
diff options
context:
space:
mode:
authorArmen Kesablyan2012-02-07 16:51:14 -0800
committerArmen Kesablyan2012-02-07 16:51:14 -0800
commit8110e01dc5093ac6baf621103dcaa5f769e5be92 (patch)
treeecf339e3097b6ba25d81cbe44d913ee67591bf4b /js/controllers/elements/element-controller.js
parent5f506542d28e12b707c3bfa41b53383519838477 (diff)
parent668510892537eaaeb2e11520831d87b44b2489b7 (diff)
downloadninja-8110e01dc5093ac6baf621103dcaa5f769e5be92.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'js/controllers/elements/element-controller.js')
-rw-r--r--js/controllers/elements/element-controller.js150
1 files changed, 113 insertions, 37 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index f254220c..65d26bdd 100644
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -69,27 +69,103 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
69 // Routines to get/set color properties 69 // Routines to get/set color properties
70 getColor: { 70 getColor: {
71 value: function(el, isFill) { 71 value: function(el, isFill) {
72 var colorObj,
73 color,
74 image;
75
76 // Return cached value if one exists
72 if(isFill) 77 if(isFill)
73 { 78 {
74 return this.application.ninja.stylesController.getElementStyle(el, "background-color"); 79 if(el.elementModel.fill)
80 {
81 return el.elementModel.fill;
82 }
83// return this.application.ninja.stylesController.getElementStyle(el, "background-color");
84 //TODO: Once logic for color and gradient is established, this needs to be revised
85 color = this.getProperty(el, "background-color");
86 image = this.getProperty(el, "background-image");
75 } 87 }
76 else 88 else
77 { 89 {
78 // TODO - Need to figure out which border side user wants 90 // TODO - Need to figure out which border side user wants
79 return this.application.ninja.stylesController.getElementStyle(el, "border-color"); 91 if(el.elementModel.stroke)
92 {
93 return el.elementModel.stroke;
94 }
95 // TODO - Need to figure out which border side user wants
96// return this.application.ninja.stylesController.getElementStyle(el, "border-color");
97 color = this.getProperty(el, "border-color");
98 image = this.getProperty(el, "border-image");
99 }
100
101 if(color || image) {
102 if (image && image !== 'none' && image.indexOf('-webkit') >= 0) {
103 //Gradient
104 colorObj = this.application.ninja.colorController.getColorObjFromCss(image);
105 } else {
106 //Solid
107 colorObj = this.application.ninja.colorController.getColorObjFromCss(color);
108 }
109 }
110
111 // Update cache
112 if(isFill)
113 {
114 el.elementModel.fill = colorObj;
115 }
116 else
117 {
118 el.elementModel.stroke = colorObj;
80 } 119 }
120
121 return colorObj;
81 } 122 }
82 }, 123 },
83 124
84 setColor: { 125 setColor: {
85 value: function(el, color, isFill) { 126 value: function(el, color, isFill) {
127 var mode = color.mode;
86 if(isFill) 128 if(isFill)
87 { 129 {
88 this.application.ninja.stylesController.setElementStyle(el, "background-color", color.color.css); 130 if(mode)
131 {
132 switch (mode) {
133 case 'nocolor':
134 this.setProperty(el, "background-image", "none");
135 this.setProperty(el, "background-color", "none");
136 el.elementModel.fill = null;
137 return;
138 case 'gradient':
139 this.setProperty(el, "background-image", color.color.css);
140 this.setProperty(el, "background-color", "none");
141 break;
142 default:
143 this.setProperty(el, "background-image", "none");
144 this.setProperty(el, "background-color", color.color.css);
145 }
146 }
147 el.elementModel.fill = color;
89 } 148 }
90 else 149 else
91 { 150 {
92 this.application.ninja.stylesController.setElementStyle(el, "border-color", color.color.css); 151 if(mode)
152 {
153 switch (mode) {
154 case 'nocolor':
155 this.setProperty(el, "border-image", "none");
156 this.setProperty(el, "border-color", "none");
157 el.elementModel.stroke = null;
158 return;
159 case 'gradient':
160 this.setProperty(el, "border-image", color.color.css);
161 this.setProperty(el, "border-color", "none");
162 break;
163 default:
164 this.setProperty(el, "border-image", "none");
165 this.setProperty(el, "border-color", color.color.css);
166 }
167 }
168 el.elementModel.stroke = color;
93 } 169 }
94 } 170 }
95 }, 171 },
@@ -103,8 +179,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
103 179
104 setStroke: { 180 setStroke: {
105 value: function(el, stroke) { 181 value: function(el, stroke) {
106 var border = stroke.borderWidth + stroke.borderUnits + " " + stroke.borderStyle + " " + stroke.color.color.css; 182 this.application.ninja.stylesController.setElementStyle(el, "border-width", stroke.borderWidth + stroke.borderUnits);
107 this.application.ninja.stylesController.setElementStyle(el, "border", border); 183 this.application.ninja.stylesController.setElementStyle(el, "border-style", stroke.borderStyle);
184 this.setColor(el, stroke.color, false);
108 } 185 }
109 }, 186 },
110 187
@@ -127,36 +204,35 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
127 } 204 }
128 else 205 else
129 { 206 {
130 // TODO - for now, just return the identity matrix 207 var mat;
131 return Matrix.I(4); 208
132// var mat; 209 if (el)
133// 210 {
134// if (elt) 211 var xformStr = this.application.ninja.elementMediator.getProperty(el, "-webkit-transform");
135// { 212 if (xformStr)
136// var xformStr = ElementsMediator.getProperty(elt, "-webkit-transform"); 213 mat = this.transformStringToMat( xformStr );
137// if (xformStr) 214 if (!mat)
138// mat = this.transformStringToMat( xformStr ); 215 mat = Matrix.I(4);
139// if (!mat) 216
140// mat = Matrix.I(4); 217 var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom");
141// 218 if (zoom)
142// if (elt.style && elt.style.zoom) 219 {
143// { 220 zoom = Number(zoom);
144// var zoom = Number(elt.style.zoom); 221 if (zoom != 1)
145// if (zoom != 1) 222 {
146// { 223 var zoomMat = Matrix.create( [
147// var zoomMat = Matrix.create( [ 224 [ zoom, 0, 0, 0],
148// [ zoom, 0, 0, 0], 225 [ 0, zoom, 0, 0],
149// [ 0, zoom, 0, 0], 226 [ 0, 0, zoom, 0],
150// [ 0, 0, zoom, 0], 227 [ 0, 0, 0, 1]
151// [ 0, 0, 0, 1] 228 ] );
152// ] ); 229 glmat4.multiply( zoomMat, mat, mat );
153// glmat4.multiply( zoomMat, mat, mat ); 230 }
154// } 231 }
155// } 232 }
156// } 233
157// 234 el.elementModel.props3D.matrix3d = mat;
158// elt.elementModel.props3D.matrix3d = mat; 235 return mat;
159// return mat;
160 } 236 }
161 } 237 }
162 }, 238 },
@@ -207,7 +283,7 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
207 el.elementModel.props3D.matrix3d = mat; 283 el.elementModel.props3D.matrix3d = mat;
208 el.elementModel.props3D.perspectiveDist = dist; 284 el.elementModel.props3D.perspectiveDist = dist;
209 285
210// if(update3DModel) 286 if(update3DModel)
211 { 287 {
212 this._update3DProperties(el, mat, dist); 288 this._update3DProperties(el, mat, dist);
213 } 289 }