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.js40
3 files changed, 39 insertions, 23 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..74353454 100755
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -278,7 +278,7 @@ exports.ShapesController = Montage.create(CanvasController, {
278 } 278 }
279 else 279 else
280 { 280 {
281 return "FlatMaterial"; 281 return "Flat";
282 } 282 }
283 case "fillMaterial": 283 case "fillMaterial":
284 var fm = el.elementModel.shapeModel.GLGeomObj.getFillMaterial(); 284 var fm = el.elementModel.shapeModel.GLGeomObj.getFillMaterial();
@@ -288,7 +288,7 @@ exports.ShapesController = Montage.create(CanvasController, {
288 } 288 }
289 else 289 else
290 { 290 {
291 return "FlatMaterial"; 291 return "Flat";
292 } 292 }
293 default: 293 default:
294 return CanvasController.getProperty(el, p); 294 return CanvasController.getProperty(el, p);
@@ -430,16 +430,16 @@ exports.ShapesController = Montage.create(CanvasController, {
430 430
431 if(gradientMode === "radial") 431 if(gradientMode === "radial")
432 { 432 {
433 if( !m || (m.getName() !== "RadialGradientMaterial") ) 433 if( !m || (m.getName() !== "Radial Gradient") )
434 { 434 {
435 gradientM = Object.create(MaterialsModel.getMaterial("RadialGradientMaterial")); 435 gradientM = Object.create(MaterialsModel.getMaterial("Radial Gradient"));
436 } 436 }
437 } 437 }
438 else 438 else
439 { 439 {
440 if( !m || (m.getName() !== "LinearGradientMaterial") ) 440 if( !m || (m.getName() !== "Linear Gradient") )
441 { 441 {
442 gradientM = Object.create(MaterialsModel.getMaterial("LinearGradientMaterial")); 442 gradientM = Object.create(MaterialsModel.getMaterial("Linear Gradient"));
443 } 443 }
444 } 444 }
445 445
@@ -471,9 +471,9 @@ exports.ShapesController = Montage.create(CanvasController, {
471 m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial(); 471 m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial();
472 } 472 }
473 473
474 if(!m || ((m.getName() === "LinearGradientMaterial") || m.getName() === "RadialGradientMaterial") ) 474 if(!m || ((m.getName() === "Linear Gradient") || m.getName() === "Radial Gradient") )
475 { 475 {
476 flatM = Object.create(MaterialsModel.getMaterial("FlatMaterial")); 476 flatM = Object.create(MaterialsModel.getMaterial("Flat"));
477 if(flatM) 477 if(flatM)
478 { 478 {
479 if(isFill) 479 if(isFill)
@@ -764,18 +764,18 @@ exports.ShapesController = Montage.create(CanvasController, {
764 // Set Linear/Radial Gradient Material for children geometry if color in canvas 2d has gradient 764 // Set Linear/Radial Gradient Material for children geometry if color in canvas 2d has gradient
765 if(child.strokeColor.gradientMode === "radial") 765 if(child.strokeColor.gradientMode === "radial")
766 { 766 {
767 child.strokeMat = "RadialGradientMaterial"; 767 child.strokeMat = "Radial Gradient";
768 } 768 }
769 else 769 else
770 { 770 {
771 child.strokeMat = "LinearGradientMaterial"; 771 child.strokeMat = "Linear Gradient";
772 } 772 }
773 } 773 }
774 else if( (child.strokeMat === "RadialGradientMaterial") || 774 else if( (child.strokeMat === "Radial Gradient") ||
775 (child.strokeMat === "LinearGradientMaterial") ) 775 (child.strokeMat === "Linear Gradient") )
776 { 776 {
777 // Set Flat Material for children geometry if color has been changed to solid 777 // Set Flat Material for children geometry if color has been changed to solid
778 child.strokeMat = "FlatMaterial"; 778 child.strokeMat = "Flat";
779 } 779 }
780 } 780 }
781 781
@@ -786,18 +786,18 @@ exports.ShapesController = Montage.create(CanvasController, {
786 // Set Linear/Radial Gradient Material for children geometry if color in canvas 2d has gradient 786 // Set Linear/Radial Gradient Material for children geometry if color in canvas 2d has gradient
787 if(child.fillColor.gradientMode === "radial") 787 if(child.fillColor.gradientMode === "radial")
788 { 788 {
789 child.fillMat = "RadialGradientMaterial"; 789 child.fillMat = "Radial Gradient";
790 } 790 }
791 else 791 else
792 { 792 {
793 child.fillMat = "LinearGradientMaterial"; 793 child.fillMat = "Linear Gradient";
794 } 794 }
795 } 795 }
796 else if( (child.fillMat === "RadialGradientMaterial") || 796 else if( (child.fillMat === "Radial Gradient") ||
797 (child.fillMat === "LinearGradientMaterial") ) 797 (child.fillMat === "Linear Gradient") )
798 { 798 {
799 // Set Flat Material for children geometry if color has been changed to solid 799 // Set Flat Material for children geometry if color has been changed to solid
800 child.fillMat = "FlatMaterial"; 800 child.fillMat = "Flat";
801 } 801 }
802 } 802 }
803 } 803 }
@@ -814,11 +814,11 @@ exports.ShapesController = Montage.create(CanvasController, {
814 { 814 {
815 var css, 815 var css,
816 colorObj; 816 colorObj;
817 if(m === "LinearGradientMaterial") 817