[FIX] web_editor: ignore read only + debug + write

In some case (for example the one solved with b51d21c5) we can have
write done on a field text in read only mode.

With 98ed53ce if :

- such a case happened (in b51d21c5 the fix only worked after the given
  field was written one time) or a similar instance,
- and the user was in debug mode,
- and the widget used was TextFieldHtmlSimple

this could lead to an issue with the code trying to toggle the code view
mode whilst the editor is closed.
This commit is contained in:
Nicolas Lempereur
2017-01-10 08:31:38 +01:00
parent 17adc2e09e
commit 3f7b1f6083
@@ -494,13 +494,18 @@ function prettify_html(html) {
* disable (false) or enable (true) the code view mode.
*/
$.summernote.pluginEvents.codeview = function (event, editor, layoutInfo, enable) {
if (layoutInfo === undefined) {
return;
}
if (layoutInfo.toolbar) {
// if editor inline (FieldTextHtmlSimple)
var is_activated = $.summernote.eventHandler.modules.codeview.isActivated(layoutInfo);
if (is_activated === enable) {
return;
}
return eventHandler.modules.codeview.toggle(layoutInfo);
} else {
// if editor iframe (FieldTextHtml)
var $editor = layoutInfo.editor();
var $textarea = $editor.prev('textarea');
if ($textarea.is('textarea') === enable) {