/* returns the style reference for a given css rule */
function getStyle (cssrule) {
for (var i in document.styleSheets) {
var styleRules = (document.styleSheets[i].rules) ? document.styleSheets[i].rules :
(document.styleSheets[i].cssRules) ? document.styleSheets[i].cssRules : [];
for (var j=0; j
if (styleRules[j].selectorText.toUpperCase() == cssrule.toUpperCase()) {
return styleRules[j];
}
}
}
return null;
}
/* Applies the skin from the Open Social container */
function updateCSS() {
var bgColor = gadgets.skins.getProperty(gadgets.skins.Property.BG_COLOR);
var fontColor = gadgets.skins.getProperty(gadgets.skins.Property.FONT_COLOR);
var anchorColor = gadgets.skins.getProperty(gadgets.skins.Property.ANCHOR_COLOR);
var hexAnchorColor = convertToHex(anchorColor);
var gadgetNingLinks = getStyle('.xg_sprite');
var gadgetStyle = getStyle('.gadget');
var gadgetLinks = getStyle('.gadget a');
var gadgetButtons = getStyle('input.button');
gadgetStyle.style.color = fontColor;
gadgetStyle.style.backgroundColor = bgColor;
gadgetLinks.style.color = anchorColor;
gadgetButtons.style.backgroundColor = anchorColor;
}
摘自[url]http://developer.ning.com/forum/topics/inheriting-network-csstheme-in?commentId=1185512:Comment:254131[/url]