summaryrefslogtreecommitdiff
path: root/addons/website/static/src
diff options
context:
space:
mode:
authorOussama MESSAOUDI <ome@odoo.com>2021-02-24 11:47:09 +0000
committerqsm-odoo <qsm@odoo.com>2021-02-24 16:56:58 +0000
commit83112caf1964801cd2edfa5a28bf8199d66e00cb (patch)
treeda240db9a251507164715576f18c1f7e5c937911 /addons/website/static/src
parent1ced9aaf7a3d6d345fe5bd05269af978c8c86ee3 (diff)
[FIX] website: hide block in mobile display mode
Before this commit, display mode is changed to block after hiding it on mobile mode. After this commit, only change display mode for mobile and use inherited mode otherwise. task-2431659 closes odoo/odoo#65716 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/website/static/src')
-rw-r--r--addons/website/static/src/js/editor/snippets.options.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js
index abd32016131..d830c99afa8 100644
--- a/addons/website/static/src/js/editor/snippets.options.js
+++ b/addons/website/static/src/js/editor/snippets.options.js
@@ -1967,6 +1967,42 @@ options.registry.topMenuColor = options.Class.extend({
});
/**
+ * Manage the visibility of snippets on mobile.
+ */
+options.registry.MobileVisibility = options.Class.extend({
+
+ //--------------------------------------------------------------------------
+ // Options
+ //--------------------------------------------------------------------------
+
+ /**
+ * Allows to show or hide the associated snippet in mobile display mode.
+ *
+ * @see this.selectClass for parameters
+ */
+ showOnMobile(previewMode, widgetValue, params) {
+ const classes = `d-none d-md-${this.$target.css('display')}`;
+ this.$target.toggleClass(classes, !widgetValue);
+ },
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @override
+ */
+ async _computeWidgetState(methodName, params) {
+ if (methodName === 'showOnMobile') {
+ const classList = [...this.$target[0].classList];
+ return classList.includes('d-none') &&
+ classList.some(className => className.startsWith('d-md-')) ? '' : 'true';
+ }
+ return await this._super(...arguments);
+ },
+});
+
+/**
* Hide/show footer in the current page.
*/
options.registry.HideFooter = VisibilityPageOptionUpdate.extend({