[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.
This commit is contained in:
committed by
Aaron Bohy
parent
cd55968212
commit
97a5eee0ac
@@ -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,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user