From 2254abbde72862e7842614c33e261571eaebae64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 16 Jun 2016 14:07:26 +0200 Subject: [PATCH] [REF] web: move Bus class to web.Bus --- addons/mail/static/src/js/chat_manager.js | 3 ++- addons/web/static/src/js/framework/bus.js | 16 ++++++++++++++++ addons/web/static/src/js/framework/core.js | 10 +--------- addons/web/views/webclient_templates.xml | 1 + 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 addons/web/static/src/js/framework/bus.js diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 2adf913faab..27daf2ea831 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -4,6 +4,7 @@ odoo.define('mail.chat_manager', function (require) { var bus = require('bus.bus').bus; var utils = require('mail.utils'); var config = require('web.config'); +var Bus = require('web.Bus'); var core = require('web.core'); var data = require('web.data'); var Model = require('web.Model'); @@ -837,7 +838,7 @@ var chat_manager = { return message.channel_ids.length === 0 && message.model === model; }); }, - bus: new core.Bus(), + bus: new Bus(), create_channel: function (name, type) { var method = type === "dm" ? "channel_get" : "channel_create"; diff --git a/addons/web/static/src/js/framework/bus.js b/addons/web/static/src/js/framework/bus.js new file mode 100644 index 00000000000..bf33c1fe01e --- /dev/null +++ b/addons/web/static/src/js/framework/bus.js @@ -0,0 +1,16 @@ +odoo.define('web.Bus', function (require) { +"use strict"; + +var Class = require('web.Class'); +var mixins = require('web.mixins'); + +/** + * Event Bus used to bind events scoped in the current instance + */ +return Class.extend(mixins.EventDispatcherMixin, { + init: function() { + mixins.EventDispatcherMixin.init.call(this, parent); + }, +}); + +}); diff --git a/addons/web/static/src/js/framework/core.js b/addons/web/static/src/js/framework/core.js index 29b461cbe8d..02a06408d9d 100644 --- a/addons/web/static/src/js/framework/core.js +++ b/addons/web/static/src/js/framework/core.js @@ -1,6 +1,7 @@ odoo.define('web.core', function (require) { "use strict"; +var Bus = require('web.Bus'); var Class = require('web.Class'); var mixins = require('web.mixins'); var Registry = require('web.Registry'); @@ -13,15 +14,6 @@ var debug = $.deparam($.param.querystring()).debug !== undefined; var _t = translation._t; var _lt = translation._lt; -/** - * Event Bus used to bind events scoped in the current instance - */ -var Bus = Class.extend(mixins.EventDispatcherMixin, { - init: function() { - mixins.EventDispatcherMixin.init.call(this, parent); - }, -}); - var bus = new Bus (); _.each('click,dblclick,keydown,keypress,keyup'.split(','), function(evtype) { diff --git a/addons/web/views/webclient_templates.xml b/addons/web/views/webclient_templates.xml index c9b268ae55a..01aa5915aee 100644 --- a/addons/web/views/webclient_templates.xml +++ b/addons/web/views/webclient_templates.xml @@ -68,6 +68,7 @@ +