From f5f82a76375bb07366f9246e15d565224e84af72 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Wed, 29 Feb 2012 14:21:35 +0100 Subject: [PATCH] Rework dynamic text contrast -Remove hard coding of default text color -add dynamic link text contrast --- static/js/ace2_inner.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/static/js/ace2_inner.js b/static/js/ace2_inner.js index 71f7d20f8bf..17d02036ff5 100644 --- a/static/js/ace2_inner.js +++ b/static/js/ace2_inner.js @@ -229,18 +229,34 @@ function Ace2Inner(){ bgcolor = fadeColor(bgcolor, info.fade); } - // Text color - var txtcolor = (colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5) ? '#ffffff' : '#000000'; - var authorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector( getAuthorClassName(author))); - authorStyle.backgroundColor = bgcolor; - authorStyle.color = txtcolor; - var authorStyleTop = dynamicCSSTop.selectorStyle(getAuthorColorClassSelector( getAuthorClassName(author))); + var anchorStyle = dynamicCSS.selectorStyle(getAuthorColorClassSelector( + getAuthorClassName(author))+' > a') + + // author color + authorStyle.backgroundColor = bgcolor; authorStyleTop.backgroundColor = bgcolor; - authorStyleTop.color = txtcolor; + + // text contrast + if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.5) + { + authorStyle.color = '#ffffff'; + authorStyleTop.color = '#ffffff'; + }else{ + authorStyle.color = null; + authorStyleTop.color = null; + } + + // anchor text contrast + if(colorutils.luminosity(colorutils.css2triple(bgcolor)) < 0.55) + { + anchorStyle.color = colorutils.triple2css(colorutils.complementary(colorutils.css2triple(bgcolor))); + }else{ + anchorStyle.color = null; + } } } }