summaryrefslogtreecommitdiff
path: root/addons/website_forum/static
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2019-09-09 15:51:47 +0000
committerqsm-odoo <qsm@odoo.com>2019-09-10 12:12:28 +0000
commit8025205bb4dee4d92a85de86a0cc4436cfb70149 (patch)
tree1ce93c225a5b40e2b5b86e0333558de8185cfa3e /addons/website_forum/static
parent50d2f188f80fd5f13f72b352962ec12e099b8751 (diff)
[IMP] web_editor, *: introduce wysiwyg frontend loader
* website_forum, website_profile - Share some code between website_forum and website_profile by exposing a function in web_editor to instantiate a wysiwyg instance on a textarea - Use no-lazy loaded JS to add a visual loading effect while the wysiwyg is not yet available. This is made in preparation of task-2024197 (see https://github.com/odoo/odoo/pull/35749) Thanks to @stefanorigano closes odoo/odoo#36581 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/website_forum/static')
-rw-r--r--addons/website_forum/static/src/js/website_forum.js15
1 files changed, 5 insertions, 10 deletions
diff --git a/addons/website_forum/static/src/js/website_forum.js b/addons/website_forum/static/src/js/website_forum.js
index b4f15dad5c8..d4e65371a58 100644
--- a/addons/website_forum/static/src/js/website_forum.js
+++ b/addons/website_forum/static/src/js/website_forum.js
@@ -2,10 +2,9 @@ odoo.define('website_forum.website_forum', function (require) {
'use strict';
var core = require('web.core');
-var Wysiwyg = require('web_editor.wysiwyg.root');
+var wysiwygLoader = require('web_editor.loader');
var publicWidget = require('web.public.widget');
var session = require('web.session');
-var utils = require('web.utils');
var qweb = core.qweb;
var _t = core._t;
@@ -111,12 +110,9 @@ publicWidget.registry.websiteForum = publicWidget.Widget.extend({
},
});
- _.each($('textarea.load_editor'), function (textarea) {
+ _.each($('textarea.o_wysiwyg_loader'), function (textarea) {
var $textarea = $(textarea);
var editorKarma = $textarea.data('karma') || 0; // default value for backward compatibility
- if (!$textarea.val().match(/\S/)) {
- $textarea.val('<p><br/></p>');
- }
var $form = $textarea.closest('form');
var hasFullEdit = parseInt($("#karma").val()) >= editorKarma;
var toolbar = [
@@ -146,12 +142,11 @@ publicWidget.registry.websiteForum = publicWidget.Widget.extend({
MediaPlugin: false,
};
}
- var wysiwyg = new Wysiwyg(self, options);
- wysiwyg.attachTo($textarea).then(function () {
+ wysiwygLoader.load(self, $textarea[0], options).then(wysiwyg => {
// float-left class messes up the post layout OPW 769721
$form.find('.note-editable').find('img.float-left').removeClass('float-left');
- $form.on('click', 'button .a-submit', function () {
- $form.find('textarea').data('wysiwyg').save();
+ $form.on('click', 'button .a-submit', () => {
+ wysiwyg.save();
});
});
});