FIX : check contrast of link when using background color for category

This commit is contained in:
jfefe 2016-02-16 12:45:18 +01:00
parent 816195cb43
commit 134c9d13bc
3 changed files with 27 additions and 20 deletions

View File

@ -1353,16 +1353,17 @@ class Categorie extends CommonObject
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option Sur quoi pointe le lien ('', 'xyz') * @param string $option Sur quoi pointe le lien ('', 'xyz')
* @param int $maxlength Max length of text * @param int $maxlength Max length of text
* @param string $forced_color Hexadecimal code to force link color
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */
function getNomUrl($withpicto=0,$option='',$maxlength=0) function getNomUrl($withpicto=0,$option='',$maxlength=0, $forced_color='')
{ {
global $langs; global $langs;
$result=''; $result='';
$label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label); $label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label);
$link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip"' . ( $forced_color ? ' style="color: #'.$forced_color.'"' : '' ) .'>';
$linkend='</a>'; $linkend='</a>';
$picto='category'; $picto='category';

View File

@ -148,7 +148,13 @@ foreach($fulltree as $key => $val)
$categstatic->ref=$val['label']; $categstatic->ref=$val['label'];
$categstatic->color=$val['color']; $categstatic->color=$val['color'];
$categstatic->type=$type; $categstatic->type=$type;
$li=$categstatic->getNomUrl(1,'',60); // Check contrast with background and correct text color
$color = colorArrayToHex(colorStringToArray($categstatic->color,array()),'');
$textcolor='000';
$tmpcolorweight=0;
foreach(colorStringToArray($color,array()) as $x) $tmpcolorweight+=$x;
if ($tmpcolorweight < 400) $textcolor='FFF';
$li=$categstatic->getNomUrl(1,'',60, $textcolor);
$desc=dol_htmlcleanlastbr($val['description']); $desc=dol_htmlcleanlastbr($val['description']);
$data[] = array( $data[] = array(

View File

@ -3661,10 +3661,10 @@ a span.select2-chosen
box-shadow: none; box-shadow: none;
-webkit-box-shadow: none !important; -webkit-box-shadow: none !important;
box-shadow: none !important; box-shadow: none !important;
color: #fff !important; color: #fff;
} }
span.noborderoncategories a, li.noborderoncategories a { span.noborderoncategories a, li.noborderoncategories a {
color: #fff !important; color: #fff;
line-height: normal; line-height: normal;
vertical-align: top; vertical-align: top;
} }