FIX Selection of email recipient with option MAIN_OPTIMIZEFORTEXTBROWSER

This commit is contained in:
Laurent Destailleur 2019-01-08 14:05:07 +01:00
parent 8e3df45cbf
commit 9a6c3ac3df

View File

@ -5628,22 +5628,31 @@ class Form
* @param int $width Force width of select box. May be used only when using jquery couch. Example: 250, 95%
* @param string $moreattrib Add more options on select component. Example: 'disabled'
* @param string $elemtype Type of element we show ('category', ...)
* @param string $placeholder String to use as placeholder
* @param int $addjscombo Add js combo
* @return string HTML multiselect string
* @see selectarray
*/
static function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='',$elemtype='')
static function multiselectarray($htmlname, $array, $selected=array(), $key_in_label=0, $value_as_key=0, $morecss='', $translate=0, $width=0, $moreattrib='',$elemtype='', $placeholder='', $addjscombo=-1)
{
global $conf, $langs;
$out = '';
if ($addjscombo < 0) {
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1;
else $addjscombo = 0;
}
// Add code for jquery to use multiselect
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))
{
$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out.="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript">
function formatResult(record) {'."\n";
<script type="text/javascript">'."\n";
if ($addjscombo == 1)
{
$out.= ' function formatResult(record) {'."\n";
if ($elemtype == 'category')
{
$out.=' //return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\';
@ -5675,8 +5684,9 @@ class Form
formatSelection: formatSelection,
templateResult: formatSelection /* For 4.0 */
});
});
</script>';
});';
}
$out.=' </script>';
}
// Try also magic suggest
@ -6044,7 +6054,7 @@ class Form
if (! empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || ! in_array($key, $excludelinksto)))
{
print '<div id="'.$key.'list"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)?' style="display:none"':'').'>';
print '<div id="'.$key.'list"'.(empty($conf->use_javascript_ajax)?'':' style="display:none"').'>';
$sql = $possiblelink['sql'];
$resqllist = $this->db->query($sql);
@ -6105,8 +6115,9 @@ class Form
{
$linktoelem='
<dl class="dropdown" id="linktoobjectname">
<dt><a href="#linktoobjectname">'.$langs->trans("LinkTo").'...</a></dt>
<dd>
';
if (! empty($conf->use_javascript_ajax)) $linktoelem.='<dt><a href="#linktoobjectname">'.$langs->trans("LinkTo").'...</a></dt>';
$linktoelem.='<dd>
<div class="multiselectlinkto">
<ul class="ulselectedfields">'.$linktoelemlist.'
</ul>
@ -6119,7 +6130,9 @@ class Form
$linktoelem='';
}
print '<!-- Add js to show linkto box -->
if (! empty($conf->use_javascript_ajax))
{
print '<!-- Add js to show linkto box -->
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery(".linkto").click(function() {
@ -6129,7 +6142,8 @@ class Form
});
});
</script>
';
';
}
return $linktoelem;
}