2
0
forked from Wavyzz/dolibarr

Debug v21 - fix js warnings

This commit is contained in:
Laurent Destailleur (aka Eldy)
2025-01-16 15:19:36 +01:00
parent 63c991413e
commit 4acacc2e9f

View File

@@ -9044,7 +9044,7 @@ class Form
*/
public static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
{
global $conf, $langs;
global $conf;
global $delayedhtmlcontent; // Will be used later outside of this function
// TODO Use an internal dolibarr component instead of select2
@@ -9091,9 +9091,9 @@ class Form
},
cache: true
},
language: select2arrayoflanguage,
language: select2arrayoflanguage || \'en\',
containerCssClass: \':all:\', /* Line to add class from the original SELECT propagated to the new <span class="select2-selection...> tag */
placeholder: "' . dol_escape_js($placeholder) . '",
placeholder: \'' . dol_escape_js($placeholder) . '\',
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
minimumInputLength: ' . ((int) $minimumInputLength) . ',
formatResult: function (result, container, query, escapeMarkup) {
@@ -9104,9 +9104,9 @@ class Form
' . ($callurlonselect ? '
/* Code to execute a GET when we select a value */
$(".' . $htmlname . '").change(function() {
var selected = $(".' . $htmlname . '").val();
var selected = $(\'.' . dol_escape_js($htmlname) . '\').val();
console.log("We select in selectArrayAjax the entry "+selected)
$(".' . $htmlname . '").val(""); /* reset visible combo value */
$(\'.' . dol_escape_js($htmlname) . '\').val(""); /* reset visible combo value */
$.each( saveRemoteData, function( key, value ) {
if (key == selected)
{
@@ -9149,7 +9149,7 @@ class Form
*/
public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0, $textfortitle = '')
{
global $conf, $langs;
global $conf;
global $delayedhtmlcontent; // Will be used later outside of this function
// TODO Use an internal dolibarr component instead of select2
@@ -9179,13 +9179,13 @@ class Form
' . ($callurlonselect ? 'var saveRemoteData = ' . json_encode($array) . ';' : '') . '
$(".' . $htmlname . '").select2({
$(\'.' . dol_escape_js($htmlname) . '\').select2({
data: data,
language: select2arrayoflanguage,
language: select2arrayoflanguage || \'en\',
containerCssClass: \':all:\', /* Line to add class from the original SELECT propagated to the new <span class="select2-selection...> tag */
placeholder: "' . dol_escape_js($placeholder) . '",
placeholder: \'' . dol_escape_js($placeholder) . '\',
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
minimumInputLength: ' . $minimumInputLength . ',
minimumInputLength: ' . ((int) $minimumInputLength) . ',
formatResult: function (result, container, query, escapeMarkup) {
return escapeMarkup(result.text);
},
@@ -9224,11 +9224,11 @@ class Form
' . ($callurlonselect ? '
/* Code to execute a GET when we select a value */
$(".' . $htmlname . '").change(function() {
var selected = $(".' . $htmlname . '").val();
$(\'.' . dol_escape_js($htmlname) . '\').change(function() {
var selected = $(\'.' . dol_escape_js($htmlname) . '\').val();
console.log("We select "+selected)
$(".' . $htmlname . '").val(""); /* reset visible combo value */
$(\'.' . dol_escape_js($htmlname) . '\').val(""); /* reset visible combo value */
$.each( saveRemoteData, function( key, value ) {
if (key == selected)
{
@@ -9357,7 +9357,7 @@ class Form
}
$out .= '}' . "\n";
$out .= '$(document).ready(function () {
$(\'#' . $htmlname . '\').' . $tmpplugin . '({';
$(\'#' . dol_escape_js($htmlname) . '\').' . $tmpplugin . '({';
if ($placeholder) {
$out .= '
placeholder: {
@@ -9367,7 +9367,7 @@ class Form
}
$out .= ' dir: \'ltr\',
containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag (ko with multiselect) */
dropdownCssClass: \'' . $morecss . '\', /* Line to add class on the new <span class="select2-selection...> tag (ok with multiselect). Need full version of select2. */
dropdownCssClass: \'' . dol_escape_js($morecss) . '\', /* Line to add class on the new <span class="select2-selection...> tag (ok with multiselect). Need full version of select2. */
// Specify format function for dropdown item
formatResult: formatResult,
templateResult: formatResult, /* For 4.0 */
@@ -9375,26 +9375,26 @@ class Form
// Specify format function for selected item
formatSelection: formatSelection,
templateSelection: formatSelection, /* For 4.0 */
language: select2arrayoflanguage
language: select2arrayoflanguage || \'en\'
});
/* Add also morecss to the css .select2 that is after the #htmlname, for component that are show dynamically after load, because select2 set
the size only if component is not hidden by default on load */
$(\'#' . $htmlname . ' + .select2\').addClass(\'' . $morecss . '\');
$(\'#' . dol_escape_js($htmlname) . ' + .select2\').addClass(\'' . dol_escape_js($morecss) . '\');
});' . "\n";
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) {
// Add other js lib
// TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
// ...
$out .= 'console.log(\'addjscombo=2 for htmlname=' . $htmlname . '\');';
$out .= 'console.log(\'addjscombo=2 for htmlname=' . dol_escape_js($htmlname) . '\');';
$out .= '$(document).ready(function () {
$(\'#' . $htmlname . '\').multiSelect({
$(\'#' . dol_escape_js($htmlname) . '\').multiSelect({
containerHTML: \'<div class="multi-select-container">\',
menuHTML: \'<div class="multi-select-menu">\',
buttonHTML: \'<span class="multi-select-button ' . $morecss . '">\',
buttonHTML: \'<span class="multi-select-button ' . dol_escape_js($morecss) . '">\',
menuItemHTML: \'<label class="multi-select-menuitem">\',
activeClass: \'multi-select-container--open\',
noneText: \'' . $placeholder . '\'
noneText: \'' . dol_escape_js($placeholder) . '\'
});
})';
}