diff options
Diffstat (limited to 'addons/bus/static/src/js/bus.js')
| -rw-r--r-- | addons/bus/static/src/js/bus.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/addons/bus/static/src/js/bus.js b/addons/bus/static/src/js/bus.js index b0756132012..3c828668308 100644 --- a/addons/bus/static/src/js/bus.js +++ b/addons/bus/static/src/js/bus.js @@ -9,12 +9,21 @@ bus.ERROR_DELAY = 10000; bus.Bus = Widget.extend({ init: function(){ + var self = this; this._super(); this.options = {}; this.activated = false; this.channels = []; this.last = 0; this.stop = false; + + // bus presence + this.set("window_focus", true); + this.on("change:window_focus", self, function(e) { + self.options.im_presence = self.get("window_focus"); + }); + $(window).on("focus", _.bind(this.window_focus, this)); + $(window).on("blur", _.bind(this.window_blur, this)); }, start_polling: function(){ if(!this.activated){ @@ -57,6 +66,13 @@ bus.Bus = Widget.extend({ delete_channel: function(channel){ this.channels = _.without(this.channels, channel); }, + // bus presence : window focus/unfocus + window_focus: function() { + this.set("window_focus", true); + }, + window_blur: function() { + this.set("window_focus", false); + }, }); // singleton |
