mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-25 18:59:04 +02:00
Merge branch 'suspend-autorefresh-when-invisible' of https://github.com/towolf/icingaweb2 into feature/disable-auto-refresh-of-inactive-tabs-2761
This commit is contained in:
commit
bfaf000dba
@ -105,6 +105,8 @@
|
||||
// Note: It is important that this is the first handler for this event!
|
||||
$(document).on('rendered', { self: this }, this.applyHandlers);
|
||||
|
||||
$(document).on('visibilitychange', { self: this }, this.onVisibilityChange);
|
||||
|
||||
$.each(this.icinga.behaviors, function (name, behavior) {
|
||||
behavior.bind($(document));
|
||||
});
|
||||
@ -172,6 +174,18 @@
|
||||
icinga.destroy();
|
||||
},
|
||||
|
||||
onVisibilityChange: function (event) {
|
||||
var icinga = event.data.self.icinga;
|
||||
|
||||
if !!(document.visibilityState === undefined || document.visibilityState === 'visible') {
|
||||
icinga.logger.info('Page visible, enabling auto-refresh');
|
||||
icinga.loader.enableAutorefresh()
|
||||
} else {
|
||||
icinga.logger.info('Page invisible, disabling auto-refresh');
|
||||
icinga.loader.disableAutorefresh()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* A scroll event happened in one of our containers
|
||||
*/
|
||||
@ -610,6 +624,7 @@
|
||||
$(document).off('change', 'form input.autosubmit', this.submitForm);
|
||||
$(document).off('focus', 'form select[data-related-radiobtn]', this.autoCheckRadioButton);
|
||||
$(document).off('focus', 'form input[data-related-radiobtn]', this.autoCheckRadioButton);
|
||||
$(document).off('visibilitychange', this.onVisibilityChange);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user