UNPKG

unnotify

Version:

Pure JS growlish notifications with zero dependencies, simple API written in TypeScript.

3 lines (2 loc) 4.5 kB
!function n(t,e,i){function a(r,d){if(!e[r]){if(!t[r]){var s="function"==typeof require&&require;if(!d&&s)return s(r,!0);if(o)return o(r,!0);var u=new Error("Cannot find module '"+r+"'");throw u.code="MODULE_NOT_FOUND",u}var c=e[r]={exports:{}};t[r][0].call(c.exports,function(n){var e=t[r][1][n];return a(e||n)},c,c.exports,n,t,e,i)}return e[r].exports}for(var o="function"==typeof require&&require,r=0;r<i.length;r++)a(i[r]);return a}({1:[function(n,t,e){"use strict";function i(n){try{var t=document.getElementById(n),e=t.getAttribute("data-animate-out"),i=t.getAttribute("data-animate-in");0!=e.length?(t.classList.contains("animated")||t.classList.add("animated"),0!=i.length&&t.classList.remove(i),t.classList.add(e),setTimeout(function(){a(t)},1e3)):a(t)}catch(n){}}function a(n){try{n.parentNode.removeChild(n)}catch(n){}}e.__esModule=!0;var o,r="unnotify-center",d="unnotify-panel",s="unnotify-button",u=5e3;e.init=function(){var n=document.createElement("style");n.type="text/css",n.innerHTML="\n ."+r+" {\n position: absolute;\n top: 20px;\n z-index: 25000;\n overflow-y: auto;\n overflow-x: hidden;\n }\n\n ."+d+" {\n padding: 10px;\n margin: 10px;\n border-radius: 5px;\n color: #fff;\n width: 350px;\n min-height: 40px;\n position: static;\n top: 30px;\n z-index: 25100;\n pointer-events: none;\n }\n\n ."+s+" {\n float: right;\n position: relative;\n top: -7px;\n right: -10px;\n background-color: transparent;\n border: none;\n pointer-events: initial;\n }\n\n .unnotify-success {\n background-color: rgba(27, 94, 32, 0.8);\n }\n\n .unnotify-info {\n background-color: rgba(29, 121, 198, 0.8);\n }\n\n .unnotify-warning {\n background-color: rgba(251, 114, 4, 0.8);\n }\n\n .unnotify-danger {\n background-color: rgba(213, 0, 0, 0.8);\n }\n\n /* Custom, iPhone Retina */ \n @media only screen and (min-width : 320px) {\n ."+r+" {\n margin: 0px 2px;\n padding: 0px 2px;\n }\n\n ."+d+" {\n width: 300px;\n }\n }\n \n /* Extra Small Devices, Phones */ \n @media only screen and (min-width : 480px) {\n ."+r+" {\n width: 360px;\n right: 0px;\n padding: 10px;\n margin: 0px 20px;\n }\n\n ."+d+" {\n width: 100%;\n }\n }\n \n /* Small Devices, Tablets */\n @media only screen and (min-width : 768px) {\n ."+r+" {\n width: 360px;\n right: 0px;\n padding: 10px;\n margin: 0px 20px;\n }\n\n ."+d+" {\n width: 100%;\n }\n }\n ",document.getElementsByTagName("head")[0].appendChild(n),(o=document.createElement("div")).classList.add(r),document.body.insertBefore(o,document.body.firstChild)},e.show=function(n,t,e){var a=document.createElement("div");a.id=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),a.classList.add(d),"success"==e.type||"info"==e.type||"danger"==e.type||"warning"==e.type?a.classList.add("unnotify-"+e.type):void 0===e.customClass&&null==typeof e.customClass&&""==e.customClass||a.classList.add(e.customClass);var r=document.createElement("div"),c=document.createElement("span");c.innerText=n,r.appendChild(c);var p=document.createElement("button");p.classList.add(s),p.innerText="x",r.appendChild(p),p.addEventListener("click",function(){i(a.id)}),void 0===e.timeout||null==typeof e.timeout||e.timeout<0?setTimeout(function(){i(a.id)},u):e.timeout>0&&setTimeout(function(){i(a.id)},e.timeout);var l=document.createElement("div");return l.innerHTML=t,void 0!==e.animateIn?(a.classList.add("animated"),a.classList.add(e.animateIn),a.setAttribute("data-animate-in",e.animateIn)):a.setAttribute("data-animate-in",""),void 0!==e.animateOut?a.setAttribute("data-animate-out",e.animateOut):a.setAttribute("data-animate-out",""),a.appendChild(r),a.appendChild(l),o.appendChild(a),a.id},e.destroy=i},{}]},{},[1]); //# sourceMappingURL=unnotify.min.js.map