UNPKG

snack.js

Version:

Lightweight toast notifications module

2 lines (1 loc) 3.87 kB
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Snack=e()}}(function(){return function e(t,n,i){function s(r,a){if(!n[r]){if(!t[r]){var c="function"==typeof require&&require;if(!a&&c)return c(r,!0);if(o)return o(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var l=n[r]={exports:{}};t[r][0].call(l.exports,function(e){var n=t[r][1][e];return s(n?n:e)},l,l.exports,e,t,n,i)}return n[r].exports}for(var o="function"==typeof require&&require,r=0;r<i.length;r++)s(i[r]);return s}({1:[function(e,t,n){"use strict";function i(e,t,n){var i=e.getElementById(t);if(i)n(i);else{var s=e.getElementsByTagName("head")[0];i=e.createElement("style"),null!=t&&(i.id=t),n(i),s.appendChild(i)}return i}t.exports=function(e,t,n){var s=t||document;if(s.createStyleSheet){var o=s.createStyleSheet();return o.cssText=e,o.ownerNode}return i(s,n,function(t){t.styleSheet?t.styleSheet.cssText=e:t.innerHTML=e})},t.exports.byUrl=function(e){if(document.createStyleSheet)return document.createStyleSheet(e).ownerNode;var t=document.getElementsByTagName("head")[0],n=document.createElement("link");return n.rel="stylesheet",n.href=e,t.appendChild(n),n}},{}],2:[function(e,t,n){function i(e){e=e||{},this.domParent=e.domParent||document.body,this.container=document.createElement("div"),this.element=document.createElement("div"),this.container.classList.add("snack-container"),this.element.classList.add("snack"),this.container.appendChild(this.element),this.domParent.appendChild(this.container)}e("../styles/snack.min.css");var s=function(e){return!!("object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName)};i.prototype.constructor=i,t.exports=i,Object.defineProperties(i,{visible:{get:function(){return!!this._isVisible},set:function(e){this[e?"show":"hide"]()}}}),i.prototype.toggle=function(){this.visible=!this.visible},i.prototype.show=function(e,t){s(e)?(this.element.innerHTML="",this.element.appendChild(e)):this.element.innerHTML=e,this.element.classList.add("snack-opened"),this._isVisible=!0,t&&setTimeout(this.hide.bind(this),t)},i.prototype.hide=function(){this.element.classList.remove("snack-opened"),this._isVisible=!1},i.prototype.destroy=function(){this.domParent.removeChild(this.container)}},{"../styles/snack.min.css":3}],3:[function(e,t,n){var i=e("./../node_modules/cssify"),s=".snack-container{position:fixed;left:20px;bottom:0;z-index:99999}.snack{overflow:hidden;clear:both;min-width:288px;max-width:568px;cursor:pointer;opacity:0;background-color:#323232;color:#fff;font-size:14px;border-radius:2px;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24);height:0;transition:transform .2s ease-in-out,opacity .2s ease-in,height 0s linear .2s,padding 0s linear .2s,height 0s linear .2s;transition:transform .2s ease-in-out,opacity .2s ease-in,height 0s linear .2s,padding 0s linear .2s,height 0s linear .2s,-webkit-transform .2s ease-in-out;-webkit-transform:translateY(200%);transform:translateY(200%)}.snack.snack-opened{height:auto;opacity:1;padding:14px 15px;margin-bottom:20px;transition:transform .2s ease-in-out,opacity .2s ease-in,height 0s linear .2s,height 0s linear .2s;transition:transform .2s ease-in-out,opacity .2s ease-in,height 0s linear .2s,height 0s linear .2s,-webkit-transform .2s ease-in-out;-webkit-transform:none;transform:none}@media (max-width:767px){.snack-container{left:0!important;right:0;width:100%}.snack-container .snack{min-width:100%}.snack-container .snack.snack-opened{border-radius:0;margin-bottom:0}}\n";i(s,void 0,"_19gnn7m"),t.exports=s},{"./../node_modules/cssify":1}]},{},[2])(2)});