Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sweetalert2

Package Overview
Dependencies
Maintainers
1
Versions
742
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sweetalert2 - npm Package Compare versions

Comparing version 2.2.4 to 2.2.5

2

dist/sweetalert2.min.js

@@ -1,1 +0,1 @@

!function(e,t){"use strict";function s(){if(void 0===arguments[0])return e.console.error("sweetAlert2 expects at least 1 attribute!"),!1;var s=B({},c);switch(typeof arguments[0]){case"string":s.title=arguments[0],s.text=arguments[1]||"",s.type=arguments[2]||"";break;case"object":s.title=arguments[0].title||c.title,s.text=arguments[0].text||c.text,s.html=arguments[0].html||c.html,s.type=arguments[0].type||c.type,s.animation=void 0!==arguments[0].animation?arguments[0].animation:c.animation,s.customClass=arguments[0].customClass||s.customClass,s.allowOutsideClick=void 0!==arguments[0].allowOutsideClick?arguments[0].allowOutsideClick:c.allowOutsideClick,s.allowEscapeKey=void 0!==arguments[0].allowEscapeKey?arguments[0].allowEscapeKey:c.allowEscapeKey,s.showConfirmButton=void 0!==arguments[0].showConfirmButton?arguments[0].showConfirmButton:c.showConfirmButton,s.showCancelButton=void 0!==arguments[0].showCancelButton?arguments[0].showCancelButton:c.showCancelButton,s.preConfirm=arguments[0].preConfirm||c.preConfirm,s.timer=parseInt(arguments[0].timer,10)||c.timer,s.width=parseInt(arguments[0].width,10)||c.width,s.padding=parseInt(arguments[0].padding,10)||c.padding,s.background=void 0!==arguments[0].background?arguments[0].background:c.background,s.confirmButtonText=arguments[0].confirmButtonText||c.confirmButtonText,s.confirmButtonColor=arguments[0].confirmButtonColor||c.confirmButtonColor,s.confirmButtonClass=arguments[0].confirmButtonClass||s.confirmButtonClass,s.cancelButtonText=arguments[0].cancelButtonText||c.cancelButtonText,s.cancelButtonColor=arguments[0].cancelButtonColor||c.cancelButtonColor,s.cancelButtonClass=arguments[0].cancelButtonClass||s.cancelButtonClass,s.buttonsStyling=void 0!==arguments[0].buttonsStyling?arguments[0].buttonsStyling:c.buttonsStyling,s.reverseButtons=void 0!==arguments[0].reverseButtons?arguments[0].reverseButtons:c.reverseButtons,s.showCloseButton=void 0!==arguments[0].showCloseButton?arguments[0].showCloseButton:c.showCloseButton,s.imageUrl=arguments[0].imageUrl||c.imageUrl,s.imageWidth=arguments[0].imageWidth||c.imageWidth,s.imageHeight=arguments[0].imageHeight||c.imageHeight,s.imageClass=arguments[0].imageClass||c.imageClass,s.input=arguments[0].input||c.input,s.inputPlaceholder=arguments[0].inputPlaceholder||c.inputPlaceholder,s.inputValue=arguments[0].inputValue||c.inputValue,s.inputOptions=arguments[0].inputOptions||c.inputOptions,s.inputClass=arguments[0].inputClass||c.inputClass,s.inputAttributes=arguments[0].inputAttributes||c.inputAttributes,s.inputValidator=arguments[0].inputValidator||c.inputValidator,"email"===s.input&&null===s.inputValidator&&(s.inputValidator=function(e){return new Promise(function(t,s){var a=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;a.test(e)?t():s("Invalid email address")})});break;default:return e.console.error('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}T(s),L(),M();var a=u();return new Promise(function(l){function i(e,t){for(var s=0;s<T.length;s++)if(e+=t,e===T.length?e=0:-1===e&&(e=T.length-1),T[e].offsetWidth||T[e].offsetHeight||T[e].getClientRects().length)return void T[e].focus()}function c(t){var a=t||e.event,n=a.keyCode||a.which;if(-1!==[9,13,32,27].indexOf(n)){for(var o=a.target||a.srcElement,r=-1,c=0;c<T.length;c++)if(o===T[c]){r=c;break}9===n?(a.shiftKey?i(r,-1):i(r,1),S(a)):13===n||32===n?-1===r&&x(B,a):27===n&&s.allowEscapeKey===!0&&(e.swal.closeModal(),l(void 0))}}s.timer&&(a.timeout=setTimeout(function(){e.swal.closeModal(),l(void 0)},s.timer));var u=function(){switch(s.input){case"select":return a.querySelector("."+e.swalClasses.select);case"radio":return a.querySelector("."+e.swalClasses.radio+" input:checked")||a.querySelector("."+e.swalClasses.radio+" input:first-child");case"checkbox":return a.querySelector("#"+e.swalClasses.checkbox);case"textarea":return a.querySelector("."+e.swalClasses.textarea);default:return a.querySelector("."+e.swalClasses.input)}},C=function(){var e=u();switch(s.input){case"checkbox":return e.checked?1:0;case"radio":return e.checked?e.value:null;default:return e.value}};s.input&&setTimeout(function(){w(u())},0);var v,g=function(t){s.preConfirm?s.preConfirm().then(function(s){l(s||t),e.swal.closeModal()}):(l(t),e.swal.closeModal())},b=function(t){var n=t||e.event,o=n.target||n.srcElement,r=p(o,e.swalClasses.confirm),i=p(o,e.swalClasses.cancel),c=p(a,"visible");switch(n.type){case"mouseover":case"mouseup":case"focus":s.buttonsStyling&&(r?o.style.backgroundColor=q(s.confirmButtonColor,-.1):i&&(o.style.backgroundColor=q(s.cancelButtonColor,-.1)));break;case"mouseout":case"blur":s.buttonsStyling&&(r?o.style.backgroundColor=s.confirmButtonColor:i&&(o.style.backgroundColor=s.cancelButtonColor));break;case"mousedown":s.buttonsStyling&&(r?o.style.backgroundColor=q(s.confirmButtonColor,-.2):i&&(o.style.backgroundColor=q(s.cancelButtonColor,-.2)));break;case"click":if(r&&c)if(s.input){var u=C();s.inputValidator?s.inputValidator(u).then(function(){g(u)},function(t){e.swal.showValidationError(t)}):g(u)}else g(!0);else i&&c?(e.swal.closeModal(),l(!1)):e.swal.closeModal()}},k=a.querySelectorAll("button");for(v=0;v<k.length;v++)k[v].onclick=b,k[v].onmouseover=b,k[v].onmouseout=b,k[v].onmousedown=b;n=t.onclick,t.onclick=function(t){var a=t||e.event,n=a.target||a.srcElement;(p(n,e.swalClasses.close)||n===d()&&s.allowOutsideClick)&&(e.swal.closeModal(),l(void 0))};var B=a.querySelector("button."+e.swalClasses.confirm),E=a.querySelector("button."+e.swalClasses.cancel),T=[B,E].concat(Array.prototype.slice.call(a.querySelectorAll("button:not([class^="+e.swalPrefix+"]), input:not([type=hidden]), textarea, select")));for(v=0;v<T.length;v++)T[v].onfocus=b,T[v].onblur=b;s.reverseButtons&&B.parentNode.insertBefore(E,B),i(-1,1),o=e.onkeydown,e.onkeydown=c,s.buttonsStyling&&(B.style.borderLeftColor=s.confirmButtonColor,B.style.borderRightColor=s.confirmButtonColor),e.swal.enableLoading=function(){f(B,"loading"),f(a,"loading"),E.disabled=!0},e.swal.disableLoading=function(){m(B,"loading"),m(a,"loading"),E.disabled=!1},e.swal.enableButtons=function(){B.disabled=!1,E.disabled=!1},e.swal.disableButtons=function(){B.disabled=!0,E.disabled=!0},e.swal.showValidationError=function(t){var s=a.querySelector("."+e.swalClasses.validationerror);s.innerHTML=t,y(s);var l=u();w(l),f(l,"error")},e.swal.resetValidationError=function(){var t=a.querySelector("."+e.swalClasses.validationerror);h(t);var s=u();m(s,"error")},e.swal.enableButtons(),e.swal.disableLoading(),e.swal.resetValidationError(),e.onfocus=function(){e.setTimeout(function(){void 0!==r&&(r.focus(),r=void 0)},0)}})}e.swalPrefix="swal2-";var a=function(t){var s={};for(var a in t)s[t[a]]=e.swalPrefix+t[a];return s};e.swalClasses=a(["container","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","select","radio","checkbox","textarea","validationerror"]),e.swalClasses.iconTypes=a(["success","warning","info","question","error"]);var l,n,o,r,i=e.swalPrefix+"mediaquery",c={title:"",text:"",html:"",type:null,animation:!0,allowOutsideClick:!0,allowEscapeKey:!0,showConfirmButton:!0,showCancelButton:!1,preConfirm:null,confirmButtonText:"OK",confirmButtonColor:"#3085d6",confirmButtonClass:null,cancelButtonText:"Cancel",cancelButtonColor:"#aaa",cancelButtonClass:null,buttonsStyling:!0,reverseButtons:!1,showCloseButton:!1,imageUrl:null,imageWidth:null,imageHeight:null,imageClass:null,timer:null,width:500,padding:20,background:"#fff",input:null,inputPlaceholder:"",inputValue:"",inputOptions:{},inputClass:null,inputAttributes:{},inputValidator:null},u=function(){return t.querySelector("."+e.swalClasses.modal)},d=function(){return t.querySelector("."+e.swalClasses.overlay)},p=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},w=function(e){e.focus();var t=e.value;e.value="",e.value=t},f=function(e,t){t&&!p(e,t)&&(e.className+=" "+t)},m=function(e,t){var s=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(p(e,t)){for(;s.indexOf(" "+t+" ")>=0;)s=s.replace(" "+t+" "," ");e.className=s.replace(/^\s+|\s+$/g,"")}},C=function(e){e.style.opacity="",e.style.display="block"},y=function(e){if(e&&!e.length)return C(e);for(var t=0;t<e.length;++t)C(e[t])},v=function(e){e.style.opacity="",e.style.display="none"},h=function(e){if(e&&!e.length)return v(e);for(var t=0;t<e.length;++t)v(e[t])},g=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},b=function(e){e.style.left="-9999px",e.style.display="block";var t=e.clientHeight,s=parseInt(getComputedStyle(e).getPropertyValue("padding-top"),10);return e.style.left="",e.style.display="none","-"+parseInt(t/2+s,10)+"px"},k=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var s=+new Date,a=function(){e.style.opacity=+e.style.opacity+(new Date-s)/100,s=+new Date,+e.style.opacity<1&&setTimeout(a,t)};a()}},B=function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e},x=function(s){if("function"==typeof MouseEvent){var a=new MouseEvent("click",{view:e,bubbles:!1,cancelable:!0});s.dispatchEvent(a)}else if(t.createEvent){var l=t.createEvent("MouseEvents");l.initEvent("click",!1,!1),s.dispatchEvent(l)}else t.createEventObject?s.fireEvent("onclick"):"function"==typeof s.onclick&&s.onclick()},S=function(t){"function"==typeof t.stopPropagation?(t.stopPropagation(),t.preventDefault()):e.event&&e.event.hasOwnProperty("cancelBubble")&&(e.event.cancelBubble=!0)},E=function(){var s=u();e.onkeydown=o,t.onclick=n,l&&l.focus(),r=void 0,clearTimeout(s.timeout);var a=t.getElementsByTagName("head")[0],c=t.getElementById(i);c&&a.removeChild(c)},q=function(e,t){e=String(e).replace(/[^0-9a-f]/gi,""),e.length<6&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),t=t||0;for(var s="#",a=0;3>a;a++){var l=parseInt(e.substr(2*a,2),16);l=Math.round(Math.min(Math.max(0,l+l*t),255)).toString(16),s+=("00"+l).substr(l.length)}return s},T=function(s){var a,l=u();l.style.width=s.width+"px",l.style.padding=s.padding+"px",l.style.marginLeft=-s.width/2+"px",l.style.background=s.background;var n=t.getElementsByTagName("head")[0],o=t.createElement("style");o.type="text/css",o.id=i,o.innerHTML="@media screen and (max-width: "+s.width+"px) {."+e.swalClasses.modal+" {max-width: 100%;left: 0 !important;margin-left: 0 !important;}}",n.appendChild(o);var r=l.querySelector("h2"),c=l.querySelector("."+e.swalClasses.content),d=l.querySelector("button."+e.swalClasses.confirm),p=l.querySelector("button."+e.swalClasses.cancel),w=l.querySelector("."+e.swalClasses.spacer),b=l.querySelector("."+e.swalClasses.close);if(r.innerHTML=s.title.split("\n").join("<br>"),s.text||s.html){if("object"==typeof s.html)if(c.innerHTML="",0 in s.html)for(a=0;a in s.html;a++)c.appendChild(s.html[a]);else c.appendChild(s.html);else c.innerHTML=s.html||s.text.split("\n").join("<br>");y(c)}else h(c);if(s.showCloseButton?y(b):h(b),l.className=e.swalClasses.modal,s.customClass&&f(l,s.customClass),h(l.querySelectorAll("."+e.swalClasses.icon)),s.type){var k=!1;for(var B in e.swalClasses.iconTypes)if(s.type===B){k=!0;break}if(!k)return e.console.error("Unknown alert type: "+s.type),!1;var x=l.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes[s.type]);switch(y(x),s.type){case"success":f(x,"animate"),f(x.querySelector(".tip"),"animate-success-tip"),f(x.querySelector(".long"),"animate-success-long");break;case"error":f(x,"animate-error-icon"),f(x.querySelector(".x-mark"),"animate-x-mark");break;case"warning":f(x,"pulse-warning")}}var S=l.querySelector("."+e.swalClasses.image);s.imageUrl?(S.setAttribute("src",s.imageUrl),y(S),s.imageWidth&&S.setAttribute("width",s.imageWidth),s.imageHeight&&S.setAttribute("height",s.imageHeight),s.imageClass&&f(S,s.imageClass)):h(S);var E,q=["input","select","radio","checkbox","textarea"];for(a=0;a<q.length;a++){var T=e.swalClasses[q[a]];for(E=l.querySelector("."+T);E.attributes.length>0;)E.removeAttribute(E.attributes[0].name);for(var M in s.inputAttributes)E.setAttribute(M,s.inputAttributes[M]);E.className=T,s.inputClass&&f(E,s.inputClass),v(E)}switch(s.input){case"text":case"email":case"password":E=l.querySelector("."+e.swalClasses.input),E.value=s.inputValue,E.placeholder=s.inputPlaceholder,E.type=s.input,C(E);break;case"select":var L=l.querySelector("."+e.swalClasses.select);if(L.innerHTML="",s.inputPlaceholder){var V=t.createElement("option");V.innerHTML=s.inputPlaceholder,V.disabled=!0,V.selected=!0,L.appendChild(V)}for(var A in s.inputOptions){var P=t.createElement("option");P.value=A,P.innerHTML=s.inputOptions[A],s.inputValue===A&&(P.selected=!0),L.appendChild(P)}C(L);break;case"radio":var O=l.querySelector("."+e.swalClasses.radio);O.innerHTML="";for(var H in s.inputOptions){var N=1,I=t.createElement("input"),K=t.createElement("label"),U=t.createElement("span");I.type="radio",I.name=e.swalClasses.radio,I.value=H,I.id=e.swalClasses.radio+"-"+N++,s.inputValue===H&&(I.checked=!0),U.innerHTML=s.inputOptions[H],K.appendChild(I),K.appendChild(U),K["for"]=I.id,O.appendChild(K)}C(O);break;case"checkbox":var j=l.querySelector("."+e.swalClasses.checkbox),D=l.querySelector("#"+e.swalClasses.checkbox);D.value=1,D.checked=Boolean(s.inputValue);var W=j.getElementsByTagName("span");W.length&&j.removeChild(W[0]),W=t.createElement("span"),W.innerHTML=s.inputPlaceholder,j.appendChild(W),C(j);break;case"textarea":var R=l.querySelector("."+e.swalClasses.textarea);R.value=s.inputValue,R.placeholder=s.inputPlaceholder,C(R);break;case null:break;default:e.console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox" or "textarea", got '+typeof arguments[0])}s.showCancelButton?p.style.display="inline-block":h(p),s.showConfirmButton?g(d,"display"):h(d),s.showConfirmButton||s.showCancelButton?y(w):h(w),d.innerHTML=s.confirmButtonText,p.innerHTML=s.cancelButtonText,s.buttonsStyling&&(d.style.backgroundColor=s.confirmButtonColor,p.style.backgroundColor=s.cancelButtonColor),d.className=e.swalClasses.confirm,f(d,s.confirmButtonClass),p.className=e.swalClasses.cancel,f(p,s.cancelButtonClass),s.buttonsStyling?(f(d,"styled"),f(p,"styled")):(m(d,"styled"),m(p,"styled"),d.style.backgroundColor=d.style.borderLeftColor=d.style.borderRightColor="",p.style.backgroundColor=p.style.borderLeftColor=p.style.borderRightColor=""),s.animation===!0?m(l,"no-animation"):f(l,"no-animation")},M=function(){var e=u();k(d(),10),y(e),f(e,"show-swal2"),m(e,"hide-swal2"),l=t.activeElement,f(e,"visible")},L=function(){var e=u();e.style.marginTop=b(u())};e.sweetAlert=e.swal=function(){var t=arguments,a=u();return null===a&&(e.swal.init(),a=u()),p(a,"visible")&&E(),s.apply(this,t)},e.sweetAlert.close=e.swal.close=e.sweetAlert.closeModal=e.swal.closeModal=function(){var t=u();v(d()),v(t),m(t,"show-swal2"),f(t,"hide-swal2"),m(t,"visible");var s=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.success);m(s,"animate"),m(s.querySelector(".tip"),"animate-success-tip"),m(s.querySelector(".long"),"animate-success-long");var a=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.error);m(a,"animate-error-icon"),m(a.querySelector(".x-mark"),"animate-x-mark");var l=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.warning);m(l,"pulse-warning"),E()},e.sweetAlert.clickConfirm=e.swal.clickConfirm=function(){var t=u(),s=t.querySelector("button."+e.swalClasses.confirm);s.click()},e.sweetAlert.clickCancel=e.swal.clickCancel=function(){var t=u(),s=t.querySelector("button."+e.swalClasses.cancel);s.click()},e.swal.init=function(){if(!t.getElementsByClassName(e.swalClasses.container).length){var s='<div class="'+e.swalClasses.overlay+'" tabIndex="-1"></div><div class="'+e.swalClasses.modal+'" style="display: none" tabIndex="-1"><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.question+'">?</div><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.warning+'">!</div><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.info+'">i</div><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+e.swalClasses.image+'"><h2></h2><div class="'+e.swalClasses.content+'"></div><input class="'+e.swalClasses.input+'"><select class="'+e.swalClasses.select+'"></select><fieldset class="'+e.swalClasses.radio+'"></fieldset><label for="'+e.swalClasses.checkbox+'" class="'+e.swalClasses.checkbox+'"><input type="checkbox" id="'+e.swalClasses.checkbox+'"></label><textarea class="'+e.swalClasses.textarea+'"></textarea><div class="'+e.swalClasses.validationerror+'"></div><hr class="'+e.swalClasses.spacer+'"><button class="'+e.swalClasses.confirm+'">OK</button><button class="'+e.swalClasses.cancel+'">Cancel</button><span class="'+e.swalClasses.close+'">&times;</span></div>',a=t.createElement("div");a.className=e.swalClasses.container,a.innerHTML=s,t.body.appendChild(a);var l=u(),n=l.querySelector("."+e.swalClasses.input),o=l.querySelector("."+e.swalClasses.select),r=l.querySelector("#"+e.swalClasses.checkbox),i=l.querySelector("."+e.swalClasses.textarea);n.oninput=function(){e.swal.resetValidationError()},n.onkeyup=function(t){13===t.keyCode&&e.swal.clickConfirm()},o.onchange=function(){e.swal.resetValidationError()},r.onchange=function(){e.swal.resetValidationError()},i.onchange=function(){e.swal.resetValidationError()}}},e.swal.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");B(c,e)},function(){"complete"===t.readyState||"interactive"===t.readyState&&t.body?e.swal.init():t.addEventListener?t.addEventListener("DOMContentLoaded",function s(){t.removeEventListener("DOMContentLoaded",s,!1),e.swal.init()},!1):t.attachEvent&&t.attachEvent("onreadystatechange",function a(){"complete"===t.readyState&&(t.detachEvent("onreadystatechange",a),e.swal.init())})}()}(window,document);
!function(e,t){"use strict";function s(){if(void 0===arguments[0])return e.console.error("sweetAlert2 expects at least 1 attribute!"),!1;var s=B({},c);switch(typeof arguments[0]){case"string":s.title=arguments[0],s.text=arguments[1]||"",s.type=arguments[2]||"";break;case"object":s.title=arguments[0].title||c.title,s.text=arguments[0].text||c.text,s.html=arguments[0].html||c.html,s.type=arguments[0].type||c.type,s.animation=void 0!==arguments[0].animation?arguments[0].animation:c.animation,s.customClass=arguments[0].customClass||s.customClass,s.allowOutsideClick=void 0!==arguments[0].allowOutsideClick?arguments[0].allowOutsideClick:c.allowOutsideClick,s.allowEscapeKey=void 0!==arguments[0].allowEscapeKey?arguments[0].allowEscapeKey:c.allowEscapeKey,s.showConfirmButton=void 0!==arguments[0].showConfirmButton?arguments[0].showConfirmButton:c.showConfirmButton,s.showCancelButton=void 0!==arguments[0].showCancelButton?arguments[0].showCancelButton:c.showCancelButton,s.preConfirm=arguments[0].preConfirm||c.preConfirm,s.timer=parseInt(arguments[0].timer,10)||c.timer,s.width=parseInt(arguments[0].width,10)||c.width,s.padding=parseInt(arguments[0].padding,10)||c.padding,s.background=void 0!==arguments[0].background?arguments[0].background:c.background,s.confirmButtonText=arguments[0].confirmButtonText||c.confirmButtonText,s.confirmButtonColor=arguments[0].confirmButtonColor||c.confirmButtonColor,s.confirmButtonClass=arguments[0].confirmButtonClass||s.confirmButtonClass,s.cancelButtonText=arguments[0].cancelButtonText||c.cancelButtonText,s.cancelButtonColor=arguments[0].cancelButtonColor||c.cancelButtonColor,s.cancelButtonClass=arguments[0].cancelButtonClass||s.cancelButtonClass,s.buttonsStyling=void 0!==arguments[0].buttonsStyling?arguments[0].buttonsStyling:c.buttonsStyling,s.reverseButtons=void 0!==arguments[0].reverseButtons?arguments[0].reverseButtons:c.reverseButtons,s.showCloseButton=void 0!==arguments[0].showCloseButton?arguments[0].showCloseButton:c.showCloseButton,s.imageUrl=arguments[0].imageUrl||c.imageUrl,s.imageWidth=arguments[0].imageWidth||c.imageWidth,s.imageHeight=arguments[0].imageHeight||c.imageHeight,s.imageClass=arguments[0].imageClass||c.imageClass,s.input=arguments[0].input||c.input,s.inputPlaceholder=arguments[0].inputPlaceholder||c.inputPlaceholder,s.inputValue=arguments[0].inputValue||c.inputValue,s.inputOptions=arguments[0].inputOptions||c.inputOptions,s.inputAutoTrim=void 0!==arguments[0].inputAutoTrim?arguments[0].inputAutoTrim:c.inputAutoTrim,s.inputClass=arguments[0].inputClass||c.inputClass,s.inputAttributes=arguments[0].inputAttributes||c.inputAttributes,s.inputValidator=arguments[0].inputValidator||c.inputValidator,"email"===s.input&&null===s.inputValidator&&(s.inputValidator=function(e){return new Promise(function(t,s){var a=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;a.test(e)?t():s("Invalid email address")})});break;default:return e.console.error('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}q(s),M(),A();var a=u();return new Promise(function(l){function r(e,t){for(var s=0;s<q.length;s++)if(e+=t,e===q.length?e=0:-1===e&&(e=q.length-1),q[e].offsetWidth||q[e].offsetHeight||q[e].getClientRects().length)return void q[e].focus()}function c(t){var a=t||e.event,n=a.keyCode||a.which;if(-1!==[9,13,32,27].indexOf(n)){for(var o=a.target||a.srcElement,i=-1,c=0;c<q.length;c++)if(o===q[c]){i=c;break}9===n?(a.shiftKey?r(i,-1):r(i,1),S(a)):13===n||32===n?-1===i&&x(B,a):27===n&&s.allowEscapeKey===!0&&(e.swal.closeModal(),l(void 0))}}s.timer&&(a.timeout=setTimeout(function(){e.swal.closeModal(),l(void 0)},s.timer));var u=function(){switch(s.input){case"select":return a.querySelector("."+e.swalClasses.select);case"radio":return a.querySelector("."+e.swalClasses.radio+" input:checked")||a.querySelector("."+e.swalClasses.radio+" input:first-child");case"checkbox":return a.querySelector("#"+e.swalClasses.checkbox);case"textarea":return a.querySelector("."+e.swalClasses.textarea);default:return a.querySelector("."+e.swalClasses.input)}},C=function(){var e=u();switch(s.input){case"checkbox":return e.checked?1:0;case"radio":return e.checked?e.value:null;default:return s.inputAutoTrim?e.value.trim():e.value}};s.input&&setTimeout(function(){w(u())},0);var v,g=function(t){s.preConfirm?s.preConfirm().then(function(s){l(s||t),e.swal.closeModal()}):(l(t),e.swal.closeModal())},b=function(t){var n=t||e.event,o=n.target||n.srcElement,i=p(o,e.swalClasses.confirm),r=p(o,e.swalClasses.cancel),c=p(a,"visible");switch(n.type){case"mouseover":case"mouseup":case"focus":s.buttonsStyling&&(i?o.style.backgroundColor=T(s.confirmButtonColor,-.1):r&&(o.style.backgroundColor=T(s.cancelButtonColor,-.1)));break;case"mouseout":case"blur":s.buttonsStyling&&(i?o.style.backgroundColor=s.confirmButtonColor:r&&(o.style.backgroundColor=s.cancelButtonColor));break;case"mousedown":s.buttonsStyling&&(i?o.style.backgroundColor=T(s.confirmButtonColor,-.2):r&&(o.style.backgroundColor=T(s.cancelButtonColor,-.2)));break;case"click":if(i&&c)if(s.input){var u=C();s.inputValidator?s.inputValidator(u).then(function(){g(u)},function(t){e.swal.showValidationError(t)}):g(u)}else g(!0);else r&&c?(e.swal.closeModal(),l(!1)):e.swal.closeModal()}},k=a.querySelectorAll("button");for(v=0;v<k.length;v++)k[v].onclick=b,k[v].onmouseover=b,k[v].onmouseout=b,k[v].onmousedown=b;n=t.onclick,t.onclick=function(t){var a=t||e.event,n=a.target||a.srcElement;(p(n,e.swalClasses.close)||n===d()&&s.allowOutsideClick)&&(e.swal.closeModal(),l(void 0))};var B=a.querySelector("button."+e.swalClasses.confirm),E=a.querySelector("button."+e.swalClasses.cancel),q=[B,E].concat(Array.prototype.slice.call(a.querySelectorAll("button:not([class^="+e.swalPrefix+"]), input:not([type=hidden]), textarea, select")));for(v=0;v<q.length;v++)q[v].onfocus=b,q[v].onblur=b;s.reverseButtons&&B.parentNode.insertBefore(E,B),r(-1,1),o=e.onkeydown,e.onkeydown=c,s.buttonsStyling&&(B.style.borderLeftColor=s.confirmButtonColor,B.style.borderRightColor=s.confirmButtonColor),e.swal.enableLoading=function(){m(B,"loading"),m(a,"loading"),E.disabled=!0},e.swal.disableLoading=function(){f(B,"loading"),f(a,"loading"),E.disabled=!1},e.swal.enableButtons=function(){B.disabled=!1,E.disabled=!1},e.swal.disableButtons=function(){B.disabled=!0,E.disabled=!0},e.swal.showValidationError=function(t){var s=a.querySelector("."+e.swalClasses.validationerror);s.innerHTML=t,y(s);var l=u();w(l),m(l,"error")},e.swal.resetValidationError=function(){var t=a.querySelector("."+e.swalClasses.validationerror);h(t);var s=u();f(s,"error")},e.swal.enableButtons(),e.swal.disableLoading(),e.swal.resetValidationError(),e.onfocus=function(){e.setTimeout(function(){void 0!==i&&(i.focus(),i=void 0)},0)}})}e.swalPrefix="swal2-";var a=function(t){var s={};for(var a in t)s[t[a]]=e.swalPrefix+t[a];return s};e.swalClasses=a(["container","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","select","radio","checkbox","textarea","validationerror"]),e.swalClasses.iconTypes=a(["success","warning","info","question","error"]);var l,n,o,i,r=e.swalPrefix+"mediaquery",c={title:"",text:"",html:"",type:null,animation:!0,allowOutsideClick:!0,allowEscapeKey:!0,showConfirmButton:!0,showCancelButton:!1,preConfirm:null,confirmButtonText:"OK",confirmButtonColor:"#3085d6",confirmButtonClass:null,cancelButtonText:"Cancel",cancelButtonColor:"#aaa",cancelButtonClass:null,buttonsStyling:!0,reverseButtons:!1,showCloseButton:!1,imageUrl:null,imageWidth:null,imageHeight:null,imageClass:null,timer:null,width:500,padding:20,background:"#fff",input:null,inputPlaceholder:"",inputValue:"",inputOptions:{},inputAutoTrim:!0,inputClass:null,inputAttributes:{},inputValidator:null},u=function(){return t.querySelector("."+e.swalClasses.modal)},d=function(){return t.querySelector("."+e.swalClasses.overlay)},p=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},w=function(e){e.focus();var t=e.value;e.value="",e.value=t},m=function(e,t){t&&!p(e,t)&&(e.className+=" "+t)},f=function(e,t){var s=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(p(e,t)){for(;s.indexOf(" "+t+" ")>=0;)s=s.replace(" "+t+" "," ");e.className=s.replace(/^\s+|\s+$/g,"")}},C=function(e){e.style.opacity="",e.style.display="block"},y=function(e){if(e&&!e.length)return C(e);for(var t=0;t<e.length;++t)C(e[t])},v=function(e){e.style.opacity="",e.style.display="none"},h=function(e){if(e&&!e.length)return v(e);for(var t=0;t<e.length;++t)v(e[t])},g=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},b=function(e){e.style.left="-9999px",e.style.display="block";var t=e.clientHeight,s=parseInt(getComputedStyle(e).getPropertyValue("padding-top"),10);return e.style.left="",e.style.display="none","-"+parseInt(t/2+s,10)+"px"},k=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var s=+new Date,a=function(){e.style.opacity=+e.style.opacity+(new Date-s)/100,s=+new Date,+e.style.opacity<1&&setTimeout(a,t)};a()}},B=function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e},x=function(s){if("function"==typeof MouseEvent){var a=new MouseEvent("click",{view:e,bubbles:!1,cancelable:!0});s.dispatchEvent(a)}else if(t.createEvent){var l=t.createEvent("MouseEvents");l.initEvent("click",!1,!1),s.dispatchEvent(l)}else t.createEventObject?s.fireEvent("onclick"):"function"==typeof s.onclick&&s.onclick()},S=function(t){"function"==typeof t.stopPropagation?(t.stopPropagation(),t.preventDefault()):e.event&&e.event.hasOwnProperty("cancelBubble")&&(e.event.cancelBubble=!0)},E=function(){var s=u();e.onkeydown=o,t.onclick=n,l&&l.focus(),i=void 0,clearTimeout(s.timeout);var a=t.getElementsByTagName("head")[0],c=t.getElementById(r);c&&a.removeChild(c)},T=function(e,t){e=String(e).replace(/[^0-9a-f]/gi,""),e.length<6&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),t=t||0;for(var s="#",a=0;3>a;a++){var l=parseInt(e.substr(2*a,2),16);l=Math.round(Math.min(Math.max(0,l+l*t),255)).toString(16),s+=("00"+l).substr(l.length)}return s},q=function(s){var a,l=u();l.style.width=s.width+"px",l.style.padding=s.padding+"px",l.style.marginLeft=-s.width/2+"px",l.style.background=s.background;var n=t.getElementsByTagName("head")[0],o=t.createElement("style");o.type="text/css",o.id=r,o.innerHTML="@media screen and (max-width: "+s.width+"px) {."+e.swalClasses.modal+" {max-width: 100%;left: 0 !important;margin-left: 0 !important;}}",n.appendChild(o);var i=l.querySelector("h2"),c=l.querySelector("."+e.swalClasses.content),d=l.querySelector("button."+e.swalClasses.confirm),p=l.querySelector("button."+e.swalClasses.cancel),w=l.querySelector("."+e.swalClasses.spacer),b=l.querySelector("."+e.swalClasses.close);if(i.innerHTML=s.title.split("\n").join("<br>"),s.text||s.html){if("object"==typeof s.html)if(c.innerHTML="",0 in s.html)for(a=0;a in s.html;a++)c.appendChild(s.html[a]);else c.appendChild(s.html);else c.innerHTML=s.html||s.text.split("\n").join("<br>");y(c)}else h(c);if(s.showCloseButton?y(b):h(b),l.className=e.swalClasses.modal,s.customClass&&m(l,s.customClass),h(l.querySelectorAll("."+e.swalClasses.icon)),s.type){var k=!1;for(var B in e.swalClasses.iconTypes)if(s.type===B){k=!0;break}if(!k)return e.console.error("Unknown alert type: "+s.type),!1;var x=l.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes[s.type]);switch(y(x),s.type){case"success":m(x,"animate"),m(x.querySelector(".tip"),"animate-success-tip"),m(x.querySelector(".long"),"animate-success-long");break;case"error":m(x,"animate-error-icon"),m(x.querySelector(".x-mark"),"animate-x-mark");break;case"warning":m(x,"pulse-warning")}}var S=l.querySelector("."+e.swalClasses.image);s.imageUrl?(S.setAttribute("src",s.imageUrl),y(S),s.imageWidth&&S.setAttribute("width",s.imageWidth),s.imageHeight&&S.setAttribute("height",s.imageHeight),s.imageClass&&m(S,s.imageClass)):h(S);var E,T=["input","select","radio","checkbox","textarea"];for(a=0;a<T.length;a++){var q=e.swalClasses[T[a]];for(E=l.querySelector("."+q);E.attributes.length>0;)E.removeAttribute(E.attributes[0].name);for(var A in s.inputAttributes)E.setAttribute(A,s.inputAttributes[A]);E.className=q,s.inputClass&&m(E,s.inputClass),v(E)}switch(s.input){case"text":case"email":case"password":E=l.querySelector("."+e.swalClasses.input),E.value=s.inputValue,E.placeholder=s.inputPlaceholder,E.type=s.input,C(E);break;case"select":var M=l.querySelector("."+e.swalClasses.select);if(M.innerHTML="",s.inputPlaceholder){var L=t.createElement("option");L.innerHTML=s.inputPlaceholder,L.disabled=!0,L.selected=!0,M.appendChild(L)}for(var V in s.inputOptions){var P=t.createElement("option");P.value=V,P.innerHTML=s.inputOptions[V],s.inputValue===V&&(P.selected=!0),M.appendChild(P)}C(M);break;case"radio":var O=l.querySelector("."+e.swalClasses.radio);O.innerHTML="";for(var H in s.inputOptions){var N=1,I=t.createElement("input"),K=t.createElement("label"),U=t.createElement("span");I.type="radio",I.name=e.swalClasses.radio,I.value=H,I.id=e.swalClasses.radio+"-"+N++,s.inputValue===H&&(I.checked=!0),U.innerHTML=s.inputOptions[H],K.appendChild(I),K.appendChild(U),K["for"]=I.id,O.appendChild(K)}C(O);break;case"checkbox":var j=l.querySelector("."+e.swalClasses.checkbox),D=l.querySelector("#"+e.swalClasses.checkbox);D.value=1,D.checked=Boolean(s.inputValue);var W=j.getElementsByTagName("span");W.length&&j.removeChild(W[0]),W=t.createElement("span"),W.innerHTML=s.inputPlaceholder,j.appendChild(W),C(j);break;case"textarea":var R=l.querySelector("."+e.swalClasses.textarea);R.value=s.inputValue,R.placeholder=s.inputPlaceholder,C(R);break;case null:break;default:e.console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox" or "textarea", got '+typeof arguments[0])}s.showCancelButton?p.style.display="inline-block":h(p),s.showConfirmButton?g(d,"display"):h(d),s.showConfirmButton||s.showCancelButton?y(w):h(w),d.innerHTML=s.confirmButtonText,p.innerHTML=s.cancelButtonText,s.buttonsStyling&&(d.style.backgroundColor=s.confirmButtonColor,p.style.backgroundColor=s.cancelButtonColor),d.className=e.swalClasses.confirm,m(d,s.confirmButtonClass),p.className=e.swalClasses.cancel,m(p,s.cancelButtonClass),s.buttonsStyling?(m(d,"styled"),m(p,"styled")):(f(d,"styled"),f(p,"styled"),d.style.backgroundColor=d.style.borderLeftColor=d.style.borderRightColor="",p.style.backgroundColor=p.style.borderLeftColor=p.style.borderRightColor=""),s.animation===!0?f(l,"no-animation"):m(l,"no-animation")},A=function(){var e=u();k(d(),10),y(e),m(e,"show-swal2"),f(e,"hide-swal2"),l=t.activeElement,m(e,"visible")},M=function(){var e=u();e.style.marginTop=b(u())};e.sweetAlert=e.swal=function(){var t=arguments,a=u();return null===a&&(e.swal.init(),a=u()),p(a,"visible")&&E(),s.apply(this,t)},e.sweetAlert.close=e.swal.close=e.sweetAlert.closeModal=e.swal.closeModal=function(){var t=u();v(d()),v(t),f(t,"show-swal2"),m(t,"hide-swal2"),f(t,"visible");var s=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.success);f(s,"animate"),f(s.querySelector(".tip"),"animate-success-tip"),f(s.querySelector(".long"),"animate-success-long");var a=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.error);f(a,"animate-error-icon"),f(a.querySelector(".x-mark"),"animate-x-mark");var l=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.warning);f(l,"pulse-warning"),E()},e.sweetAlert.clickConfirm=e.swal.clickConfirm=function(){var t=u(),s=t.querySelector("button."+e.swalClasses.confirm);s.click()},e.sweetAlert.clickCancel=e.swal.clickCancel=function(){var t=u(),s=t.querySelector("button."+e.swalClasses.cancel);s.click()},e.swal.init=function(){if(!t.getElementsByClassName(e.swalClasses.container).length){var s='<div class="'+e.swalClasses.overlay+'" tabIndex="-1"></div><div class="'+e.swalClasses.modal+'" style="display: none" tabIndex="-1"><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.question+'">?</div><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.warning+'">!</div><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.info+'">i</div><div class="'+e.swalClasses.icon+" "+e.swalClasses.iconTypes.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+e.swalClasses.image+'"><h2></h2><div class="'+e.swalClasses.content+'"></div><input class="'+e.swalClasses.input+'"><select class="'+e.swalClasses.select+'"></select><fieldset class="'+e.swalClasses.radio+'"></fieldset><label for="'+e.swalClasses.checkbox+'" class="'+e.swalClasses.checkbox+'"><input type="checkbox" id="'+e.swalClasses.checkbox+'"></label><textarea class="'+e.swalClasses.textarea+'"></textarea><div class="'+e.swalClasses.validationerror+'"></div><hr class="'+e.swalClasses.spacer+'"><button class="'+e.swalClasses.confirm+'">OK</button><button class="'+e.swalClasses.cancel+'">Cancel</button><span class="'+e.swalClasses.close+'">&times;</span></div>',a=t.createElement("div");a.className=e.swalClasses.container,a.innerHTML=s,t.body.appendChild(a);var l=u(),n=l.querySelector("."+e.swalClasses.input),o=l.querySelector("."+e.swalClasses.select),i=l.querySelector("#"+e.swalClasses.checkbox),r=l.querySelector("."+e.swalClasses.textarea);n.oninput=function(){e.swal.resetValidationError()},n.onkeyup=function(t){13===t.keyCode&&e.swal.clickConfirm()},o.onchange=function(){e.swal.resetValidationError()},i.onchange=function(){e.swal.resetValidationError()},r.onchange=function(){e.swal.resetValidationError()}}},e.swal.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");B(c,e)},function(){"complete"===t.readyState||"interactive"===t.readyState&&t.body?e.swal.init():t.addEventListener?t.addEventListener("DOMContentLoaded",function s(){t.removeEventListener("DOMContentLoaded",s,!1),e.swal.init()},!1):t.attachEvent&&t.attachEvent("onreadystatechange",function a(){"complete"===t.readyState&&(t.detachEvent("onreadystatechange",a),e.swal.init())})}()}(window,document);
{
"name": "sweetalert2",
"version": "2.2.4",
"version": "2.2.5",
"repository": "git@github.com:limonte/sweetalert2.git",

@@ -5,0 +5,0 @@ "description": "A replacement for JavaScript's popup boxes, supported fork of sweetalert",

@@ -138,2 +138,3 @@ SweetAlert2 [![Build Status](https://travis-ci.org/limonte/sweetalert2.svg?branch=master)](https://travis-ci.org/limonte/sweetalert2)

| `inputOptions` | `{}` | If `input` parameter is set to `"select"`, you can provide options. Object keys will represent options values, object values will represent options text values. |
| `inputAutoTrim` | `true` | Automatically remove whitespaces from both ends of a result string. Set this parameter to `false` to disable auto-trimming. |
| `inputValidator` | `null` | Validator for input field, should return Promise, see <a href="https://limonte.github.io/sweetalert2/#select-box">usage example</a>. |

@@ -140,0 +141,0 @@ | `inputClass` | `null` | A custom CSS class for the input field. |

@@ -56,2 +56,3 @@ // SweetAlert2

inputOptions: {},
inputAutoTrim: true,
inputClass: null,

@@ -624,2 +625,3 @@ inputAttributes: {},

params.inputOptions = arguments[0].inputOptions || defaultParams.inputOptions;
params.inputAutoTrim = arguments[0].inputAutoTrim !== undefined ? arguments[0].inputAutoTrim : defaultParams.inputAutoTrim;
params.inputClass = arguments[0].inputClass || defaultParams.inputClass;

@@ -690,3 +692,3 @@ params.inputAttributes = arguments[0].inputAttributes || defaultParams.inputAttributes;

default:
return input.value;
return params.inputAutoTrim? input.value.trim() : input.value;
}

@@ -693,0 +695,0 @@ };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc