odoo.define('website.s_media_list_options', function (require) { 'use strict'; const options = require('web_editor.snippets.options'); options.registry.MediaItemLayout = options.Class.extend({ //-------------------------------------------------------------------------- // Options //-------------------------------------------------------------------------- /** * Change the media item layout. * * @see this.selectClass for parameters */ layout: function (previewMode, widgetValue, params) { const $image = this.$target.find('.s_media_list_img_wrapper'); const $content = this.$target.find('.s_media_list_body'); for (const possibleValue of params.possibleValues) { $image.removeClass(`col-lg-${possibleValue}`); $content.removeClass(`col-lg-${12 - possibleValue}`); } $image.addClass(`col-lg-${widgetValue}`); $content.addClass(`col-lg-${12 - widgetValue}`); }, //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- /** * @override */ _computeWidgetState(methodName, params) { switch (methodName) { case 'layout': { const $image = this.$target.find('.s_media_list_img_wrapper'); for (const possibleValue of params.possibleValues) { if ($image.hasClass(`col-lg-${possibleValue}`)) { return possibleValue; } } } } return this._super(...arguments); }, }); });