aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/color-controller.js17
-rwxr-xr-xjs/controllers/elements/body-controller.js5
-rwxr-xr-xjs/controllers/elements/shapes-controller.js119
-rw-r--r--js/controllers/objects-controller.js6
-rw-r--r--js/controllers/presets-controller.js20
-rwxr-xr-xjs/controllers/styles-controller.js33
6 files changed, 150 insertions, 50 deletions
diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js
index 3165988d..2a6fe9bd 100755
--- a/js/controllers/color-controller.js
+++ b/js/controllers/color-controller.js
@@ -254,7 +254,12 @@ exports.ColorController = Montage.create(Component, {
254 gradient.css = css; 254 gradient.css = css;
255 // 255 //
256 arr = css.split('from('); 256 arr = css.split('from(');
257 arr = arr[1].split('),'); 257 //
258 if (arr.length > 1) {
259 arr = arr[1].split('),');
260 } else {
261 arr = (css.split(css.split('color-stop(')[0])[1]).split('),');
262 }
258 // 263 //
259 for (i=0; arr[i]; i++) { 264 for (i=0; arr[i]; i++) {
260 arr[i] = arr[i].replace(/ color-stop\(/i, ""); 265 arr[i] = arr[i].replace(/ color-stop\(/i, "");
@@ -264,14 +269,20 @@ exports.ColorController = Montage.create(Component, {
264 arr[i] = arr[i].replace(/\)\)/i, ""); 269 arr[i] = arr[i].replace(/\)\)/i, "");
265 } 270 }
266 // 271 //
267 if (i === 0) { 272 if (i === 0 && arr[i].indexOf('color-stop') === -1) {
268 arr[i] = {css: arr[i], percent: 0}; 273 arr[i] = {css: arr[i], percent: 0};
269 } else if (i === arr.length-1) { 274 } else if (i === arr.length-1) {
270 arr[i] = {css: arr[i], percent: 100}; 275 temp = arr[i].split(', rgb');
276 if (temp.length > 1) {
277 arr[i] = {css: 'rgb'+temp[1].replace(/\)\)/i, ""), percent: Math.round(parseFloat(temp[0])*100)};
278 } else {
279 arr[i] = {css: arr[i], percent: 100};
280 }
271 } else { 281 } else {
272 // 282 //
273 if (arr[i].indexOf('rgb') >= 0 && arr[i].indexOf('rgba') < 0) { 283 if (arr[i].indexOf('rgb') >= 0 && arr[i].indexOf('rgba') < 0) {
274 temp = arr[i].split(', rgb'); 284 temp = arr[i].split(', rgb');
285 temp[0] = temp[0].replace(/color\-stop\(/gi, '');
275 arr[i] = {css: 'rgb'+temp[1], percent: Math.round(parseFloat(temp[0])*100)}; 286 arr[i] = {css: 'rgb'+temp[1], percent: Math.round(parseFloat(temp[0])*100)};
276 } else if (arr[i].indexOf('rgba') >= 0) { 287 } else if (arr[i].indexOf('rgba') >= 0) {
277 temp = arr[i].split(', rgba'); 288 temp = arr[i].split(', rgba');
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
index 604b22d0..bc4d2e42 100755
--- a/js/controllers/elements/body-controller.js
+++ b/js/controllers/elements/body-controller.js
@@ -39,6 +39,8 @@ exports.BodyController = Montage.create(ElementController, {
39 value: function(el, p) { 39 value: function(el, p) {
40 switch(p) { 40 switch(p) {
41 case "background" : 41 case "background" :
42 case "background-image":
43 return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-image"));
42 case "background-color": 44 case "background-color":
43 if(this.application.ninja.currentDocument.model.views.design._template) { 45 if(this.application.ninja.currentDocument.model.views.design._template) {
44 return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el.parentNode, "background-color")); 46 return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el.parentNode, "background-color"));
@@ -62,6 +64,9 @@ exports.BodyController = Montage.create(ElementController, {
62 value: function(el, p, value) { 64 value: function(el, p, value) {
63 switch(p) { 65 switch(p) {
64 case "background": 66 case "background":
67 case "background-image":
68 this.application.ninja.stylesController.setElementStyle(el, "background-image", value);
69 break;
65 case "background-color": 70 case "background-color":
66 if(this.application.ninja.currentDocument.model.views.design._template) { 71 if(this.application.ninja.currentDocument.model.views.design._template) {
67 this.application.ninja.stylesController.setElementStyle(el.parentNode, "background-color", value); 72 this.application.ninja.stylesController.setElementStyle(el.parentNode, "background-color", value);
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index e62af921..c3099459 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -138,6 +138,10 @@ exports.ShapesController = Montage.create(CanvasController, {
138 this.application.ninja.elementMediator.replaceElement(canvas, el); 138 this.application.ninja.elementMediator.replaceElement(canvas, el);
139 break; 139 break;
140 case "strokeMaterial": 140 case "strokeMaterial":
141 // skip shape types that don't support WebGL
142 if(!el.elementModel.shapeModel.useWebGl) {
143 return;
144 }
141 m = Object.create(MaterialsModel.getMaterial(value)); 145 m = Object.create(MaterialsModel.getMaterial(value));
142 if(m) 146 if(m)
143 { 147 {
@@ -152,6 +156,10 @@ exports.ShapesController = Montage.create(CanvasController, {
152 } 156 }
153 break; 157 break;
154 case "fillMaterial": 158 case "fillMaterial":
159 // skip shape types that don't support WebGL or fill color
160 if(!el.elementModel.shapeModel.GLGeomObj.canFill || !el.elementModel.shapeModel.useWebGl) {
161 return;
162 }
155 m = Object.create(MaterialsModel.getMaterial(value)); 163 m = Object.create(MaterialsModel.getMaterial(value));
156 if(m) 164 if(m)
157 { 165 {
@@ -278,7 +286,7 @@ exports.ShapesController = Montage.create(CanvasController, {
278 } 286 }
279 else 287 else
280 { 288 {
281 return "FlatMaterial"; 289 return "Flat";
282 } 290 }
283 case "fillMaterial": 291 case "fillMaterial":
284 var fm = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); 292 var fm = el.elementModel.shapeModel.GLGeomObj.getFillMaterial();
@@ -288,7 +296,7 @@ exports.ShapesController = Montage.create(CanvasController, {
288 } 296 }
289 else 297 else
290 { 298 {
291 return "FlatMaterial"; 299 return "Flat";
292 } 300 }
293 default: 301 default:
294 return CanvasController.getProperty(el, p); 302 return CanvasController.getProperty(el, p);
@@ -430,32 +438,32 @@ exports.ShapesController = Montage.create(CanvasController, {
430 438
431 if(gradientMode === "radial") 439 if(gradientMode === "radial")
432 { 440 {
433 if( !m || (m.getName() !== "RadialGradientMaterial") ) 441 if( !m || (m.getName() !== "Radial Gradient") )
434 { 442 {
435 gradientM = Object.create(MaterialsModel.getMaterial("RadialGradientMaterial")); 443 gradientM = Object.create(MaterialsModel.getMaterial("Radial Gradient"));
436 } 444 }
437 } 445 }
438 else 446 else
439 { 447 {
440 if( !m || (m.getName() !== "LinearGradientMaterial") ) 448 if( !m || (m.getName() !== "Linear Gradient") )
441 { 449 {
442 gradientM = Object.create(MaterialsModel.getMaterial("LinearGradientMaterial")); 450 gradientM = Object.create(MaterialsModel.getMaterial("Linear Gradient"));
443 } 451 }
444 } 452 }
445 453
446 if(gradientM) 454 if(gradientM)
447 { 455 {
448 if(isFill) 456 if(isFill)
449 { 457 {
450 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(gradientM); 458 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(gradientM);
451 } 459 }
452 else 460 else
453 { 461 {
454 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(gradientM); 462 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(gradientM);
455 } 463 }
456 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 464 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
457 } 465 }
458 } 466 }
459 }, 467 },
460 468
461 _setFlatMaterial: { 469 _setFlatMaterial: {
@@ -471,11 +479,14 @@ exports.ShapesController = Montage.create(CanvasController, {
471 m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); 479 m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial();
472 } 480 }
473 481
474 if(!m || ((m.getName() === "LinearGradientMaterial") || m.getName() === "RadialGradientMaterial") ) 482 if(!m || ((m.getName() === "Linear Gradient") || m.getName() === "Radial Gradient") )
475 { 483 {
476 flatM = Object.create(MaterialsModel.getMaterial("FlatMaterial")); 484 // Uber Material also supports solid colors, so don't change from Uber to Flat Material
485 if(m && (m.getName() === "Uber")) { return; }
486
487 flatM = Object.create(MaterialsModel.getMaterial("Flat"));
477 if(flatM) 488 if(flatM)
478 { 489 {
479 if(isFill) 490 if(isFill)
480 { 491 {
481 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(flatM); 492 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(flatM);
@@ -484,10 +495,10 @@ exports.ShapesController = Montage.create(CanvasController, {
484 { 495 {
485 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(flatM); 496 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(flatM);
486 } 497 }
487 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 498 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
488 }
489 } 499<