diff options
| author | Fabien Meghazi <fme@openerp.com> | 2012-06-14 14:17:19 +0200 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2012-06-14 14:17:19 +0200 |
| commit | 6f7e0a562e7dac5dfd5e6bbc0012e6a91586d1fc (patch) | |
| tree | e0fe381a206e9e738e711465c33a0712a4f80b4d /addons/web/static/src/js | |
| parent | 812f6aca49ae3f3ca96cdb78712515c3167cad6c (diff) | |
[ADD] Added Event Bus
bzr revid: fme@openerp.com-20120614121719-tri5zx5gjjqj3ea6
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/coresetup.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/addons/web/static/src/js/coresetup.js b/addons/web/static/src/js/coresetup.js index 4defde54a3c..2ab5e71ca0b 100644 --- a/addons/web/static/src/js/coresetup.js +++ b/addons/web/static/src/js/coresetup.js @@ -400,6 +400,29 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess } }); +/** + * Event Bus used to bind events scoped in the current instance + */ +instance.web.bus = new (instance.web.Class.extend(instance.web.EventDispatcherMixin, { + init: function() { + instance.web.EventDispatcherMixin.init.call(this, parent); + var self = this; + // TODO fme: allow user to bind keys for some global actions. + // check gtk bindings + // http://unixpapa.com/js/key.html + _.each('click,dblclick,keydown,keypress,keyup'.split(','), function(evtype) { + $('html').on(evtype, self, function(ev) { + self.trigger(evtype, ev, evtype); + }); + }); + _.each('resize,scroll'.split(','), function(evtype) { + $(window).on(evtype, self, function(ev) { + self.trigger(evtype, ev, evtype); + }); + }); + } +}))(); + /** OpenERP Translations */ instance.web.TranslationDataBase = instance.web.Class.extend(/** @lends instance.web.TranslationDataBase# */{ /** |
