1
|
(function(a){if(typeof module!=="undefined"&&typeof exports=="object"){if(typeof window!="undefined"){module.exports=a()}else{module.exports=a}}else{window.Alert=a()}})(function(e){var a=function(f){this.btn=typeof f==="object"?f:document.querySelector(f);this.alert=null;this.duration=150;this.init()};a.prototype={init:function(){this.actions();document.addEventListener("click",this.close,false)},actions:function(){var f=this;this.close=function(g){var h=g.target;f.btn=h.getAttribute("data-dismiss")==="alert"&&h.className==="close"?h:h.parentNode;f.alert=f.btn.parentNode;if(f.alert!==null&&f.btn.getAttribute("data-dismiss")==="alert"&&/in/.test(f.alert.className)){f.alert.className=f.alert.className.replace(" in","");setTimeout(function(){f.alert&&f.alert.parentNode.removeChild(f.alert)},f.duration)}}}};var b=document.querySelectorAll('[data-dismiss="alert"]'),d=0,c=b.length;for(d;d<c;d++){new a(b[d])}return a});
|