aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJose Antonio Marquez Russo2012-01-31 17:40:17 -0800
committerJose Antonio Marquez Russo2012-01-31 17:40:17 -0800
commit92ddcf89711c77453a55c4621afb469d61075e96 (patch)
treebae583f698d4993c52b31432b598bf4254f59bb0 /js
parentb125c02c3d2e28cc9364d16e23791cd6b540f17c (diff)
parentaffafafc4db16e5f918c74dfc919025d4c563cc6 (diff)
downloadninja-92ddcf89711c77453a55c4621afb469d61075e96.tar.gz
Merge pull request #1 from mqg734/NiveshColor
Updated color code to handle shapes.
Diffstat (limited to 'js')
-rw-r--r--js/components/combobox.reel/combobox.js2
-rw-r--r--js/components/layout/bread-crumb.reel/bread-crumb.css1
-rw-r--r--js/components/radio.reel/radio.js6
-rw-r--r--js/controllers/color-controller.js97
-rw-r--r--js/controllers/elements/element-controller.js43
-rw-r--r--js/controllers/elements/shapes-controller.js2
-rw-r--r--js/mediators/element-mediator.js2
-rw-r--r--js/models/color-model.js4
-rw-r--r--js/ninja.reel/ninja.js5
-rwxr-xr-xjs/preloader/Preloader.js1
10 files changed, 69 insertions, 94 deletions
diff --git a/js/components/combobox.reel/combobox.js b/js/components/combobox.reel/combobox.js
index f262bb06..a68a7d6b 100644
--- a/js/components/combobox.reel/combobox.js
+++ b/js/components/combobox.reel/combobox.js
@@ -67,7 +67,7 @@ exports.Combobox = Montage.create(Component, {
67 var e = document.createEvent("CustomEvent"); 67 var e = document.createEvent("CustomEvent");
68 e.initEvent("change", true, true); 68 e.initEvent("change", true, true);
69 e.type = "change"; 69 e.type = "change";
70 e._wasSetByCode = this._wasSetByCode; 70 e.wasSetByCode = this._wasSetByCode;
71 e.value = this._value; 71 e.value = this._value;
72 this.dispatchEvent(e); 72 this.dispatchEvent(e);
73 73
diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.css b/js/components/layout/bread-crumb.reel/bread-crumb.css
index f84c6e80..cc984609 100644
--- a/js/components/layout/bread-crumb.reel/bread-crumb.css
+++ b/js/components/layout/bread-crumb.reel/bread-crumb.css
@@ -5,6 +5,7 @@
5 </copyright> */ 5 </copyright> */
6 6
7.bread_crumb{ 7.bread_crumb{
8 background-color: #282828;
8 border-style: double; 9 border-style: double;
9 height: 26px; 10 height: 26px;
10} 11}
diff --git a/js/components/radio.reel/radio.js b/js/components/radio.reel/radio.js
index 954da3c4..c661ec11 100644
--- a/js/components/radio.reel/radio.js
+++ b/js/components/radio.reel/radio.js
@@ -41,7 +41,7 @@ exports.RadioGroup = Montage.create(Component, {
41 e = document.createEvent("CustomEvent"); 41 e = document.createEvent("CustomEvent");
42 e.initEvent("change", true, true); 42 e.initEvent("change", true, true);
43 e.type = "change"; 43 e.type = "change";
44 e._wasSetByCode = this._wasSetByCode; 44 e.wasSetByCode = this._wasSetByCode;
45 e.selectedIndex = i; 45 e.selectedIndex = i;
46 e.selectedItem = value; 46 e.selectedItem = value;
47 this.dispatchEvent(e); 47 this.dispatchEvent(e);
@@ -77,7 +77,7 @@ exports.RadioGroup = Montage.create(Component, {
77 { 77 {
78 value:function(event) 78 value:function(event)
79 { 79 {
80 this._wasSetByCode = event._event._wasSetByCode; 80 this._wasSetByCode = event._event.wasSetByCode;
81 this.selectedItem = event._event.value; 81 this.selectedItem = event._event.value;
82 } 82 }
83 } 83 }
@@ -126,7 +126,7 @@ exports.Radio = Montage.create(Component, {
126 var e = document.createEvent("CustomEvent"); 126 var e = document.createEvent("CustomEvent");
127 e.initEvent("change", true, true); 127 e.initEvent("change", true, true);
128 e.type = "change"; 128 e.type = "change";
129 e._wasSetByCode = this._wasSetByCode; 129 e.wasSetByCode = this._wasSetByCode;
130 e.value = this; 130 e.value = this;
131 this.dispatchEvent(e); 131 this.dispatchEvent(e);
132 132
diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js
index 87180873..925b525d 100644
--- a/js/controllers/color-controller.js
+++ b/js/controllers/color-controller.js
@@ -175,76 +175,21 @@ exports.ColorController = Montage.create(Component, {
175 }, 175 },
176 //////////////////////////////////////////////////////////////////// 176 ////////////////////////////////////////////////////////////////////
177 // 177 //
178 setBackground: { 178 setColor: {
179 enumerable: true, 179 enumerable: true,
180 value: function (type, background, selection) { 180 value: function (mode, color, isFill, selection) {
181 //TODO: Remove hack 181 var elements;
182 var elements, i, hack = [], hackNone = [];
183 //The selection is optional, if none, it asks for the currently selected elements 182 //The selection is optional, if none, it asks for the currently selected elements
184 if (selection) { 183 if (selection) {
185 elements = selection; 184 elements = selection;
186 } else { 185 } else {
187 elements = this.application.ninja.selectedElements; 186 elements = this.application.ninja.selectedElements;
188 } 187 }
189 // 188 if (elements && elements.length) {
190 for (i=0; elements[i]; i++) { 189 var colorInfo = { mode:mode,
191 hack[i] = background; 190 color:color
192 hackNone[i] = 'none'; 191 };
193 } 192 ElementsMediator.setColor(elements, colorInfo, isFill, "Change", "color-controller");
194 //
195 if (elements && elements.length > 0) {
196 switch (type) {
197 case 'image':
198 ElementsMediator.setProperty(elements, "background-image", hack, {"background-image": background}, "Change", "color-controller");
199 ElementsMediator.setProperty(elements, "background-color", hackNone, {"background-color": 'none'}, "Change", "color-controller");
200 break;
201 case 'color':
202 //TODO: Add logic to handle setting color when image (like gradients) is applied
203 //TODO: Handle applying to multiple items, currently, we need to create a dummy array of the same value
204 ElementsMediator.setProperty(elements, "background-image", hackNone, {"background-image": 'none'}, "Change", "color-controller");
205 ElementsMediator.setProperty(elements, "background-color", hack, {"background-color": background}, "Change", "color-controller");
206 break;
207 case 'background':
208 break;
209 }
210 //
211 //console.log(this.getColorObjFromCss('#333'));
212 }
213 }
214 },
215 ////////////////////////////////////////////////////////////////////
216 //
217 setBorder: {
218 enumerable: true,
219 value: function (type, border, selection) {
220 //
221 var elements, i, hack = [], hackNone = [];
222 //The selection is optional, if none, it asks for the currently selected elements
223 if (selection) {
224 elements = selection;
225 } else {
226 elements = this.application.ninja.selectedElements;
227 }
228 //
229 for (i=0; elements[i]; i++) {
230 hack[i] = border;
231 hackNone[i] = 'none';
232 }
233 //
234 if (elements && elements.length > 0) {
235 switch (type) {
236 case 'image':
237 //TODO: Figure out why color must be removed, might be related to the CSS
238 ElementsMediator.setProperty(elements, "border-color", hackNone, {"border-color": 'none'}, "Change", "color-controller");
239 ElementsMediator.setProperty(elements, "border-image", hack, {"border-image": border}, "Change", "color-controller");
240 break;
241 case 'color':
242 ElementsMediator.setProperty(elements, "border-image", hackNone, {"border-image": 'none'}, "Change", "color-controller");
243 ElementsMediator.setProperty(elements, "border-color", hack, {"border-color": border}, "Change", "color-controller");
244 break;
245 case 'border':
246 break;
247 }
248 } 193 }
249 } 194 }
250 }, 195 },
@@ -264,8 +209,10 @@ exports.ColorController = Montage.create(Component, {
264 color = {value: null, css: 'none'}; 209 color = {value: null, css: 'none'};
265 } else if (panelMode === 'rgb' && e._event.rgba && mode !== 'gradient') { 210 } else if (panelMode === 'rgb' && e._event.rgba && mode !== 'gradient') {
266 color = e._event.rgba; 211 color = e._event.rgba;
212 color.webGlColor = e._event.webGlColor;
267 } else if (panelMode === 'hsl' && e._event.hsla && mode !== 'gradient') { 213 } else if (panelMode === 'hsl' && e._event.hsla && mode !== 'gradient') {
268 color = e._event.hsla; 214 color = e._event.hsla;
215 color.webGlColor = e._event.webGlColor;
269 } else if (mode !== 'gradient'){ 216 } else if (mode !== 'gradient'){
270 color = {value: e._event.hex, css: '#'+e._event.hex}; 217 color = {value: e._event.hex, css: '#'+e._event.hex};
271 } else if (mode === 'gradient'){ 218 } else if (mode === 'gradient'){
@@ -280,32 +227,14 @@ exports.ColorController = Montage.create(Component, {
280 // 227 //
281 if(e._event.wasSetByCode) return; 228 if(e._event.wasSetByCode) return;
282 // 229 //
283 if (mode === 'nocolor') { 230 this.setColor(mode, color, true);
284 //TODO: Add a check instead of setting properties
285 this.setBackground('image', color.css, false);
286 this.setBackground('color', color.css, false);
287 this.setBackground('background', color.css, false);
288 } else if (mode === 'gradient') {
289 this.setBackground('image', color.css, false);
290 } else {
291 this.setBackground('color', color.css, false);
292 }
293 } else if (input === 'stroke') { 231 } else if (input === 'stroke') {
294 // 232 //
295 this.stroke = color; 233 this.stroke = color;
296 // 234 //
297 if(e._event.wasSetByCode) return; 235 if(e._event.wasSetByCode) return;
298 // 236
299 if (mode === 'nocolor') { 237 this.setColor(mode, color, false);
300 //TODO: Add a check instead of setting properties
301 this.setBorder('image', color.css, false);
302 this.setBorder('color', color.css, false);
303 this.setBorder('border', color.css, false);
304 } else if (mode === 'gradient') {
305 this.setBorder('image', color.css, false);
306 } else {
307 this.setBorder('color', color.css, false);
308 }
309 } 238 }
310 //////////////////////////////////////////////////////////// 239 ////////////////////////////////////////////////////////////