diff options
| author | Géry Debongnie <ged@odoo.com> | 2015-04-29 11:55:33 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2015-05-15 09:16:34 +0200 |
| commit | 97a5eee0ac8930ef3d533182e8eaaf0e2909c6f4 (patch) | |
| tree | 6e1f799ef35dd08d565e0b498fcc7300f2b7560d | |
| parent | cd559682121d0d30876f31e8ba283e8f5287c736 (diff) | |
[IMP] web: performance improvement with bus
The bus class listen for many mouse/keyboard events and trigger them on
itself. This was intended for the main bus, but not for custom buses.
This commit should improve the performance when using many buses.
| -rw-r--r-- | addons/web/static/src/js/framework/core.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/addons/web/static/src/js/framework/core.js b/addons/web/static/src/js/framework/core.js index 437bfffb87f..7bd4800ec98 100644 --- a/addons/web/static/src/js/framework/core.js +++ b/addons/web/static/src/js/framework/core.js @@ -21,23 +21,23 @@ var _lt = translation._lt; var Bus = Class.extend(mixins.EventDispatcherMixin, { init: function() { mixins.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, function(ev) { - self.trigger(evtype, ev); - }); - }); - _.each('resize,scroll'.split(','), function(evtype) { - $(window).on(evtype, function(ev) { - self.trigger(evtype, ev); - }); - }); }, }); +var main_bus = new Bus (); + +_.each('click,dblclick,keydown,keypress,keyup'.split(','), function(evtype) { + $('html').on(evtype, function(ev) { + main_bus.trigger(evtype, ev); + }); +}); +_.each('resize,scroll'.split(','), function(evtype) { + $(window).on(evtype, function(ev) { + main_bus.trigger(evtype, ev); + }); +}); + + // Underscore customization //------------------------------------------------------------------------- _.str.toBoolElse = function (str, elseValues, trueValues, falseValues) { @@ -172,7 +172,7 @@ return { Class: Class, Bus: Bus, mixins: mixins, - bus: new Bus (), + bus: main_bus, _t: _t, _lt: _lt, |
