From 83a020cc5e27256e364ce55d095b26b988337413 Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 11 Apr 2017 16:35:44 -0700 Subject: [PATCH] Move focus listeners to their own file // FREEBIE --- background.html | 1 + js/focus_listener.js | 16 ++++++++++++++++ js/panel_controller.js | 14 +------------- 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 js/focus_listener.js diff --git a/background.html b/background.html index 06eabaf8e86..a843df38486 100644 --- a/background.html +++ b/background.html @@ -716,6 +716,7 @@ + diff --git a/js/focus_listener.js b/js/focus_listener.js new file mode 100644 index 00000000000..08434f1cc92 --- /dev/null +++ b/js/focus_listener.js @@ -0,0 +1,16 @@ +(function () { + 'use strict'; + + var windowFocused; + window.addEventListener('blur', function() { + windowFocused = false; + }); + window.addEventListener('focus', function() { + windowFocused = true; + }); + + window.isFocused = function() { + return windowFocused; + }; + +})(); diff --git a/js/panel_controller.js b/js/panel_controller.js index 64eea47f832..1c9da847423 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -9,24 +9,12 @@ window.Whisper = window.Whisper || {}; - - var inboxFocused = false; - window.addEventListener('blur', function() { - inboxFocused = false; - }); - window.addEventListener('focus', function() { - inboxFocused = true; - clearAttention(); - }); - window.isFocused = function() { - return inboxFocused; - }; window.isOpen = function() { return inboxOpened; }; window.drawAttention = function() { - if (inboxOpened && !inboxFocused) { + if (inboxOpened && !isFocused()) { if (window.keepClear) { clearInterval(window.keepClear); delete window.keepClear;