summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/rte.summernote.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-01-10 13:50:48 +0100
committerChristophe Simonis <chs@odoo.com>2017-01-10 13:50:48 +0100
commit557feb950cb74656c92e59a62847c9e414c9b41f (patch)
tree8b95618acf9659f7f5a6bc6d36e5b5090ce1ef68 /addons/web_editor/static/src/js/rte.summernote.js
parent63f732b9a10b9f13e7e5538a84a1d61dc6fb3ad8 (diff)
parent482fd04167410885264d5903ea621682f5f917db (diff)
[MERGE] forward port branch 10.0 up to 482fd041674
Diffstat (limited to 'addons/web_editor/static/src/js/rte.summernote.js')
-rw-r--r--addons/web_editor/static/src/js/rte.summernote.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js
index 1789ed69e7e..9f908a245bc 100644
--- a/addons/web_editor/static/src/js/rte.summernote.js
+++ b/addons/web_editor/static/src/js/rte.summernote.js
@@ -511,12 +511,32 @@ function prettify_html(html) {
}
return result;
}
-$.summernote.pluginEvents.codeview = function (event, editor, layoutInfo) {
+
+/*
+ * This override when clicking on the 'Code View' button has two aims:
+ *
+ * - have our own code view implementation for FieldTextHtml
+ * - add an 'enable' paramater to call the function directly and allow us to
+ * 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) {
+ return;
+ }
if (!$textarea.length) {
// init and create texarea