@unaxiom/unnotify
Version:
Pure JS growlish notifications with zero dependencies, simple API written in TypeScript.
3 lines (2 loc) • 8.02 kB
JavaScript
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).unnotify=n()}}(function(){return function a(r,d,c){function u(t,n){if(!d[t]){if(!r[t]){var e="function"==typeof require&&require;if(!n&&e)return e(t,!0);if(l)return l(t,!0);var i=new Error("Cannot find module '"+t+"'");throw i.code="MODULE_NOT_FOUND",i}var o=d[t]={exports:{}};r[t][0].call(o.exports,function(n){return u(r[t][1][n]||n)},o,o.exports,a,r,d,c)}return d[t].exports}for(var l="function"==typeof require&&require,n=0;n<c.length;n++)u(c[n]);return u}({1:[function(n,t,e){"use strict";var f;e.__esModule=!0;var i="unnotify-center",o="unnotify-panel",a="unnotify-button",u=5e3;function r(n,t,e,i,o){i=null==i?"right":"left"===i?"left":"right";var a=document.createElement("style");a.type="text/css",a.innerHTML=function(n,t,e,i,o){var a="initial";o||(a="none");return"\n ."+n+" {\n position: absolute;\n top: 20px;\n z-index: 25000;\n overflow-y: auto;\n overflow-x: hidden;\n pointer-events: "+a+";\n }\n\n ."+t+" {\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: "+a+";\n }\n\n ."+e+" {\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-close-btn {\n color: #fff;\n cursor: pointer;\n }\n\n .unnotify-action-btn {\n width: 50%;\n color: #fff;\n text-align: center;\n padding: 5px 0px;\n margin-top: 10px;\n border: none;\n cursor: pointer;\n background-color: rgba(0, 0, 0, 0);\n outline: none;\n }\n\n .unnotify-action-btn:hover {\n background-color: rgba(0, 0, 0, 0.1);\n outline: none;\n }\n\n .unnotify-input {\n background-color: rgba(0, 0, 0, 0.2);\n width: 100%;\n margin: 5px 0px;\n padding: 5px 0px;\n text-align: center;\n color: #fff;\n border-top-style: hidden;\n border-right-style: hidden;\n border-left-style: hidden;\n border-bottom-style: hidden;\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 ."+n+" {\n margin: 0px 2px;\n padding: 0px 2px;\n }\n\n ."+t+" {\n width: 300px;\n }\n }\n \n /* Extra Small Devices, Phones */ \n @media only screen and (min-width : 480px) {\n ."+n+" {\n width: 360px;\n "+i+": 0px;\n padding: 0px 10px;\n margin: 0px 20px;\n }\n\n ."+t+" {\n width: 90%;\n }\n }\n \n /* Small Devices, Tablets */\n @media only screen and (min-width : 768px) {\n ."+n+" {\n width: 360px;\n "+i+": 0px;\n padding: 0px 10px;\n margin: 0px 20px;\n }\n\n ."+t+" {\n width: 90%;\n }\n }\n "}(n,t,e,i,o),document.getElementsByTagName("head")[0].appendChild(a),(f=document.createElement("div")).classList.add(n),document.body.insertBefore(f,document.body.firstChild)}function p(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}function m(n,t){var e=document.createElement("div");return e.id=p(),e.classList.add(n),"success"==t.type||"info"==t.type||"danger"==t.type||"warning"==t.type?e.classList.add("unnotify-"+t.type):void 0===t.customClass&&null==typeof t.customClass&&""==t.customClass||e.classList.add(t.customClass),void 0!==t.animateIn?(e.classList.add("animated"),e.classList.add(t.animateIn),e.setAttribute("data-animate-in",t.animateIn)):e.setAttribute("data-animate-in",""),void 0!==t.animateOut?e.setAttribute("data-animate-out",t.animateOut):e.setAttribute("data-animate-out",""),e}function h(n){var t=document.createElement("button");return t.classList.add(n),t.classList.add("unnotify-close-btn"),t.innerText="x",t}function y(n){var t=document.createElement("button");return t.classList.add("unnotify-action-btn"),t.innerText=n,t}function g(n){var t=document.createElement("div");return t.innerHTML=n,t}function d(n,t,e,i,o){var a=m(n,o),r=function(n){var t=document.createElement("div"),e=document.createElement("span");return e.style.fontWeight="700",e.style.fontSize="1.6rem",e.innerText=n,t.appendChild(e),t}(e),d=h(t);r.appendChild(d),d.addEventListener("click",function(){x(a.id)});var c=g(i);return a.appendChild(r),a.appendChild(c),function(n,t){void 0===t.timeout||null==typeof t.timeout||t.timeout<0?setTimeout(function(){x(n.id)},u):0<t.timeout&&setTimeout(function(){x(n.id)},t.timeout)}(a,o),f.appendChild(a),a.id}function c(n,t,e,i,o,a,r,d){var c=m(n,i),u=h(t);u.addEventListener("click",function(){x(c.id)});var l=g(e),s=y(o),p=y(a);return c.appendChild(u),c.appendChild(l),c.appendChild(s),c.appendChild(p),null!=r&&null!=r&&s.addEventListener("click",function(n){r(n,c.id)}),null!=d&&null!=d&&p.addEventListener("click",function(n){d(n,c.id)}),f.appendChild(c),c.id}function l(n,t,e,i,o,a){var r=m(n,i),d=h(t);d.addEventListener("click",function(){x(r.id)});var c=g(e),u=document.createElement("input");u.id=p(),u.classList.add("unnotify-input");var l=y("Next"),s=y("Cancel");return r.appendChild(d),r.appendChild(c),r.appendChild(u),r.appendChild(l),r.appendChild(s),null!=o&&null!=o&&l.addEventListener("click",function(n){var t=u.value;o(n,r.id,t)}),null!=a&&null!=a&&s.addEventListener("click",function(n){a(n,r.id)}),f.appendChild(r),r.id}function s(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(){t.parentNode.removeChild(t)},1e3)):t.parentNode.removeChild(t)}catch(n){}}function x(n){s(n)}e.init=function(n,t){r(i,o,a,n,t)},e.show=function(n,t,e){return d(o,a,n,t,e)},e.confirm=function(n,t,e,i){return c(o,a,n,t,"Confirm","Cancel",e,i)},e.affirm=function(n,t,e,i){return c(o,a,n,t,"Yes","No",e,i)},e.input=function(n,t,e,i){return l(o,a,n,t,e,i)},e.destroy=x;var v=(b.prototype.show=function(n,t,e){return d(this.localEachNotificationClassName,a,n,t,e)},b.prototype.confirm=function(n,t,e,i){return c(this.localEachNotificationClassName,a,n,t,"Confirm","Cancel",e,i)},b.prototype.affirm=function(n,t,e,i){return c(this.localEachNotificationClassName,a,n,t,"Yes","No",e,i)},b.prototype.input=function(n,t,e,i){return l(this.localEachNotificationClassName,a,n,t,e,i)},b.prototype.destroy=function(n){s(n)},b);function b(n,t){this.localNotificationCenterClassName=i+"-"+n,this.localEachNotificationClassName=o+"-"+n,r(this.localNotificationCenterClassName,this.localEachNotificationClassName,a,n,t)}e.Unnotify=v},{}]},{},[1])(1)});
//# sourceMappingURL=unnotify.min.js.map