From 30430953dea56b8a24c82af9de3cec73c47204e6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 23 Oct 2012 09:30:48 +0200 Subject: [PATCH] Fix: missing row and col parameters --- htdocs/core/class/html.form.class.php | 18 +- htdocs/core/js/editinplace.js | 459 +++++++++++++------------- htdocs/core/lib/functions.lib.php | 12 +- htdocs/fichinter/fiche.php | 2 +- 4 files changed, 254 insertions(+), 237 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8e03d9b32d8..471948cbd59 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -292,8 +292,8 @@ class Form { $tmp=explode(':',$inputType); $inputType=$tmp[0]; - if (! empty($tmp[1])) $rows=$tmp[1]; - if (! empty($tmp[2])) $cols=$tmp[2]; + $rows=($tmp[1]?$tmp[1]:'8'); + $cols=($tmp[2]?$tmp[2]:'80'); } else if (preg_match('/^ckeditor/',$inputType)) { @@ -320,6 +320,10 @@ class Form if (! empty($savemethod)) $out.= ''."\n"; if (! empty($ext_element)) $out.= ''."\n"; if (! empty($success)) $out.= ''."\n"; + if ($inputType == 'textarea') { + $out.= ''."\n"; + $out.= ''."\n"; + } $out.= ''.$value.''."\n"; $out.= ''.(! empty($editvalue) ? $editvalue : $value).''."\n"; @@ -1480,7 +1484,7 @@ class Form $outval.=$objRef.' ('.$objRefFourn.') - '; $opt.=dol_trunc($objp->label,18).' - '; $outval.=dol_trunc($label,18).' - '; - + if (! empty($objp->idprodfournprice)) { $currencytext=$langs->trans("Currency".$conf->currency); @@ -1505,7 +1509,7 @@ class Form $opt.= $langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding $outval.=$langs->transnoentities("Units"); } - + if ($objp->quantity >= 1) { $opt.=" (".price($objp->unitprice).' '.$currencytext."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding @@ -1533,8 +1537,8 @@ class Form $outval.=$langs->transnoentities("NoPriceDefinedForThisSupplier"); } $opt .= "\n"; - - + + // Add new entry // "key" value of json key array is used by jQuery automatically as selected value // "label" value of json key array is used by jQuery automatically as text for combo box @@ -1548,7 +1552,7 @@ class Form //var_dump($outval); var_dump(utf8_check($outval)); var_dump(json_encode($outval)); //$outval=array('label'=>'ppp (fff2) - ppp - 20,00 Euros/ Unité (20,00 Euros/unité)'); //var_dump($outval); var_dump(utf8_check($outval)); var_dump(json_encode($outval)); - + $i++; } $outselect.=''; diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index c4ea20f0e43..4ccbbd87681 100644 --- a/htdocs/core/js/editinplace.js +++ b/htdocs/core/js/editinplace.js @@ -26,48 +26,51 @@ $(document).ready(function() { var table_element = $('#jeditable_table_element').html(); var fk_element = $('#jeditable_fk_element').html(); - $('.editval_textarea').editable(urlSaveInPlace, { - type : 'textarea', - rows : 4, - id : 'field', - tooltip : tooltipInPlace, - placeholder : ' ', - cancel : cancelInPlace, - submit : submitInPlace, - indicator : indicatorInPlace, - loadurl : urlLoadInPlace, - loaddata : function(result, settings) { - return getParameters(this, 'textarea'); - }, - submitdata : function(result, settings) { - return getParameters(this, 'textarea'); - }, - callback : function(result, settings) { - getResult(this, result); - }, - onreset : function(result, settings) { - getDefault(settings); - } - }); - $('.editkey_textarea').hover( - function () { - $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + if ($('.editval_textarea').length > 0) { + $('.editval_textarea').editable(urlSaveInPlace, { + type : 'textarea', + rows : $('#textarea_' + $('.editval_textarea').attr('id').substr(8) + '_rows').val(), + cols : $('#textarea_' + $('.editval_textarea').attr('id').substr(8) + '_cols').val(), + id : 'field', + tooltip : tooltipInPlace, + placeholder : ' ', + cancel : cancelInPlace, + submit : submitInPlace, + indicator : indicatorInPlace, + loadurl : urlLoadInPlace, + loaddata : function(result, settings) { + return getParameters(this, 'textarea'); }, - function () { - $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + submitdata : function(result, settings) { + return getParameters(this, 'textarea'); + }, + callback : function(result, settings) { + getResult(this, result); + }, + onreset : function(result, settings) { + getDefault(settings); } - ); - $('.editkey_textarea').click(function() { - $('#viewval_' + $(this).attr('id')).click(); - }); - $('.viewval_textarea.active').click(function() { - $('#viewval_' + $(this).attr('id').substr(8)).hide(); - $('#editval_' + $(this).attr('id').substr(8)).show().click(); - }); - $('.editkey_textarea').click(function() { - $('#viewval_' + $(this).attr('id')).hide(); - $('#editval_' + $(this).attr('id')).show().click(); - }); + }); + $('.editkey_textarea').hover( + function () { + $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + }, + function () { + $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + } + ); + $('.editkey_textarea').click(function() { + $('#viewval_' + $(this).attr('id')).click(); + }); + $('.viewval_textarea.active').click(function() { + $('#viewval_' + $(this).attr('id').substr(8)).hide(); + $('#editval_' + $(this).attr('id').substr(8)).show().click(); + }); + $('.editkey_textarea').click(function() { + $('#viewval_' + $(this).attr('id')).hide(); + $('#editval_' + $(this).attr('id')).show().click(); + }); + } if (typeof ckeditorConfig != 'undefined') { $('.editval_ckeditor').editable(urlSaveInPlace, { @@ -120,204 +123,214 @@ $(document).ready(function() { }); } - $('.editval_string').editable(urlSaveInPlace, { - type : 'text', - id : 'field', - width : 300, - tooltip : tooltipInPlace, - placeholder : placeholderInPlace, - cancel : cancelInPlace, - submit : submitInPlace, - indicator : indicatorInPlace, - submitdata : function(result, settings) { - return getParameters(this, 'string'); - }, - callback : function(result, settings) { - getResult(this, result); - }, - onreset : function(result, settings) { - getDefault(settings); - } - }); - $('.editkey_string').hover( - function () { - $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + if ($('.editval_string').length > 0) { + $('.editval_string').editable(urlSaveInPlace, { + type : 'text', + id : 'field', + width : 300, + tooltip : tooltipInPlace, + placeholder : placeholderInPlace, + cancel : cancelInPlace, + submit : submitInPlace, + indicator : indicatorInPlace, + submitdata : function(result, settings) { + return getParameters(this, 'string'); }, - function () { - $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + callback : function(result, settings) { + getResult(this, result); + }, + onreset : function(result, settings) { + getDefault(settings); } - ); - $('.editkey_string').click(function() { - $( '#viewval_' + $(this).attr('id') ).click(); - }); - $('.viewval_string.active').click(function() { - $('#viewval_' + $(this).attr('id').substr(8)).hide(); - $('#editval_' + $(this).attr('id').substr(8)).show().click(); - }); - $('.editkey_string').click(function() { - $('#viewval_' + $(this).attr('id')).hide(); - $('#editval_' + $(this).attr('id')).show().click(); - }); + }); + $('.editkey_string').hover( + function () { + $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + }, + function () { + $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + } + ); + $('.editkey_string').click(function() { + $( '#viewval_' + $(this).attr('id') ).click(); + }); + $('.viewval_string.active').click(function() { + $('#viewval_' + $(this).attr('id').substr(8)).hide(); + $('#editval_' + $(this).attr('id').substr(8)).show().click(); + }); + $('.editkey_string').click(function() { + $('#viewval_' + $(this).attr('id')).hide(); + $('#editval_' + $(this).attr('id')).show().click(); + }); + } - $('.editval_numeric').editable(urlSaveInPlace, { - type : 'text', - id : 'field', - width : 100, - tooltip : tooltipInPlace, - placeholder : placeholderInPlace, - cancel : cancelInPlace, - submit : submitInPlace, - indicator : indicatorInPlace, - submitdata : function(result, settings) { - return getParameters(this, 'numeric'); - }, - callback : function(result, settings) { - getResult(this, result); - }, - onreset : function(result, settings) { - getDefault(settings); - } - }); - $('.editkey_numeric').hover( - function () { - $( '#viewval_' + $(this).attr('id') ).addClass("viewval_hover"); + if ($('.editval_numeric').length > 0) { + $('.editval_numeric').editable(urlSaveInPlace, { + type : 'text', + id : 'field', + width : 100, + tooltip : tooltipInPlace, + placeholder : placeholderInPlace, + cancel : cancelInPlace, + submit : submitInPlace, + indicator : indicatorInPlace, + submitdata : function(result, settings) { + return getParameters(this, 'numeric'); }, - function () { - $( '#viewval_' + $(this).attr('id') ).removeClass("viewval_hover"); + callback : function(result, settings) { + getResult(this, result); + }, + onreset : function(result, settings) { + getDefault(settings); } - ); - $('.editkey_numeric').click(function() { - $( '#viewval_' + $(this).attr('id') ).click(); - }); - $('.viewval_numeric.active').click(function() { - $('#viewval_' + $(this).attr('id').substr(8)).hide(); - $('#editval_' + $(this).attr('id').substr(8)).show().click(); - }); - $('.editkey_numeric').click(function() { - $('#viewval_' + $(this).attr('id')).hide(); - $('#editval_' + $(this).attr('id')).show().click(); - }); + }); + $('.editkey_numeric').hover( + function () { + $( '#viewval_' + $(this).attr('id') ).addClass("viewval_hover"); + }, + function () { + $( '#viewval_' + $(this).attr('id') ).removeClass("viewval_hover"); + } + ); + $('.editkey_numeric').click(function() { + $( '#viewval_' + $(this).attr('id') ).click(); + }); + $('.viewval_numeric.active').click(function() { + $('#viewval_' + $(this).attr('id').substr(8)).hide(); + $('#editval_' + $(this).attr('id').substr(8)).show().click(); + }); + $('.editkey_numeric').click(function() { + $('#viewval_' + $(this).attr('id')).hide(); + $('#editval_' + $(this).attr('id')).show().click(); + }); + } - $('.editval_datepicker').editable(urlSaveInPlace, { - type : 'datepicker', - id : 'field', - onblur : 'ignore', - tooltip : tooltipInPlace, - placeholder : ' ', - cancel : cancelInPlace, - submit : submitInPlace, - indicator : indicatorInPlace, - submitdata : function(result, settings) { - return getParameters(this, 'datepicker'); - }, - callback : function(result, settings) { - getResult(this, result); - }, - onreset : function(result, settings) { - getDefault(settings); - } - }); - $('.editkey_datepicker').hover( - function () { - $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + if ($('.editval_datepicker').length > 0) { + $('.editval_datepicker').editable(urlSaveInPlace, { + type : 'datepicker', + id : 'field', + onblur : 'ignore', + tooltip : tooltipInPlace, + placeholder : ' ', + cancel : cancelInPlace, + submit : submitInPlace, + indicator : indicatorInPlace, + submitdata : function(result, settings) { + return getParameters(this, 'datepicker'); }, - function () { - $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + callback : function(result, settings) { + getResult(this, result); + }, + onreset : function(result, settings) { + getDefault(settings); } - ); - $('.viewval_datepicker.active').click(function() { - $('#viewval_' + $(this).attr('id').substr(8)).hide(); - $('#editval_' + $(this).attr('id').substr(8)).show().click(); - }); - $('.editkey_datepicker').click(function() { - $('#viewval_' + $(this).attr('id')).hide(); - $('#editval_' + $(this).attr('id')).show().click(); - }); + }); + $('.editkey_datepicker').hover( + function () { + $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + }, + function () { + $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + } + ); + $('.viewval_datepicker.active').click(function() { + $('#viewval_' + $(this).attr('id').substr(8)).hide(); + $('#editval_' + $(this).attr('id').substr(8)).show().click(); + }); + $('.editkey_datepicker').click(function() { + $('#viewval_' + $(this).attr('id')).hide(); + $('#editval_' + $(this).attr('id')).show().click(); + }); + } - $('.editval_select').editable(urlSaveInPlace, { - type : 'select', - id : 'field', - onblur : 'ignore', - cssclass : 'flat', - tooltip : tooltipInPlace, - placeholder : ' ', - cancel : cancelInPlace, - submit : submitInPlace, - indicator : indicatorInPlace, - loadurl : urlLoadInPlace, - loaddata : function(result, settings) { - return getParameters(this, 'select'); - }, - submitdata : function(result, settings) { - return getParameters(this, 'select'); - }, - callback : function(result, settings) { - getResult(this, result); - }, - onreset : function(result, settings) { - getDefault(settings); - } - }); - $('.editkey_select').hover( - function () { - $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + if ($('.editval_select').length > 0) { + $('.editval_select').editable(urlSaveInPlace, { + type : 'select', + id : 'field', + onblur : 'ignore', + cssclass : 'flat', + tooltip : tooltipInPlace, + placeholder : ' ', + cancel : cancelInPlace, + submit : submitInPlace, + indicator : indicatorInPlace, + loadurl : urlLoadInPlace, + loaddata : function(result, settings) { + return getParameters(this, 'select'); }, - function () { - $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + submitdata : function(result, settings) { + return getParameters(this, 'select'); + }, + callback : function(result, settings) { + getResult(this, result); + }, + onreset : function(result, settings) { + getDefault(settings); } - ); - $('.viewval_select.active').click(function() { - $('#viewval_' + $(this).attr('id').substr(8)).hide(); - $('#editval_' + $(this).attr('id').substr(8)).show().click(); - }); - $('.editkey_select').click(function() { - $('#viewval_' + $(this).attr('id')).hide(); - $('#editval_' + $(this).attr('id')).show().click(); - }); + }); + $('.editkey_select').hover( + function () { + $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + }, + function () { + $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + } + ); + $('.viewval_select.active').click(function() { + $('#viewval_' + $(this).attr('id').substr(8)).hide(); + $('#editval_' + $(this).attr('id').substr(8)).show().click(); + }); + $('.editkey_select').click(function() { + $('#viewval_' + $(this).attr('id')).hide(); + $('#editval_' + $(this).attr('id')).show().click(); + }); + } // for test only (not stable) - $('.editval_autocomplete').editable(urlSaveInPlace, { - type : 'autocomplete', - id : 'field', - width : 300, - onblur : 'ignore', - tooltip : tooltipInPlace, - placeholder : ' ', - cancel : cancelInPlace, - submit : submitInPlace, - indicator : indicatorInPlace, - autocomplete : { - source : urlLoadInPlace, - data : function(result, settings) { - return getParameters(this, 'select'); - } - }, - submitdata : function(result, settings) { - return getParameters(this, 'select'); - }, - callback : function(result, settings) { - getResult(this, result); - }, - onreset : function(result, settings) { - getDefault(settings); - } - }); - $('.editkey_autocomplete').hover( - function () { - $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + if ($('.editval_autocomplete').length > 0) { + $('.editval_autocomplete').editable(urlSaveInPlace, { + type : 'autocomplete', + id : 'field', + width : 300, + onblur : 'ignore', + tooltip : tooltipInPlace, + placeholder : ' ', + cancel : cancelInPlace, + submit : submitInPlace, + indicator : indicatorInPlace, + autocomplete : { + source : urlLoadInPlace, + data : function(result, settings) { + return getParameters(this, 'select'); + } }, - function () { - $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + submitdata : function(result, settings) { + return getParameters(this, 'select'); + }, + callback : function(result, settings) { + getResult(this, result); + }, + onreset : function(result, settings) { + getDefault(settings); } - ); - $('.viewval_autocomplete.active').click(function() { - $('#viewval_' + $(this).attr('id').substr(8)).hide(); - $('#editval_' + $(this).attr('id').substr(8)).show().click(); - }); - $('.editkey_autocomplete').click(function() { - $('#viewval_' + $(this).attr('id')).hide(); - $('#editval_' + $(this).attr('id')).show().click(); - }); + }); + $('.editkey_autocomplete').hover( + function () { + $('#viewval_' + $(this).attr('id')).addClass("viewval_hover"); + }, + function () { + $('#viewval_' + $(this).attr('id')).removeClass("viewval_hover"); + } + ); + $('.viewval_autocomplete.active').click(function() { + $('#viewval_' + $(this).attr('id').substr(8)).hide(); + $('#editval_' + $(this).attr('id').substr(8)).show().click(); + }); + $('.editkey_autocomplete').click(function() { + $('#viewval_' + $(this).attr('id')).hide(); + $('#editval_' + $(this).attr('id')).show().click(); + }); + } function getParameters(obj, type) { var htmlname = $(obj).attr('id').substr(8); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a576079919e..6416cac14ef 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -447,22 +447,22 @@ function dol_escape_htmltag($stringtoescape,$keepb=0) } -/** +/** * Convert a string to lower. Never use strtolower because it does not works with UTF8 strings. - * + * * @param string $utf8_string String to encode - * @return string String converted + * @return string String converted */ function dol_strtolower($utf8_string) { return mb_strtolower($utf8_string, "UTF-8"); } -/** +/** * Convert a string to upper. Never use strtolower because it does not works with UTF8 strings. - * + * * @param string $utf8_string String to encode - * @return string String converted + * @return string String converted */ function dol_strtoupper($utf8_string) { diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 7914a475f96..d0b09b22279 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -912,7 +912,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print $form->editfieldkey("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea'); print ''; - print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea:8:80'); print ''; print '';