sweetalert2
Advanced tools
Comparing version 3.1.0 to 3.1.1
/*! | ||
* sweetalert2 v3.0.2 | ||
* (c) 2016 t4t5 & limonte | ||
* sweetalert2 v3.1.1 | ||
* (c) 2016 Tristan Edwards <tristan.edwards@me.com> (http://tristanedwards.me) | ||
* Released under the MIT License. | ||
@@ -1219,3 +1219,3 @@ */ | ||
sweetAlert.version = '3.0.2'; | ||
sweetAlert.version = '3.1.1'; | ||
@@ -1222,0 +1222,0 @@ window.sweetAlert = window.swal = sweetAlert; |
/*! | ||
* sweetalert2 v3.0.2 | ||
* (c) 2016 t4t5 & limonte | ||
* sweetalert2 v3.1.1 | ||
* (c) 2016 Tristan Edwards <tristan.edwards@me.com> (http://tristanedwards.me) | ||
* Released under the MIT License. | ||
@@ -1223,3 +1223,3 @@ */ | ||
sweetAlert.version = '3.0.2'; | ||
sweetAlert.version = '3.1.1'; | ||
@@ -1226,0 +1226,0 @@ window.sweetAlert = window.swal = sweetAlert; |
/*! | ||
* sweetalert2 v3.0.2 | ||
* (c) 2016 t4t5 & limonte | ||
* sweetalert2 v3.1.1 | ||
* (c) 2016 Tristan Edwards <tristan.edwards@me.com> (http://tristanedwards.me) | ||
* Released under the MIT License. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Sweetalert2=t()}(this,function(){"use strict";function e(){if(void 0===arguments[0])return console.error("sweetAlert2 expects at least 1 attribute!"),!1;var e=T({},u);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":e.title=arguments[0].title||u.title,e.text=arguments[0].text||u.text,e.html=arguments[0].html||u.html,e.type=arguments[0].type||u.type,e.animation=void 0!==arguments[0].animation?arguments[0].animation:u.animation,e.customClass=arguments[0].customClass||e.customClass,e.allowOutsideClick=void 0!==arguments[0].allowOutsideClick?arguments[0].allowOutsideClick:u.allowOutsideClick,e.allowEscapeKey=void 0!==arguments[0].allowEscapeKey?arguments[0].allowEscapeKey:u.allowEscapeKey,e.showConfirmButton=void 0!==arguments[0].showConfirmButton?arguments[0].showConfirmButton:u.showConfirmButton,e.showCancelButton=void 0!==arguments[0].showCancelButton?arguments[0].showCancelButton:u.showCancelButton,e.preConfirm=arguments[0].preConfirm||u.preConfirm,e.timer=parseInt(arguments[0].timer,10)||u.timer,e.width=parseInt(arguments[0].width,10)||u.width,e.padding=parseInt(arguments[0].padding,10)||u.padding,e.background=void 0!==arguments[0].background?arguments[0].background:u.background,e.confirmButtonText=arguments[0].confirmButtonText||u.confirmButtonText,e.confirmButtonColor=arguments[0].confirmButtonColor||u.confirmButtonColor,e.confirmButtonClass=arguments[0].confirmButtonClass||e.confirmButtonClass,e.cancelButtonText=arguments[0].cancelButtonText||u.cancelButtonText,e.cancelButtonColor=arguments[0].cancelButtonColor||u.cancelButtonColor,e.cancelButtonClass=arguments[0].cancelButtonClass||e.cancelButtonClass,e.buttonsStyling=void 0!==arguments[0].buttonsStyling?arguments[0].buttonsStyling:u.buttonsStyling,e.reverseButtons=void 0!==arguments[0].reverseButtons?arguments[0].reverseButtons:u.reverseButtons,e.showCloseButton=void 0!==arguments[0].showCloseButton?arguments[0].showCloseButton:u.showCloseButton,e.imageUrl=arguments[0].imageUrl||u.imageUrl,e.imageWidth=arguments[0].imageWidth||u.imageWidth,e.imageHeight=arguments[0].imageHeight||u.imageHeight,e.imageClass=arguments[0].imageClass||u.imageClass,e.input=arguments[0].input||u.input,e.inputPlaceholder=arguments[0].inputPlaceholder||u.inputPlaceholder,e.inputValue=arguments[0].inputValue||u.inputValue,e.inputOptions=arguments[0].inputOptions||u.inputOptions,e.inputAutoTrim=void 0!==arguments[0].inputAutoTrim?arguments[0].inputAutoTrim:u.inputAutoTrim,e.inputClass=arguments[0].inputClass||u.inputClass,e.inputAttributes=arguments[0].inputAttributes||u.inputAttributes,e.inputValidator=arguments[0].inputValidator||u.inputValidator,e.extraParams=arguments[0].extraParams,"email"===e.input&&null===e.inputValidator&&(e.inputValidator=function(e){return new Promise(function(t,n){var o=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;o.test(e)?t():n("Invalid email address")})});break;default:return console.error('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}V(e),H(),O();var o=p();return new Promise(function(l){function s(e,t){for(var n=0;n<T.length;n++)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 u(n){var o=n||window.event,i=o.keyCode||o.which;if(-1!==[9,13,32,27].indexOf(i)){for(var a=o.target||o.srcElement,r=-1,c=0;c<T.length;c++)if(a===T[c]){r=c;break}9===i?(o.shiftKey?s(r,-1):s(r,1),A(o)):13===i||32===i?-1===r&&q(E,o):27===i&&e.allowEscapeKey===!0&&(t.closeModal(),l(void 0))}}e.timer&&(o.timeout=setTimeout(function(){t.closeModal(),l(void 0)},e.timer));var d=function(){switch(e.input){case"select":return b(o,i.select);case"radio":return o.querySelector("."+i.radio+" input:checked")||o.querySelector("."+i.radio+" input:first-child");case"checkbox":return o.querySelector("#"+i.checkbox);case"textarea":return b(o,i.textarea);default:return b(o,i.input)}},p=function(){var t=d();switch(e.input){case"checkbox":return t.checked?1:0;case"radio":return t.checked?t.value:null;default:return e.inputAutoTrim?t.value.trim():t.value}};e.input&&setTimeout(function(){y(d())},0);var g,C=function(n){e.preConfirm?e.preConfirm(n,e.extraParams).then(function(e){l(e||n),t.closeModal()}):(l(n),t.closeModal())},x=function(n){var a=n||window.event,r=a.target||a.srcElement,c=f(r,i.confirm),s=f(r,i.cancel),u=f(o,"visible");switch(a.type){case"mouseover":case"mouseup":case"focus":e.buttonsStyling&&(c?r.style.backgroundColor=P(e.confirmButtonColor,-.1):s&&(r.style.backgroundColor=P(e.cancelButtonColor,-.1)));break;case"mouseout":case"blur":e.buttonsStyling&&(c?r.style.backgroundColor=e.confirmButtonColor:s&&(r.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(c?r.style.backgroundColor=P(e.confirmButtonColor,-.2):s&&(r.style.backgroundColor=P(e.cancelButtonColor,-.2)));break;case"click":if(c&&u)if(e.input){var d=p();e.inputValidator?(t.disableInput(),e.inputValidator(d,e.extraParams).then(function(){t.enableInput(),C(d)},function(e){t.enableInput(),t.showValidationError(e)})):C(d)}else C(!0);else s&&u&&(t.closeModal(),l(!1))}},B=o.querySelectorAll("button");for(g=0;g<B.length;g++)B[g].onclick=x,B[g].onmouseover=x,B[g].onmouseout=x,B[g].onmousedown=x;a=document.onclick,document.onclick=function(n){var o=n||window.event,a=o.target||o.srcElement;(f(a,i.close)||a===m()&&e.allowOutsideClick)&&(t.closeModal(),l(void 0))};var E=o.querySelector("button."+i.confirm),S=o.querySelector("button."+i.cancel),T=[E,S].concat(Array.prototype.slice.call(o.querySelectorAll("button:not([class^="+n+"]), input:not([type=hidden]), textarea, select")));for(g=0;g<T.length;g++)T[g].onfocus=x,T[g].onblur=x;e.reverseButtons&&E.parentNode.insertBefore(S,E),s(-1,1),r=window.onkeydown,window.onkeydown=u,e.buttonsStyling&&(E.style.borderLeftColor=e.confirmButtonColor,E.style.borderRightColor=e.confirmButtonColor),t.enableLoading=function(){v(E,"loading"),v(o,"loading"),S.disabled=!0},t.disableLoading=function(){h(E,"loading"),h(o,"loading"),S.disabled=!1},t.enableButtons=function(){E.disabled=!1,S.disabled=!1},t.disableButtons=function(){E.disabled=!0,S.disabled=!0},t.enableInput=function(){var e=d();if("radio"===e.type)for(var t=e.parentNode.parentNode,n=t.querySelectorAll("input"),o=0;o<n.length;o++)n[o].disabled=!1;else e.disabled=!1},t.disableInput=function(){var e=d();if("radio"===e.type)for(var t=e.parentNode.parentNode,n=t.querySelectorAll("input"),o=0;o<n.length;o++)n[o].disabled=!0;else e.disabled=!0},t.showValidationError=function(e){var t=o.querySelector("."+i.validationerror);t.innerHTML=e,w(t);var n=d();y(n),v(n,"error")},t.resetValidationError=function(){var e=o.querySelector("."+i.validationerror);k(e);var t=d();h(t,"error")},t.enableButtons(),t.disableLoading(),t.resetValidationError(),window.onfocus=function(){window.setTimeout(function(){void 0!==c&&(c.focus(),c=void 0)},0)}})}function t(){var n=arguments,o=p();return null===o&&(t.init(),o=p()),f(o,"visible")&&L(),e.apply(this,n)}var n="swal2-",o=function(e){var t={};for(var o in e)t[e[o]]=n+e[o];return t},i=o(["container","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","select","radio","checkbox","textarea","validationerror"]);i.iconTypes=o(["success","warning","info","question","error"]);var a,r,l,c,s=n+"mediaquery",u={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},d=function(e){return document.querySelector("."+e)},p=function(){return d(i.modal)},m=function(){return d(i.overlay)},f=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},y=function(e){e.focus();var t=e.value;e.value="",e.value=t},v=function(e,t){t&&!f(e,t)&&(e.className+=" "+t)},h=function(e,t){var n=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(f(e,t)){for(;n.indexOf(" "+t+" ")>=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},b=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(e.childNodes[n].classList.contains(t))return e.childNodes[n]},g=function(e){e.style.opacity="",e.style.display="block"},w=function(e){if(e&&!e.length)return g(e);for(var t=0;t<e.length;++t)g(e[t])},C=function(e){e.style.opacity="",e.style.display="none"},k=function(e){if(e&&!e.length)return C(e);for(var t=0;t<e.length;++t)C(e[t])},x=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,n=parseInt(getComputedStyle(e).getPropertyValue("padding-top"),10);return e.style.left="",e.style.display="none","-"+parseInt(t/2+n,10)+"px"},E=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var n=+new Date,o=function(){var i=+e.style.opacity+(new Date-n)/100;e.style.opacity=i>1?1:i,n=+new Date,+e.style.opacity<1&&setTimeout(o,t)};o()}},S=function(e,t){if(+e.style.opacity>0){t=t||16;var n=e.style.opacity,o=+new Date,i=function(){var a=new Date-o,r=+e.style.opacity-a/(100*n);e.style.opacity=r,o=+new Date,+e.style.opacity>0?setTimeout(i,t):C(e)};i()}},T=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},q=function(e){if("function"==typeof MouseEvent){var t=new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0});e.dispatchEvent(t)}else if(document.createEvent){var n=document.createEvent("MouseEvents");n.initEvent("click",!1,!1),e.dispatchEvent(n)}else document.createEventObject?e.fireEvent("onclick"):"function"==typeof e.onclick&&e.onclick()},A=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},M=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd oanimationend",msAnimation:"MSAnimationEnd",animation:"animationend"};for(var n in t)if(t.hasOwnProperty(n)&&void 0!==e.style[n])return t[n];return!1}(),L=function(){var e=p();window.onkeydown=r,document.onclick=a,l&&l.focus(),c=void 0,clearTimeout(e.timeout);var t=document.getElementsByTagName("head")[0],n=document.getElementById(s);n&&t.removeChild(n)},P=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 n="#",o=0;3>o;o++){var i=parseInt(e.substr(2*o,2),16);i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),n+=("00"+i).substr(i.length)}return n},V=function(e){var t,n=p();n.style.width=e.width+"px",n.style.padding=e.padding+"px",n.style.marginLeft=-e.width/2+"px",n.style.background=e.background;var o=document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",a.id=s;var r=5,l=e.width+parseInt(e.width*(r/100)*2,10);a.innerHTML="@media screen and (max-width: "+l+"px) {."+i.modal+" {width: auto !important;left: "+r+"% !important;right: "+r+"% !important;margin-left: 0 !important;}}",o.appendChild(a);var c=n.querySelector("h2"),u=n.querySelector("."+i.content),d=n.querySelector("button."+i.confirm),m=n.querySelector("button."+i.cancel),f=n.querySelector("."+i.spacer),y=n.querySelector("."+i.close);if(c.innerHTML=e.title.split("\n").join("<br>"),e.text||e.html){if("object"==typeof e.html)if(u.innerHTML="",0 in e.html)for(t=0;t in e.html;t++)u.appendChild(e.html[t]);else u.appendChild(e.html);else u.innerHTML=e.html||e.text.split("\n").join("<br>");w(u)}else k(u);if(e.showCloseButton?w(y):k(y),n.className=i.modal,e.customClass&&v(n,e.customClass),k(n.querySelectorAll("."+i.icon)),e.type){var B=!1;for(var E in i.iconTypes)if(e.type===E){B=!0;break}if(!B)return console.error("Unknown alert type: "+e.type),!1;var S=n.querySelector("."+i.icon+"."+i.iconTypes[e.type]);switch(w(S),e.type){case"success":v(S,"animate"),v(S.querySelector(".tip"),"animate-success-tip"),v(S.querySelector(".long"),"animate-success-long");break;case"error":v(S,"animate-error-icon"),v(S.querySelector(".x-mark"),"animate-x-mark");break;case"warning":v(S,"pulse-warning")}}var T=n.querySelector("."+i.image);e.imageUrl?(T.setAttribute("src",e.imageUrl),w(T),e.imageWidth&&T.setAttribute("width",e.imageWidth),e.imageHeight&&T.setAttribute("height",e.imageHeight),e.imageClass&&v(T,e.imageClass)):k(T);var q,A=["input","select","radio","checkbox","textarea"];for(t=0;t<A.length;t++){var M=i[A[t]];for(q=b(n,M);q.attributes.length>0;)q.removeAttribute(q.attributes[0].name);for(var L in e.inputAttributes)q.setAttribute(L,e.inputAttributes[L]);q.className=M,e.inputClass&&v(q,e.inputClass),C(q)}switch(e.input){case"text":case"email":case"password":q=b(n,i.input),q.value=e.inputValue,q.placeholder=e.inputPlaceholder,q.type=e.input,g(q);break;case"select":var P=b(n,i.select);if(P.innerHTML="",e.inputPlaceholder){var V=document.createElement("option");V.innerHTML=e.inputPlaceholder,V.value="",V.disabled=!0,V.selected=!0,P.appendChild(V)}for(var O in e.inputOptions){var H=document.createElement("option");H.value=O,H.innerHTML=e.inputOptions[O],e.inputValue===O&&(H.selected=!0),P.appendChild(H)}g(P);break;case"radio":var N=b(n,i.radio);N.innerHTML="";for(var I in e.inputOptions){var D=1,j=document.createElement("input"),K=document.createElement("label"),U=document.createElement("span");j.type="radio",j.name=i.radio,j.value=I,j.id=i.radio+"-"+D++,e.inputValue===I&&(j.checked=!0),U.innerHTML=e.inputOptions[I],K.appendChild(j),K.appendChild(U),K["for"]=j.id,N.appendChild(K)}g(N);break;case"checkbox":var W=b(n,i.checkbox),z=n.querySelector("#"+i.checkbox);z.value=1,z.checked=Boolean(e.inputValue);var R=W.getElementsByTagName("span");R.length&&W.removeChild(R[0]),R=document.createElement("span"),R.innerHTML=e.inputPlaceholder,W.appendChild(R),g(W);break;case"textarea":var Z=b(n,i.textarea);Z.value=e.inputValue,Z.placeholder=e.inputPlaceholder,g(Z);break;case null:break;default:console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox" or "textarea", got '+typeof arguments[0])}e.showCancelButton?m.style.display="inline-block":k(m),e.showConfirmButton?x(d,"display"):k(d),e.showConfirmButton||e.showCancelButton?w(f):k(f),d.innerHTML=e.confirmButtonText,m.innerHTML=e.cancelButtonText,e.buttonsStyling&&(d.style.backgroundColor=e.confirmButtonColor,m.style.backgroundColor=e.cancelButtonColor),d.className=i.confirm,v(d,e.confirmButtonClass),m.className=i.cancel,v(m,e.cancelButtonClass),e.buttonsStyling?(v(d,"styled"),v(m,"styled")):(h(d,"styled"),h(m,"styled"),d.style.backgroundColor=d.style.borderLeftColor=d.style.borderRightColor="",m.style.backgroundColor=m.style.borderLeftColor=m.style.borderRightColor=""),e.animation===!0?h(n,"no-animation"):v(n,"no-animation")},O=function(){var e=p();E(m(),10),w(e),v(e,"show-swal2"),h(e,"hide-swal2"),l=document.activeElement,v(e,"visible")},H=function(){var e=p();e.style.marginTop=B(p())};return t.close=t.closeModal=function(){var e=p();h(e,"show-swal2"),v(e,"hide-swal2"),h(e,"visible");var t=e.querySelector("."+i.icon+"."+i.iconTypes.success);h(t,"animate"),h(t.querySelector(".tip"),"animate-success-tip"),h(t.querySelector(".long"),"animate-success-long");var n=e.querySelector("."+i.icon+"."+i.iconTypes.error);h(n,"animate-error-icon"),h(n.querySelector(".x-mark"),"animate-x-mark");var o=e.querySelector("."+i.icon+"."+i.iconTypes.warning);h(o,"pulse-warning"),L(),M&&!f(e,"no-animation")?e.addEventListener(M,function a(){e.removeEventListener(M,a),f(e,"hide-swal2")&&(C(e),S(m(),0))}):(C(e),S(m(),0))},t.clickConfirm=function(){var e=p(),t=e.querySelector("button."+i.confirm);t.click()},t.clickCancel=function(){var e=p(),t=e.querySelector("button."+i.cancel);t.click()},t.init=function(){if("undefined"==typeof document)return void console.log("SweetAlert2 requires document to initialize");if(!document.getElementsByClassName(i.container).length){var e='<div class="'+i.overlay+'" tabIndex="-1"></div><div class="'+i.modal+'" style="display: none" tabIndex="-1"><div class="'+i.icon+" "+i.iconTypes.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+i.icon+" "+i.iconTypes.question+'">?</div><div class="'+i.icon+" "+i.iconTypes.warning+'">!</div><div class="'+i.icon+" "+i.iconTypes.info+'">i</div><div class="'+i.icon+" "+i.iconTypes.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+i.image+'"><h2></h2><div class="'+i.content+'"></div><input class="'+i.input+'"><select class="'+i.select+'"></select><div class="'+i.radio+'"></div><label for="'+i.checkbox+'" class="'+i.checkbox+'"><input type="checkbox" id="'+i.checkbox+'"></label><textarea class="'+i.textarea+'"></textarea><div class="'+i.validationerror+'"></div><hr class="'+i.spacer+'"><button class="'+i.confirm+'">OK</button><button class="'+i.cancel+'">Cancel</button><span class="'+i.close+'">×</span></div>',n=document.createElement("div");n.className=i.container,n.innerHTML=e,document.body.appendChild(n);var o=p(),a=b(o,i.input),r=b(o,i.select),l=o.querySelector("#"+i.checkbox),c=b(o,i.textarea);a.oninput=function(){t.resetValidationError()},a.onkeyup=function(e){e.stopPropagation(),13===e.keyCode&&t.clickConfirm()},r.onchange=function(){t.resetValidationError()},l.onchange=function(){t.resetValidationError()},c.onchange=function(){t.resetValidationError()}}},t.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");T(u,e)},t.version="3.0.2",window.sweetAlert=window.swal=t,function(){"complete"===document.readyState||"interactive"===document.readyState&&document.body?t.init():document.addEventListener("DOMContentLoaded",function e(){document.removeEventListener("DOMContentLoaded",e,!1),t.init()},!1)}(),t}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Sweetalert2=t()}(this,function(){"use strict";function e(){if(void 0===arguments[0])return console.error("sweetAlert2 expects at least 1 attribute!"),!1;var e=T({},u);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":e.title=arguments[0].title||u.title,e.text=arguments[0].text||u.text,e.html=arguments[0].html||u.html,e.type=arguments[0].type||u.type,e.animation=void 0!==arguments[0].animation?arguments[0].animation:u.animation,e.customClass=arguments[0].customClass||e.customClass,e.allowOutsideClick=void 0!==arguments[0].allowOutsideClick?arguments[0].allowOutsideClick:u.allowOutsideClick,e.allowEscapeKey=void 0!==arguments[0].allowEscapeKey?arguments[0].allowEscapeKey:u.allowEscapeKey,e.showConfirmButton=void 0!==arguments[0].showConfirmButton?arguments[0].showConfirmButton:u.showConfirmButton,e.showCancelButton=void 0!==arguments[0].showCancelButton?arguments[0].showCancelButton:u.showCancelButton,e.preConfirm=arguments[0].preConfirm||u.preConfirm,e.timer=parseInt(arguments[0].timer,10)||u.timer,e.width=parseInt(arguments[0].width,10)||u.width,e.padding=parseInt(arguments[0].padding,10)||u.padding,e.background=void 0!==arguments[0].background?arguments[0].background:u.background,e.confirmButtonText=arguments[0].confirmButtonText||u.confirmButtonText,e.confirmButtonColor=arguments[0].confirmButtonColor||u.confirmButtonColor,e.confirmButtonClass=arguments[0].confirmButtonClass||e.confirmButtonClass,e.cancelButtonText=arguments[0].cancelButtonText||u.cancelButtonText,e.cancelButtonColor=arguments[0].cancelButtonColor||u.cancelButtonColor,e.cancelButtonClass=arguments[0].cancelButtonClass||e.cancelButtonClass,e.buttonsStyling=void 0!==arguments[0].buttonsStyling?arguments[0].buttonsStyling:u.buttonsStyling,e.reverseButtons=void 0!==arguments[0].reverseButtons?arguments[0].reverseButtons:u.reverseButtons,e.showCloseButton=void 0!==arguments[0].showCloseButton?arguments[0].showCloseButton:u.showCloseButton,e.imageUrl=arguments[0].imageUrl||u.imageUrl,e.imageWidth=arguments[0].imageWidth||u.imageWidth,e.imageHeight=arguments[0].imageHeight||u.imageHeight,e.imageClass=arguments[0].imageClass||u.imageClass,e.input=arguments[0].input||u.input,e.inputPlaceholder=arguments[0].inputPlaceholder||u.inputPlaceholder,e.inputValue=arguments[0].inputValue||u.inputValue,e.inputOptions=arguments[0].inputOptions||u.inputOptions,e.inputAutoTrim=void 0!==arguments[0].inputAutoTrim?arguments[0].inputAutoTrim:u.inputAutoTrim,e.inputClass=arguments[0].inputClass||u.inputClass,e.inputAttributes=arguments[0].inputAttributes||u.inputAttributes,e.inputValidator=arguments[0].inputValidator||u.inputValidator,e.extraParams=arguments[0].extraParams,"email"===e.input&&null===e.inputValidator&&(e.inputValidator=function(e){return new Promise(function(t,n){var o=/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;o.test(e)?t():n("Invalid email address")})});break;default:return console.error('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}V(e),H(),O();var o=p();return new Promise(function(l){function s(e,t){for(var n=0;n<T.length;n++)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 u(n){var o=n||window.event,i=o.keyCode||o.which;if(-1!==[9,13,32,27].indexOf(i)){for(var a=o.target||o.srcElement,r=-1,c=0;c<T.length;c++)if(a===T[c]){r=c;break}9===i?(o.shiftKey?s(r,-1):s(r,1),A(o)):13===i||32===i?-1===r&&q(E,o):27===i&&e.allowEscapeKey===!0&&(t.closeModal(),l(void 0))}}e.timer&&(o.timeout=setTimeout(function(){t.closeModal(),l(void 0)},e.timer));var d=function(){switch(e.input){case"select":return b(o,i.select);case"radio":return o.querySelector("."+i.radio+" input:checked")||o.querySelector("."+i.radio+" input:first-child");case"checkbox":return o.querySelector("#"+i.checkbox);case"textarea":return b(o,i.textarea);default:return b(o,i.input)}},p=function(){var t=d();switch(e.input){case"checkbox":return t.checked?1:0;case"radio":return t.checked?t.value:null;default:return e.inputAutoTrim?t.value.trim():t.value}};e.input&&setTimeout(function(){y(d())},0);var g,C=function(n){e.preConfirm?e.preConfirm(n,e.extraParams).then(function(e){l(e||n),t.closeModal()}):(l(n),t.closeModal())},x=function(n){var a=n||window.event,r=a.target||a.srcElement,c=f(r,i.confirm),s=f(r,i.cancel),u=f(o,"visible");switch(a.type){case"mouseover":case"mouseup":case"focus":e.buttonsStyling&&(c?r.style.backgroundColor=P(e.confirmButtonColor,-.1):s&&(r.style.backgroundColor=P(e.cancelButtonColor,-.1)));break;case"mouseout":case"blur":e.buttonsStyling&&(c?r.style.backgroundColor=e.confirmButtonColor:s&&(r.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(c?r.style.backgroundColor=P(e.confirmButtonColor,-.2):s&&(r.style.backgroundColor=P(e.cancelButtonColor,-.2)));break;case"click":if(c&&u)if(e.input){var d=p();e.inputValidator?(t.disableInput(),e.inputValidator(d,e.extraParams).then(function(){t.enableInput(),C(d)},function(e){t.enableInput(),t.showValidationError(e)})):C(d)}else C(!0);else s&&u&&(t.closeModal(),l(!1))}},B=o.querySelectorAll("button");for(g=0;g<B.length;g++)B[g].onclick=x,B[g].onmouseover=x,B[g].onmouseout=x,B[g].onmousedown=x;a=document.onclick,document.onclick=function(n){var o=n||window.event,a=o.target||o.srcElement;(f(a,i.close)||a===m()&&e.allowOutsideClick)&&(t.closeModal(),l(void 0))};var E=o.querySelector("button."+i.confirm),S=o.querySelector("button."+i.cancel),T=[E,S].concat(Array.prototype.slice.call(o.querySelectorAll("button:not([class^="+n+"]), input:not([type=hidden]), textarea, select")));for(g=0;g<T.length;g++)T[g].onfocus=x,T[g].onblur=x;e.reverseButtons&&E.parentNode.insertBefore(S,E),s(-1,1),r=window.onkeydown,window.onkeydown=u,e.buttonsStyling&&(E.style.borderLeftColor=e.confirmButtonColor,E.style.borderRightColor=e.confirmButtonColor),t.enableLoading=function(){v(E,"loading"),v(o,"loading"),S.disabled=!0},t.disableLoading=function(){h(E,"loading"),h(o,"loading"),S.disabled=!1},t.enableButtons=function(){E.disabled=!1,S.disabled=!1},t.disableButtons=function(){E.disabled=!0,S.disabled=!0},t.enableInput=function(){var e=d();if("radio"===e.type)for(var t=e.parentNode.parentNode,n=t.querySelectorAll("input"),o=0;o<n.length;o++)n[o].disabled=!1;else e.disabled=!1},t.disableInput=function(){var e=d();if("radio"===e.type)for(var t=e.parentNode.parentNode,n=t.querySelectorAll("input"),o=0;o<n.length;o++)n[o].disabled=!0;else e.disabled=!0},t.showValidationError=function(e){var t=o.querySelector("."+i.validationerror);t.innerHTML=e,w(t);var n=d();y(n),v(n,"error")},t.resetValidationError=function(){var e=o.querySelector("."+i.validationerror);k(e);var t=d();h(t,"error")},t.enableButtons(),t.disableLoading(),t.resetValidationError(),window.onfocus=function(){window.setTimeout(function(){void 0!==c&&(c.focus(),c=void 0)},0)}})}function t(){var n=arguments,o=p();return null===o&&(t.init(),o=p()),f(o,"visible")&&L(),e.apply(this,n)}var n="swal2-",o=function(e){var t={};for(var o in e)t[e[o]]=n+e[o];return t},i=o(["container","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","select","radio","checkbox","textarea","validationerror"]);i.iconTypes=o(["success","warning","info","question","error"]);var a,r,l,c,s=n+"mediaquery",u={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},d=function(e){return document.querySelector("."+e)},p=function(){return d(i.modal)},m=function(){return d(i.overlay)},f=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},y=function(e){e.focus();var t=e.value;e.value="",e.value=t},v=function(e,t){t&&!f(e,t)&&(e.className+=" "+t)},h=function(e,t){var n=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(f(e,t)){for(;n.indexOf(" "+t+" ")>=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},b=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(e.childNodes[n].classList.contains(t))return e.childNodes[n]},g=function(e){e.style.opacity="",e.style.display="block"},w=function(e){if(e&&!e.length)return g(e);for(var t=0;t<e.length;++t)g(e[t])},C=function(e){e.style.opacity="",e.style.display="none"},k=function(e){if(e&&!e.length)return C(e);for(var t=0;t<e.length;++t)C(e[t])},x=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,n=parseInt(getComputedStyle(e).getPropertyValue("padding-top"),10);return e.style.left="",e.style.display="none","-"+parseInt(t/2+n,10)+"px"},E=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var n=+new Date,o=function(){var i=+e.style.opacity+(new Date-n)/100;e.style.opacity=i>1?1:i,n=+new Date,+e.style.opacity<1&&setTimeout(o,t)};o()}},S=function(e,t){if(+e.style.opacity>0){t=t||16;var n=e.style.opacity,o=+new Date,i=function(){var a=new Date-o,r=+e.style.opacity-a/(100*n);e.style.opacity=r,o=+new Date,+e.style.opacity>0?setTimeout(i,t):C(e)};i()}},T=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},q=function(e){if("function"==typeof MouseEvent){var t=new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0});e.dispatchEvent(t)}else if(document.createEvent){var n=document.createEvent("MouseEvents");n.initEvent("click",!1,!1),e.dispatchEvent(n)}else document.createEventObject?e.fireEvent("onclick"):"function"==typeof e.onclick&&e.onclick()},A=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},M=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd oanimationend",msAnimation:"MSAnimationEnd",animation:"animationend"};for(var n in t)if(t.hasOwnProperty(n)&&void 0!==e.style[n])return t[n];return!1}(),L=function(){var e=p();window.onkeydown=r,document.onclick=a,l&&l.focus(),c=void 0,clearTimeout(e.timeout);var t=document.getElementsByTagName("head")[0],n=document.getElementById(s);n&&t.removeChild(n)},P=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 n="#",o=0;3>o;o++){var i=parseInt(e.substr(2*o,2),16);i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),n+=("00"+i).substr(i.length)}return n},V=function(e){var t,n=p();n.style.width=e.width+"px",n.style.padding=e.padding+"px",n.style.marginLeft=-e.width/2+"px",n.style.background=e.background;var o=document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",a.id=s;var r=5,l=e.width+parseInt(e.width*(r/100)*2,10);a.innerHTML="@media screen and (max-width: "+l+"px) {."+i.modal+" {width: auto !important;left: "+r+"% !important;right: "+r+"% !important;margin-left: 0 !important;}}",o.appendChild(a);var c=n.querySelector("h2"),u=n.querySelector("."+i.content),d=n.querySelector("button."+i.confirm),m=n.querySelector("button."+i.cancel),f=n.querySelector("."+i.spacer),y=n.querySelector("."+i.close);if(c.innerHTML=e.title.split("\n").join("<br>"),e.text||e.html){if("object"==typeof e.html)if(u.innerHTML="",0 in e.html)for(t=0;t in e.html;t++)u.appendChild(e.html[t]);else u.appendChild(e.html);else u.innerHTML=e.html||e.text.split("\n").join("<br>");w(u)}else k(u);if(e.showCloseButton?w(y):k(y),n.className=i.modal,e.customClass&&v(n,e.customClass),k(n.querySelectorAll("."+i.icon)),e.type){var B=!1;for(var E in i.iconTypes)if(e.type===E){B=!0;break}if(!B)return console.error("Unknown alert type: "+e.type),!1;var S=n.querySelector("."+i.icon+"."+i.iconTypes[e.type]);switch(w(S),e.type){case"success":v(S,"animate"),v(S.querySelector(".tip"),"animate-success-tip"),v(S.querySelector(".long"),"animate-success-long");break;case"error":v(S,"animate-error-icon"),v(S.querySelector(".x-mark"),"animate-x-mark");break;case"warning":v(S,"pulse-warning")}}var T=n.querySelector("."+i.image);e.imageUrl?(T.setAttribute("src",e.imageUrl),w(T),e.imageWidth&&T.setAttribute("width",e.imageWidth),e.imageHeight&&T.setAttribute("height",e.imageHeight),e.imageClass&&v(T,e.imageClass)):k(T);var q,A=["input","select","radio","checkbox","textarea"];for(t=0;t<A.length;t++){var M=i[A[t]];for(q=b(n,M);q.attributes.length>0;)q.removeAttribute(q.attributes[0].name);for(var L in e.inputAttributes)q.setAttribute(L,e.inputAttributes[L]);q.className=M,e.inputClass&&v(q,e.inputClass),C(q)}switch(e.input){case"text":case"email":case"password":q=b(n,i.input),q.value=e.inputValue,q.placeholder=e.inputPlaceholder,q.type=e.input,g(q);break;case"select":var P=b(n,i.select);if(P.innerHTML="",e.inputPlaceholder){var V=document.createElement("option");V.innerHTML=e.inputPlaceholder,V.value="",V.disabled=!0,V.selected=!0,P.appendChild(V)}for(var O in e.inputOptions){var H=document.createElement("option");H.value=O,H.innerHTML=e.inputOptions[O],e.inputValue===O&&(H.selected=!0),P.appendChild(H)}g(P);break;case"radio":var N=b(n,i.radio);N.innerHTML="";for(var I in e.inputOptions){var D=1,j=document.createElement("input"),K=document.createElement("label"),U=document.createElement("span");j.type="radio",j.name=i.radio,j.value=I,j.id=i.radio+"-"+D++,e.inputValue===I&&(j.checked=!0),U.innerHTML=e.inputOptions[I],K.appendChild(j),K.appendChild(U),K["for"]=j.id,N.appendChild(K)}g(N);break;case"checkbox":var W=b(n,i.checkbox),z=n.querySelector("#"+i.checkbox);z.value=1,z.checked=Boolean(e.inputValue);var R=W.getElementsByTagName("span");R.length&&W.removeChild(R[0]),R=document.createElement("span"),R.innerHTML=e.inputPlaceholder,W.appendChild(R),g(W);break;case"textarea":var Z=b(n,i.textarea);Z.value=e.inputValue,Z.placeholder=e.inputPlaceholder,g(Z);break;case null:break;default:console.error('Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox" or "textarea", got '+typeof arguments[0])}e.showCancelButton?m.style.display="inline-block":k(m),e.showConfirmButton?x(d,"display"):k(d),e.showConfirmButton||e.showCancelButton?w(f):k(f),d.innerHTML=e.confirmButtonText,m.innerHTML=e.cancelButtonText,e.buttonsStyling&&(d.style.backgroundColor=e.confirmButtonColor,m.style.backgroundColor=e.cancelButtonColor),d.className=i.confirm,v(d,e.confirmButtonClass),m.className=i.cancel,v(m,e.cancelButtonClass),e.buttonsStyling?(v(d,"styled"),v(m,"styled")):(h(d,"styled"),h(m,"styled"),d.style.backgroundColor=d.style.borderLeftColor=d.style.borderRightColor="",m.style.backgroundColor=m.style.borderLeftColor=m.style.borderRightColor=""),e.animation===!0?h(n,"no-animation"):v(n,"no-animation")},O=function(){var e=p();E(m(),10),w(e),v(e,"show-swal2"),h(e,"hide-swal2"),l=document.activeElement,v(e,"visible")},H=function(){var e=p();e.style.marginTop=B(p())};return t.close=t.closeModal=function(){var e=p();h(e,"show-swal2"),v(e,"hide-swal2"),h(e,"visible");var t=e.querySelector("."+i.icon+"."+i.iconTypes.success);h(t,"animate"),h(t.querySelector(".tip"),"animate-success-tip"),h(t.querySelector(".long"),"animate-success-long");var n=e.querySelector("."+i.icon+"."+i.iconTypes.error);h(n,"animate-error-icon"),h(n.querySelector(".x-mark"),"animate-x-mark");var o=e.querySelector("."+i.icon+"."+i.iconTypes.warning);h(o,"pulse-warning"),L(),M&&!f(e,"no-animation")?e.addEventListener(M,function a(){e.removeEventListener(M,a),f(e,"hide-swal2")&&(C(e),S(m(),0))}):(C(e),S(m(),0))},t.clickConfirm=function(){var e=p(),t=e.querySelector("button."+i.confirm);t.click()},t.clickCancel=function(){var e=p(),t=e.querySelector("button."+i.cancel);t.click()},t.init=function(){if("undefined"==typeof document)return void console.log("SweetAlert2 requires document to initialize");if(!document.getElementsByClassName(i.container).length){var e='<div class="'+i.overlay+'" tabIndex="-1"></div><div class="'+i.modal+'" style="display: none" tabIndex="-1"><div class="'+i.icon+" "+i.iconTypes.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+i.icon+" "+i.iconTypes.question+'">?</div><div class="'+i.icon+" "+i.iconTypes.warning+'">!</div><div class="'+i.icon+" "+i.iconTypes.info+'">i</div><div class="'+i.icon+" "+i.iconTypes.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+i.image+'"><h2></h2><div class="'+i.content+'"></div><input class="'+i.input+'"><select class="'+i.select+'"></select><div class="'+i.radio+'"></div><label for="'+i.checkbox+'" class="'+i.checkbox+'"><input type="checkbox" id="'+i.checkbox+'"></label><textarea class="'+i.textarea+'"></textarea><div class="'+i.validationerror+'"></div><hr class="'+i.spacer+'"><button class="'+i.confirm+'">OK</button><button class="'+i.cancel+'">Cancel</button><span class="'+i.close+'">×</span></div>',n=document.createElement("div");n.className=i.container,n.innerHTML=e,document.body.appendChild(n);var o=p(),a=b(o,i.input),r=b(o,i.select),l=o.querySelector("#"+i.checkbox),c=b(o,i.textarea);a.oninput=function(){t.resetValidationError()},a.onkeyup=function(e){e.stopPropagation(),13===e.keyCode&&t.clickConfirm()},r.onchange=function(){t.resetValidationError()},l.onchange=function(){t.resetValidationError()},c.onchange=function(){t.resetValidationError()}}},t.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");T(u,e)},t.version="3.1.1",window.sweetAlert=window.swal=t,function(){"complete"===document.readyState||"interactive"===document.readyState&&document.body?t.init():document.addEventListener("DOMContentLoaded",function e(){document.removeEventListener("DOMContentLoaded",e,!1),t.init()},!1)}(),t}); |
{ | ||
"name": "sweetalert2", | ||
"version": "3.1.0", | ||
"repository": "git@github.com:limonte/sweetalert2.git", | ||
"version": "3.1.1", | ||
"repository": "https://github.com/limonte/sweetalert2.git", | ||
"homepage": "https://limonte.github.io/sweetalert2/", | ||
"description": "A replacement for JavaScript's popup boxes, supported fork of sweetalert", | ||
@@ -25,4 +26,15 @@ "main": "dist/sweetalert2.js", | ||
], | ||
"author": "t4t5 & limonte", | ||
"author": "Tristan Edwards <tristan.edwards@me.com> (http://tristanedwards.me)", | ||
"contributors": [ | ||
"Limon Monte <limon.monte@gmail.com> (https://limonte.github.io)", | ||
"Sam Turrell <sam@samturrell.co.uk> (http://samturrell.co.uk)" | ||
], | ||
"keywords": [ | ||
"sweetalert", | ||
"sweetalert2", | ||
"alert", | ||
"prompt" | ||
], | ||
"bugs": "https://github.com/limonte/sweetalert2/issues", | ||
"license": "MIT" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
190477
1