dolibarr  16.0.5
badges.inc.php
1 <?php
2 if (!defined('ISLOADEDBYSTEELSHEET')) {
3  die('Must be call by steelsheet');
4 }
5 ?>
6 /* <style type="text/css" > */
7 /*
8  Badge style is based on boostrap framework
9  */
10 
11 .badge {
12  display: inline-block;
13  padding: .1em .35em;
14  font-size: 80%;
15  font-weight: 700 !important;
16  line-height: 1;
17  text-align: center;
18  white-space: nowrap;
19  vertical-align: baseline;
20  border-radius: .25rem;
21  transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
22  border-width: 2px;
23  border-style: solid;
24  border-color: rgba(255,255,255,0);
25  box-sizing: border-box;
26 }
27 
28 .badge-status {
29  font-size: 1em;
30  padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */
31 }
32 .tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status {
33  font-size: 1.1em;
34  padding: .4em .4em;
35 }
36 /* Force values for small screen 767 */
37 @media only screen and (max-width: 767px)
38 {
39  .tabBar .arearef .statusref .badge-status, .tabBar .arearefnobottom .statusref .badge-status {
40  font-size: 0.95em;
41  padding: .3em .2em;
42  }
43 }
44 
45 .badge-pill, .tabs .badge {
46  padding-right: .5em;
47  padding-left: .5em;
48  border-radius: 0.25rem;
49 }
50 
51 .badge-dot {
52  padding: 0;
53  border-radius: 50%;
54  padding: 0.45em;
55  vertical-align: unset;
56 }
57 
58 a.badge:focus, a.badge:hover {
59  text-decoration: none;
60 }
61 
62 .liste_titre .badge:not(.nochangebackground) {
63  background-color: <?php print $badgeSecondary; ?>;
64  color: #fff;
65 }
66 
67 span.badgeneutral {
68  padding: 2px 7px 2px 7px;
69  background-color: #e4e4e4;
70  color: #666;
71  border-radius: 10px;
72 }
73 
74 
75 /* PRIMARY */
76 .badge-primary{
77  color: #fff !important;
78  background-color: <?php print $badgePrimary; ?>;
79 }
80 a.badge-primary.focus, a.badge-primary:focus {
81  outline: 0;
82  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgePrimary, 0.5); ?>;
83 }
84 a.badge-primary:focus, a.badge-primary:hover {
85  color: #fff !important;
86  background-color: <?php print colorDarker($badgePrimary, 10); ?>;
87 }
88 
89 /* SECONDARY */
90 .badge-secondary, .tabs .badge {
91  color: #fff !important;
92  background-color: <?php print $badgeSecondary; ?>;
93 }
94 a.badge-secondary.focus, a.badge-secondary:focus {
95  outline: 0;
96  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSecondary, 0.5); ?>;
97 }
98 a.badge-secondary:focus, a.badge-secondary:hover {
99  color: #fff !important;
100  background-color: <?php print colorDarker($badgeSecondary, 10); ?>;
101 }
102 
103 /* SUCCESS */
104 .badge-success {
105  color: #fff !important;
106  background-color: <?php print $badgeSuccess; ?>;
107 }
108 a.badge-success.focus, a.badge-success:focus {
109  outline: 0;
110  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeSuccess, 0.5); ?>;
111 }
112 a.badge-success:focus, a.badge-success:hover {
113  color: #fff !important;
114  background-color: <?php print colorDarker($badgeSuccess, 10); ?>;
115 }
116 
117 /* DANGER */
118 .badge-danger {
119  color: #fff !important;
120  background-color: <?php print $badgeDanger; ?>;
121 }
122 a.badge-danger.focus, a.badge-danger:focus {
123  outline: 0;
124  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDanger, 0.5); ?>;
125 }
126 a.badge-danger:focus, a.badge-danger:hover {
127  color: #fff !important;
128  background-color: <?php print colorDarker($badgeDanger, 10); ?>;
129 }
130 
131 /* WARNING */
132 .badge-warning {
133  color: #fff !important;
134  background-color: <?php print $badgeWarning; ?>;
135 }
136 a.badge-warning.focus, a.badge-warning:focus {
137  outline: 0;
138  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeWarning, 0.5); ?>;
139 }
140 a.badge-warning:focus, a.badge-warning:hover {
141  color: #212529 !important;
142  background-color: <?php print colorDarker($badgeWarning, 10); ?>;
143 }
144 
145 /* WARNING colorblind */
146 body[class*="colorblind-"] .badge-warning {
147  background-color: <?php print $colorblind_deuteranopes_badgeWarning; ?>;
148  }
149 body[class*="colorblind-"] a.badge-warning.focus,body[class^="colorblind-"] a.badge-warning:focus {
150  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($colorblind_deuteranopes_badgeWarning, 0.5); ?>;
151 }
152 body[class*="colorblind-"] a.badge-warning:focus, a.badge-warning:hover {
153  background-color: <?php print colorDarker($colorblind_deuteranopes_badgeWarning, 10); ?>;
154 }
155 
156 /* INFO */
157 .badge-info {
158  color: #fff !important;
159  background-color: <?php print $badgeInfo; ?>;
160 }
161 a.badge-info.focus, a.badge-info:focus {
162  outline: 0;
163  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeInfo, 0.5); ?>;
164 }
165 a.badge-info:focus, a.badge-info:hover {
166  color: #fff !important;
167  background-color: <?php print colorDarker($badgeInfo, 10); ?>;
168 }
169 
170 /* LIGHT */
171 .badge-light {
172  color: #212529 !important;
173  background-color: <?php print $badgeLight; ?>;
174 }
175 a.badge-light.focus, a.badge-light:focus {
176  outline: 0;
177  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeLight, 0.5); ?>;
178 }
179 a.badge-light:focus, a.badge-light:hover {
180  color: #212529 !important;
181  background-color: <?php print colorDarker($badgeLight, 10); ?>;
182 }
183 
184 /* DARK */
185 .badge-dark {
186  color: #fff !important;
187  background-color: <?php print $badgeDark; ?>;
188 }
189 a.badge-dark.focus, a.badge-dark:focus {
190  outline: 0;
191  box-shadow: 0 0 0 0.2rem <?php print colorHexToRgb($badgeDark, 0.5); ?>;
192 }
193 a.badge-dark:focus, a.badge-dark:hover {
194  color: #fff !important;
195  background-color: <?php print colorDarker($badgeDark, 10); ?>;
196 }
197 
198 
199 @media only screen and (max-width: 570px)
200 {
201  span.badge.badge-status {
202  overflow: hidden;
203  max-width: 130px;
204  text-overflow: ellipsis;
205  }
206 }
207 
208 
209 /* STATUS BADGES */
210 <?php
211 for ($i = 0; $i <= 10; $i++) {
212  /* Default Status */
213  _createStatusBadgeCss($i, '', "STATUS".$i);
214 
215  // create status for accessibility
216  _createStatusBadgeCss($i, 'colorblind_deuteranopes_', "COLORBLIND STATUS".$i, 'body[class*="colorblind-"] ');
217 }
218 
219 _createStatusBadgeCss('1b', '', "STATUS1b");
220 _createStatusBadgeCss('4b', '', "STATUS4b");
221 
231 function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentLabel = '', $cssPrefix = '')
232 {
233 
234  global ${$statusVarNamePrefix.'badgeStatus'.$statusName}, ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
235 
236  if (!empty(${$statusVarNamePrefix.'badgeStatus'.$statusName})) {
237  print "\n/* ".strtoupper($commentLabel)." */\n";
238 
239  $thisBadgeBackgroundColor = $thisBadgeBorderColor = ${$statusVarNamePrefix.'badgeStatus'.$statusName};
240 
241 
242  $TBadgeBorderOnly = array('0', '1b', '3', '4b', '5', '7', '10');
243  $thisBadgeTextColor = colorIsLight(${$statusVarNamePrefix.'badgeStatus'.$statusName}) ? '#212529' : '#ffffff';
244 
245  if (!empty(${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName})) {
246  $thisBadgeTextColor = ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
247  }
248 
249  if (in_array((string) $statusName, $TBadgeBorderOnly)) {
250  $thisBadgeTextColor = '#212529';
251  $thisBadgeBackgroundColor = "#fff";
252  }
253 
254  if (in_array((string) $statusName, array('0', '5', '9'))) {
255  $thisBadgeTextColor = '#999999';
256  }
257  if (in_array((string) $statusName, array('6'))) {
258  $thisBadgeTextColor = '#777777';
259  }
260 
261  print $cssPrefix.".badge-status".$statusName." {\n";
262  print " color: ".$thisBadgeTextColor." !important;\n";
263  if (in_array((string) $statusName, $TBadgeBorderOnly)) {
264  print " border-color: ".$thisBadgeBorderColor." !important;\n";
265  }
266  print " background-color: ".$thisBadgeBackgroundColor." !important;\n";
267  print "}\n";
268 
269  print $cssPrefix.".font-status".$statusName." {\n";
270  print " color: ".$thisBadgeBackgroundColor." !important;\n";
271  print "}\n";
272 
273  print $cssPrefix.".badge-status".$statusName.".focus, ".$cssPrefix.".badge-status".$statusName.":focus {\n";
274  print " outline: 0;\n";
275  print " box-shadow: 0 0 0 0.2rem ".colorHexToRgb($thisBadgeBackgroundColor, 0.5)." !important;\n";
276  print "}\n";
277 
278  print $cssPrefix.".badge-status".$statusName.":focus, ".$cssPrefix.".badge-status".$statusName.":hover {\n";
279  print " color: ".$thisBadgeTextColor." !important;\n";
280  //print " background-color: ".colorDarker($thisBadgeBackgroundColor, 10).";\n";
281  if (in_array((string) $statusName, $TBadgeBorderOnly)) {
282  print " border-color: ".colorDarker($thisBadgeBorderColor, 10)." !important;\n";
283  }
284  print "}\n";
285  }
286 }
287 
colorDarker
colorDarker($hex, $percent)
Definition: functions2.lib.php:2531
colorHexToRgb
colorHexToRgb($hex, $alpha=false, $returnArray=false)
Definition: functions2.lib.php:2555
colorIsLight
colorIsLight($stringcolor)
Return true if the color is light.
Definition: functions.lib.php:10182