badges.inc.php 8.1 KB

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