(fix) JS exception when printing calendars

Fixes #3203
This commit is contained in:
Francis Lachapelle
2015-11-19 09:22:31 -05:00
parent 7015713741
commit 85ce41dc68
2 changed files with 28 additions and 9 deletions
+13
View File
@@ -1,3 +1,16 @@
2.3.4 (YYYY-MM-DD)
------------------
New features
-
Enhancements
-
Bug fixes
- JavaScript exception when printing events from calendars with no assigned color (#3203)
2.3.3a (2015-11-18)
-------------------
+15 -9
View File
@@ -440,17 +440,23 @@ function onAjaxRequestStateChange(http) {
/* taken from Lightning */
function getContrastingTextColor(bgColor) {
var calcColor = bgColor.substring(1);
var red = parseInt(calcColor.substring(0, 2), 16);
var green = parseInt(calcColor.substring(2, 4), 16);
var blue = parseInt(calcColor.substring(4, 6), 16);
var textColor = "black";
if (bgColor) {
var calcColor = bgColor.substring(1);
var red = parseInt(calcColor.substring(0, 2), 16);
var green = parseInt(calcColor.substring(2, 4), 16);
var blue = parseInt(calcColor.substring(4, 6), 16);
// Calculate the brightness (Y) value using the YUV color system.
var brightness = (0.299 * red) + (0.587 * green) + (0.114 * blue);
// Calculate the brightness (Y) value using the YUV color system.
var brightness = (0.299 * red) + (0.587 * green) + (0.114 * blue);
// Consider all colors with less than 56% brightness as dark colors and
// use white as the foreground color, otherwise use black.
return ((brightness < 144) ? "white" : "black");
// Consider all colors with less than 56% brightness as dark colors and
// use white as the foreground color, otherwise use black.
if (brightness < 144)
textColor = "white";
}
return textColor;
}
function triggerAjaxRequest(url, callback, userdata, content, headers, attempt) {