26 lines
594 B
HTML
26 lines
594 B
HTML
|
<script>
|
||
|
'use strict';
|
||
|
var vis = (function() {
|
||
|
var stateKey,
|
||
|
eventKey,
|
||
|
keys = {
|
||
|
hidden: "visibilitychange",
|
||
|
webkitHidden: "webkitvisibilitychange",
|
||
|
mozHidden: "mozvisibilitychange",
|
||
|
msHidden: "msvisibilitychange"
|
||
|
};
|
||
|
for (stateKey in keys) {
|
||
|
if (stateKey in document) {
|
||
|
eventKey = keys[stateKey];
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return function(c) {
|
||
|
if (c) {
|
||
|
document.addEventListener(eventKey, c);
|
||
|
}
|
||
|
return !document[stateKey];
|
||
|
};
|
||
|
})();
|
||
|
</script>
|