aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements/element-controller.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-02-01 17:05:07 -0800
committerNivesh Rajbhandari2012-02-01 17:05:07 -0800
commit830b011d94d728882286d72e129f7405134957c7 (patch)
tree72a4fb831d74c5d3f28ddca731431c59fb516bd8 /js/controllers/elements/element-controller.js
parentaffafafc4db16e5f918c74dfc919025d4c563cc6 (diff)
downloadninja-830b011d94d728882286d72e129f7405134957c7.tar.gz
Updated color code in the PI to go through element mediator.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/controllers/elements/element-controller.js')
-rw-r--r--js/controllers/elements/element-controller.js53
1 files changed, 49 insertions, 4 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 8a0735f7..892ac2f2 100644
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -69,15 +69,56 @@ 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");
80 } 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;
119 }
120
121 return colorObj;
81 } 122 }
82 }, 123 },
83 124
@@ -92,7 +133,8 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
92 case 'nocolor': 133 case 'nocolor':
93 this.setProperty(el, "background-image", "none"); 134 this.setProperty(el, "background-image", "none");
94 this.setProperty(el, "background-color", "none"); 135 this.setProperty(el, "background-color", "none");
95 break; 136 el.elementModel.fill = null;
137 return;
96 case 'gradient': 138 case 'gradient':
97 this.setProperty(el, "background-image", color.color.css); 139 this.setProperty(el, "background-image", color.color.css);
98 this.setProperty(el, "background-color", "none"); 140 this.setProperty(el, "background-color", "none");
@@ -106,6 +148,7 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
106 { 148 {
107 this.application.ninja.stylesController.setElementStyle(el, "background-color", color.color.css); 149 this.application.ninja.stylesController.setElementStyle(el, "background-color", color.color.css);
108 } 150 }
151 el.elementModel.fill = color;
109 } 152 }
110 else 153 else
111 { 154 {
@@ -115,7 +158,8 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
115 case 'nocolor': 158 case 'nocolor':
116 this.setProperty(el, "border-image", "none"); 159 this.setProperty(el, "border-image", "none");
117 this.setProperty(el, "border-color", "none"); 160 this.setProperty(el, "border-color", "none");
118 break; 161 el.elementModel.stroke = null;
162 return;
119 case 'gradient': 163 case 'gradient':
120 this.setProperty(el, "border-image", color.color.css); 164 this.setProperty(el, "border-image", color.color.css);
121 this.setProperty(el, "border-color", "none"); 165 this.setProperty(el, "border-color", "none");
@@ -129,6 +173,7 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
129 { 173 {
130 this.application.ninja.stylesController.setElementStyle(el, "border-color", color.color.css); 174 this.application.ninja.stylesController.setElementStyle(el, "border-color", color.color.css);
131 } 175 }
176 el.elementModel.stroke = color;
132 } 177 }
133 } 178 }
134 }, 179 },