This repository has been archived by the owner on Nov 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
notie.js
2 lines (2 loc) · 9.97 KB
/
notie.js
1
2
console.log("\n %c Notie %c 通知插件 %c \n","color: #fff; background: #eb0; padding:5px 0; border: 1px solid #eb0;","color: #eb0; background: #fff; padding:5px 0; border: 1px solid #eb0;","");
var notie=function(t){function e(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){t.exports=o(2)},function(t,e){"use strict";t.exports=function(){var t=[];return t.toString=function(){for(var t=[],e=0;e<this.length;e++){var o=this[e];o[2]?t.push("@media "+o[2]+"{"+o[1]+"}"):t.push(o[1])}return t.join("")},t.i=function(e,o){"string"==typeof e&&(e=[[null,e,""]]);for(var n={},i=0;i<this.length;i++){var r=this[i][0];"number"==typeof r&&(n[r]=!0)}for(i=0;i<e.length;i++){var s=e[i];"number"==typeof s[0]&&n[s[0]]||(o&&!s[2]?s[2]=o:o&&(s[2]="("+s[2]+") and ("+o+")"),t.push(s))}},t}},function(t,e,o){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){Array.prototype.forEach.call(t,e)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,o,n){return o&&t(e.prototype,o),n&&t(e,n),e}}(),a=o(5),l=(n(a),o(6)),c=n(l),u=o(8),f=n(u),p=o(9),d=n(p),h=o(7),v=n(h),m={info:v["default"],success:f["default"],warning:d["default"],error:c["default"]},g=document.querySelector.bind(document),b=(document.querySelectorAll.bind(document),function(){function t(e,o){i(this,t),this.text=e,this.opts=o,this.events={},this.notify()}return s(t,[{key:"init",value:function(){var t=g(".noties-"+this.opts.position);t?this.noties=t:(this.noties=document.createElement("div"),this.noties.className="noties noties-"+this.opts.position,g("body").appendChild(this.noties))}},{key:"notify",value:function(){var t=this;this.init(),this.notie=document.createElement("div"),this.notie.style.width=this.opts.width+"px",this.notie.className="notie notie-"+this.opts.type+(this.opts.autoHide?"":" notie-auto-hide-disabled"),this.notie.innerHTML='\n <div class="notie-body">\n <span class="notie-svg">'+m[this.opts.type]+'</span>\n <span class="notie-text">'+this.text+"</span>\n </div>\n ";var e=this.noties.firstChild;this.noties.insertBefore(this.notie,e),setTimeout(function(){t.notie.classList.add("notie-shown")},100),this.opts.autoHide&&this.startTimeout(),this.registerEvents()}},{key:"registerEvents",value:function(){var t=this;this.opts.autoHide?(this.events.mouseover=function(){clearTimeout(t.timeout),t.timeout=null},this.events.mouseleave=function(){return t.startTimeout()},this.notie.addEventListener("mouseover",this.events.mouseover,!1),this.notie.addEventListener("mouseleave",this.events.mouseleave,!1)):(this.notie.addEventListener("click",function(){return t.removeNotie()}),r(this.notie.querySelectorAll("[notie-prevent]"),function(t){t.addEventListener("click",function(t){return t.stopPropagation()},!1)}))}},{key:"startTimeout",value:function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?this.opts.timeout:arguments[0];this.timeout=setTimeout(function(){t.removeNotie()},e)}},{key:"removeNotie",value:function(){var t=this,e=arguments.length<=0||void 0===arguments[0]?this.notie:arguments[0];e.classList.remove("notie-shown"),setTimeout(function(){t.noties.removeChild(e),e=null},200)}}]),t}()),x=function(){var t=arguments.length<=0||void 0===arguments[0]?"":arguments[0],e=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=e.position,n=void 0===o?"top-right":o,i=e.type,r=void 0===i?"info":i,s=e.autoHide,a=void 0===s?!0:s,l=e.timeout,c=void 0===l?3e3:l,u=e.width,f=void 0===u?240:u;return new b(t,{type:r,position:n,autoHide:a,timeout:c,width:f})};e["default"]=x,t.exports=e["default"]},function(t,e,o){e=t.exports=o(1)(),e.push([t.id,".noties{position:fixed;max-width:80%;z-index:9999}.noties:empty{display:none}.noties-top-right{right:0;top:20px}.noties-top-right .notie{transform:translateX(100%)}.noties-top-right .notie.notie-shown{transform:translateX(-20px)}.noties-top-left{left:0;top:20px}.noties-top-left .notie{transform:translateX(-100%)}.noties-top-left .notie.notie-shown{transform:translateX(20px)}.noties-bottom-right{right:0;bottom:20px}.noties-bottom-right .notie{transform:translateX(100%)}.noties-bottom-right .notie.notie-shown{transform:translateX(-20px)}.noties-bottom-left{left:0;bottom:20px}.noties-bottom-left .notie{transform:translateX(-100%)}.noties-bottom-left .notie.notie-shown{transform:translateX(20px)}.noties-top-center{left:50%;transform:translateX(-50%);top:0}.noties-top-center .notie{transform:translateY(-100%)}.noties-top-center .notie.notie-shown{transform:translateY(20px)}.noties-bottom-center{left:50%;transform:translateX(-50%);bottom:0}.noties-bottom-center .notie{transform:translateY(100%)}.noties-bottom-center .notie.notie-shown{transform:translateY(-20px)}.notie{background-color:#ddd;opacity:0;transition:transform .3s,opacity .3s;border:1px solid #ddd;font:14px/1.4 Helvetica,serif;word-wrap:break-word}.notie:not(:last-child){margin-bottom:10px}.notie.notie-auto-hide-disabled{cursor:pointer}.notie.notie-shown{opacity:1}.notie .notie-body{padding:10px 12px}.notie .notie-svg{height:23px;display:block;float:left}.notie .notie-text{display:block;padding-left:30px;padding-top:2px}.notie svg{height:23px;width:23px}.notie.notie-info{background-color:#c6e4f4;border-color:#a9d3eb;color:#477dac;a{color:#477dac}}.notie.notie-error{background-color:#eac1bd;border-color:#d7a9a6;color:#ab2925;a{color:#ab2925}}.notie.notie-success{background-color:#d9f1cf;border-color:#c8e1bf;color:#748c6c;a{color:#748c6c}}.notie.notie-warning{background-color:#f7f2cf;border-color:#e8e2b2;color:#9c7d45;a{color:#9c7d45}}",""])},function(t,e,o){function n(t,e){for(var o=0;o<t.length;o++){var n=t[o],i=d[n.id];if(i){i.refs++;for(var r=0;r<i.parts.length;r++)i.parts[r](n.parts[r]);for(;r<n.parts.length;r++)i.parts.push(c(n.parts[r],e))}else{for(var s=[],r=0;r<n.parts.length;r++)s.push(c(n.parts[r],e));d[n.id]={id:n.id,refs:1,parts:s}}}}function i(t){for(var e=[],o={},n=0;n<t.length;n++){var i=t[n],r=i[0],s=i[1],a=i[2],l=i[3],c={css:s,media:a,sourceMap:l};o[r]?o[r].parts.push(c):e.push(o[r]={id:r,parts:[c]})}return e}function r(t,e){var o=m(),n=x[x.length-1];if("top"===t.insertAt)n?n.nextSibling?o.insertBefore(e,n.nextSibling):o.appendChild(e):o.insertBefore(e,o.firstChild),x.push(e);else{if("bottom"!==t.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");o.appendChild(e)}}function s(t){t.parentNode.removeChild(t);var e=x.indexOf(t);e>=0&&x.splice(e,1)}function a(t){var e=document.createElement("style");return e.type="text/css",r(t,e),e}function l(t){var e=document.createElement("link");return e.rel="stylesheet",r(t,e),e}function c(t,e){var o,n,i;if(e.singleton){var r=b++;o=g||(g=a(e)),n=u.bind(null,o,r,!1),i=u.bind(null,o,r,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(o=l(e),n=p.bind(null,o),i=function(){s(o),o.href&&URL.revokeObjectURL(o.href)}):(o=a(e),n=f.bind(null,o),i=function(){s(o)});return n(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;n(t=e)}else i()}}function u(t,e,o,n){var i=o?"":n.css;if(t.styleSheet)t.styleSheet.cssText=y(e,i);else{var r=document.createTextNode(i),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(r,s[e]):t.appendChild(r)}}function f(t,e){var o=e.css,n=e.media;if(n&&t.setAttribute("media",n),t.styleSheet)t.styleSheet.cssText=o;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(o))}}function p(t,e){var o=e.css,n=e.sourceMap;n&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */");var i=new Blob([o],{type:"text/css"}),r=t.href;t.href=URL.createObjectURL(i),r&&URL.revokeObjectURL(r)}var d={},h=function(t){var e;return function(){return"undefined"==typeof e&&(e=t.apply(this,arguments)),e}},v=h(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),m=h(function(){return document.head||document.getElementsByTagName("head")[0]}),g=null,b=0,x=[];t.exports=function(t,e){e=e||{},"undefined"==typeof e.singleton&&(e.singleton=v()),"undefined"==typeof e.insertAt&&(e.insertAt="bottom");var o=i(t);return n(o,e),function(t){for(var r=[],s=0;s<o.length;s++){var a=o[s],l=d[a.id];l.refs--,r.push(l)}if(t){var c=i(t);n(c,e)}for(var s=0;s<r.length;s++){var l=r[s];if(0===l.refs){for(var u=0;u<l.parts.length;u++)l.parts[u]();delete d[l.id]}}}};var y=function(){var t=[];return function(e,o){return t[e]=o,t.filter(Boolean).join("\n")}}()},function(t,e,o){var n=o(3);"string"==typeof n&&(n=[[t.id,n,""]]);o(4)(n,{});n.locals&&(t.exports=n.locals)},function(t,e){t.exports='<svg fill="#AB2925" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg>'},function(t,e){t.exports='<svg fill="#477DAC" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"></path><path d="M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 9h2V7h-2v2z"></path></svg>'},function(t,e){t.exports='<svg fill="#748C6C" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"></path><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"></path></svg>'},function(t,e){t.exports='<svg fill="#9C7D45" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"></path><path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"></path></svg>'}]);