diff options
| author | Jeremy Kersten <jke@odoo.com> | 2020-08-18 14:15:46 +0000 |
|---|---|---|
| committer | Laurent Stukkens (LTU) <ltu@odoo.com> | 2020-08-18 17:40:16 +0000 |
| commit | 8fb2ac4e6518842ac2a9f85b7710953c0089b8e3 (patch) | |
| tree | 99caa7b0420db5764c84b03cb6ead9ee7d525b49 /addons/web/static/src | |
| parent | d43d791f3e6b210b03520fd24fa75e489f472693 (diff) | |
[IMP] web: add a size_changed bus event
This commit will add a bus in the web.config config that allows
to trigger events.
The first use case is the trigger of the size_changed event that
is triggered each time the size of the screen changed of bootstrap
breakpoint.
task-2276740
PR #53175
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/services/config.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/addons/web/static/src/js/services/config.js b/addons/web/static/src/js/services/config.js index 7ded43e291c..6c576c351bb 100644 --- a/addons/web/static/src/js/services/config.js +++ b/addons/web/static/src/js/services/config.js @@ -1,6 +1,10 @@ -odoo.define('web.config', function () { +odoo.define('web.config', function (require) { "use strict"; +const Bus = require('web.Bus'); + +const bus = new Bus(); + /** * This module contains all the (mostly) static 'environmental' information. * This is often necessary to allow the rest of the web client to properly @@ -13,6 +17,13 @@ odoo.define('web.config', function () { var config = { device: { /** + * bus to use in order to be able to handle device config related events + * - 'size_changed' : triggered when window size is + * corresponding to a new bootstrap breakpoint. The new size_class + * is provided. + */ + bus: bus, + /** * touch is a boolean, true if the device supports touch interaction * * @type Boolean @@ -99,6 +110,7 @@ function _updateSizeProps() { if (sc !== config.device.size_class) { config.device.size_class = sc; config.device.isMobile = config.device.size_class <= config.device.SIZES.SM; + config.device.bus.trigger('size_changed', config.device.size_class); } } |
