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 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 $moreattrib Add more options on select component. Example: 'disabled'
* @param string $elemtype Type of element we show ('category', ...) * @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 * @return string HTML multiselect string
* @see selectarray * @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; global $conf, $langs;
$out = ''; $out = '';
if ($addjscombo < 0) {
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1;
else $addjscombo = 0;
}
// Add code for jquery to use multiselect // Add code for jquery to use multiselect
if (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_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; $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.' --> $out.="\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
<script type="text/javascript"> <script type="text/javascript">'."\n";
function formatResult(record) {'."\n"; if ($addjscombo == 1)
{
$out.= ' function formatResult(record) {'."\n";
if ($elemtype == 'category') 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>\'; $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, formatSelection: formatSelection,
templateResult: formatSelection /* For 4.0 */ templateResult: formatSelection /* For 4.0 */
}); });
}); });';
</script>'; }
$out.=' </script>';
} }
// Try also magic suggest // 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))) 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']; $sql = $possiblelink['sql'];
$resqllist = $this->db->query($sql); $resqllist = $this->db->query($sql);
@ -6105,8 +6115,9 @@ class Form
{ {
$linktoelem=' $linktoelem='
<dl class="dropdown" id="linktoobjectname"> <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"> <div class="multiselectlinkto">
<ul class="ulselectedfields">'.$linktoelemlist.' <ul class="ulselectedfields">'.$linktoelemlist.'
</ul> </ul>
@ -6119,7 +6130,9 @@ class Form
$linktoelem=''; $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"> <script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery(".linkto").click(function() { jQuery(".linkto").click(function() {
@ -6129,7 +6142,8 @@ class Form
}); });
}); });
</script> </script>
'; ';
}
return $linktoelem; return $linktoelem;
} }