123456789101112 |
- /**
- * HumaneJS
- * Humanized Messages for Notifications
- * @author Marc Harter (@wavded)
- * @contributers
- * Alexander (@bga_)
- * Jose (@joseanpg)
- * Will McKenzie (@OiNutter)
- * @example
- * humane('hello world');
- * See more usage examples at: http://wavded.github.com/humane-js/
- */(function(a,b){function p(a){return l?l+a:a.toLowerCase()}function q(){h=b.createElement("div"),h.id="humane",h.className="humane",b.body.appendChild(h);for(vendor in k)h.style[vendor+"TransitionProperty"]!==undefined&&(l=k[vendor]);m=!0}function r(){d(b.body,"mousemove",r),d(b.body,"click",r),d(b.body,"keypress",r),d(b.body,"touchstart",r),f=!1,humane.clickToClose&&(d(h,"click",r),d(h,"touchstart",r)),g&&t(0)}function s(){if(g&&!a.humane.forceNew)return;if(!n.length){r();return}o=null,g=!0,i&&(clearTimeout(i),i=null),a.humane.timeout&&(i=setTimeout(function(){f||(c(b.body,"mousemove",r),c(b.body,"click",r),c(b.body,"keypress",r),c(b.body,"touchstart",r),f=!0,a.humane.waitForMove||r())},a.humane.timeout)),humane.clickToClose&&(c(h,"click",r),c(h,"touchstart",r));var d=n.shift(),j=d[0],k=d[1],l=d[2];o=l,e(k)&&(k="<ul><li>"+k.join("<li>")+"</ul>"),h.innerHTML=k,t(j,1)}function t(a,b){b===1?h.className="humane humane-"+a+" humane-animate":(h.className=h.className.replace(" humane-animate",""),o!=null&&c(h,p("TransitionEnd"),o),u())}function u(){setTimeout(function(){g=!1,s()},500)}function w(b,c){var d,e;c===1?(e=0,h.className="humane humane-js-animate humane-"+b,h.filters&&(h.filters.item("DXImageTransform.Microsoft.Alpha").Opacity=0),a.humane.forceNew&&(e=j?h.filters.item("DXImageTransform.Microsoft.Alpha").Opacity/100|0:h.style.opacity|0),d=setInterval(function(){e<1?(e+=.1,e>1&&(e=1),v(e)):clearInterval(d)},5)):(e=1,d=setInterval(function(){e>0?(e-=.1,e<0&&(e=0),v(e)):(h.className=h.className.replace(" humane-js-animate",""),clearInterval(d),o!=null&&o(),u())},5))}function x(a){return function(b,c){n.push([a,b,c]),m&&s()}}var c,d,e,f=!1,g=!1,h=null,i=null,j=/msie [678]/i.test(navigator.userAgent),k={Webkit:"webkit",Moz:"",O:"o",ms:"MS"},l="",m=!1,n=[],o=null;"addEventListener"in a?(c=function(a,b,c){a.addEventListener(b,c,!1)},d=function(a,b,c){a.removeEventListener(b,c,!1)}):(c=function(a,b,c){a.attachEvent("on"+b,c)},d=function(a,b,c){a.detachEvent("on"+b,c)}),e=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},c(a,"load",function(){var a=function(a){var b=["MozT","WebkitT","OT","msT","KhtmlT","t"];for(var c=0,d;d=b[c];c++)if(d+"ransition"in a)return!0;return!1}(b.body.style);a||(t=w),q(),s()});var v=function(){return j?function(a){h.filters.item("DXImageTransform.Microsoft.Alpha").Opacity=a*100}:function(a){h.style.opacity=String(a)}}();a.humane=x("log"),a.humane.log=x("log"),a.humane.error=x("error"),a.humane.info=x("info"),a.humane.success=x("success"),a.humane.timeout=2500,a.humane.waitForMove=!1,a.humane.forceNew=!1,a.humane.clickToClose=!1})(window,document);
|