-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-idleness.min.js
1 lines (1 loc) · 1.29 KB
/
angular-idleness.min.js
1
angular.module("angular-idleness").service("idleness",function(i){this.idle=void 0,this.stateKey=null,this.eventKey=void 0,this.keys={hidden:"visibilitychange",webkitHidden:"webkitvisibilitychange",mozHidden:"mozvisibilitychange",msHidden:"msvisibilitychange"},this.crossBrowserize=function(){for(this.stateKey in this.keys)if(this.stateKey in document){this.eventKey=this.keys[this.stateKey];break}},this.visible=function(i){return this.crossBrowserize(),i&&document.addEventListener(this.eventKey,i),!document[this.stateKey]},this.observe=function(){var e=this;e.visible(function(){e.visible()?setTimeout(function(){e.idlize(!1)},300):e.idlize(!0)});var t=i.chrome,n=void 0===document.documentMode;n&&!t?$(i).on("focusin",function(){setTimeout(function(){e.idlize(!1)},300)}).on("focusout",function(){e.idlize(!0)}):i.addEventListener?(i.addEventListener("focus",function(){setTimeout(function(){e.idlize(!1)},300)},!1),i.addEventListener("blur",function(){e.idlize(!0)},!1)):(i.attachEvent("focus",function(){setTimeout(function(){e.idlize(!1)},300)}),i.attachEvent("blur",function(){e.idlize(!0)}))},this.idlize=function(i){this.idle!==i&&(this.idle=i,i?this.onIdleFn():this.onNotIdleFn())},this.onIdle=function(i,e){this.onIdleFn=i,this.onNotIdleFn=e},this.onIdleFn=function(){},this.onNotIdleFn=function(){}});