-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhumane.min.js
8 lines (8 loc) · 2.85 KB
/
humane.min.js
1
2
3
4
5
6
7
8
/**
* humane.js
* Humanized Messages for Notifications
* @author Marc Harter (@wavded)
* @example
* humane('hello world');
* See more usage examples at: http://wavded.github.com/humane-js/
*/(function(a,b){function t(a){return n?n+a:a.toLowerCase()}function u(b,c){return p.instance[c]!==void 0?p.instance[c]:a.humane[c]}function v(){j=b.createElement("div"),j.id="humane",j.className="humane",b.body.appendChild(j);for(vendor in m)vendor+"TransitionProperty"in j.style&&(n=m[vendor],h=!0);h||(x=B),o=!0,w()}function w(){if(i)return;if(!s.length)return;after=null,i=!0,k&&(clearTimeout(k),k=null);var a=s.shift();p={type:a[0],message:a[1],instance:a[2],callback:a[3]};var c=p.message,e=p.type;u(e,"clickToClose")===!0&&(d(j,"click",y),d(j,"touchstart",y));var h=u(e,"timeout");h>0&&(k=setTimeout(function(){g||(d(b.body,"mousemove",y),d(b.body,"click",y),d(b.body,"keypress",y),d(b.body,"touchstart",y),g=!0,u(e,"waitForMove")!==!0&&y())},h)),r.show(e,c,"show"),f(c)&&(c="<ul><li>"+c.join("<li>")+"</ul>"),j.innerHTML=c,j.style.display="block",setTimeout(function(){x(1,e)},50)}function x(a,b){a===1?j.className="humane humane-"+b+" humane-animate":(j.className=j.className.replace(" humane-animate",""),d(j,t("TransitionEnd"),z))}function y(){e(b.body,"mousemove",y),e(b.body,"click",y),e(b.body,"keypress",y),e(b.body,"touchstart",y),e(j,"click",y),e(j,"touchstart",y),g=!1,i&&x(0)}function z(){h&&e(j,t("TransitionEnd"),z),i=!1,p.callback&&p.callback(),r.hide(p.type,p.message,"hide"),j.style.display="none",w()}function B(a,b){var c,d;a===1?(d=0,j.className="humane humane-js-animate humane-"+b,l&&A(0),j.style.zIndex=1e6,c=setInterval(function(){d<1?(d+=.1,d>1&&(d=1),A(d)):clearInterval(c)},5)):(d=1,c=setInterval(function(){d>0?(d-=.1,d<0&&(d=0),A(d)):(j.className=j.className.replace(" humane-js-animate",""),j.style.zIndex=-1,clearInterval(c),z())},5))}function C(a){return function b(c,d){s.push([a,c,b,d]),r.add(a,c,"add"),o&&w()}}var c,d,e,f,g=!1,h=!1,i=!1,j=null,k=null,l=/msie [678]/i.test(navigator.userAgent),m={Webkit:"webkit",Moz:"",O:"o",ms:"MS"},n="",o=!1,p={},q=function(){},r={add:q,show:q,hide:q},s=[];"addEventListener"in a?(d=function(a,b,c){a.addEventListener(b,c,!1)},e=function(a,b,c){a.removeEventListener(b,c,!1)}):(d=function(a,b,c){a.attachEvent("on"+b,c)},e=function(a,b,c){a.detachEvent("on"+b,c)}),f=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},d(a,"load",v);var A=l?function(a){j.filters.item("DXImageTransform.Microsoft.Alpha").Opacity=a*100}:function(a){j.style.opacity=String(a)};c=C("log"),c.log=C("log"),c.error=C("error"),c.info=C("info"),c.success=C("success"),c.remove=y,c.create=function(a){var b=C(a.type||"log");return b.timeout=a.timeout||2500,b.waitForMove=a.waitForMove||!1,b.clickToClose=a.clickToClose||!1,b},c.timeout=2500,c.waitForMove=!1,c.clickToClose=!1,c.on=function(a,b){r[a]=b},a.humane=c})(window,document);