/* * Message.js v1.0.0 * https://github.com/snwjas/Message.js */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Qmsg=t()}(this,function(){"use strict";var e={timeout:2500,showClose:!1,autoClose:!0,content:"",onClose:null,html:!1,maxNums:5};function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){for(var n=0;n',success:'',warning:'',error:'',loading:'',close:''},i=function(){function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),this.settings=Object.assign({},this.defaults,e),this.id="qmsg-"+Math.random().toString(36).substr(2,9),this.timer=null,this.render()}var s,a,c;return s=i,c=[{key:"config",value:function(t){e=Object.assign({},e,t)}},{key:"info",value:function(e,t){return new i(Object.assign({content:e,type:"info"},t))}},{key:"success",value:function(e,t){return new i(Object.assign({content:e,type:"success"},t))}},{key:"warning",value:function(e,t){return new i(Object.assign({content:e,type:"warning"},t))}},{key:"error",value:function(e,t){return new i(Object.assign({content:e,type:"error"},t))}},{key:"loading",value:function(e,t){return new i(Object.assign({content:e,type:"loading",autoClose:!1},t))}},{key:"closeAll",value:function(){var e=document.querySelectorAll(".qmsg");e.forEach(function(e){e.remove()})}}],(a=[{key:"defaults",get:function(){return window.QMSG_GLOBALS&&window.QMSG_GLOBALS.DEFAULTS?Object.assign({},e,window.QMSG_GLOBALS.DEFAULTS):e}},{key:"render",value:function(){var e=this,t=document.querySelector(".qmsg-wrapper");t||((t=document.createElement("div")).className="qmsg-wrapper",document.body.appendChild(t));var n=document.createElement("div");n.className="qmsg qmsg-"+this.settings.type,n.id=this.id;var s="";this.settings.showClose&&(s='
'+o.close+"
");var a=this.settings.content;this.settings.html||(a=a.replace(//g,">")),n.innerHTML='
'+o[this.settings.type]+'
'+a+"
"+s,t.appendChild(n),this.settings.showClose&&n.querySelector(".qmsg-close").addEventListener("click",function(){e.close()}),this.settings.autoClose&&(this.timer=setTimeout(function(){e.close()},this.settings.timeout)),this.checkMaxNums()}},{key:"checkMaxNums",value:function(){var e=document.querySelectorAll(".qmsg");if(e.length>this.settings.maxNums){for(var t=0;t