Move focus listeners to their own file
// FREEBIE
This commit is contained in:
parent
9f47ff9040
commit
83a020cc5e
3 changed files with 18 additions and 13 deletions
|
@ -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
16
js/focus_listener.js
Normal 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;
|
||||
};
|
||||
|
||||
})();
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue