Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.8
-
None
-
None
-
Normal
-
Patch available
Description
In cocoon.ajax.Fader
this.toColor = cocoon.ajax.Fader.colorToRgb(cocoon.ajax.Fader.getBgColor(this.element));
getBgColor will return '#fff'
/** Converts a "#RRGGBB" color as an array of 3 ints */
cocoon.ajax.Fader.colorToRgb = function(hex) {
return [
parseInt(hex.substr(1,2),16),
parseInt(hex.substr(3,2),16),
parseInt(hex.substr(5,2),16) ];
}
Assumes that hex starts with a '#' and has 6 additional hex characters.
The corrected implementation is
/** Converts a "#RRGGBB" color as an array of 3 ints */
cocoon.ajax.Fader.colorToRgb = function(hex) {
var r = 255; // defaults if no match
var g = 255;
var b = 255;
var i=-1;
var colors = hex.match(/^#(\d{2})(\d{2})(\d{2})$/);
if (colors) {
r = parseInt(colors[++i]);
g = parseInt(colors[++i]);
b = parseInt(colors[++i]);
} else if (colors = hex.match(/^#(\d)(\d)(\d)$/)) {
r = parseInt(colors[++i] + colors[i]);
g = parseInt(colors[++i] + colors[i]);
b = parseInt(colors[++i] + colors[i]);
}
return [r,g,b];
}
Patch attached.
Regards,
Eric Meyer, VP, Quoin, Inc.
this.toColor = cocoon.ajax.Fader.colorToRgb(cocoon.ajax.Fader.getBgColor(this.element));
getBgColor will return '#fff'
/** Converts a "#RRGGBB" color as an array of 3 ints */
cocoon.ajax.Fader.colorToRgb = function(hex) {
return [
parseInt(hex.substr(1,2),16),
parseInt(hex.substr(3,2),16),
parseInt(hex.substr(5,2),16) ];
}
Assumes that hex starts with a '#' and has 6 additional hex characters.
The corrected implementation is
/** Converts a "#RRGGBB" color as an array of 3 ints */
cocoon.ajax.Fader.colorToRgb = function(hex) {
var r = 255; // defaults if no match
var g = 255;
var b = 255;
var i=-1;
var colors = hex.match(/^#(\d{2})(\d{2})(\d{2})$/);
if (colors) {
r = parseInt(colors[++i]);
g = parseInt(colors[++i]);
b = parseInt(colors[++i]);
} else if (colors = hex.match(/^#(\d)(\d)(\d)$/)) {
r = parseInt(colors[++i] + colors[i]);
g = parseInt(colors[++i] + colors[i]);
b = parseInt(colors[++i] + colors[i]);
}
return [r,g,b];
}
Patch attached.
Regards,
Eric Meyer, VP, Quoin, Inc.