Fix regression (class not found, css on hover broken) with try to manage
contrast on categories.
This commit is contained in:
parent
6c7fc55988
commit
d8e173af03
@ -1349,6 +1349,7 @@ class Categorie extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return name and link of category (with picto)
|
* Return name and link of category (with picto)
|
||||||
|
* Use ->id, ->ref, ->label, ->color
|
||||||
*
|
*
|
||||||
* @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')
|
||||||
@ -1363,13 +1364,18 @@ class Categorie extends CommonObject
|
|||||||
$label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label);
|
$label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label);
|
||||||
|
|
||||||
// Check contrast with background and correct text color
|
// Check contrast with background and correct text color
|
||||||
$color = colorArrayToHex(colorStringToArray($this->color,array()),'');
|
$forced_color='categtextwhite';
|
||||||
$forced_color='000';
|
if ($this->color)
|
||||||
$tmpcolorweight=0;
|
{
|
||||||
foreach(colorStringToArray($color,array()) as $x) $tmpcolorweight+=$x;
|
$hex=$this->color;
|
||||||
if ($tmpcolorweight < 400) $forced_color='FFF';
|
$r = hexdec($hex[0].$hex[1]);
|
||||||
|
$g = hexdec($hex[2].$hex[3]);
|
||||||
|
$b = hexdec($hex[4].$hex[5]);
|
||||||
|
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
|
||||||
|
if ($bright > 0.6) $forced_color='categtextblack'; // Higher than 60%
|
||||||
|
}
|
||||||
|
|
||||||
$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.'"' : '' ) .'>';
|
$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 .'">';
|
||||||
$linkend='</a>';
|
$linkend='</a>';
|
||||||
|
|
||||||
$picto='category';
|
$picto='category';
|
||||||
|
|||||||
@ -595,13 +595,20 @@ class FormOther
|
|||||||
*/
|
*/
|
||||||
static function showColor($color, $textifnotdefined='')
|
static function showColor($color, $textifnotdefined='')
|
||||||
{
|
{
|
||||||
|
$textcolor='FFF';
|
||||||
|
if ($color)
|
||||||
|
{
|
||||||
|
$hex=$color;
|
||||||
|
$r = hexdec($hex[0].$hex[1]);
|
||||||
|
$g = hexdec($hex[2].$hex[3]);
|
||||||
|
$b = hexdec($hex[4].$hex[5]);
|
||||||
|
$bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
|
||||||
|
if ($bright > 0.6) $textcolor='000';
|
||||||
|
}
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
|
||||||
$color = colorArrayToHex(colorStringToArray($color,array()),'');
|
$color = colorArrayToHex(colorStringToArray($color,array()),'');
|
||||||
$textcolor='000';
|
|
||||||
$tmpcolorweight=0;
|
|
||||||
foreach(colorStringToArray($color,array()) as $x) $tmpcolorweight+=$x;
|
|
||||||
if ($tmpcolorweight < 400) $textcolor='FFF';
|
|
||||||
if ($color) print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">';
|
if ($color) print '<input type="text" class="colorthumb" disabled style="padding: 1px; margin-top: 0; margin-bottom: 0; color: #'.$textcolor.'; background-color: #'.$color.'" value="'.$color.'">';
|
||||||
else print $textifnotdefined;
|
else print $textifnotdefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3655,22 +3655,31 @@ a span.select2-chosen
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================================== */
|
||||||
|
/* For categories */
|
||||||
|
/* ============================================================================== */
|
||||||
|
|
||||||
.noborderoncategories {
|
.noborderoncategories {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
border-radius: 5px !important;
|
border-radius: 5px !important;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
span.noborderoncategories a, li.noborderoncategories a {
|
span.noborderoncategories a, li.noborderoncategories a {
|
||||||
color: #fff;
|
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
span.noborderoncategories {
|
span.noborderoncategories {
|
||||||
padding: 3px 5px 0px 5px;
|
padding: 3px 5px 0px 5px;
|
||||||
}
|
}
|
||||||
|
.categtextwhite, .treeview .categtextwhite.hover {
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
.categtextblack {
|
||||||
|
color: #000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ============================================================================== */
|
/* ============================================================================== */
|
||||||
|
|||||||
@ -2789,6 +2789,14 @@ table.dp {
|
|||||||
color: rgb(<?php print $colortextlink; ?>);
|
color: rgb(<?php print $colortextlink; ?>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.categtextwhite, .treeview .categtextwhite.hover {
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
.categtextblack {
|
||||||
|
color: #000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ============================================================================== */
|
/* ============================================================================== */
|
||||||
/* Afficher/cacher */
|
/* Afficher/cacher */
|
||||||
/* ============================================================================== */
|
/* ============================================================================== */
|
||||||
@ -3498,22 +3506,30 @@ a span.select2-chosen
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================================== */
|
||||||
|
/* For categories */
|
||||||
|
/* ============================================================================== */
|
||||||
|
|
||||||
.noborderoncategories {
|
.noborderoncategories {
|
||||||
border: none !important;
|
border: none !important;
|
||||||
border-radius: 5px !important;
|
border-radius: 5px !important;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
span.noborderoncategories a, li.noborderoncategories a {
|
span.noborderoncategories a, li.noborderoncategories a {
|
||||||
color: #fff !important;
|
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
}
|
}
|
||||||
span.noborderoncategories {
|
span.noborderoncategories {
|
||||||
padding: 5px 5px 0px 5px;
|
padding: 5px 5px 0px 5px;
|
||||||
}
|
}
|
||||||
|
.categtextwhite, .treeview .categtextwhite.hover {
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
.categtextblack {
|
||||||
|
color: #000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ============================================================================== */
|
/* ============================================================================== */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user