Move focus listeners to their own file

// FREEBIE
This commit is contained in:
lilia 2017-04-11 16:35:44 -07:00 committed by Scott Nonnenberg
parent 9f47ff9040
commit 83a020cc5e
No known key found for this signature in database
GPG key ID: A4931C09644C654B
3 changed files with 18 additions and 13 deletions

View file

@ -716,6 +716,7 @@
<script type='text/javascript' src='js/signal_protocol_store.js'></script>
<script type='text/javascript' src='js/libtextsecure.js'></script>
<script type='text/javascript' src='js/focus_listener.js'></script>
<script type='text/javascript' src='js/notifications.js'></script>
<script type='text/javascript' src='js/delivery_receipts.js'></script>
<script type='text/javascript' src='js/read_receipts.js'></script>

16
js/focus_listener.js Normal file
View file

@ -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;
};
})();

View file

@ -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;