From c2b8d2a3017256e4ea60a3710bdaab6d1f693d81 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 18 Oct 2018 13:28:09 +0000 Subject: [FIX] web_editor: review _setActive system for select-class - Handle the case where one select-class is a subset of another select-class of the same group e.g. <... data-select-class="hello"/> <... data-select-class="hello world"/> - Handle empty values <... data-select-class=""/> Note: both cases worked but were not displaying the active checkbox correctly in the editor UI. --- .../static/src/js/editor/snippets.options.js | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'addons/web_editor/static/src/js') 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 346fc3d8f91..67df263f60f 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -275,15 +275,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'); + } }, //-------------------------------------------------------------------------- -- cgit v1.2.3 From 4150dd584973e0b1860c5122d531462ccf7c1ccd Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 18 Oct 2018 13:44:04 +0000 Subject: [FIX] web_editor: fix background reset system for carousel items When the user previews a background color, the background image of the snippet is removed and re-added if the user chooses not to pick the color. The background-image was not correctly added for carousel items. --- addons/web_editor/static/src/js/editor/snippets.options.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'addons/web_editor/static/src/js') 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 67df263f60f..3f0212c201b 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -933,7 +933,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(); }, //-------------------------------------------------------------------------- -- cgit v1.2.3 From 3a2939d494d9270b5246de5af5f77480a6505170 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 18 Oct 2018 12:20:34 +0200 Subject: [FIX] web_editor: disable strange resize handles on Firefox See comments in the code for details... Closes https://github.com/odoo/odoo/pull/27964 --- addons/web_editor/static/src/js/rte.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'addons/web_editor/static/src/js') diff --git a/addons/web_editor/static/src/js/rte.js b/addons/web_editor/static/src/js/rte.js index da2c2acd5e0..940d8482341 100644 --- a/addons/web_editor/static/src/js/rte.js +++ b/addons/web_editor/static/src/js/rte.js @@ -518,6 +518,14 @@ var RTE = 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 -- cgit v1.2.3 From cd580dd60545766acd0a02ea9dc89e2c9c5de743 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 26 Oct 2018 09:44:13 +0000 Subject: [FIX] web_editor: fix forward-port Forward-port of https://github.com/odoo/odoo/commit/227fc6408ddc998529bb1c38222ddba50f40868b made with https://github.com/odoo/odoo/commit/717f4583949219c346c87c390fbc336b4f31571c introduced a JS error. closes odoo/odoo#28187 --- addons/web_editor/static/src/js/editor/snippets.options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web_editor/static/src/js') 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 3f0212c201b..b9aeafd7ccd 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -834,7 +834,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'); }, }); -- cgit v1.2.3