center_popup
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -1,1 +0,1 @@ | ||
"use strict";function _typeof(e){return(_typeof="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(e,n){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).Popup=n()}(void 0,function(){function r(e){if("undefined"!=typeof console&&console.error)return console.error.call(console,e)}function i(e){return(new DOMParser).parseFromString(e,"text/html").body.childNodes[0]}function u(){return document.querySelectorAll(".popup-wrapper")[0]}function a(e){return e.parentNode.removeChild(e)}function s(e){return document.body.insertAdjacentElement("beforeend",e)}return function(e,n){var t=1<arguments.length&&void 0!==n?n:{},o=this;o.openStatus=!1,o.node=function(e){return null!==e&&"object"===_typeof(e)}(e)?e:i(e),o.options=Object.assign({display:"block",success:function(){}},t),o.node.style.display="none",o.options.success.call(o),function(){var e=".popup-wrapper{position:fixed;width:100vw;height:100vh;top:0;left:0;background:rgba(0, 0, 0, 0.7)}.popup-wrapper .popup-inner{position:absolute;top:50%;transform:translateY(-50%);left:0;right:0;margin:auto;background:#fff;max-width:576px;max-height:90%;overflow:auto}@media (max-width: 768px){.popup-wrapper .popup-inner{max-width:320px}}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}",n=document.createElement("style");n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(n)}();function p(e){var n=i('<div class="popup-wrapper"></div>'),t=i('<div class="popup-inner"></div>');return e.style.display=o.options.display,t.insertAdjacentElement("beforeend",e),n.insertAdjacentElement("beforeend",t),n}o.open=function(){if(o.openStatus)return r("Popup is now openned!");var e=p(o.node);return o.openStatus=!0,s(e)},o.close=function(){if(!o.openStatus)return r("Popup is now closed!");var e=u();o.openStatus=!1,a(e)},o.fadeIn=function(e){if(o.openStatus)return r("Popup is now openned!");var n=p(o.node);return o.openStatus=!0,n.style.animation="fadeIn "+e+"s",s(n)},o.fadeOut=function(e){if(!o.openStatus)return r("Popup is now closed!");var n=u();n.addEventListener("animationend",function(){a(n)}),o.openStatus=!1,n.style.animation="fadeOut "+e+"s"}}}); | ||
"use strict";function _typeof(e){return(_typeof="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(e,n){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).Popup=n()}(void 0,function(){function p(e){if("undefined"!=typeof console&&console.error)return console.error.call(console,e)}function i(e){return"function"==typeof e}function r(e){return(new DOMParser).parseFromString(e,"text/html").body.childNodes[0]}function a(e){return e.parentNode.removeChild(e)}return function(e,n){var o=1<arguments.length&&void 0!==n?n:{},t=this;t.openStatus=!1,t.node=function(e){return null!==e&&"object"===_typeof(e)}(e)?e:r(e),t.options=Object.assign({display:"block",success:function(){}},o),t.node.style.display="none",t.options.success.call(t),function(){var e=".popup-wrapper{position:fixed;width:100vw;height:100vh;top:0;left:0;background:rgba(0, 0, 0, 0.7)}.popup-wrapper .popup-inner{position:absolute;top:50%;transform:translateY(-50%);left:0;right:0;margin:auto;background:#fff;max-width:576px;max-height:90%;overflow:auto}@media (max-width: 768px){.popup-wrapper .popup-inner{max-width:320px}}@keyframes popupFadeIn{0%{opacity:0}100%{opacity:1}}@keyframes popupFadeOut{0%{opacity:1}100%{opacity:0}}@keyframes popupFadeInDown{0%{opacity:0;transform:translateY(-100%)}100%{opacity:1}}",n=document.createElement("style");n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(n)}();t.open=function(e){if(t.openStatus)return p("Popup is now openned!");var n=function(e){var n=r('<div class="popup-wrapper"></div>'),o=r('<div class="popup-inner"></div>');return e.style.display=t.options.display,o.insertAdjacentElement("beforeend",e),n.insertAdjacentElement("beforeend",o),n}(t.node);return t.openStatus=!0,i(e)&&e(n),function(e){return document.body.insertAdjacentElement("beforeend",e)}(n)},t.close=function(e){if(!t.openStatus)return p("Popup is now closed!");var n=document.querySelectorAll(".popup-wrapper")[0];t.openStatus=!1,i(e)?e(n):a(n)},t.fadeIn=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.3;t.open(function(e){e.style.animation="popupFadeIn "+n+"s"})},t.fadeInDown=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.3;t.open(function(e){e.style.animation="popupFadeIn "+n+"s",t.node.parentNode.style.animation="popupFadeInDown "+n+"s"})},t.fadeOut=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.3;t.close(function(e){e.addEventListener("animationend",function(){a(e)}),e.style.animation="PopupFadeOut "+n+"s"})}}}); |
/*! | ||
* center-popup.js v1.0.4 | ||
* center-popup.js v1.0.8 | ||
* (c) 2019 Johnny Wang | ||
@@ -22,2 +22,3 @@ * Released under the MIT License. | ||
} | ||
const isObject = v => { | ||
@@ -27,2 +28,6 @@ return v !== null && typeof v === 'object'; | ||
const isFn = v => { | ||
return typeof v === 'function'; | ||
} | ||
/* */ | ||
@@ -95,8 +100,7 @@ | ||
self.openStatus = true; | ||
fn !== void 0 && typeof fn === 'function' && fn(template); | ||
isFn(fn) && fn(template); | ||
return appendToBody(template); | ||
} | ||
self.close = function() { | ||
self.close = function(fn) { | ||
if (!self.openStatus) return error('Popup is now closed!'); | ||
@@ -106,6 +110,5 @@ | ||
self.openStatus = false; | ||
removeNode(wrapper); | ||
(isFn(fn)) ? fn(wrapper) : removeNode(wrapper); | ||
} | ||
self.fadeIn = function(s = .3) { | ||
@@ -124,12 +127,9 @@ self.open(template => { | ||
self.fadeOut = function(s = .3) { | ||
if (!self.openStatus) return error('Popup is now closed!'); | ||
const wrapper = getWrapper(); | ||
wrapper.addEventListener('animationend', function() { | ||
removeNode(wrapper); | ||
self.close(wrapper => { | ||
wrapper.addEventListener('animationend', function() { | ||
removeNode(wrapper); | ||
}) | ||
wrapper.style.animation = 'PopupFadeOut '+s+'s'; | ||
}) | ||
self.openStatus = false; | ||
wrapper.style.animation = 'popupFadeOut '+s+'s'; | ||
} | ||
@@ -136,0 +136,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";function _typeof(e){return(_typeof="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(e,n){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).Popup=n()}(void 0,function(){function r(e){if("undefined"!=typeof console&&console.error)return console.error.call(console,e)}function i(e){return(new DOMParser).parseFromString(e,"text/html").body.childNodes[0]}function u(){return document.querySelectorAll(".popup-wrapper")[0]}function a(e){return e.parentNode.removeChild(e)}function s(e){return document.body.insertAdjacentElement("beforeend",e)}return function(e,n){var t=1<arguments.length&&void 0!==n?n:{},o=this;o.openStatus=!1,o.node=function(e){return null!==e&&"object"===_typeof(e)}(e)?e:i(e),o.options=Object.assign({display:"block",success:function(){}},t),o.node.style.display="none",o.options.success.call(o),function(){var e=".popup-wrapper{position:fixed;width:100vw;height:100vh;top:0;left:0;background:rgba(0, 0, 0, 0.7)}.popup-wrapper .popup-inner{position:absolute;top:50%;transform:translateY(-50%);left:0;right:0;margin:auto;background:#fff;max-width:576px;max-height:90%;overflow:auto}@media (max-width: 768px){.popup-wrapper .popup-inner{max-width:320px}}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}",n=document.createElement("style");n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(n)}();function p(e){var n=i('<div class="popup-wrapper"></div>'),t=i('<div class="popup-inner"></div>');return e.style.display=o.options.display,t.insertAdjacentElement("beforeend",e),n.insertAdjacentElement("beforeend",t),n}o.open=function(){if(o.openStatus)return r("Popup is now openned!");var e=p(o.node);return o.openStatus=!0,s(e)},o.close=function(){if(!o.openStatus)return r("Popup is now closed!");var e=u();o.openStatus=!1,a(e)},o.fadeIn=function(e){if(o.openStatus)return r("Popup is now openned!");var n=p(o.node);return o.openStatus=!0,n.style.animation="fadeIn "+e+"s",s(n)},o.fadeOut=function(e){if(!o.openStatus)return r("Popup is now closed!");var n=u();n.addEventListener("animationend",function(){a(n)}),o.openStatus=!1,n.style.animation="fadeOut "+e+"s"}}}); | ||
"use strict";function _typeof(e){return(_typeof="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(e,n){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).Popup=n()}(void 0,function(){function p(e){if("undefined"!=typeof console&&console.error)return console.error.call(console,e)}function i(e){return"function"==typeof e}function r(e){return(new DOMParser).parseFromString(e,"text/html").body.childNodes[0]}function a(e){return e.parentNode.removeChild(e)}return function(e,n){var o=1<arguments.length&&void 0!==n?n:{},t=this;t.openStatus=!1,t.node=function(e){return null!==e&&"object"===_typeof(e)}(e)?e:r(e),t.options=Object.assign({display:"block",success:function(){}},o),t.node.style.display="none",t.options.success.call(t),function(){var e=".popup-wrapper{position:fixed;width:100vw;height:100vh;top:0;left:0;background:rgba(0, 0, 0, 0.7)}.popup-wrapper .popup-inner{position:absolute;top:50%;transform:translateY(-50%);left:0;right:0;margin:auto;background:#fff;max-width:576px;max-height:90%;overflow:auto}@media (max-width: 768px){.popup-wrapper .popup-inner{max-width:320px}}@keyframes popupFadeIn{0%{opacity:0}100%{opacity:1}}@keyframes popupFadeOut{0%{opacity:1}100%{opacity:0}}@keyframes popupFadeInDown{0%{opacity:0;transform:translateY(-100%)}100%{opacity:1}}",n=document.createElement("style");n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(n)}();t.open=function(e){if(t.openStatus)return p("Popup is now openned!");var n=function(e){var n=r('<div class="popup-wrapper"></div>'),o=r('<div class="popup-inner"></div>');return e.style.display=t.options.display,o.insertAdjacentElement("beforeend",e),n.insertAdjacentElement("beforeend",o),n}(t.node);return t.openStatus=!0,i(e)&&e(n),function(e){return document.body.insertAdjacentElement("beforeend",e)}(n)},t.close=function(e){if(!t.openStatus)return p("Popup is now closed!");var n=document.querySelectorAll(".popup-wrapper")[0];t.openStatus=!1,i(e)?e(n):a(n)},t.fadeIn=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.3;t.open(function(e){e.style.animation="popupFadeIn "+n+"s"})},t.fadeInDown=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.3;t.open(function(e){e.style.animation="popupFadeIn "+n+"s",t.node.parentNode.style.animation="popupFadeInDown "+n+"s"})},t.fadeOut=function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:.3;t.close(function(e){e.addEventListener("animationend",function(){a(e)}),e.style.animation="PopupFadeOut "+n+"s"})}}}); |
{ | ||
"name": "center_popup", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "A library for creating a centered popup window", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
13401
105