Merge pull request #1249 from leblanc-simon/develop

Fix author colors in chat
This commit is contained in:
Marcel Klehr 2012-12-07 05:59:28 -08:00
commit 45b1e3eacb
2 changed files with 12 additions and 3 deletions

View file

@ -166,10 +166,12 @@ function Ace2Inner(){
} }
var dynamicCSS = null; var dynamicCSS = null;
var parentDynamicCSS = null;
function initDynamicCSS() function initDynamicCSS()
{ {
dynamicCSS = makeCSSManager("dynamicsyntax"); dynamicCSS = makeCSSManager("dynamicsyntax");
parentDynamicCSS = makeCSSManager("dynamicsyntax", true);
} }
var changesetTracker = makeChangesetTracker(scheduler, rep.apool, { var changesetTracker = makeChangesetTracker(scheduler, rep.apool, {
@ -217,6 +219,7 @@ function Ace2Inner(){
if (dynamicCSS) if (dynamicCSS)
{ {
dynamicCSS.removeSelectorStyle(getAuthorColorClassSelector(getAuthorClassName(author))); dynamicCSS.removeSelectorStyle(getAuthorColorClassSelector(getAuthorClassName(author)));
parentDynamicCSS.removeSelectorStyle(getAuthorColorClassSelector(getAuthorClassName(author)));
} }
} }
else else
@ -234,18 +237,23 @@ function Ace2Inner(){
var authorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector( var authorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector(
getAuthorClassName(author))); getAuthorClassName(author)));
var parentAuthorStyle = parentDynamicCSS.selectorStyle(getAuthorColorClassSelector(
getAuthorClassName(author)));
var anchorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector( var anchorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector(
getAuthorClassName(author))+' > a') getAuthorClassName(author))+' > a')
// author color // author color
authorStyle.backgroundColor = bgcolor; authorStyle.backgroundColor = bgcolor;
parentAuthorStyle.backgroundColor = bgcolor;
// text contrast // text contrast
if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5) if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5)
{ {
authorStyle.color = '#ffffff'; authorStyle.color = '#ffffff';
parentAuthorStyle.color = '#ffffff';
}else{ }else{
authorStyle.color = null; authorStyle.color = null;
parentAuthorStyle.color = null;
} }
// anchor text contrast // anchor text contrast

View file

@ -20,12 +20,13 @@
* limitations under the License. * limitations under the License.
*/ */
function makeCSSManager(emptyStylesheetTitle) function makeCSSManager(emptyStylesheetTitle, parentCss)
{ {
function getSheetByTitle(title) function getSheetByTitle(title)
{ {
var allSheets = document.styleSheets; if (parentCss) var allSheets = window.parent.parent.document.styleSheets;
else var allSheets = document.styleSheets;
for (var i = 0; i < allSheets.length; i++) for (var i = 0; i < allSheets.length; i++)
{ {
@ -38,7 +39,7 @@ function makeCSSManager(emptyStylesheetTitle)
return null; return null;
} }
var browserSheet = getSheetByTitle(emptyStylesheetTitle); var browserSheet = getSheetByTitle(emptyStylesheetTitle, parentCss);
function browserRules() function browserRules()
{ {