diff --git a/mozilla/calendar/base/content/calendar-multiday-view.css b/mozilla/calendar/base/content/calendar-multiday-view.css index e1e22726bf3..ddfdff9d6d0 100644 --- a/mozilla/calendar/base/content/calendar-multiday-view.css +++ b/mozilla/calendar/base/content/calendar-multiday-view.css @@ -70,7 +70,6 @@ calendar-event-box { } .calendar-event-box-container { - background: #4e84c2; padding: 2px; overflow: hidden; } diff --git a/mozilla/calendar/lightning/content/calendar-management.js b/mozilla/calendar/lightning/content/calendar-management.js index 12af18734a5..a4dc443a3db 100644 --- a/mozilla/calendar/lightning/content/calendar-management.js +++ b/mozilla/calendar/lightning/content/calendar-management.js @@ -38,10 +38,12 @@ function updateStyleSheetForCalendar(aCalendar) } var color = getCalendarManager().getCalendarPref(aCalendar, 'color'); + // This color looks nice with the gripbars, etc. if (!color) - color = "black"; + color = "#4e84c2"; - rule.style.color = color; + rule.style.backgroundColor = color; + rule.style.color = getContrastingTextColor(color); } function addCalendarToTree(aCalendar) diff --git a/mozilla/calendar/resources/content/calendar.js b/mozilla/calendar/resources/content/calendar.js index cbc97296b88..b24731d0b33 100644 --- a/mozilla/calendar/resources/content/calendar.js +++ b/mozilla/calendar/resources/content/calendar.js @@ -1249,37 +1249,6 @@ function CalendarToolboxCustomizeDone(aToolboxChanged) window.focus(); } -/** - * Pick whichever of "black" or "white" will look better when used as a text - * color against a background of bgColor. - * - * @param bgColor the background color as a "#RRGGBB" string - */ -function getContrastingTextColor(bgColor) -{ - var calcColor = bgColor.replace(/#/g, ""); - 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 L(ightness) value of the HSL color system. - // L = (max(R, G, B) + min(R, G, B)) / 2 - var max = Math.max(Math.max(red, green), blue); - var min = Math.min(Math.min(red, green), blue); - var lightness = (max + min) / 2; - - // Consider all colors with less than 50% Lightness as dark colors - // and use white as the foreground color; otherwise use black. - // Actually we use a threshold a bit below 50%, so colors like - // #FF0000, #00FF00 and #0000FF still get black text which looked - // better when we tested this. - if (lightness < 120) { - return "white"; - } - - return "black"; -} - var gTransactionMgr = Components.classes["@mozilla.org/transactionmanager;1"] .createInstance(Components.interfaces.nsITransactionManager); function doTransaction(aAction, aItem, aCalendar, aOldItem, aListener) { diff --git a/mozilla/calendar/resources/content/calendarUtils.js b/mozilla/calendar/resources/content/calendarUtils.js index 7551a335205..ac219428658 100644 --- a/mozilla/calendar/resources/content/calendarUtils.js +++ b/mozilla/calendar/resources/content/calendarUtils.js @@ -321,3 +321,34 @@ function guessSystemTimezone() // Everything failed, so this is our only option. return "floating"; } + +/** + * Pick whichever of "black" or "white" will look better when used as a text + * color against a background of bgColor. + * + * @param bgColor the background color as a "#RRGGBB" string + */ +function getContrastingTextColor(bgColor) +{ + var calcColor = bgColor.replace(/#/g, ""); + 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 L(ightness) value of the HSL color system. + // L = (max(R, G, B) + min(R, G, B)) / 2 + var max = Math.max(Math.max(red, green), blue); + var min = Math.min(Math.min(red, green), blue); + var lightness = (max + min) / 2; + + // Consider all colors with less than 50% Lightness as dark colors + // and use white as the foreground color; otherwise use black. + // Actually we use a threshold a bit below 50%, so colors like + // #FF0000, #00FF00 and #0000FF still get black text which looked + // better when we tested this. + if (lightness < 120) { + return "white"; + } + + return "black"; +}