*: mass_mailing, web, web_editor, website_blog, website_event, website_event_meet, website_livechat, website_sale, website_twitter, base This commit does 3 things: - Adapt existing code so that the editor can be run outside of its editing element. Prior to this commit, it was expected that the editor would be attached to the element it was currently editing. This needs to change however as the editable is now inside an iframe for the website edition. mass_mailing already had a similar approach but the editor was started within the iframe. With these changes, the editor is alongside the iframe, editing the content that's inside it. This allows multiple features such as reloading the iframe while keeping the editor visible and resizing the iframe for a mobile preview. - Adds logic to the wysiwyg_adapter so that it can undertake the duty of the previous widget sytem. The wysiwyg existed not only in the legacy widget system, but most importantly in the frontend. One of the duties of this adapter is to send events inside the iframe when it is necessary to reach the frontend public widget (i.e. widgets_start_request) - Removes existing SCSS that is no longer used. See merge commit for more information. task-2687506
71 lines
2.2 KiB
JavaScript
71 lines
2.2 KiB
JavaScript
odoo.define('website_twitter.editor', function (require) {
|
|
'use strict';
|
|
|
|
var core = require('web.core');
|
|
var dom = require('web.dom');
|
|
var sOptions = require('web_editor.snippets.options');
|
|
|
|
var _t = core._t;
|
|
|
|
sOptions.registry.twitter = sOptions.Class.extend({
|
|
/**
|
|
* @override
|
|
*/
|
|
start: function () {
|
|
var self = this;
|
|
var $configuration = dom.renderButton({
|
|
attrs: {
|
|
class: 'btn-primary d-none',
|
|
contenteditable: 'false',
|
|
},
|
|
text: _t("Reload"),
|
|
});
|
|
const div = document.createElement('div');
|
|
document.body.appendChild(div);
|
|
$configuration.appendTo(div).on('click', function (ev) {
|
|
ev.preventDefault();
|
|
ev.stopPropagation();
|
|
self._rpc({route: '/website_twitter/reload'});
|
|
});
|
|
this.$target.on('mouseover.website_twitter', function () {
|
|
var $selected = $(this);
|
|
var position = $selected.offset();
|
|
$configuration.removeClass('d-none').offset({
|
|
top: $selected.outerHeight() / 2
|
|
+ position.top
|
|
- $configuration.outerHeight() / 2,
|
|
left: $selected.outerWidth() / 2
|
|
+ position.left
|
|
- $configuration.outerWidth() / 2,
|
|
});
|
|
}).on('mouseleave.website_twitter', function (e) {
|
|
var current = document.elementFromPoint(e.clientX, e.clientY);
|
|
if (current === $configuration[0]) {
|
|
return;
|
|
}
|
|
$configuration.addClass('d-none');
|
|
});
|
|
this.$target.on('click.website_twitter', '.lnk_configure', function (e) {
|
|
window.location = e.currentTarget.href;
|
|
});
|
|
this.trigger_up('widgets_stop_request', {
|
|
$target: this.$target,
|
|
});
|
|
return this._super.apply(this, arguments);
|
|
},
|
|
/**
|
|
* @override
|
|
*/
|
|
cleanForSave: function () {
|
|
this.$target.find('.twitter_timeline').empty();
|
|
},
|
|
/**
|
|
* @override
|
|
*/
|
|
destroy: function () {
|
|
this._super.apply(this, arguments);
|
|
this.$target.off('.website_twitter');
|
|
},
|
|
});
|
|
});
|