gophish/static/js/sweetalert2.min.js

1 line
17 KiB
JavaScript
Raw Normal View History

!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=c({},N);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":c(e,arguments[0]),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);var o=f();return new Promise(function(r,a){function l(e,t){for(var n=0;n<O.length;n++)if(e+=t,e===O.length?e=0:-1===e&&(e=O.length-1),O[e].offsetWidth||O[e].offsetHeight||O[e].getClientRects().length)return void O[e].focus()}function c(n){var o=n||window.event,i=o.keyCode||o.which;if(-1!==[9,13,32,27].indexOf(i)){for(var r=o.target||o.srcElement,c=-1,s=0;s<O.length;s++)if(r===O[s]){c=s;break}9===i?(o.shiftKey?l(c,-1):l(c,1),T(o)):13===i||32===i?-1===c&&M(A,o):27===i&&e.allowEscapeKey===!0&&(t.closeModal(e.onClose),a("esc"))}}e.timer&&(o.timeout=setTimeout(function(){t.closeModal(e.onClose),a("timer")},e.timer));var u=function(){switch(e.input){case"select":return C(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 C(o,i.textarea);default:return C(o,i.input)}},p=function(){var t=u();switch(e.input){case"checkbox":return t.checked?1:0;case"radio":return t.checked?t.value:null;case"file":return t.files.length?t.files[0]:null;default:return e.inputAutoTrim?t.value.trim():t.value}};e.input&&setTimeout(function(){var e=u();e&&b(e)},0);var f,B=function(n){e.showLoaderOnConfirm&&t.showLoading(),e.preConfirm?e.preConfirm(n,e.extraParams).then(function(o){t.closeModal(e.onClose),r(o||n)},function(e){t.hideLoading(),e&&t.showValidationError(e)}):(t.closeModal(e.onClose),r(n))},L=function(n){var i=n||window.event,r=i.target||i.srcElement,l=v()===r||v().contains(r),c=y()===r||y().contains(r),u=h(o,"visible");switch(i.type){case"mouseover":case"mouseup":case"focus":e.buttonsStyling&&(l?r.style.backgroundColor=s(e.confirmButtonColor,-.1):c&&(r.style.backgroundColor=s(e.cancelButtonColor,-.1)));break;case"mouseout":case"blur":e.buttonsStyling&&(l?r.style.backgroundColor=e.confirmButtonColor:c&&(r.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(l?r.style.backgroundColor=s(e.confirmButtonColor,-.2):c&&(r.style.backgroundColor=s(e.cancelButtonColor,-.2)));break;case"click":if(l&&u)if(e.input){var d=p();e.inputValidator?(t.disableInput(),e.inputValidator(d,e.extraParams).then(function(){t.enableInput(),B(d)},function(e){t.enableInput(),e&&t.showValidationError(e)})):B(d)}else B(!0);else c&&u&&(t.closeModal(e.onClose),a("cancel"))}},q=o.querySelectorAll("button");for(f=0;f<q.length;f++)q[f].onclick=L,q[f].onmouseover=L,q[f].onmouseout=L,q[f].onmousedown=L;d.previousDocumentClick=document.onclick,document.onclick=function(n){var o=n||window.event,r=o.target||o.srcElement;h(r,i.close)?(t.closeModal(e.onClose),a("close")):r===m()&&e.allowOutsideClick&&(t.closeModal(e.onClose),a("overlay"))};var A=v(),P=y(),O=[A,P].concat(Array.prototype.slice.call(o.querySelectorAll("button:not([class^="+n+"]), input:not([type=hidden]), textarea, select")));for(f=0;f<O.length;f++)O[f].onfocus=L,O[f].onblur=L;e.reverseButtons&&A.parentNode.insertBefore(P,A),d.previousWindowKeyDown=window.onkeydown,window.onkeydown=c,e.buttonsStyling&&(A.style.borderLeftColor=e.confirmButtonColor,A.style.borderRightColor=e.confirmButtonColor),t.showLoading=t.enableLoading=function(){g(A,"loading"),g(o,"loading"),A.disabled=!0,P.disabled=!0},t.hideLoading=t.disableLoading=functio