summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorFabien Meghazi <fme@openerp.com>2012-06-14 14:17:19 +0200
committerFabien Meghazi <fme@openerp.com>2012-06-14 14:17:19 +0200
commit6f7e0a562e7dac5dfd5e6bbc0012e6a91586d1fc (patch)
treee0fe381a206e9e738e711465c33a0712a4f80b4d /addons
parent812f6aca49ae3f3ca96cdb78712515c3167cad6c (diff)
[ADD] Added Event Bus
bzr revid: fme@openerp.com-20120614121719-tri5zx5gjjqj3ea6
Diffstat (limited to 'addons')
-rw-r--r--addons/web/static/src/js/coresetup.js23
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# */{
/**