From d848e98759937e7b5f6e7e065f6734fe791571d7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 12 Oct 2016 15:33:33 +0200 Subject: [PATCH 1/2] Fix: add possibility to change width type to prevent some display issues --- htdocs/core/lib/ajax.lib.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 4b0ae91ee3f..ab6828581a8 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -35,7 +35,7 @@ * @param string $urloption More parameters on URL request * @param int $minLength Minimum number of chars to trigger that Ajax search * @param int $autoselect Automatic selection if just one value - * @param array $ajaxoptions Multiple options array + * @param array $ajaxoptions Multiple options array * Ex: array('update'=>array('field1','field2'...)) will reset field1 and field2 once select done * Ex: array('disabled'=> * Ex: array('show'=> @@ -61,8 +61,8 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt $("input#search_'.$htmlname.'").keydown(function() { $("#'.$htmlname.'").val(""); }); - - /* I disable this. A call to trigger is already done later into the select action of the autocomplete code + + /* I disable this. A call to trigger is already done later into the select action of the autocomplete code $("input#search_'.$htmlname.'").change(function() { console.log("Call the change trigger on input '.$htmlname.' because of a change on search_'.$htmlname.' was triggered"); $("#'.$htmlname.'").trigger("change"); @@ -291,7 +291,7 @@ function ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLengt needtotrigger="#" + fields[i]; } } - + if (needtotrigger != "") // To force select2 to refresh visible content { // We introduce a delay so hand is back to js and all other js change can be done before the trigger that may execute a submit is done @@ -366,6 +366,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; if (empty($conf->use_javascript_ajax)) return ''; + $widthTypeOfAutocomplete = (!empty($conf->global->MAIN_WIDTH_TYPE_OF_AUTOCOMPLETE) ? $conf->global->MAIN_WIDTH_TYPE_OF_AUTOCOMPLETE : 'resolve'); if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0; $tmpplugin='select2'; @@ -374,7 +375,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ $(document).ready(function () { $(\''.(preg_match('/^\./',$htmlname)?$htmlname:'#'.$htmlname).'\').'.$tmpplugin.'({ dir: \'ltr\', - width: \'resolve\', /* off or resolve */ + width: \''.$widthTypeOfAutocomplete.'\', /* off or resolve */ minimumInputLength: '.$minLengthToAutocomplete.' })'; if ($forcefocus) $msg.= '.select2(\'focus\')'; From 6423b23fb3fc5a890ceddc778f367d56b3ed4529 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 12 Oct 2016 15:36:51 +0200 Subject: [PATCH 2/2] Fix: use parameter instead constant --- htdocs/core/lib/ajax.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index ab6828581a8..756fbcf9672 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -357,7 +357,7 @@ function ajax_dialog($title,$message,$w=350,$h=150) * @param int $forcefocus Force focus on field * @return string Return html string to convert a select field into a combo, or '' if feature has been disabled for some reason. */ -function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0) +function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve') { global $conf; @@ -366,7 +366,6 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; if (empty($conf->use_javascript_ajax)) return ''; - $widthTypeOfAutocomplete = (!empty($conf->global->MAIN_WIDTH_TYPE_OF_AUTOCOMPLETE) ? $conf->global->MAIN_WIDTH_TYPE_OF_AUTOCOMPLETE : 'resolve'); if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0; $tmpplugin='select2';