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

@ -229,7 +229,7 @@ class Categorie extends CommonObject
$error=0; $error=0;
dol_syslog(get_class($this).'::create', LOG_DEBUG); dol_syslog(get_class($this).'::create', LOG_DEBUG);
// Clean parameters // Clean parameters
$this->label = trim($this->label); $this->label = trim($this->label);
$this->description = trim($this->description); $this->description = trim($this->description);
@ -405,7 +405,7 @@ class Categorie extends CommonObject
// End call triggers // End call triggers
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
else else
@ -571,12 +571,12 @@ class Categorie extends CommonObject
if ($this->id == -1) return -2; if ($this->id == -1) return -2;
// For backward compatibility // For backward compatibility
if ($type == 'societe') if ($type == 'societe')
{ {
$type = 'customer'; $type = 'customer';
dol_syslog(get_class($this) . "::add_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING); dol_syslog(get_class($this) . "::add_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING);
} }
elseif ($type == 'fournisseur') elseif ($type == 'fournisseur')
{ {
$type = 'supplier'; $type = 'supplier';
dol_syslog(get_class($this) . "::add_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING); dol_syslog(get_class($this) . "::add_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING);
@ -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

@ -653,7 +653,7 @@ div.arearef {
margin-bottom: 10px; margin-bottom: 10px;
} }
div.heightref { div.heightref {
min-height: 80px; min-height: 80px;
} }
div.divphotoref { div.divphotoref {
padding-right: 20px; padding-right: 20px;
@ -1177,8 +1177,8 @@ div.vmenu, td.vmenu {
width: 188px; width: 188px;
} }
.menu_contenu { .menu_contenu {
padding-top: 5px; padding-top: 5px;
padding-bottom: 2px; padding-bottom: 2px;
} }
#menu_contenu_logo { padding-right: 4px; } #menu_contenu_logo { padding-right: 4px; }
@ -1247,7 +1247,7 @@ div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks, div.blockvmen
-moz-box-shadow: 3px 3px 4px #DDD; -moz-box-shadow: 3px 3px 4px #DDD;
-webkit-box-shadow: 3px 3px 4px #DDD; -webkit-box-shadow: 3px 3px 4px #DDD;
box-shadow: 3px 3px 4px #DDD; box-shadow: 3px 3px 4px #DDD;
*/ */
} }
div.blockvmenusearch div.blockvmenusearch
@ -2078,7 +2078,7 @@ table.liste, table.noborder, table.formdoc, div.noborder {
border-bottom-width: 1px; border-bottom-width: 1px;
border-bottom-color: #BBB; border-bottom-color: #BBB;
border-bottom-style: solid; border-bottom-style: solid;
margin: 0px 0px 5px 0px; margin: 0px 0px 5px 0px;
-moz-box-shadow: 2px 2px 4px #CCC; -moz-box-shadow: 2px 2px 4px #CCC;
@ -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;
} }
@ -3772,10 +3772,10 @@ a.ui-link, a.ui-link:hover, .ui-btn:hover, span.ui-btn-text:hover, span.ui-btn-i
} }
select { select {
/* display: inline-block; */ /* We can't set this. This disable ability to make */ /* display: inline-block; */ /* We can't set this. This disable ability to make */
/* TODO added by jmobile, replace jmobile with pure css*/ /* TODO added by jmobile, replace jmobile with pure css*/
overflow:hidden; overflow:hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.fiche .ui-controlgroup { .fiche .ui-controlgroup {
margin: 0px; margin: 0px;
@ -3953,11 +3953,11 @@ border-top-right-radius: 6px;
@media only screen and (max-width: 767px) @media only screen and (max-width: 767px)
{ {
.imgopensurveywizard { width:95%; height: auto; } .imgopensurveywizard { width:95%; height: auto; }
#tooltip { #tooltip {
position: absolute; position: absolute;
width: <?php print dol_size(350,'width'); ?>px; width: <?php print dol_size(350,'width'); ?>px;
} }
} }
@ -3997,14 +3997,14 @@ border-top-right-radius: 6px;
top: 4px; top: 4px;
max-width: 82px; max-width: 82px;
} }
div.mainmenu { div.mainmenu {
min-width: 20px; min-width: 20px;
} }
.topmenuimage { .topmenuimage {
background-size: 20px auto; background-size: 20px auto;
} }
#tooltip { #tooltip {
position: absolute; position: absolute;
width: <?php print dol_size(300,'width'); ?>px; width: <?php print dol_size(300,'width'); ?>px;