summaryrefslogtreecommitdiff
path: root/addons/web_editor/static
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-10-29 11:56:32 +0100
committerChristophe Simonis <chs@odoo.com>2018-10-29 11:56:32 +0100
commita299517f8327e9cd6036dbd0920ed5d3e9dac75a (patch)
treefbca208c214184e94bfa6868982c9078736ff71d /addons/web_editor/static
parent62b6889fe14d6781b4ffddc8f5b0f8f6db16672c (diff)
parent6136f0c02e5c15d245c2b19d990900314be8b8f4 (diff)
[MERGE] forward port branch saas-11.3 up to 6136f0c02e5
Diffstat (limited to 'addons/web_editor/static')
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js8
-rw-r--r--addons/web_editor/static/src/js/editor/snippets.options.js35
2 files changed, 37 insertions, 6 deletions
diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js
index bcc6a441e27..1e745d7cceb 100644
--- a/addons/web_editor/static/src/js/editor/rte.js
+++ b/addons/web_editor/static/src/js/editor/rte.js
@@ -607,6 +607,14 @@ var RTEWidget = Widget.extend({
return;
}
+ // Removes strange _moz_abspos attribute when it appears. Cannot
+ // find another solution which works in all cases. A grabber still
+ // appears at the same time which I did not manage to remove.
+ // TODO find a complete and better solution
+ _.defer(function () {
+ $editable.find('[_moz_abspos]').removeAttr('_moz_abspos');
+ });
+
if ($target.is('a')) {
/**
* Remove content editable everywhere and add it on the link only so that characters can be added
diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js
index d452dfe07b8..49285986240 100644
--- a/addons/web_editor/static/src/js/editor/snippets.options.js
+++ b/addons/web_editor/static/src/js/editor/snippets.options.js
@@ -279,15 +279,36 @@ var SnippetOption = Widget.extend({
*/
_setActive: function () {
var self = this;
- this.$el.find('[data-toggle-class], [data-select-class]')
- .addBack('[data-toggle-class], [data-select-class]')
+ this.$el.find('[data-toggle-class]')
+ .addBack('[data-toggle-class]')
.removeClass('active')
.filter(function () {
- var $elem = $(this);
- var className = $elem.data('toggleClass') || $elem.data('selectClass');
- return self.$target.hasClass(className);
+ var className = $(this).data('toggleClass');
+ return !className || self.$target.hasClass(className);
})
.addClass('active');
+
+ _processSelectClassElements(this.$el);
+ _.each(this.$el.find('.dropdown-menu'), function (group) {
+ _processSelectClassElements($(group).children());
+ });
+
+ function _processSelectClassElements($elements) {
+ var maxNbClasses = -1;
+ $elements.filter('[data-select-class]')
+ .removeClass('active')
+ .filter(function () {
+ var className = $(this).data('selectClass');
+ var nbClasses = className ? className.split(' ').length : 0;
+ if (nbClasses >= maxNbClasses && (!className || self.$target.hasClass(className))) {
+ maxNbClasses = nbClasses;
+ return true;
+ }
+ return false;
+ })
+ .last()
+ .addClass('active');
+ }
},
//--------------------------------------------------------------------------
@@ -754,7 +775,7 @@ registry.colorpicker = SnippetOption.extend({
*/
_onColorResetButtonClick: function () {
this.$target.removeClass(this.classes);
- self.$target.trigger('content_changed');
+ this.$target.trigger('content_changed');
this.$el.find('.colorpicker button.selected').removeClass('selected');
},
});
@@ -854,7 +875,9 @@ registry.background = SnippetOption.extend({
*/
setTarget: function () {
this._super.apply(this, arguments);
+ // TODO should be automatic for all options as equal to the start method
this.bindBackgroundEvents();
+ this.__customImageSrc = this._getSrcFromCssValue();
},
//--------------------------------------------------------------------------