summaryrefslogtreecommitdiff
path: root/ob_chatter_position/static/src/js/form_chatter_position.js
blob: 706b0572e8b9fe56b40e5d83660ad53060631610 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
odoo.define('ob_chatter_position.ChatterPositionFormController', function (require) {
    "use strict";

    var config = require('web.config');
    var FormController = require('web.FormController');
    var FormRenderer = require('web.FormRenderer');

    var ChatterPositionFormController = FormController.include({

        renderButtons: function ($node) {
            this._super.apply(this, arguments);
            if (this.$buttons) {
                this.$buttons.on('click', '.o_chatter_position_button', this._onChatterPosition.bind(this));
            }
        },

        _onChatterPosition: function () {
            if (this.$el.offsetParent().hasClass("o_chatter_position_normal")) {
                this.$el.offsetParent().attr('class', 'o_web_client o_chatter_position_sided');
            } else if (this.$el.offsetParent().hasClass("o_chatter_position_sided")) {
                this.$el.offsetParent().attr('class', 'o_web_client o_chatter_position_normal');
            }
        },
    });

    FormRenderer.include({
        _applyFormSizeClass: function () {
            const formEl = this.$el[0];
            if (config.device.size_class <= config.device.SIZES.XS) {
                formEl.classList.add('o_xxs_form_view');
            } else {
                formEl.classList.remove('o_xxs_form_view');
            }
        },
    });

    return ChatterPositionFormController;

    });