From 2ca115f650e9f67c528cab0b3369a92b98842738 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Thu, 8 Oct 2020 08:59:55 +0000 Subject: [PATCH] [FIX] web_editor, website, website_mass_mailing: center bg images Before this commit, background images were not centered by default. It was especially annoying on mobile device. We created a new class to center background image and we added it on all the snippets with a background image except those with a parallax effect because they already have a background-position in inline style. task-2318526 closes odoo/odoo#60430 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.options.js | 4 ++-- addons/website/static/src/scss/website.scss | 3 +++ addons/website/static/src/snippets/s_blockquote/options.js | 5 ++--- addons/website/views/snippets/s_carousel.xml | 6 +++--- addons/website/views/snippets/s_masonry_block.xml | 2 +- addons/website/views/snippets/s_popup.xml | 2 +- addons/website/views/snippets/s_product_catalog.xml | 2 +- addons/website/views/snippets/s_quotes_carousel.xml | 4 ++-- addons/website/views/website_templates.xml | 2 +- addons/website_mass_mailing/views/snippets_templates.xml | 2 +- 10 files changed, 17 insertions(+), 15 deletions(-) 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 55fcc9fb2ad..2a90a7b4675 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -3833,10 +3833,10 @@ registry.BackgroundImage = SnippetOptionWidget.extend({ _setBackground($target, backgroundURL) { if (backgroundURL) { $target.css('background-image', `url('${backgroundURL}')`); - $target.addClass('oe_img_bg'); + $target.addClass('oe_img_bg o_bg_img_center'); } else { $target.css('background-image', ''); - $target.removeClass('oe_img_bg'); + $target.removeClass('oe_img_bg o_bg_img_center'); } }, }); diff --git a/addons/website/static/src/scss/website.scss b/addons/website/static/src/scss/website.scss index 9a489ba1b76..723037ca69d 100644 --- a/addons/website/static/src/scss/website.scss +++ b/addons/website/static/src/scss/website.scss @@ -358,6 +358,9 @@ font[class*='bg-'] { background-size: auto; background-repeat: repeat; } + &.o_bg_img_center { + background-position: center; + } // Compatibility <= 13.0, TODO remove? // ----------------------------------- diff --git a/addons/website/static/src/snippets/s_blockquote/options.js b/addons/website/static/src/snippets/s_blockquote/options.js index 66bbfbd583a..85c6d81a962 100644 --- a/addons/website/static/src/snippets/s_blockquote/options.js +++ b/addons/website/static/src/snippets/s_blockquote/options.js @@ -22,8 +22,7 @@ snippetOptions.registry.Blockquote = snippetOptions.SnippetOptionWidget.extend({ const $blockquote = this.$target.find('.s_blockquote_content'); if (widgetValue === 'cover') { $blockquote.css({"background-image": "url('/web/image/website.s_blockquote_cover_default_image')"}); - $blockquote.css({"background-position": "50% 50%"}); - $blockquote.addClass('oe_img_bg'); + $blockquote.addClass('oe_img_bg o_bg_img_center'); if (!$blockquote.find('.o_we_bg_filter').length) { const bgFilterEl = document.createElement('div'); bgFilterEl.classList.add('o_we_bg_filter', 'bg-white-50'); @@ -32,7 +31,7 @@ snippetOptions.registry.Blockquote = snippetOptions.SnippetOptionWidget.extend({ } else { $blockquote.css({"background-image": ""}); $blockquote.css({"background-position": ""}); - $blockquote.removeClass('oe_img_bg'); + $blockquote.removeClass('oe_img_bg o_bg_img_center'); $blockquote.find('.o_we_bg_filter').remove(); $blockquote.find('.s_blockquote_filter').contents().unwrap(); // Compatibility } diff --git a/addons/website/views/snippets/s_carousel.xml b/addons/website/views/snippets/s_carousel.xml index cf4bdbe39e5..1ddda20ca62 100644 --- a/addons/website/views/snippets/s_carousel.xml +++ b/addons/website/views/snippets/s_carousel.xml @@ -13,7 +13,7 @@