N°3379 - Introduce more modern tooltip lib. in the backoffice

- Allow usage of quotes, especially in attributes description
- Allow line breaks, especially in attributes description
- Allow better positioning (automatic) when close to the screen limits
- Allow HTML (careful about XSS), content is sanitized by default
This commit is contained in:
Molkobain
2020-10-16 11:10:51 +02:00
parent 9a47e3cf74
commit 6edb308480
3 changed files with 70 additions and 6 deletions

View File

@@ -882,8 +882,14 @@ EOF
$aArgs).'';
}
$aFieldsMap[$sAttCode] = $sInputId;
// Attribute description
$sDescription = $oAttDef->GetDescription();
$sDescriptionForHTMLTag = utils::HtmlEntities($sDescription);
$sDescriptionHTMLTag = (empty($sDescriptionForHTMLTag)) ? '' : 'class="ibo-has-description" data-tooltip-content="'.$sDescriptionForHTMLTag.'"';
$val = array(
'label' => '<span title="'.$oAttDef->GetDescription().'">'.$oAttDef->GetLabel().'</span>',
'label' => '<span '.$sDescriptionHTMLTag.' >'.$oAttDef->GetLabel().'</span>',
'value' => $sHTMLValue,
'comments' => $sComments,
'infos' => $sInfos,
@@ -892,8 +898,13 @@ EOF
}
else
{
// Attribute description
$sDescription = $oAttDef->GetDescription();
$sDescriptionForHTMLTag = utils::HtmlEntities($sDescription);
$sDescriptionHTMLTag = (empty($sDescriptionForHTMLTag)) ? '' : 'class="ibo-has-description" data-tooltip-content="'.$sDescriptionForHTMLTag.'"';
$val = array(
'label' => '<span title="'.$oAttDef->GetDescription().'">'.$oAttDef->GetLabel().'</span>',
'label' => '<span '.$sDescriptionHTMLTag.' >'.$oAttDef->GetLabel().'</span>',
'value' => "<span id=\"field_{$sInputId}\">".$this->GetAsHTML($sAttCode)."</span>",
'comments' => $sComments,
'infos' => $sInfos,
@@ -3240,9 +3251,14 @@ EOF
$sDisplayValue = $this->GetAsHTML($sAttCode);
}
}
// Attribute description
$sDescription = $oAttDef->GetDescription();
$sDescriptionForHTMLTag = utils::HtmlEntities($sDescription);
$sDescriptionHTMLTag = (empty($sDescriptionForHTMLTag)) ? '' : 'class="ibo-has-description" data-tooltip-content="'.$sDescriptionForHTMLTag.'"';
$retVal = array(
'label' => '<span title="'.MetaModel::GetDescription($sClass,
$sAttCode).'">'.MetaModel::GetLabel($sClass, $sAttCode).'</span>',
'label' => '<span '.$sDescriptionHTMLTag.' >'.MetaModel::GetLabel($sClass, $sAttCode).'</span>',
'value' => $sDisplayValue,
);
}