diff options
author | Ananya Sen | 2012-06-28 15:19:28 -0700 |
---|---|---|
committer | Ananya Sen | 2012-06-28 15:19:28 -0700 |
commit | 624acffc0619d879deaa6dcd8ce3c0cfeaf2227a (patch) | |
tree | ca53a666a93f9bed8912a5c3211ba84fc603c58f /js/controllers/color-controller.js | |
parent | e4d3e040e521648ec9a6d0e0db2e62754f2d8882 (diff) | |
parent | 3ba9accb8e1887bfd6f1f912b6135073a3d9c70c (diff) | |
download | ninja-624acffc0619d879deaa6dcd8ce3c0cfeaf2227a.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into bugfix-master
Diffstat (limited to 'js/controllers/color-controller.js')
-rwxr-xr-x | js/controllers/color-controller.js | 17 |
1 files changed, 14 insertions, 3 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'); |