sweetalert2
Advanced tools
Comparing version 1.3.2 to 1.3.4
@@ -1,1 +0,1 @@ | ||
!function(e,t){"use strict";function s(){if(void 0===arguments[0])return e.console.error("sweetAlert expects at least 1 attribute!"),!1;var s=b({},r);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||r.title,s.text=arguments[0].text||r.text,s.html=arguments[0].html||r.html,s.type=arguments[0].type||r.type,s.animation=void 0!==arguments[0].animation?arguments[0].animation:r.animation,s.customClass=arguments[0].customClass||s.customClass,s.allowOutsideClick=void 0!==arguments[0].allowOutsideClick?arguments[0].allowOutsideClick:r.allowOutsideClick,s.allowEscapeKey=void 0!==arguments[0].allowEscapeKey?arguments[0].allowEscapeKey:r.allowEscapeKey,s.showConfirmButton=void 0!==arguments[0].showConfirmButton?arguments[0].showConfirmButton:r.showConfirmButton,s.showCancelButton=void 0!==arguments[0].showCancelButton?arguments[0].showCancelButton:r.showCancelButton,s.closeOnConfirm=void 0!==arguments[0].closeOnConfirm?arguments[0].closeOnConfirm:r.closeOnConfirm,s.closeOnCancel=void 0!==arguments[0].closeOnCancel?arguments[0].closeOnCancel:r.closeOnCancel,s.timer=parseInt(arguments[0].timer,10)||r.timer,s.width=parseInt(arguments[0].width,10)||r.width,s.padding=parseInt(arguments[0].padding,10)||r.padding,s.background=void 0!==arguments[0].background?arguments[0].background:r.background,s.confirmButtonText=arguments[0].confirmButtonText||r.confirmButtonText,s.confirmButtonColor=arguments[0].confirmButtonColor||r.confirmButtonColor,s.confirmButtonClass=arguments[0].confirmButtonClass||s.confirmButtonClass,s.cancelButtonText=arguments[0].cancelButtonText||r.cancelButtonText,s.cancelButtonColor=arguments[0].cancelButtonColor||r.cancelButtonColor,s.cancelButtonClass=arguments[0].cancelButtonClass||s.cancelButtonClass,s.buttonsStyling=void 0!==arguments[0].buttonsStyling?arguments[0].buttonsStyling:r.buttonsStyling,s.reverseButtons=void 0!==arguments[0].reverseButtons?arguments[0].reverseButtons:r.reverseButtons,s.showCloseButton=void 0!==arguments[0].showCloseButton?arguments[0].showCloseButton:r.showCloseButton,s.imageUrl=arguments[0].imageUrl||r.imageUrl,s.imageWidth=arguments[0].imageWidth||r.imageWidth,s.imageHeight=arguments[0].imageHeight||r.imageHeight,s.imageClass=arguments[0].imageClass||r.imageClass;break;default:return e.console.error('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}T(s),q(),E();var n=c();return new Promise(function(i){function r(e,t){for(var s=0;s<v.length;s++)if(e+=t,e===v.length?e=0:-1===e&&(e=v.length-1),v[e].offsetWidth||v[e].offsetHeight||v[e].getClientRects().length)return void v[e].focus()}function c(t){var n=t||e.event,o=n.keyCode||n.which;if(-1!==[9,13,32,27].indexOf(o)){for(var l=n.target||n.srcElement,a=-1,c=0;c<v.length;c++)if(l===v[c]){a=c;break}9===o?(n.shiftKey?r(a,-1):r(a,1),k(n)):13===o||32===o?-1===a&&B(p,n):27===o&&s.allowEscapeKey===!0&&(e.swal.closeModal(),i(void 0))}}s.timer&&(n.timeout=setTimeout(function(){e.swal.closeModal(),i(void 0)},s.timer));var y,f=function(t){var o=t||e.event,l=o.target||o.srcElement,a=d(l,e.swalClasses.confirm),r=d(l,e.swalClasses.cancel),c=d(n,"visible");switch(o.type){case"mouseover":case"mouseup":case"focus":s.buttonsStyling&&(a?l.style.backgroundColor=x(s.confirmButtonColor,-.1):r&&(l.style.backgroundColor=x(s.cancelButtonColor,-.1)));break;case"mouseout":case"blur":s.buttonsStyling&&(a?l.style.backgroundColor=s.confirmButtonColor:r&&(l.style.backgroundColor=s.cancelButtonColor));break;case"mousedown":s.buttonsStyling&&(a?l.style.backgroundColor=x(s.confirmButtonColor,-.2):r&&(l.style.backgroundColor=x(s.cancelButtonColor,-.2)));break;case"click":a&&c?(s.closeOnConfirm&&e.swal.closeModal(),i(!0)):r&&c?(s.closeOnCancel&&e.swal.closeModal(),i(!1)):e.swal.closeModal()}},C=n.querySelectorAll("button");for(y=0;y<C.length;y++)C[y].onclick=f,C[y].onmouseover=f,C[y].onmouseout=f,C[y].onmousedown=f;o=t.onclick,t.onclick=function(t){var n=t||e.event,o=n.target||n.srcElement;(d(o,e.swalClasses.close)||o===u()&&s.allowOutsideClick)&&(e.swal.closeModal(),i(void 0))};var p=n.querySelector("button."+e.swalClasses.confirm),g=n.querySelector("button."+e.swalClasses.cancel),v=[p,g].concat(n.querySelectorAll("button:not([class^=sweet-]), input:not([type=hidden]), textarea, select"));for(y=0;y<v.length;y++)v[y].onfocus=f,v[y].onblur=f;s.reverseButtons&&p.parentNode.insertBefore(g,p),r(-1,1),l=e.onkeydown,e.onkeydown=c,s.buttonsStyling&&(p.style.borderLeftColor=s.confirmButtonColor,p.style.borderRightColor=s.confirmButtonColor),e.swal.enableLoading=function(){m(p,"loading"),m(n,"loading"),g.disabled=!0},e.swal.disableLoading=function(){w(p,"loading"),w(n,"loading"),g.disabled=!1},e.swal.enableButtons=function(){p.disabled=!1,g.disabled=!1},e.swal.disableButtons=function(){p.disabled=!0,g.disabled=!0},e.swal.enableButtons(),e.swal.disableLoading(),e.onfocus=function(){e.setTimeout(function(){void 0!==a&&(a.focus(),a=void 0)},0)}})}e.swalClasses={container:"sweet-container",modal:"sweet-alert",overlay:"sweet-overlay",close:"sweet-close",content:"sweet-content",spacer:"sweet-spacer",confirm:"sweet-confirm",cancel:"sweet-cancel",icon:"sweet-icon",image:"sweet-image",iconTypes:{success:"sweet-success",warning:"sweet-warning",info:"sweet-info",question:"sweet-question",error:"sweet-error"}};var n,o,l,a,i="sweet-alert-mediaquery",r={title:"",text:"",html:"",type:null,animation:!0,allowOutsideClick:!0,allowEscapeKey:!0,showConfirmButton:!0,showCancelButton:!1,closeOnConfirm:!0,closeOnCancel:!0,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"},c=function(){return t.querySelector("."+e.swalClasses.modal)},u=function(){return t.querySelector("."+e.swalClasses.overlay)},d=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},m=function(e,t){t&&!d(e,t)&&(e.className+=" "+t)},w=function(e,t){var s=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(d(e,t)){for(;s.indexOf(" "+t+" ")>=0;)s=s.replace(" "+t+" "," ");e.className=s.replace(/^\s+|\s+$/g,"")}},y=function(e){e.style.opacity="",e.style.display="block"},f=function(e){if(e&&!e.length)return y(e);for(var t=0;t<e.length;++t)y(e[t])},C=function(e){e.style.opacity="",e.style.display="none"},p=function(e){if(e&&!e.length)return C(e);for(var t=0;t<e.length;++t)C(e[t])},g=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},v=function(e){e.style.left="-9999px",e.style.display="block";var t=e.clientHeight,s=parseInt(getComputedStyle(e).getPropertyValue("padding"),10);return e.style.left="",e.style.display="none","-"+parseInt(t/2+s,10)+"px"},h=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var s=+new Date,n=function(){e.style.opacity=+e.style.opacity+(new Date-s)/100,s=+new Date,+e.style.opacity<1&&setTimeout(n,t)};n()}},b=function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e},B=function(s){if("function"==typeof MouseEvent){var n=new MouseEvent("click",{view:e,bubbles:!1,cancelable:!0});s.dispatchEvent(n)}else if(t.createEvent){var o=t.createEvent("MouseEvents");o.initEvent("click",!1,!1),s.dispatchEvent(o)}else t.createEventObject?s.fireEvent("onclick"):"function"==typeof s.onclick&&s.onclick()},k=function(t){"function"==typeof t.stopPropagation?(t.stopPropagation(),t.preventDefault()):e.event&&e.event.hasOwnProperty("cancelBubble")&&(e.event.cancelBubble=!0)},S=function(){var s=c();e.onkeydown=l,t.onclick=o,n&&n.focus(),a=void 0,clearTimeout(s.timeout);var r=t.getElementsByTagName("head")[0],u=t.getElementById(i);u&&r.removeChild(u)},x=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="#",n=0;3>n;n++){var o=parseInt(e.substr(2*n,2),16);o=Math.round(Math.min(Math.max(0,o+o*t),255)).toString(16),s+=("00"+o).substr(o.length)}return s},T=function(s){var n=c();n.style.width=s.width+"px",n.style.padding=s.padding+"px",n.style.marginLeft=-s.width/2+"px",n.style.background=s.background;var o=t.getElementsByTagName("head")[0],l=t.createElement("style");l.type="text/css",l.id=i,l.innerHTML="@media screen and (max-width: "+s.width+"px) {."+e.swalClasses.modal+" {max-width: 100%;left: 0 !important;margin-left: 0 !important;}}",o.appendChild(l);var a=n.querySelector("h2"),r=n.querySelector("."+e.swalClasses.content),u=n.querySelector("button."+e.swalClasses.confirm),d=n.querySelector("button."+e.swalClasses.cancel),y=n.querySelector("."+e.swalClasses.spacer),C=n.querySelector("."+e.swalClasses.close);if(a.innerHTML=s.title.split("\n").join("<br>"),s.text||s.html){if("object"==typeof s.html)if(r.innerHTML="",0 in s.html)for(var v=0;v in s.html;v++)r.appendChild(s.html[v]);else r.appendChild(s.html);else r.innerHTML=s.html||"<p>"+s.text.split("\n").join("<br>")+"</p>";f(r)}else p(r);if(s.showCloseButton?f(C):p(C),n.className=e.swalClasses.modal,s.customClass&&m(n,s.customClass),p(n.querySelectorAll("."+e.swalClasses.icon)),s.type){var h=!1;for(var b in e.swalClasses.iconTypes)if(s.type===b){h=!0;break}if(!h)return e.console.error("Unknown alert type: "+s.type),!1;var B=n.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes[s.type]);switch(f(B),s.type){case"success":m(B,"animate"),m(B.querySelector(".tip"),"animate-success-tip"),m(B.querySelector(".long"),"animate-success-long");break;case"error":m(B,"animate-error-icon"),m(B.querySelector(".x-mark"),"animate-x-mark");break;case"warning":m(B,"pulse-warning")}}var k=n.querySelector("."+e.swalClasses.image);s.imageUrl?(k.setAttribute("src",s.imageUrl),f(k),s.imageWidth&&k.setAttribute("width",s.imageWidth),s.imageHeight&&k.setAttribute("height",s.imageHeight),s.imageClass&&m(k,s.imageClass)):p(k),s.showCancelButton?d.style.display="inline-block":p(d),s.showConfirmButton?g(u,"display"):p(u),s.showConfirmButton||s.showCancelButton?f(y):p(y),u.innerHTML=s.confirmButtonText,d.innerHTML=s.cancelButtonText,s.buttonsStyling&&(u.style.backgroundColor=s.confirmButtonColor,d.style.backgroundColor=s.cancelButtonColor),u.className=e.swalClasses.confirm,m(u,s.confirmButtonClass),d.className=e.swalClasses.cancel,m(d,s.cancelButtonClass),s.buttonsStyling?(m(u,"styled"),m(d,"styled")):(w(u,"styled"),w(d,"styled"),u.style.backgroundColor=u.style.borderLeftColor=u.style.borderRightColor="",d.style.backgroundColor=d.style.borderLeftColor=d.style.borderRightColor=""),s.animation===!0?w(n,"no-animation"):m(n,"no-animation")},E=function(){var e=c();h(u(),10),f(e),m(e,"show-sweet-alert"),w(e,"hide-sweet-alert"),n=t.activeElement,m(e,"visible")},q=function(){var e=c();e.style.marginTop=v(c())};e.sweetAlert=e.swal=function(){var t=arguments,n=c();return null===n&&(e.swal.init(),n=c()),d(n,"visible")&&S(),s.apply(this,t)},e.sweetAlert.close=e.swal.close=e.sweetAlert.closeModal=e.swal.closeModal=function(){var t=c();C(u()),C(t),w(t,"showSweetAlert"),m(t,"hideSweetAlert"),w(t,"visible");var s=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.success);w(s,"animate"),w(s.querySelector(".tip"),"animate-success-tip"),w(s.querySelector(".long"),"animate-success-long");var n=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.error);w(n,"animate-error-icon"),w(n.querySelector(".x-mark"),"animate-x-mark");var o=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.warning);w(o,"pulse-warning"),S()},e.sweetAlert.clickConfirm=e.swal.clickConfirm=function(){var t=c(),s=t.querySelector("button."+e.swalClasses.confirm);s.click()},e.sweetAlert.clickCancel=e.swal.clickCancel=function(){var t=c(),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>Title</h2><div class="'+e.swalClasses.content+'">Text</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+'">×</span></div>',n=t.createElement("div");n.className=e.swalClasses.container,n.innerHTML=s,t.body.appendChild(n)}},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(r,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 n(){"complete"===t.readyState&&(t.detachEvent("onreadystatechange",n),e.swal.init())})}()}(window,document); | ||
!function(e,t){"use strict";function s(){if(void 0===arguments[0])return e.console.error("sweetAlert expects at least 1 attribute!"),!1;var s=b({},r);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||r.title,s.text=arguments[0].text||r.text,s.html=arguments[0].html||r.html,s.type=arguments[0].type||r.type,s.animation=void 0!==arguments[0].animation?arguments[0].animation:r.animation,s.customClass=arguments[0].customClass||s.customClass,s.allowOutsideClick=void 0!==arguments[0].allowOutsideClick?arguments[0].allowOutsideClick:r.allowOutsideClick,s.allowEscapeKey=void 0!==arguments[0].allowEscapeKey?arguments[0].allowEscapeKey:r.allowEscapeKey,s.showConfirmButton=void 0!==arguments[0].showConfirmButton?arguments[0].showConfirmButton:r.showConfirmButton,s.showCancelButton=void 0!==arguments[0].showCancelButton?arguments[0].showCancelButton:r.showCancelButton,s.closeOnConfirm=void 0!==arguments[0].closeOnConfirm?arguments[0].closeOnConfirm:r.closeOnConfirm,s.closeOnCancel=void 0!==arguments[0].closeOnCancel?arguments[0].closeOnCancel:r.closeOnCancel,s.timer=parseInt(arguments[0].timer,10)||r.timer,s.width=parseInt(arguments[0].width,10)||r.width,s.padding=parseInt(arguments[0].padding,10)||r.padding,s.background=void 0!==arguments[0].background?arguments[0].background:r.background,s.confirmButtonText=arguments[0].confirmButtonText||r.confirmButtonText,s.confirmButtonColor=arguments[0].confirmButtonColor||r.confirmButtonColor,s.confirmButtonClass=arguments[0].confirmButtonClass||s.confirmButtonClass,s.cancelButtonText=arguments[0].cancelButtonText||r.cancelButtonText,s.cancelButtonColor=arguments[0].cancelButtonColor||r.cancelButtonColor,s.cancelButtonClass=arguments[0].cancelButtonClass||s.cancelButtonClass,s.buttonsStyling=void 0!==arguments[0].buttonsStyling?arguments[0].buttonsStyling:r.buttonsStyling,s.reverseButtons=void 0!==arguments[0].reverseButtons?arguments[0].reverseButtons:r.reverseButtons,s.showCloseButton=void 0!==arguments[0].showCloseButton?arguments[0].showCloseButton:r.showCloseButton,s.imageUrl=arguments[0].imageUrl||r.imageUrl,s.imageWidth=arguments[0].imageWidth||r.imageWidth,s.imageHeight=arguments[0].imageHeight||r.imageHeight,s.imageClass=arguments[0].imageClass||r.imageClass;break;default:return e.console.error('Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}T(s),q(),E();var n=c();return new Promise(function(i){function r(e,t){for(var s=0;s<v.length;s++)if(e+=t,e===v.length?e=0:-1===e&&(e=v.length-1),v[e].offsetWidth||v[e].offsetHeight||v[e].getClientRects().length)return void v[e].focus()}function c(t){var n=t||e.event,o=n.keyCode||n.which;if(-1!==[9,13,32,27].indexOf(o)){for(var l=n.target||n.srcElement,a=-1,c=0;c<v.length;c++)if(l===v[c]){a=c;break}9===o?(n.shiftKey?r(a,-1):r(a,1),k(n)):13===o||32===o?-1===a&&B(p,n):27===o&&s.allowEscapeKey===!0&&(e.swal.closeModal(),i(void 0))}}s.timer&&(n.timeout=setTimeout(function(){e.swal.closeModal(),i(void 0)},s.timer));var y,f=function(t){var o=t||e.event,l=o.target||o.srcElement,a=d(l,e.swalClasses.confirm),r=d(l,e.swalClasses.cancel),c=d(n,"visible");switch(o.type){case"mouseover":case"mouseup":case"focus":s.buttonsStyling&&(a?l.style.backgroundColor=x(s.confirmButtonColor,-.1):r&&(l.style.backgroundColor=x(s.cancelButtonColor,-.1)));break;case"mouseout":case"blur":s.buttonsStyling&&(a?l.style.backgroundColor=s.confirmButtonColor:r&&(l.style.backgroundColor=s.cancelButtonColor));break;case"mousedown":s.buttonsStyling&&(a?l.style.backgroundColor=x(s.confirmButtonColor,-.2):r&&(l.style.backgroundColor=x(s.cancelButtonColor,-.2)));break;case"click":a&&c?(s.closeOnConfirm&&e.swal.closeModal(),i(!0)):r&&c?(s.closeOnCancel&&e.swal.closeModal(),i(!1)):e.swal.closeModal()}},C=n.querySelectorAll("button");for(y=0;y<C.length;y++)C[y].onclick=f,C[y].onmouseover=f,C[y].onmouseout=f,C[y].onmousedown=f;o=t.onclick,t.onclick=function(t){var n=t||e.event,o=n.target||n.srcElement;(d(o,e.swalClasses.close)||o===u()&&s.allowOutsideClick)&&(e.swal.closeModal(),i(void 0))};var p=n.querySelector("button."+e.swalClasses.confirm),g=n.querySelector("button."+e.swalClasses.cancel),v=[p,g].concat(Array.prototype.slice.call(n.querySelectorAll("button:not([class^=sweet-]), input:not([type=hidden]), textarea, select")));for(y=0;y<v.length;y++)v[y].onfocus=f,v[y].onblur=f;s.reverseButtons&&p.parentNode.insertBefore(g,p),r(-1,1),l=e.onkeydown,e.onkeydown=c,s.buttonsStyling&&(p.style.borderLeftColor=s.confirmButtonColor,p.style.borderRightColor=s.confirmButtonColor),e.swal.enableLoading=function(){m(p,"loading"),m(n,"loading"),g.disabled=!0},e.swal.disableLoading=function(){w(p,"loading"),w(n,"loading"),g.disabled=!1},e.swal.enableButtons=function(){p.disabled=!1,g.disabled=!1},e.swal.disableButtons=function(){p.disabled=!0,g.disabled=!0},e.swal.enableButtons(),e.swal.disableLoading(),e.onfocus=function(){e.setTimeout(function(){void 0!==a&&(a.focus(),a=void 0)},0)}})}e.swalClasses={container:"sweet-container",modal:"sweet-alert",overlay:"sweet-overlay",close:"sweet-close",content:"sweet-content",spacer:"sweet-spacer",confirm:"sweet-confirm",cancel:"sweet-cancel",icon:"sweet-icon",image:"sweet-image",iconTypes:{success:"sweet-success",warning:"sweet-warning",info:"sweet-info",question:"sweet-question",error:"sweet-error"}};var n,o,l,a,i="sweet-alert-mediaquery",r={title:"",text:"",html:"",type:null,animation:!0,allowOutsideClick:!0,allowEscapeKey:!0,showConfirmButton:!0,showCancelButton:!1,closeOnConfirm:!0,closeOnCancel:!0,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"},c=function(){return t.querySelector("."+e.swalClasses.modal)},u=function(){return t.querySelector("."+e.swalClasses.overlay)},d=function(e,t){return new RegExp(" "+t+" ").test(" "+e.className+" ")},m=function(e,t){t&&!d(e,t)&&(e.className+=" "+t)},w=function(e,t){var s=" "+e.className.replace(/[\t\r\n]/g," ")+" ";if(d(e,t)){for(;s.indexOf(" "+t+" ")>=0;)s=s.replace(" "+t+" "," ");e.className=s.replace(/^\s+|\s+$/g,"")}},y=function(e){e.style.opacity="",e.style.display="block"},f=function(e){if(e&&!e.length)return y(e);for(var t=0;t<e.length;++t)y(e[t])},C=function(e){e.style.opacity="",e.style.display="none"},p=function(e){if(e&&!e.length)return C(e);for(var t=0;t<e.length;++t)C(e[t])},g=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},v=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"},h=function(e,t){if(+e.style.opacity<1){t=t||16,e.style.opacity=0,e.style.display="block";var s=+new Date,n=function(){e.style.opacity=+e.style.opacity+(new Date-s)/100,s=+new Date,+e.style.opacity<1&&setTimeout(n,t)};n()}},b=function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s]);return e},B=function(s){if("function"==typeof MouseEvent){var n=new MouseEvent("click",{view:e,bubbles:!1,cancelable:!0});s.dispatchEvent(n)}else if(t.createEvent){var o=t.createEvent("MouseEvents");o.initEvent("click",!1,!1),s.dispatchEvent(o)}else t.createEventObject?s.fireEvent("onclick"):"function"==typeof s.onclick&&s.onclick()},k=function(t){"function"==typeof t.stopPropagation?(t.stopPropagation(),t.preventDefault()):e.event&&e.event.hasOwnProperty("cancelBubble")&&(e.event.cancelBubble=!0)},S=function(){var s=c();e.onkeydown=l,t.onclick=o,n&&n.focus(),a=void 0,clearTimeout(s.timeout);var r=t.getElementsByTagName("head")[0],u=t.getElementById(i);u&&r.removeChild(u)},x=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="#",n=0;3>n;n++){var o=parseInt(e.substr(2*n,2),16);o=Math.round(Math.min(Math.max(0,o+o*t),255)).toString(16),s+=("00"+o).substr(o.length)}return s},T=function(s){var n=c();n.style.width=s.width+"px",n.style.padding=s.padding+"px",n.style.marginLeft=-s.width/2+"px",n.style.background=s.background;var o=t.getElementsByTagName("head")[0],l=t.createElement("style");l.type="text/css",l.id=i,l.innerHTML="@media screen and (max-width: "+s.width+"px) {."+e.swalClasses.modal+" {max-width: 100%;left: 0 !important;margin-left: 0 !important;}}",o.appendChild(l);var a=n.querySelector("h2"),r=n.querySelector("."+e.swalClasses.content),u=n.querySelector("button."+e.swalClasses.confirm),d=n.querySelector("button."+e.swalClasses.cancel),y=n.querySelector("."+e.swalClasses.spacer),C=n.querySelector("."+e.swalClasses.close);if(a.innerHTML=s.title.split("\n").join("<br>"),s.text||s.html){if("object"==typeof s.html)if(r.innerHTML="",0 in s.html)for(var v=0;v in s.html;v++)r.appendChild(s.html[v]);else r.appendChild(s.html);else r.innerHTML=s.html||"<p>"+s.text.split("\n").join("<br>")+"</p>";f(r)}else p(r);if(s.showCloseButton?f(C):p(C),n.className=e.swalClasses.modal,s.customClass&&m(n,s.customClass),p(n.querySelectorAll("."+e.swalClasses.icon)),s.type){var h=!1;for(var b in e.swalClasses.iconTypes)if(s.type===b){h=!0;break}if(!h)return e.console.error("Unknown alert type: "+s.type),!1;var B=n.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes[s.type]);switch(f(B),s.type){case"success":m(B,"animate"),m(B.querySelector(".tip"),"animate-success-tip"),m(B.querySelector(".long"),"animate-success-long");break;case"error":m(B,"animate-error-icon"),m(B.querySelector(".x-mark"),"animate-x-mark");break;case"warning":m(B,"pulse-warning")}}var k=n.querySelector("."+e.swalClasses.image);s.imageUrl?(k.setAttribute("src",s.imageUrl),f(k),s.imageWidth&&k.setAttribute("width",s.imageWidth),s.imageHeight&&k.setAttribute("height",s.imageHeight),s.imageClass&&m(k,s.imageClass)):p(k),s.showCancelButton?d.style.display="inline-block":p(d),s.showConfirmButton?g(u,"display"):p(u),s.showConfirmButton||s.showCancelButton?f(y):p(y),u.innerHTML=s.confirmButtonText,d.innerHTML=s.cancelButtonText,s.buttonsStyling&&(u.style.backgroundColor=s.confirmButtonColor,d.style.backgroundColor=s.cancelButtonColor),u.className=e.swalClasses.confirm,m(u,s.confirmButtonClass),d.className=e.swalClasses.cancel,m(d,s.cancelButtonClass),s.buttonsStyling?(m(u,"styled"),m(d,"styled")):(w(u,"styled"),w(d,"styled"),u.style.backgroundColor=u.style.borderLeftColor=u.style.borderRightColor="",d.style.backgroundColor=d.style.borderLeftColor=d.style.borderRightColor=""),s.animation===!0?w(n,"no-animation"):m(n,"no-animation")},E=function(){var e=c();h(u(),10),f(e),m(e,"show-sweet-alert"),w(e,"hide-sweet-alert"),n=t.activeElement,m(e,"visible")},q=function(){var e=c();e.style.marginTop=v(c())};e.sweetAlert=e.swal=function(){var t=arguments,n=c();return null===n&&(e.swal.init(),n=c()),d(n,"visible")&&S(),s.apply(this,t)},e.sweetAlert.close=e.swal.close=e.sweetAlert.closeModal=e.swal.closeModal=function(){var t=c();C(u()),C(t),w(t,"showSweetAlert"),m(t,"hideSweetAlert"),w(t,"visible");var s=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.success);w(s,"animate"),w(s.querySelector(".tip"),"animate-success-tip"),w(s.querySelector(".long"),"animate-success-long");var n=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.error);w(n,"animate-error-icon"),w(n.querySelector(".x-mark"),"animate-x-mark");var o=t.querySelector("."+e.swalClasses.icon+"."+e.swalClasses.iconTypes.warning);w(o,"pulse-warning"),S()},e.sweetAlert.clickConfirm=e.swal.clickConfirm=function(){var t=c(),s=t.querySelector("button."+e.swalClasses.confirm);s.click()},e.sweetAlert.clickCancel=e.swal.clickCancel=function(){var t=c(),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>Title</h2><div class="'+e.swalClasses.content+'">Text</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+'">×</span></div>',n=t.createElement("div");n.className=e.swalClasses.container,n.innerHTML=s,t.body.appendChild(n)}},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(r,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 n(){"complete"===t.readyState&&(t.detachEvent("onreadystatechange",n),e.swal.init())})}()}(window,document); |
{ | ||
"name": "sweetalert2", | ||
"version": "1.3.2", | ||
"version": "1.3.4", | ||
"repository": "git@github.com:limonte/sweetalert2.git", | ||
@@ -5,0 +5,0 @@ "description": "A replacement for JavaScript's popup boxes, supported fork of sweetalert", |
@@ -153,2 +153,15 @@ SweetAlert2 [![Build Status](https://travis-ci.org/limonte/sweetalert2.svg?branch=master)](https://travis-ci.org/limonte/sweetalert2) | ||
Browser compatibility | ||
--------------------- | ||
SweetAlert works in most major browsers (yes, even IE). Some details: | ||
- **IE: 10+**, Promise polyfill should be included (see [usage example](#usage)). | ||
- **Microsoft Edge: 12+** | ||
- **Safari: 4+** | ||
- **Firefox: 4+** | ||
- **Chrome 14+** | ||
- **Opera: 15+** | ||
Contributing | ||
@@ -155,0 +168,0 @@ ------------ |
@@ -131,7 +131,7 @@ // SweetAlert2 | ||
var height = elem.clientHeight; | ||
var padding = parseInt(getComputedStyle(elem).getPropertyValue('padding'), 10); | ||
var paddingTop = parseInt(getComputedStyle(elem).getPropertyValue('padding-top'), 10); | ||
elem.style.left = ''; | ||
elem.style.display = 'none'; | ||
return ('-' + parseInt(height / 2 + padding, 10) + 'px'); | ||
return ('-' + parseInt(height / 2 + paddingTop, 10) + 'px'); | ||
}; | ||
@@ -620,5 +620,5 @@ | ||
var $cancelButton = modal.querySelector('button.' + window.swalClasses.cancel); | ||
var $modalElements = [$confirmButton, $cancelButton].concat( | ||
var $modalElements = [$confirmButton, $cancelButton].concat(Array.prototype.slice.call( | ||
modal.querySelectorAll('button:not([class^=sweet-]), input:not([type=hidden]), textarea, select') | ||
); | ||
)); | ||
for (i = 0; i < $modalElements.length; i++) { | ||
@@ -625,0 +625,0 @@ $modalElements[i].onfocus = onButtonEvent; |
256348
179