diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php
index d1559311620..4b2c56ab003 100644
--- a/htdocs/compta/deplacement/fiche.php
+++ b/htdocs/compta/deplacement/fiche.php
@@ -361,7 +361,7 @@ else if ($id)
// Km/Price
print '
| '.$langs->trans("FeesKilometersOrAmout").' | ';
- print ''.$form->editInPlace(price($object->km), 'km', $user->rights->deplacement->creer, 'numeric').' |
';
+ print ''.$form->editInPlace($object->km, 'km', $user->rights->deplacement->creer, 'numeric').' | ';
// Where
print '| '.$langs->trans("CompanyVisited").' | ';
@@ -405,9 +405,7 @@ else if ($id)
// Public note
print '
| '.$langs->trans("NotePublic").' | ';
print '';
- // FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
- // by editInPlace if necessary according to type (4rd parameter)
- print $form->editInPlace(dol_nl2br($object->note_public), 'note_public', $user->rights->deplacement->creer, 'area');
+ print $form->editInPlace($object->note_public, 'note_public', $user->rights->deplacement->creer, 'area');
print " |
";
// Private note
@@ -415,9 +413,7 @@ else if ($id)
{
print '| '.$langs->trans("NotePrivate").' | ';
print '';
- // FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
- // by editInPlace if necessary according to type (4rd parameter)
- print $form->editInPlace(dol_nl2br($object->note_private), 'note', $user->rights->deplacement->creer, 'area');
+ print $form->editInPlace($object->note_private, 'note', $user->rights->deplacement->creer, 'area');
print " |
";
}
diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php
index efae5b326a2..f34146c592f 100644
--- a/htdocs/core/ajax/saveinplace.php
+++ b/htdocs/core/ajax/saveinplace.php
@@ -37,7 +37,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
top_httphead();
//print ''."\n";
-//var_dump($_POST);
+//print_r($_POST);
// Load original field value
if((isset($_POST['field']) && ! empty($_POST['field']))
@@ -52,6 +52,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
$value = GETPOST('value');
$type = GETPOST('type');
+ $return=array();
$error=0;
if ($element == 'fichinter') $element = 'ficheinter';
@@ -70,6 +71,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
if (! is_numeric($value))
{
$error++;
+ $return['error'] = $langs->trans('ErrorBadValue');
}
}
@@ -79,11 +81,13 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
if ($ret > 0)
{
if ($type == 'numeric') $value = price($value);
- else $value = (! empty($value) ? dol_nl2br($value) : ' ');
-
- echo $value;
+ else if ($type == 'textarea') $value = dol_nl2br($value);
+
+ $return['value'] = $value;
}
}
+
+ echo json_encode($return);
}
else
{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index f9be689faf2..0454a286e0f 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -153,10 +153,13 @@ class Form
*/
function editInPlace($value, $htmlname, $condition, $type='area')
{
- global $conf,$user;
+ global $conf;
$out='';
- $value = ($value ? $value : " ");
+
+ // Check parameters
+ if ($type == 'area') $value = dol_nl2br($value);
+ else if ($type == 'numeric') $value = price($value);
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition)
{
diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js
index fe68febdd65..51b4ae89d53 100644
--- a/htdocs/core/js/editinplace.js
+++ b/htdocs/core/js/editinplace.js
@@ -7,62 +7,93 @@
$(document).ready(function() {
- $(document).ready(function() {
- var element = $('#element').html();
- var table_element = $('#table_element').html();
- var fk_element = $('#fk_element').html();
-
- $('.edit_area').editable(urlSaveInPlace, {
- type : 'textarea',
- rows : 4,
- id : 'field',
- tooltip : tooltipInPlace,
- cancel : cancelInPlace,
- submit : submitInPlace,
- indicator : indicatorInPlace,
- loadurl : urlLoadInPlace,
- loaddata : {
- type: 'textarea',
- element: element,
- table_element: table_element,
- fk_element: fk_element
- },
- submitdata : {
- type: 'textarea',
- element: element,
- table_element: table_element,
- fk_element: fk_element
+ var element = $('#element').html();
+ var table_element = $('#table_element').html();
+ var fk_element = $('#fk_element').html();
+
+ $('.edit_area').editable(urlSaveInPlace, {
+ type : 'textarea',
+ rows : 4,
+ id : 'field',
+ tooltip : tooltipInPlace,
+ placeholder : placeholderInPlace,
+ cancel : cancelInPlace,
+ submit : submitInPlace,
+ indicator : indicatorInPlace,
+ loadurl : urlLoadInPlace,
+ loaddata : {
+ type: 'textarea',
+ element: element,
+ table_element: table_element,
+ fk_element: fk_element
+ },
+ submitdata : {
+ type: 'textarea',
+ element: element,
+ table_element: table_element,
+ fk_element: fk_element
+ },
+ callback : function(result, settings) {
+ var obj = $.parseJSON(result);
+
+ if (obj.error) {
+ $(this).html(this.revert);
+ $.jnotify(obj.error, "error", true);
+ } else {
+ $(this).html(obj.value);
}
- });
- $('.edit_text').editable(urlSaveInPlace, {
- type : 'text',
- id : 'field',
- width : 300,
- tooltip : tooltipInPlace,
- cancel : cancelInPlace,
- submit : submitInPlace,
- indicator : indicatorInPlace,
- submitdata : {
- type: 'text',
- element: element,
- table_element: table_element,
- fk_element: fk_element
+ }
+ });
+ $('.edit_text').editable(urlSaveInPlace, {
+ type : 'text',
+ id : 'field',
+ width : 300,
+ tooltip : tooltipInPlace,
+ placeholder : placeholderInPlace,
+ cancel : cancelInPlace,
+ submit : submitInPlace,
+ indicator : indicatorInPlace,
+ submitdata : {
+ type: 'text',
+ element: element,
+ table_element: table_element,
+ fk_element: fk_element
+ },
+ callback : function(result, settings) {
+ var obj = $.parseJSON(result);
+
+ if (obj.error) {
+ $(this).html(this.revert);
+ $.jnotify(obj.error, "error", true);
+ } else {
+ $(this).html(obj.value);
}
- });
- $('.edit_numeric').editable(urlSaveInPlace, {
- type : 'text',
- id : 'field',
- width : 100,
- tooltip : tooltipInPlace,
- cancel : cancelInPlace,
- submit : submitInPlace,
- indicator : indicatorInPlace,
- submitdata : {
- type: 'numeric',
- element: element,
- table_element: table_element,
- fk_element: fk_element
+ }
+ });
+ $('.edit_numeric').editable(urlSaveInPlace, {
+ type : 'text',
+ id : 'field',
+ width : 100,
+ tooltip : tooltipInPlace,
+ placeholder : placeholderInPlace,
+ cancel : cancelInPlace,
+ submit : submitInPlace,
+ indicator : indicatorInPlace,
+ submitdata : {
+ type: 'numeric',
+ element: element,
+ table_element: table_element,
+ fk_element: fk_element
+ },
+ callback : function(result, settings) {
+ var obj = $.parseJSON(result);
+
+ if (obj.error) {
+ $(this).html(this.revert);
+ $.jnotify(obj.error, "error", true);
+ } else {
+ $(this).html(obj.value);
}
- });
+ }
});
});
\ No newline at end of file
diff --git a/htdocs/core/js/jnotify.js b/htdocs/core/js/jnotify.js
new file mode 100644
index 00000000000..18673c8d17a
--- /dev/null
+++ b/htdocs/core/js/jnotify.js
@@ -0,0 +1,26 @@
+// Copyright (C) 2011 Regis Houssin
+//
+// Script javascript that contains functions for jnotify default options
+//
+// \file htdocs/core/js/jnotify.js
+// \brief File that include javascript functions for jnotify default options
+
+
+$(document).ready(function() {
+ $.jnotify.setup({
+ delay: 3000 // the default time to show each notification (in milliseconds)
+ , sticky: false // determines if the message should be considered "sticky" (user must manually close notification)
+ , closeLabel: "×" // the HTML to use for the "Close" link
+ , showClose: true // determines if the "Close" link should be shown if notification is also sticky
+ , fadeSpeed: 1000 // the speed to fade messages out (in milliseconds)
+ , slideSpeed: 250 // the speed used to slide messages out (in milliseconds)
+ , classContainer: "jnotify-container"
+ , classNotification: "jnotify-notification"
+ , classBackground: "jnotify-background"
+ , classClose: "jnotify-close"
+ , classMessage: "jnotify-message"
+ , init: null // callback that occurs when the main jnotify container is created
+ , create: null // callback that occurs when when the note is created (occurs just before appearing in DOM)
+ , beforeRemove: null // callback that occurs when before the notification starts to fade away
+ });
+});
\ No newline at end of file
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index c70c05d3d5c..a9d7d4c01c0 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3963,21 +3963,6 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
jQuery.jnotify("'.dol_escape_js($out).'",
"'.($style=="ok" ? 3000 : $style).'",
'.($style=="ok" ? "false" : "true").',
- {
- closeLabel: "×" // the HTML to use for the "Close" link
- , showClose: true // determines if the "Close" link should be shown if notification is also sticky
- , fadeSpeed: 1000 // the speed to fade messages out (in milliseconds)
- , slideSpeed: 250 // the speed used to slide messages out (in milliseconds)
- , classContainer: "jnotify-container"
- , classNotification: "jnotify-notification"
- , classBackground: "jnotify-background"
- , classClose: "jnotify-close"
- , classMessage: "jnotify-message"
- , init: null // callback that occurs when the main jnotify container is created
- , create: null // callback that occurs when when the note is created (occurs just before
- // appearing in DOM)
- , beforeRemove: null // callback that occurs when before the notification starts to fade away
- },
{ remove: function (){} } );
});
';
diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php
index be28c6ee0a7..9fcf0800094 100644
--- a/htdocs/fichinter/fiche.php
+++ b/htdocs/fichinter/fiche.php
@@ -807,9 +807,7 @@ else if ($id > 0 || ! empty($ref))
{
print $langs->trans('Description');
print '';
- // FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
- // by editInPlace if necessary according to type (4rd parameter)
- print $form->editInPlace(dol_nl2br($object->description), 'description', $user->rights->ficheinter->creer && $object->statut == 0, 'area');
+ print $form->editInPlace($object->description, 'description', $user->rights->ficheinter->creer && $object->statut == 0, 'area');
}
else
{
@@ -872,9 +870,7 @@ else if ($id > 0 || ! empty($ref))
// Public note
print ' | | '.$langs->trans("NotePublic").' | ';
print '';
- // FIXME parameter note_public must not be denatured with a format function to be propagated. dol_nl2br must be used
- // by editInPlace if necessary according to type (4rd parameter)
- print $form->editInPlace(dol_nl2br($object->note_public), 'note_public', $user->rights->ficheinter->creer, 'area');
+ print $form->editInPlace($object->note_public, 'note_public', $user->rights->ficheinter->creer, 'area');
print " |
";
// Private note
@@ -882,7 +878,7 @@ else if ($id > 0 || ! empty($ref))
{
print '| '.$langs->trans("NotePrivate").' | ';
print '';
- print $form->editInPlace(dol_nl2br($object->note_private), 'note_private', $user->rights->ficheinter->creer);
+ print $form->editInPlace($object->note_private, 'note_private', $user->rights->ficheinter->creer);
print " |
";
}
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 10bd9adc5ce..6684d5ed698 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -601,6 +601,7 @@ AttributeCode=Attribute code
OptionalFieldsSetup=Extra attributes setup
URLPhoto=Url of photo/logo
CreateDraft=Create draft
+ClickToEdit=Click to edit
# Week day
Monday=Monday
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index ca02f0dbec0..2fd6ce72242 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -601,6 +601,7 @@ AttributeCode=Code de l'attribut
OptionalFieldsSetup=Configuration des attributs complémentaires
URLPhoto=Url vers photo/logo
CreateDraft=Créer brouillon
+ClickToEdit=Cliquer ici pour éditer
# Week day
Monday=Lundi
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index e5bc61c25eb..05c7e70afb1 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -922,7 +922,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print ''."\n";
}
// jQuery jnotify
- if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY)) print ''."\n";
+ if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY))
+ {
+ print ''."\n";
+ print ''."\n";
+ }
// jQuery jeditable
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE))
{
@@ -930,7 +934,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '