1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-22 15:07:44 +00:00
Files
matomo/node_modules/visibilityjs/lib/visibility.fallback.js
diosmosis b12946909f run npm update and include node_modules (#16079)
* update npm packages to latest

* fix javascript path location

* update screenshots

* Add node_modules for users that do not have npm insalled but use git to deploy.

* fix release checklist test

* Add old chroma-js + some files missing from node_module.

* remove npm install

* fix .travis.yml

* update expected screenshots

* update submodule

Co-authored-by: sgiehl <stefan@matomo.org>
2020-06-26 02:33:41 -07:00

54 خطوط
1.7 KiB
JavaScript
Vendored

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Add Page Visibility API support to old browsers by focus/blur hack.
//
// Include this script _before_ Visibility.js.
//
// Note, that this hack doesnt correctly emulate Page Visibility API:
// when user change focus from browser to another window (browser and your
// page may stay visible), this hack will decide, that you page is hidden.
//
// For Firefox 59 it will be better to use MozVisibility hack without
// this issue. See <https://github.com/private-face/mozvisibility>.
;(function (document) {
if ( document.visibilityState || document.webkitVisibilityState ) {
return;
}
document.hidden = false;
document.visibilityState = 'visible';
var event = null
var i = 0
var fireEvent = function () {
if( document.createEvent ) {
if ( !event ) {
event = document.createEvent('HTMLEvents');
event.initEvent('visibilitychange', true, true);
}
document.dispatchEvent(event);
} else {
if ( typeof(Visibility) == 'object' ) {
Visibility._change.call(Visibility, { });
}
}
}
var onFocus = function () {
document.hidden = false;
document.visibilityState = 'visible';
fireEvent();
};
var onBlur = function () {
document.hidden = true;
document.visibilityState = 'hidden';
fireEvent();
}
if ( document.addEventListener ) {
window.addEventListener('focus', onFocus, true);
window.addEventListener('blur', onBlur, true);
} else {
document.attachEvent('onfocusin', onFocus);
document.attachEvent('onfocusout', onBlur);
}
})(document);