From 5d8367747cddb8663b89f4c7b16c4fbae85d66ce Mon Sep 17 00:00:00 2001 From: fja-odoo Date: Thu, 20 Feb 2020 16:15:38 +0000 Subject: [PATCH] [REF] web_editor: remove useless code in palette Previously the widget was not refreshed everytime it was opened. Now that it is the case and since the color picker rerenders every time we select a color: It is no longer required to select/unselect the colors. It is no longer required to add custom colors to existing colors. Part of: https://github.com/odoo/odoo/pull/45872 task-2212288 closes odoo/odoo#47355 X-original-commit: 481fe703e9400fb64e96291914f76d4dca883e29 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/wysiwyg/widgets/color_palette.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js b/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js index f94a5e7b6e4..da468752b78 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/color_palette.js @@ -171,11 +171,7 @@ const ColorPaletteWidget = Widget.extend({ if (this.options.excluded.includes('custom')) { return; } - const existingColors = new Set(this.summernoteCustomColorsArray.concat( - [...this.el.querySelectorAll('.o_custom_color')].map(el => { - return ColorpickerDialog.normalizeCSSColor(el.style.backgroundColor); - }) - )); + const existingColors = new Set(this.summernoteCustomColorsArray); this.trigger_up('get_custom_colors', { onSuccess: (colors) => { colors.forEach(color => { @@ -265,8 +261,6 @@ const ColorPaletteWidget = Widget.extend({ */ _onColorButtonClick: function (ev) { const buttonEl = ev.currentTarget; - this.$('button.selected').removeClass('selected'); - $(buttonEl).addClass('selected'); const colorInfo = this._getButtonInfo(buttonEl); this._selectColor(colorInfo); }, @@ -307,7 +301,6 @@ const ColorPaletteWidget = Widget.extend({ * @param {Event} ev */ _onColorResetButtonClick: function (ev) { - this.$('button.selected').removeClass('selected'); this.selectedColor = false; this.trigger_up('color_reset', { target: ev.target, @@ -329,7 +322,6 @@ const ColorPaletteWidget = Widget.extend({ defaultColor: selectedColor, }); colorpicker.on('colorpicker:saved', this, ev => { - this.$('button.selected').removeClass('selected'); this._selectColor({ color: ev.data.cssColor, target: target,