Add param forcenowrap on tooltip function

This commit is contained in:
Laurent Destailleur 2017-11-19 12:41:37 +01:00
parent 47afe470eb
commit 4938a0ba2a
2 changed files with 9 additions and 7 deletions

View File

@ -708,8 +708,8 @@ if ($resql)
{ {
if (! empty($tabhelp[$id][$value])) if (! empty($tabhelp[$id][$value]))
{ {
if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value); // Tooltip on hover if (in_array($value, array('topic'))) $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltip'.$value); // Tooltip on click
else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2); // Tooltip on hover else $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', 1); // Tooltip on hover
} }
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder); print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
} }

View File

@ -410,12 +410,13 @@ class Form
* @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span
* @param string $incbefore Include code before the text * @param string $incbefore Include code before the text
* @param int $noencodehtmltext Do not encode into html entity the htmltext * @param int $noencodehtmltext Do not encode into html entity the htmltext
* @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key) * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key)
* @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only)
* @return string Code html du tooltip (texte+picto) * @return string Code html du tooltip (texte+picto)
* @see Use function textwithpicto if you can. * @see Use function textwithpicto if you can.
* TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip * TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip
*/ */
function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger='') function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger='', $forcenowrap=0)
{ {
global $conf; global $conf;
@ -462,7 +463,7 @@ class Form
} }
else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag
if (empty($notabs)) $s.='<table class="nobordernopadding" summary=""><tr style="height: auto;">'; if (empty($notabs)) $s.='<table class="nobordernopadding" summary=""><tr style="height: auto;">';
elseif ($notabs == 2) $s.='<div class="inline-block">'; elseif ($notabs == 2) $s.='<div class="inline-block'.($forcenowrap?' nowrap':'').'">';
// Define value if value is before // Define value if value is before
if ($direction < 0) { if ($direction < 0) {
$s.='<'.$tag.$paramfortooltipimg; $s.='<'.$tag.$paramfortooltipimg;
@ -497,9 +498,10 @@ class Form
* @param int $noencodehtmltext Do not encode into html entity the htmltext * @param int $noencodehtmltext Do not encode into html entity the htmltext
* @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span
* @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key) * @param string $tooltiptrigger ''=Tooltip on hover, 'abc'=Tooltip on click (abc is a unique key)
* @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only)
* @return string HTML code of text, picto, tooltip * @return string HTML code of text, picto, tooltip
*/ */
function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger='') function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger='', $forcenowrap=0)
{ {
global $conf, $langs; global $conf, $langs;
@ -534,7 +536,7 @@ class Form
elseif ($type == 'warning') $img = img_warning($alt); elseif ($type == 'warning') $img = img_warning($alt);
else $img = img_picto($alt, $type); else $img = img_picto($alt, $type);
return $this->textwithtooltip($text, $htmltext, (($tooltiptrigger && ! $img)?3:2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger); return $this->textwithtooltip($text, $htmltext, (($tooltiptrigger && ! $img)?3:2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
} }
/** /**