refactor setAuthorStyle

This commit is contained in:
Chia-liang Kao 2013-06-06 12:30:48 +08:00
parent cd277e5810
commit eae9faa28c

View file

@ -208,27 +208,21 @@ function Ace2Inner(){
};
editorInfo.ace_getAuthorInfos= getAuthorInfos;
function setAuthorInfo(author, info)
function setAuthorStyle(author, info)
{
if ((typeof author) != "string")
{
throw new Error("setAuthorInfo: author (" + author + ") is not a string");
if (!dynamicCSS) {
return;
}
var authorSelector = getAuthorColorClassSelector(getAuthorClassName(author));
if (!info)
{
delete authorInfos[author];
if (dynamicCSS)
{
dynamicCSS.removeSelectorStyle(getAuthorColorClassSelector(getAuthorClassName(author)));
parentDynamicCSS.removeSelectorStyle(getAuthorColorClassSelector(getAuthorClassName(author)));
}
dynamicCSS.removeSelectorStyle(authorSelector);
parentDynamicCSS.removeSelectorStyle(authorSelector);
}
else
{
authorInfos[author] = info;
if (info.bgcolor)
{
if (dynamicCSS)
{
var bgcolor = info.bgcolor;
if ((typeof info.fade) == "number")
@ -236,12 +230,9 @@ function Ace2Inner(){
bgcolor = fadeColor(bgcolor, info.fade);
}
var authorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector(
getAuthorClassName(author)));
var parentAuthorStyle = parentDynamicCSS.selectorStyle(getAuthorColorClassSelector(
getAuthorClassName(author)));
var anchorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector(
getAuthorClassName(author))+' > a')
var authorStyle = dynamicCSS.selectorStyle(authorSelector);
var parentAuthorStyle = parentDynamicCSS.selectorStyle(authorSelector);
var anchorStyle = dynamicCSS.selectorStyle(authorSelector + ' > a')
// author color
authorStyle.backgroundColor = bgcolor;
@ -267,6 +258,22 @@ function Ace2Inner(){
}
}
}
function setAuthorInfo(author, info)
{
if ((typeof author) != "string")
{
throw new Error("setAuthorInfo: author (" + author + ") is not a string");
}
if (!info)
{
delete authorInfos[author];
}
else
{
authorInfos[author] = info;
}
setAuthorStyle(author, info);
}
function getAuthorClassName(author)