diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-07-07 16:02:53 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-07-10 17:00:11 +0200 |
| commit | 8c559044a5e1be111dcb577ad7e5ab462c1002a0 (patch) | |
| tree | ba1602e15b2bca38babd6cca63a41da1d05b4321 /addons/web_editor/static/src/js/inline.js | |
| parent | a616c57c609da0e5e56835dcb45e1c05590d25b8 (diff) | |
[IMP] web_editor: split website into web_editor (to use editor in backend for html field) and website
Diffstat (limited to 'addons/web_editor/static/src/js/inline.js')
| -rw-r--r-- | addons/web_editor/static/src/js/inline.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/inline.js b/addons/web_editor/static/src/js/inline.js new file mode 100644 index 00000000000..c5fd2cfd924 --- /dev/null +++ b/addons/web_editor/static/src/js/inline.js @@ -0,0 +1,77 @@ +odoo.define('web_editor.inline', function (require) { +'use strict'; + +var editor = require('web_editor.editor'); +var rte = require('web_editor.rte'); +var widget = require('web_editor.widget'); +var transcoder = require('web_editor.transcoder'); +var snippet_editor = require('web_editor.snippet.editor'); + +widget.MediaDialog.include({ + start: function () { + this._super(); + this.$('[href="#editor-media-video"]').addClass('hidden'); + } +}); + +editor.Class.include({ + start: function () { + var self = this; + if (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")) { + setTimeout(function () { + var node = $("#editable_area *") + .filter(function () { return this.textContent.match(/\S|\u00A0/); }) + .add($("#editable_area")) + .last()[0]; + $.summernote.core.range.create(node, $.summernote.core.dom.nodeLength(node)).select(); + },0); + } + }); + }); + } + return this._super.apply(this, arguments); + }, +}); + +snippet_editor.Class.include({ + start: function () { + var self = this; + this._super(); + setTimeout(function () { + var $editable = $("#editable_area"); + transcoder.img_to_font($editable); + transcoder.style_to_class($editable); + }); + }, + clean_for_save: function () { + this._super(); + var $editable = $("#editable_area"); + transcoder.class_to_style($editable); + transcoder.font_to_img($editable); + }, + +}); + +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); + } + + $editable.html(value); + + transcoder.img_to_font($editable); + transcoder.style_to_class($editable); + } else { + $editable.trigger("content_changed"); + } +}; + +});
\ No newline at end of file |
