diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index cf5647ae055..c21931f8b25 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -346,7 +346,6 @@ else if ($id) // Type print ''.$langs->trans("Type").''; print $form->editInPlace($langs->trans($object->type), 'type', $user->rights->deplacement->creer, 'select', 'types_fees'); - //print $langs->trans($object->type); print ''; // Who @@ -407,7 +406,7 @@ else if ($id) // Public note print ''.$langs->trans("NotePublic").''; print ''; - print $form->editInPlace($object->note_public, 'note_public', $user->rights->deplacement->creer, 'textarea'); + print $form->editInPlace($object->note_public, 'note_public', $user->rights->deplacement->creer, 'ckeditor', 'dolibarr_notes'); print ""; // Private note @@ -415,7 +414,7 @@ else if ($id) { print ''.$langs->trans("NotePrivate").''; print ''; - print $form->editInPlace($object->note_private, 'note', $user->rights->deplacement->creer, 'textarea'); + print $form->editInPlace($object->note_private, 'note', $user->rights->deplacement->creer, 'ckeditor', 'dolibarr_notes'); print ""; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6372ede364b..1d644f6d6e0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -149,28 +149,44 @@ class Form * @param string $value Value to show/edit * @param string $htmlname DIV ID (field name) * @param int $condition Condition to edit - * @param string $area Type of edit - * @param string $loadmethod Name of load method + * @param string $inputType Type of input + * @param string $inputOption Input option * @return string HTML edit in place */ - function editInPlace($value, $htmlname, $condition, $type='textarea', $loadmethod='') + function editInPlace($value, $htmlname, $condition, $inputType='textarea', $inputOption='') { global $conf; $out=''; // Check parameters - if ($type == 'textarea') $value = dol_nl2br($value); - else if ($type == 'numeric') $value = price($value); - else if ($type == 'datepicker') $value = dol_print_date($value, 'day'); + if ($inputType == 'textarea') $value = dol_nl2br($value); + else if ($inputType == 'numeric') $value = price($value); + else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day'); if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition) { - // Use for timestamp format - if ($type == 'datepicker') $out.= ''; - else if ($type == 'select' && ! empty($loadmethod)) $out.= ''; + if ($inputType == 'datepicker') + { + $out.= ''; // Use for timestamp format + } + else if ($inputType == 'select' && ! empty($inputOption)) + { + $out.= ''; + } + else if ($inputType == 'ckeditor' && ! empty($inputOption)) + { + if (! empty($conf->fckeditor->enabled)) + { + $out.= ''; + } + else + { + $inputType = 'textarea'; + } + } - $out.= '
'; + $out.= '
'; $out.= $value; $out.= '
'; } diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index b36e0aa6b48..5ff7ca6cd25 100644 --- a/htdocs/core/js/editinplace.js +++ b/htdocs/core/js/editinplace.js @@ -44,6 +44,36 @@ $(document).ready(function() { } } }); + $('.edit_ckeditor').editable(urlSaveInPlace, { + type : 'ckeditor', + id : 'field', + onblur : 'ignore', + tooltip : tooltipInPlace, + placeholder : placeholderInPlace, + cancel : cancelInPlace, + submit : submitInPlace, + indicator : indicatorInPlace, + ckeditor : { + customConfig: ckeditorConfig, + toolbar: $('#toolbar').val() + }, + submitdata : { + type: 'ckeditor', + 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', diff --git a/htdocs/includes/jquery/plugins/ckeip/ckeip.jgz b/htdocs/includes/jquery/plugins/ckeip/ckeip.jgz deleted file mode 100755 index d8ef3b259bb..00000000000 Binary files a/htdocs/includes/jquery/plugins/ckeip/ckeip.jgz and /dev/null differ diff --git a/htdocs/includes/jquery/plugins/ckeip/ckeip.js b/htdocs/includes/jquery/plugins/ckeip/ckeip.js deleted file mode 100644 index bf75efbe9af..00000000000 --- a/htdocs/includes/jquery/plugins/ckeip/ckeip.js +++ /dev/null @@ -1,70 +0,0 @@ -/* -# CKEDITOR Edit-In Place jQuery Plugin. -# Created By Dave Earley. -# www.Dave-Earley.com -*/ - -$.fn.ckeip = function (options, callback) { - - var original_html = $(this); - var defaults = { - e_height: '10', - data: {}, e_url: '', - e_hover_color: '#eeeeee', - ckeditor_config: '', - e_width: '50' - }; - var settings = $.extend({}, defaults, options); - - return this.each(function () { - var eip_html = $(this).html(); - var u_id = Math.floor(Math.random() * 99999999); - - - $(this).before(""); - - $('#ckeip_e_' + u_id + '').ckeditor(settings.ckeditor_config); - - $(this).bind("dblclick", function () { - - $(this).hide(); - $('#ckeip_' + u_id + '').show(); - - }); - - $(this).hover(function () { - $(this).css({ - backgroundColor: settings.e_hover_color - }); - }, function () { - $(this).css({ - backgroundColor: '' - }); - }); - - - $("#cancel_ckeip_" + u_id + "").click(function () { - $('#ckeip_' + u_id + '').hide(); - $(original_html).fadeIn(); - return false; - }); - - $("#save_ckeip_" + u_id + "").click(function () { - var ckeip_html = $('#ckeip_e_' + u_id + '').val(); - $.post(settings.e_url, { - content: ckeip_html, - data: settings.data - }, function (response) { - if (typeof callback == "function") callback(response); - - $(original_html).html(ckeip_html); - $('#ckeip_' + u_id + '').hide(); - $(original_html).fadeIn(); - - });; - return false; - - }); - - }); -}; \ No newline at end of file diff --git a/htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js b/htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js new file mode 100644 index 00000000000..3682d4fe14e --- /dev/null +++ b/htdocs/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js @@ -0,0 +1,70 @@ +/* + * CKEditor input for Jeditable + * + * Adapted from Wysiwyg input for Jeditable by Mike Tuupola + * http://www.appelsiini.net/2008/9/wysiwyg-for-jeditable + * + * Copyright (c) 2009 Jeremy Bell + * + * Licensed under the MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * Depends on CKEditor: + * http://ckeditor/ + * + */ + +(function($) { + $.generateId = function() { + return arguments.callee.prefix + arguments.callee.count++; + }; + $.generateId.prefix = 'jq$'; + $.generateId.count = 0; + + $.fn.generateId = function() { + return this.each(function() { + this.id = $.generateId(); + }); + }; +})(jQuery); + +(function($) { +$.editable.addInputType('ckeditor', { + /* Use default textarea instead of writing code here again. */ + //element : $.editable.types.textarea.element, + element : function(settings, original) { + /* Hide textarea to avoid flicker. */ + var textarea = $('