snappymail/vendors/ifvisible/ifvisible.min.js
RainLoop Team 333c063cf1 Change build system (Grunt -> Gulp)
Remove attachments on reply (Closes #195)
Do not show deleted (flag \Deleted) messages (Closes #185)
Release commit
2014-06-16 23:56:11 +04:00

2 lines
3.2 KiB
JavaScript

/*!ifvisible.js v1.0.0 (c) 2013 Serkan Yersen | MIT */
(function(){"use strict";var e,t,n,i,r,u,o,f,c,d,s,a,v,l;c={},n=document,s=!1,a="active",o=6e4,u=!1,t=function(){var e,t,n,i,r,u;return e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)},r=function(){return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},u={},n="__ceGUID",t=function(e,t,i){return e[n]=void 0,e[n]||(e[n]="ifvisible.object.event.identifier"),u[e[n]]||(u[e[n]]={}),u[e[n]][t]||(u[e[n]][t]=[]),u[e[n]][t].push(i)},i=function(e,t,i){var r,o,f,c,d;if(e[n]&&u[e[n]]&&u[e[n]][t]){for(c=u[e[n]][t],d=[],o=0,f=c.length;f>o;o++)r=c[o],d.push(r(i||{}));return d}},{add:t,fire:i}}(),e=function(){var e;return e=!1,function(t,n,i){return e||(e=t.addEventListener?function(e,t,n){return e.addEventListener(t,n,!1)}:t.attachEvent?function(e,t,n){return e.attachEvent("on"+t,n,!1)}:function(e,t,n){return e["on"+t]=n}),e(t,n,i)}}(),i=function(e,t){var i;return n.createEventObject?e.fireEvent("on"+t,i):(i=n.createEvent("HTMLEvents"),i.initEvent(t,!0,!0),!e.dispatchEvent(i))},f=function(){var e,t,i,r,u;for(r=void 0,u=3,i=n.createElement("div"),e=i.getElementsByTagName("i"),t=function(){return i.innerHTML="<!--[if gt IE "+ ++u+"]><i></i><![endif]-->",e[0]};t(););return u>4?u:r}(),r=!1,l=void 0,"undefined"!=typeof n.hidden?(r="hidden",l="visibilitychange"):"undefined"!=typeof n.mozHidden?(r="mozHidden",l="mozvisibilitychange"):"undefined"!=typeof n.msHidden?(r="msHidden",l="msvisibilitychange"):"undefined"!=typeof n.webkitHidden&&(r="webkitHidden",l="webkitvisibilitychange"),v=function(){var t,i;return t=!1,i=function(){return clearTimeout(t),"active"!==a&&c.wakeup(),u=+new Date,t=setTimeout(function(){return"active"===a?c.idle():void 0},o)},i(),e(n,"mousemove",i),e(n,"keyup",i),e(window,"scroll",i),c.focus(i)},d=function(){var t;return s?!0:(r===!1?(t="blur",9>f&&(t="focusout"),e(window,t,function(){return c.blur()}),e(window,"focus",function(){return c.focus()})):e(n,l,function(){return n[r]?c.blur():c.focus()},!1),s=!0,v())},c={setIdleDuration:function(e){return o=1e3*e},getIdleDuration:function(){return o},getIdleInfo:function(){var e,t;return e=+new Date,t={},"idle"===a?(t.isIdle=!0,t.idleFor=e-u,t.timeLeft=0,t.timeLeftPer=100):(t.isIdle=!1,t.idleFor=e-u,t.timeLeft=u+o-e,t.timeLeftPer=(100-100*t.timeLeft/o).toFixed(2)),t},focus:function(e){return"function"==typeof e?this.on("focus",e):(a="active",t.fire(this,"focus"),t.fire(this,"wakeup"),t.fire(this,"statusChanged",{status:a}))},blur:function(e){return"function"==typeof e?this.on("blur",e):(a="hidden",t.fire(this,"blur"),t.fire(this,"idle"),t.fire(this,"statusChanged",{status:a}))},idle:function(e){return"function"==typeof e?this.on("idle",e):(a="idle",t.fire(this,"idle"),t.fire(this,"statusChanged",{status:a}))},wakeup:function(e){return"function"==typeof e?this.on("wakeup",e):(a="active",t.fire(this,"wakeup"),t.fire(this,"statusChanged",{status:a}))},on:function(e,n){return d(),t.add(this,e,n)},onEvery:function(e,t){var n;return d(),n=setInterval(function(){return"active"===a?t():void 0},1e3*e),{stop:function(){return clearInterval(n)},code:n,callback:t}},now:function(){return d(),"active"===a}},"function"==typeof define&&define.amd?define(function(){return c}):window.ifvisible=c}).call(this);