This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/initializers/focus_event.js
2013-12-03 15:11:33 -05:00

16 lines
324 B
JavaScript

/**
Keep track of when the browser is in focus.
**/
Discourse.addInitializer(function() {
// Default to true
this.set('hasFocus', true);
var self = this;
$(window).focus(function() {
self.setProperties({hasFocus: true, notify: false});
}).blur(function() {
self.set('hasFocus', false);
});
}, true);