forked from Wavyzz/dolibarr
Fix: move jnotify options in separate file
Fix: move nl2br treatment New: add error message for edit in place
This commit is contained in:
@@ -361,7 +361,7 @@ else if ($id)
|
|||||||
|
|
||||||
// Km/Price
|
// Km/Price
|
||||||
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td>';
|
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td>';
|
||||||
print '<td>'.$form->editInPlace(price($object->km), 'km', $user->rights->deplacement->creer, 'numeric').'</td></tr>';
|
print '<td>'.$form->editInPlace($object->km, 'km', $user->rights->deplacement->creer, 'numeric').'</td></tr>';
|
||||||
|
|
||||||
// Where
|
// Where
|
||||||
print '<tr><td>'.$langs->trans("CompanyVisited").'</td>';
|
print '<tr><td>'.$langs->trans("CompanyVisited").'</td>';
|
||||||
@@ -405,9 +405,7 @@ else if ($id)
|
|||||||
// Public note
|
// Public note
|
||||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
|
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
|
||||||
print '<td valign="top" colspan="3">';
|
print '<td valign="top" colspan="3">';
|
||||||
// FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
|
print $form->editInPlace($object->note_public, 'note_public', $user->rights->deplacement->creer, 'area');
|
||||||
// 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 "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
// Private note
|
// Private note
|
||||||
@@ -415,9 +413,7 @@ else if ($id)
|
|||||||
{
|
{
|
||||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
||||||
print '<td valign="top" colspan="3">';
|
print '<td valign="top" colspan="3">';
|
||||||
// FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
|
print $form->editInPlace($object->note_private, 'note', $user->rights->deplacement->creer, 'area');
|
||||||
// by editInPlace if necessary according to type (4rd parameter)
|
|
||||||
print $form->editInPlace(dol_nl2br($object->note_private), 'note', $user->rights->deplacement->creer, 'area');
|
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
|
|||||||
top_httphead();
|
top_httphead();
|
||||||
|
|
||||||
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||||
//var_dump($_POST);
|
//print_r($_POST);
|
||||||
|
|
||||||
// Load original field value
|
// Load original field value
|
||||||
if((isset($_POST['field']) && ! empty($_POST['field']))
|
if((isset($_POST['field']) && ! empty($_POST['field']))
|
||||||
@@ -52,6 +52,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
|||||||
$value = GETPOST('value');
|
$value = GETPOST('value');
|
||||||
$type = GETPOST('type');
|
$type = GETPOST('type');
|
||||||
|
|
||||||
|
$return=array();
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
if ($element == 'fichinter') $element = 'ficheinter';
|
if ($element == 'fichinter') $element = 'ficheinter';
|
||||||
@@ -70,6 +71,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
|||||||
if (! is_numeric($value))
|
if (! is_numeric($value))
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
|
$return['error'] = $langs->trans('ErrorBadValue');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,11 +81,13 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
|||||||
if ($ret > 0)
|
if ($ret > 0)
|
||||||
{
|
{
|
||||||
if ($type == 'numeric') $value = price($value);
|
if ($type == 'numeric') $value = price($value);
|
||||||
else $value = (! empty($value) ? dol_nl2br($value) : ' ');
|
else if ($type == 'textarea') $value = dol_nl2br($value);
|
||||||
|
|
||||||
echo $value;
|
$return['value'] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo json_encode($return);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -153,10 +153,13 @@ class Form
|
|||||||
*/
|
*/
|
||||||
function editInPlace($value, $htmlname, $condition, $type='area')
|
function editInPlace($value, $htmlname, $condition, $type='area')
|
||||||
{
|
{
|
||||||
global $conf,$user;
|
global $conf;
|
||||||
|
|
||||||
$out='';
|
$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)
|
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,62 +7,93 @@
|
|||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(document).ready(function() {
|
var element = $('#element').html();
|
||||||
var element = $('#element').html();
|
var table_element = $('#table_element').html();
|
||||||
var table_element = $('#table_element').html();
|
var fk_element = $('#fk_element').html();
|
||||||
var fk_element = $('#fk_element').html();
|
|
||||||
|
$('.edit_area').editable(urlSaveInPlace, {
|
||||||
$('.edit_area').editable(urlSaveInPlace, {
|
type : 'textarea',
|
||||||
type : 'textarea',
|
rows : 4,
|
||||||
rows : 4,
|
id : 'field',
|
||||||
id : 'field',
|
tooltip : tooltipInPlace,
|
||||||
tooltip : tooltipInPlace,
|
placeholder : placeholderInPlace,
|
||||||
cancel : cancelInPlace,
|
cancel : cancelInPlace,
|
||||||
submit : submitInPlace,
|
submit : submitInPlace,
|
||||||
indicator : indicatorInPlace,
|
indicator : indicatorInPlace,
|
||||||
loadurl : urlLoadInPlace,
|
loadurl : urlLoadInPlace,
|
||||||
loaddata : {
|
loaddata : {
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
element: element,
|
element: element,
|
||||||
table_element: table_element,
|
table_element: table_element,
|
||||||
fk_element: fk_element
|
fk_element: fk_element
|
||||||
},
|
},
|
||||||
submitdata : {
|
submitdata : {
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
element: element,
|
element: element,
|
||||||
table_element: table_element,
|
table_element: table_element,
|
||||||
fk_element: fk_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',
|
$('.edit_text').editable(urlSaveInPlace, {
|
||||||
id : 'field',
|
type : 'text',
|
||||||
width : 300,
|
id : 'field',
|
||||||
tooltip : tooltipInPlace,
|
width : 300,
|
||||||
cancel : cancelInPlace,
|
tooltip : tooltipInPlace,
|
||||||
submit : submitInPlace,
|
placeholder : placeholderInPlace,
|
||||||
indicator : indicatorInPlace,
|
cancel : cancelInPlace,
|
||||||
submitdata : {
|
submit : submitInPlace,
|
||||||
type: 'text',
|
indicator : indicatorInPlace,
|
||||||
element: element,
|
submitdata : {
|
||||||
table_element: table_element,
|
type: 'text',
|
||||||
fk_element: fk_element
|
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',
|
$('.edit_numeric').editable(urlSaveInPlace, {
|
||||||
id : 'field',
|
type : 'text',
|
||||||
width : 100,
|
id : 'field',
|
||||||
tooltip : tooltipInPlace,
|
width : 100,
|
||||||
cancel : cancelInPlace,
|
tooltip : tooltipInPlace,
|
||||||
submit : submitInPlace,
|
placeholder : placeholderInPlace,
|
||||||
indicator : indicatorInPlace,
|
cancel : cancelInPlace,
|
||||||
submitdata : {
|
submit : submitInPlace,
|
||||||
type: 'numeric',
|
indicator : indicatorInPlace,
|
||||||
element: element,
|
submitdata : {
|
||||||
table_element: table_element,
|
type: 'numeric',
|
||||||
fk_element: fk_element
|
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);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
26
htdocs/core/js/jnotify.js
Normal file
26
htdocs/core/js/jnotify.js
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3963,21 +3963,6 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
|
|||||||
jQuery.jnotify("'.dol_escape_js($out).'",
|
jQuery.jnotify("'.dol_escape_js($out).'",
|
||||||
"'.($style=="ok" ? 3000 : $style).'",
|
"'.($style=="ok" ? 3000 : $style).'",
|
||||||
'.($style=="ok" ? "false" : "true").',
|
'.($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 (){} } );
|
{ remove: function (){} } );
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
|
|||||||
@@ -807,9 +807,7 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
print $langs->trans('Description');
|
print $langs->trans('Description');
|
||||||
print '</td><td colspan="3">';
|
print '</td><td colspan="3">';
|
||||||
// FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
|
print $form->editInPlace($object->description, 'description', $user->rights->ficheinter->creer && $object->statut == 0, 'area');
|
||||||
// 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');
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -872,9 +870,7 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
// Public note
|
// Public note
|
||||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
|
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
|
||||||
print '<td valign="top" colspan="3">';
|
print '<td valign="top" colspan="3">';
|
||||||
// FIXME parameter note_public must not be denatured with a format function to be propagated. dol_nl2br must be used
|
print $form->editInPlace($object->note_public, 'note_public', $user->rights->ficheinter->creer, 'area');
|
||||||
// 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 "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
// Private note
|
// Private note
|
||||||
@@ -882,7 +878,7 @@ else if ($id > 0 || ! empty($ref))
|
|||||||
{
|
{
|
||||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
||||||
print '<td valign="top" colspan="3">';
|
print '<td valign="top" colspan="3">';
|
||||||
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 "</td></tr>";
|
print "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -601,6 +601,7 @@ AttributeCode=Attribute code
|
|||||||
OptionalFieldsSetup=Extra attributes setup
|
OptionalFieldsSetup=Extra attributes setup
|
||||||
URLPhoto=Url of photo/logo
|
URLPhoto=Url of photo/logo
|
||||||
CreateDraft=Create draft
|
CreateDraft=Create draft
|
||||||
|
ClickToEdit=Click to edit
|
||||||
|
|
||||||
# Week day
|
# Week day
|
||||||
Monday=Monday
|
Monday=Monday
|
||||||
|
|||||||
@@ -601,6 +601,7 @@ AttributeCode=Code de l'attribut
|
|||||||
OptionalFieldsSetup=Configuration des attributs complémentaires
|
OptionalFieldsSetup=Configuration des attributs complémentaires
|
||||||
URLPhoto=Url vers photo/logo
|
URLPhoto=Url vers photo/logo
|
||||||
CreateDraft=Créer brouillon
|
CreateDraft=Créer brouillon
|
||||||
|
ClickToEdit=Cliquer ici pour éditer
|
||||||
|
|
||||||
# Week day
|
# Week day
|
||||||
Monday=Lundi
|
Monday=Lundi
|
||||||
|
|||||||
@@ -922,7 +922,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
|
|||||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/layout/jquery.layout-latest'.$ext.'"></script>'."\n";
|
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/layout/jquery.layout-latest'.$ext.'"></script>'."\n";
|
||||||
}
|
}
|
||||||
// jQuery jnotify
|
// jQuery jnotify
|
||||||
if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY)) print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js"></script>'."\n";
|
if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY))
|
||||||
|
{
|
||||||
|
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js"></script>'."\n";
|
||||||
|
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/jnotify.js"></script>'."\n";
|
||||||
|
}
|
||||||
// jQuery jeditable
|
// jQuery jeditable
|
||||||
if (! empty($conf->global->MAIN_USE_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 '<script type="text/javascript">'."\n";
|
print '<script type="text/javascript">'."\n";
|
||||||
print 'var urlSaveInPlace = \''.DOL_URL_ROOT.'/core/ajax/saveinplace.php\';'."\n";
|
print 'var urlSaveInPlace = \''.DOL_URL_ROOT.'/core/ajax/saveinplace.php\';'."\n";
|
||||||
print 'var urlLoadInPlace = \''.DOL_URL_ROOT.'/core/ajax/loadinplace.php\';'."\n";
|
print 'var urlLoadInPlace = \''.DOL_URL_ROOT.'/core/ajax/loadinplace.php\';'."\n";
|
||||||
print 'var tooltipInPlace = \''.$langs->trans('ClickToEdit').'\';'."\n";
|
print 'var tooltipInPlace = \''.$langs->transnoentities('ClickToEdit').'\';'."\n";
|
||||||
|
print 'var placeholderInPlace = \''.$langs->trans('ClickToEdit').'\';'."\n";
|
||||||
print 'var cancelInPlace = \''.$langs->trans('Cancel').'\';'."\n";
|
print 'var cancelInPlace = \''.$langs->trans('Cancel').'\';'."\n";
|
||||||
print 'var submitInPlace = \''.$langs->trans('Ok').'\';'."\n";
|
print 'var submitInPlace = \''.$langs->trans('Ok').'\';'."\n";
|
||||||
print 'var indicatorInPlace = \'<img src="'.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'">\';'."\n";
|
print 'var indicatorInPlace = \'<img src="'.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'">\';'."\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user