Fix dynamic CSS in IE8
When adding a calendar or subscribing to a calendar, the dynamic CSS was not properly applied in IE8. This new technique seems to fix all cases.
This commit is contained in:
parent
128368f66c
commit
99669f2d5c
|
@ -3096,21 +3096,15 @@ function appendStyleElement(folderPath, color) {
|
||||||
var fgColor = getContrastingTextColor(color);
|
var fgColor = getContrastingTextColor(color);
|
||||||
var styleElement = document.createElement("style");
|
var styleElement = document.createElement("style");
|
||||||
styleElement.type = "text/css";
|
styleElement.type = "text/css";
|
||||||
var selectors = [
|
|
||||||
'DIV.calendarFolder' + folderPath.substr(1),
|
var styles = ' .calendarFolder' + folderPath.substr(1)
|
||||||
'LI.calendarFolder' + folderPath.substr(1),
|
+ ' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }'
|
||||||
'UL#calendarList DIV.calendarFolder' + folderPath.substr(1)
|
+ ' div.colorBox.calendarFolder' + folderPath.substr(1)
|
||||||
];
|
+ ' { color: ' + color + ' !important; }';
|
||||||
var rules = [
|
|
||||||
' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }',
|
if (styleElement.styleSheet) styleElement.styleSheet.cssText = styles; // IE
|
||||||
' { background-color: ' + color + ' !important;' + ' color: ' + fgColor + ' !important; }',
|
else styleElement.appendChild(document.createTextNode(styles)); // Mozilla + Webkit
|
||||||
' { color: ' + color + ' !important; }'
|
|
||||||
];
|
|
||||||
for (var i = 0; i < rules.length; i++)
|
|
||||||
if (styleElement.styleSheet && styleElement.styleSheet.addRule)
|
|
||||||
styleElement.styleSheet.addRule(selectors[i], rules[i]); // IE
|
|
||||||
else
|
|
||||||
styleElement.appendChild(document.createTextNode(selectors[i] + rules[i])); // Mozilla + Safari
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
document.getElementsByTagName("head")[0].appendChild(styleElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue