summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/inline.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_editor/static/src/js/inline.js')
-rw-r--r--addons/web_editor/static/src/js/inline.js51
1 files changed, 26 insertions, 25 deletions
diff --git a/addons/web_editor/static/src/js/inline.js b/addons/web_editor/static/src/js/inline.js
index 765ce7682df..ac0dee435ae 100644
--- a/addons/web_editor/static/src/js/inline.js
+++ b/addons/web_editor/static/src/js/inline.js
@@ -1,6 +1,7 @@
odoo.define('web_editor.inline', function (require) {
'use strict';
+var core = require('web.core');
var editor = require('web_editor.editor');
var rte = require('web_editor.rte');
var widget = require('web_editor.widget');
@@ -9,22 +10,22 @@ var snippet_editor = require('web_editor.snippet.editor');
widget.MediaDialog.include({
start: function () {
- this._super.apply(this, arguments);
this.$('[href="#editor-media-video"]').addClass('hidden');
- }
+ return this._super.apply(this, arguments);
+ },
});
editor.Class.include({
start: function () {
- if (location.search.indexOf("enable_editor") !== -1) {
+ if (window.location.search.indexOf('enable_editor') !== -1) {
this.on('rte:start', this, function () {
// move the caret at the end of the text when click after all content
- $("#wrapwrap").on('click', function (event) {
- if ($(event.target).is("#wrapwrap") || $(event.target).is("#editable_area:empty")) {
+ $('#wrapwrap').on('click', function (event) {
+ if ($(event.target).is('#wrapwrap') || $(event.target).is('#editable_area:empty')) {
_.defer(function () {
- var node = $("#editable_area *")
+ var node = $('#editable_area *')
.filter(function () { return this.textContent.match(/\S|\u00A0/); })
- .add($("#editable_area"))
+ .add($('#editable_area'))
.last()[0];
$.summernote.core.range.create(node, $.summernote.core.dom.nodeLength(node)).select();
});
@@ -38,21 +39,22 @@ editor.Class.include({
snippet_editor.Class.include({
start: function () {
- this._super.apply(this, arguments);
- setTimeout(function () {
- var $editable = $("#editable_area");
- transcoder.img_to_font($editable);
- transcoder.style_to_class($editable);
+ _.defer(function () {
+ var $editable = $('#editable_area');
+ transcoder.imgToFont($editable);
+ transcoder.styleToClass($editable);
// fix outlook image rendering bug
$editable.find('img[style*="width"], img[style*="height"]').removeAttr('height width');
});
+ return this._super.apply(this, arguments);
},
- clean_for_save: function () {
+ cleanForSave: function () {
this._super.apply(this, arguments);
- var $editable = $("#editable_area");
- transcoder.font_to_img($editable);
- transcoder.class_to_style($editable);
+
+ var $editable = $('#editable_area');
+ transcoder.fontToImg($editable);
+ transcoder.classToStyle($editable);
// fix outlook image rendering bug
_.each(['width', 'height'], function (attribute) {
@@ -65,24 +67,23 @@ snippet_editor.Class.include({
},
});
-window.top.odoo[callback+"_updown"] = function (value, fields_values) {
- var $editable = $("#editable_area");
- value = value || "";
+var callback = window ? window['callback'] : undefined;
+window.top.odoo[callback + '_updown'] = function (value, fields_values) {
+ var $editable = $('#editable_area');
+ value = value || '';
if (value.indexOf('on_change_model_and_list') === -1 && value !== $editable.html()) {
rte.history.recordUndo($editable, null, true);
- if (snippet_editor.instance) {
- snippet_editor.instance.make_active(false);
- }
+ core.bus.trigger('deactivate_snippet');
$editable.html(value);
- transcoder.img_to_font($editable);
- transcoder.style_to_class($editable);
+ transcoder.imgToFont($editable);
+ transcoder.styleToClass($editable);
// fix outlook image rendering bug
$editable.find('img[style*="width"], img[style*="height"]').removeAttr('height width');
} else {
- $editable.trigger("content_changed");
+ $editable.trigger('content_changed');
}
};
});