sweetalert2
Advanced tools
Comparing version 5.1.1 to 5.2.0
/*! | ||
* sweetalert2 v5.1.1 | ||
* sweetalert2 v5.2.0 | ||
* Released under the MIT License. | ||
@@ -528,3 +528,3 @@ */ | ||
var progressStepsContainer = getProgressSteps(); | ||
var currentProgressStep = parseInt(params.currentProgressStep === null? sweetAlert$1.getQueueStep() : params.currentProgressStep, 10); | ||
var currentProgressStep = parseInt(params.currentProgressStep === null? sweetAlert.getQueueStep() : params.currentProgressStep, 10); | ||
if (params.progressSteps.length) { | ||
@@ -786,3 +786,3 @@ show(progressStepsContainer); | ||
modal.timeout = setTimeout(function() { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
reject('timer'); | ||
@@ -842,3 +842,3 @@ }, params.timer); | ||
if (params.showLoaderOnConfirm) { | ||
sweetAlert$1.showLoading(); | ||
sweetAlert.showLoading(); | ||
} | ||
@@ -849,9 +849,9 @@ | ||
function(preConfirmValue) { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
resolve(preConfirmValue || value); | ||
}, | ||
function(error) { | ||
sweetAlert$1.hideLoading(); | ||
sweetAlert.hideLoading(); | ||
if (error) { | ||
sweetAlert$1.showValidationError(error); | ||
sweetAlert.showValidationError(error); | ||
} | ||
@@ -861,3 +861,3 @@ } | ||
} else { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
resolve(value); | ||
@@ -907,3 +907,3 @@ } | ||
// Clicked 'confirm' | ||
if (targetedConfirm && sweetAlert$1.isVisible()) { | ||
if (targetedConfirm && sweetAlert.isVisible()) { | ||
if (params.input) { | ||
@@ -913,12 +913,12 @@ var inputValue = getInputValue(); | ||
if (params.inputValidator) { | ||
sweetAlert$1.disableInput(); | ||
sweetAlert.disableInput(); | ||
params.inputValidator(inputValue, params.extraParams).then( | ||
function() { | ||
sweetAlert$1.enableInput(); | ||
sweetAlert.enableInput(); | ||
confirm(inputValue); | ||
}, | ||
function(error) { | ||
sweetAlert$1.enableInput(); | ||
sweetAlert.enableInput(); | ||
if (error) { | ||
sweetAlert$1.showValidationError(error); | ||
sweetAlert.showValidationError(error); | ||
} | ||
@@ -936,4 +936,4 @@ } | ||
// Clicked 'cancel' | ||
} else if (targetedCancel && sweetAlert$1.isVisible()) { | ||
sweetAlert$1.closeModal(params.onClose); | ||
} else if (targetedCancel && sweetAlert.isVisible()) { | ||
sweetAlert.closeModal(params.onClose); | ||
reject('cancel'); | ||
@@ -958,3 +958,3 @@ } | ||
getCloseButton().onclick = function() { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
reject('close'); | ||
@@ -969,3 +969,3 @@ }; | ||
if (params.allowOutsideClick) { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
reject('overlay'); | ||
@@ -1052,3 +1052,3 @@ } | ||
} else if (keyCode === 27 && params.allowEscapeKey === true) { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
reject('esc'); | ||
@@ -1071,3 +1071,3 @@ } | ||
*/ | ||
sweetAlert$1.showLoading = sweetAlert$1.enableLoading = function() { | ||
sweetAlert.showLoading = sweetAlert.enableLoading = function() { | ||
show(getSpacer()); | ||
@@ -1084,3 +1084,3 @@ show($confirmButton, 'inline-block'); | ||
*/ | ||
sweetAlert$1.hideLoading = sweetAlert$1.disableLoading = function() { | ||
sweetAlert.hideLoading = sweetAlert.disableLoading = function() { | ||
if (!params.showConfirmButton) { | ||
@@ -1098,3 +1098,3 @@ hide($confirmButton); | ||
sweetAlert$1.enableButtons = function() { | ||
sweetAlert.enableButtons = function() { | ||
$confirmButton.disabled = false; | ||
@@ -1104,3 +1104,3 @@ $cancelButton.disabled = false; | ||
sweetAlert$1.disableButtons = function() { | ||
sweetAlert.disableButtons = function() { | ||
$confirmButton.disabled = true; | ||
@@ -1110,11 +1110,11 @@ $cancelButton.disabled = true; | ||
sweetAlert$1.enableConfirmButton = function() { | ||
sweetAlert.enableConfirmButton = function() { | ||
$confirmButton.disabled = false; | ||
}; | ||
sweetAlert$1.disableConfirmButton = function() { | ||
sweetAlert.disableConfirmButton = function() { | ||
$confirmButton.disabled = true; | ||
}; | ||
sweetAlert$1.enableInput = function() { | ||
sweetAlert.enableInput = function() { | ||
var input = getInput(); | ||
@@ -1135,3 +1135,3 @@ if (!input) { | ||
sweetAlert$1.disableInput = function() { | ||
sweetAlert.disableInput = function() { | ||
var input = getInput(); | ||
@@ -1153,3 +1153,3 @@ if (!input) { | ||
// Set modal min-height to disable scrolling inside the modal | ||
sweetAlert$1.recalculateHeight = debounce(function() { | ||
sweetAlert.recalculateHeight = debounce(function() { | ||
var modal = getModal(); | ||
@@ -1164,3 +1164,3 @@ var prevState = modal.style.display; | ||
// Show block with validation error | ||
sweetAlert$1.showValidationError = function(error) { | ||
sweetAlert.showValidationError = function(error) { | ||
var validationError = getValidationError(); | ||
@@ -1176,6 +1176,6 @@ validationError.innerHTML = error; | ||
// Hide block with validation error | ||
sweetAlert$1.resetValidationError = function() { | ||
sweetAlert.resetValidationError = function() { | ||
var validationError = getValidationError(); | ||
hide(validationError); | ||
sweetAlert$1.recalculateHeight(); | ||
sweetAlert.recalculateHeight(); | ||
@@ -1188,7 +1188,7 @@ var input = getInput(); | ||
sweetAlert$1.getProgressSteps = function() { | ||
sweetAlert.getProgressSteps = function() { | ||
return params.progressSteps; | ||
}; | ||
sweetAlert$1.setProgressSteps = function(progressSteps) { | ||
sweetAlert.setProgressSteps = function(progressSteps) { | ||
params.progressSteps = progressSteps; | ||
@@ -1198,13 +1198,13 @@ setParameters(params); | ||
sweetAlert$1.showProgressSteps = function() { | ||
sweetAlert.showProgressSteps = function() { | ||
show(getProgressSteps()); | ||
}; | ||
sweetAlert$1.hideProgressSteps = function() { | ||
sweetAlert.hideProgressSteps = function() { | ||
hide(getProgressSteps()); | ||
}; | ||
sweetAlert$1.enableButtons(); | ||
sweetAlert$1.hideLoading(); | ||
sweetAlert$1.resetValidationError(); | ||
sweetAlert.enableButtons(); | ||
sweetAlert.hideLoading(); | ||
sweetAlert.resetValidationError(); | ||
@@ -1356,5 +1356,5 @@ // inputs | ||
if (params.inputOptions instanceof Promise) { | ||
sweetAlert$1.showLoading(); | ||
sweetAlert.showLoading(); | ||
params.inputOptions.then(function(inputOptions) { | ||
sweetAlert$1.hideLoading(); | ||
sweetAlert.hideLoading(); | ||
populateInputOptions(inputOptions); | ||
@@ -1379,3 +1379,3 @@ }); | ||
if (typeof MutationObserver !== 'undefined' && !swal2Observer) { | ||
swal2Observer = new MutationObserver(sweetAlert$1.recalculateHeight); | ||
swal2Observer = new MutationObserver(sweetAlert.recalculateHeight); | ||
swal2Observer.observe(modal, {childList: true, characterData: true, subtree: true}); | ||
@@ -1387,8 +1387,8 @@ } | ||
// SweetAlert function | ||
function sweetAlert$1() { | ||
function sweetAlert() { | ||
// Copy arguments to the local args variable | ||
var args = arguments; | ||
if (sweetAlert$1.isVisible()) { | ||
sweetAlert$1.close(); | ||
if (sweetAlert.isVisible()) { | ||
sweetAlert.close(); | ||
} | ||
@@ -1402,3 +1402,3 @@ | ||
*/ | ||
sweetAlert$1.isVisible = function() { | ||
sweetAlert.isVisible = function() { | ||
var modal = getModal(); | ||
@@ -1411,3 +1411,3 @@ return isVisible(modal); | ||
*/ | ||
sweetAlert$1.queue = function(steps) { | ||
sweetAlert.queue = function(steps) { | ||
queue = steps; | ||
@@ -1424,3 +1424,3 @@ var modal = getModal(); | ||
sweetAlert$1(queue[i]).then(function() { | ||
sweetAlert(queue[i]).then(function() { | ||
step(i+1, callback); | ||
@@ -1442,3 +1442,3 @@ }, function(dismiss) { | ||
*/ | ||
sweetAlert$1.getQueueStep = function() { | ||
sweetAlert.getQueueStep = function() { | ||
return getModal().getAttribute('data-queue-step'); | ||
@@ -1450,3 +1450,3 @@ }; | ||
*/ | ||
sweetAlert$1.insertQueueStep = function(step, index) { | ||
sweetAlert.insertQueueStep = function(step, index) { | ||
if (index && index < queue.length) { | ||
@@ -1461,3 +1461,3 @@ return queue.splice(index, 0, step); | ||
*/ | ||
sweetAlert$1.deleteQueueStep = function(index) { | ||
sweetAlert.deleteQueueStep = function(index) { | ||
if (typeof queue[index] !== 'undefined') { | ||
@@ -1471,3 +1471,3 @@ queue.splice(index, 1); | ||
*/ | ||
sweetAlert$1.close = sweetAlert$1.closeModal = function(onComplete) { | ||
sweetAlert.close = sweetAlert.closeModal = function(onComplete) { | ||
var modal = getModal(); | ||
@@ -1518,3 +1518,3 @@ removeClass(modal, 'show-swal2'); | ||
*/ | ||
sweetAlert$1.clickConfirm = function() { | ||
sweetAlert.clickConfirm = function() { | ||
getConfirmButton().click(); | ||
@@ -1526,3 +1526,3 @@ }; | ||
*/ | ||
sweetAlert$1.clickCancel = function() { | ||
sweetAlert.clickCancel = function() { | ||
getCancelButton().click(); | ||
@@ -1535,3 +1535,3 @@ }; | ||
*/ | ||
sweetAlert$1.setDefaults = function(userParams) { | ||
sweetAlert.setDefaults = function(userParams) { | ||
if (!userParams) { | ||
@@ -1550,10 +1550,8 @@ throw new Error('userParams is required'); | ||
*/ | ||
sweetAlert$1.resetDefaults = function() { | ||
sweetAlert.resetDefaults = function() { | ||
modalParams = extend({}, defaultParams); | ||
}; | ||
sweetAlert$1.version = ''; | ||
sweetAlert.version = '5.2.0'; | ||
window.sweetAlert = window.swal = sweetAlert$1; | ||
if (typeof Promise === 'function') { | ||
@@ -1570,2 +1568,3 @@ Promise.prototype.done = Promise.prototype.done || function() { | ||
module.exports = sweetAlert$1; | ||
module.exports = sweetAlert; | ||
if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2; |
/*! | ||
* sweetalert2 v5.1.1 | ||
* sweetalert2 v5.2.0 | ||
* Released under the MIT License. | ||
@@ -532,3 +532,3 @@ */ | ||
var progressStepsContainer = getProgressSteps(); | ||
var currentProgressStep = parseInt(params.currentProgressStep === null? sweetAlert$1.getQueueStep() : params.currentProgressStep, 10); | ||
var currentProgressStep = parseInt(params.currentProgressStep === null? sweetAlert.getQueueStep() : params.currentProgressStep, 10); | ||
if (params.progressSteps.length) { | ||
@@ -790,3 +790,3 @@ show(progressStepsContainer); | ||
modal.timeout = setTimeout(function() { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
reject('timer'); | ||
@@ -846,3 +846,3 @@ }, params.timer); | ||
if (params.showLoaderOnConfirm) { | ||
sweetAlert$1.showLoading(); | ||
sweetAlert.showLoading(); | ||
} | ||
@@ -853,9 +853,9 @@ | ||
function(preConfirmValue) { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
resolve(preConfirmValue || value); | ||
}, | ||
function(error) { | ||
sweetAlert$1.hideLoading(); | ||
sweetAlert.hideLoading(); | ||
if (error) { | ||
sweetAlert$1.showValidationError(error); | ||
sweetAlert.showValidationError(error); | ||
} | ||
@@ -865,3 +865,3 @@ } | ||
} else { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
resolve(value); | ||
@@ -911,3 +911,3 @@ } | ||
// Clicked 'confirm' | ||
if (targetedConfirm && sweetAlert$1.isVisible()) { | ||
if (targetedConfirm && sweetAlert.isVisible()) { | ||
if (params.input) { | ||
@@ -917,12 +917,12 @@ var inputValue = getInputValue(); | ||
if (params.inputValidator) { | ||
sweetAlert$1.disableInput(); | ||
sweetAlert.disableInput(); | ||
params.inputValidator(inputValue, params.extraParams).then( | ||
function() { | ||
sweetAlert$1.enableInput(); | ||
sweetAlert.enableInput(); | ||
confirm(inputValue); | ||
}, | ||
function(error) { | ||
sweetAlert$1.enableInput(); | ||
sweetAlert.enableInput(); | ||
if (error) { | ||
sweetAlert$1.showValidationError(error); | ||
sweetAlert.showValidationError(error); | ||
} | ||
@@ -940,4 +940,4 @@ } | ||
// Clicked 'cancel' | ||
} else if (targetedCancel && sweetAlert$1.isVisible()) { | ||
sweetAlert$1.closeModal(params.onClose); | ||
} else if (targetedCancel && sweetAlert.isVisible()) { | ||
sweetAlert.closeModal(params.onClose); | ||
reject('cancel'); | ||
@@ -962,3 +962,3 @@ } | ||
getCloseButton().onclick = function() { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
reject('close'); | ||
@@ -973,3 +973,3 @@ }; | ||
if (params.allowOutsideClick) { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
reject('overlay'); | ||
@@ -1056,3 +1056,3 @@ } | ||
} else if (keyCode === 27 && params.allowEscapeKey === true) { | ||
sweetAlert$1.closeModal(params.onClose); | ||
sweetAlert.closeModal(params.onClose); | ||
reject('esc'); | ||
@@ -1075,3 +1075,3 @@ } | ||
*/ | ||
sweetAlert$1.showLoading = sweetAlert$1.enableLoading = function() { | ||
sweetAlert.showLoading = sweetAlert.enableLoading = function() { | ||
show(getSpacer()); | ||
@@ -1088,3 +1088,3 @@ show($confirmButton, 'inline-block'); | ||
*/ | ||
sweetAlert$1.hideLoading = sweetAlert$1.disableLoading = function() { | ||
sweetAlert.hideLoading = sweetAlert.disableLoading = function() { | ||
if (!params.showConfirmButton) { | ||
@@ -1102,3 +1102,3 @@ hide($confirmButton); | ||
sweetAlert$1.enableButtons = function() { | ||
sweetAlert.enableButtons = function() { | ||
$confirmButton.disabled = false; | ||
@@ -1108,3 +1108,3 @@ $cancelButton.disabled = false; | ||
sweetAlert$1.disableButtons = function() { | ||
sweetAlert.disableButtons = function() { | ||
$confirmButton.disabled = true; | ||
@@ -1114,11 +1114,11 @@ $cancelButton.disabled = true; | ||
sweetAlert$1.enableConfirmButton = function() { | ||
sweetAlert.enableConfirmButton = function() { | ||
$confirmButton.disabled = false; | ||
}; | ||
sweetAlert$1.disableConfirmButton = function() { | ||
sweetAlert.disableConfirmButton = function() { | ||
$confirmButton.disabled = true; | ||
}; | ||
sweetAlert$1.enableInput = function() { | ||
sweetAlert.enableInput = function() { | ||
var input = getInput(); | ||
@@ -1139,3 +1139,3 @@ if (!input) { | ||
sweetAlert$1.disableInput = function() { | ||
sweetAlert.disableInput = function() { | ||
var input = getInput(); | ||
@@ -1157,3 +1157,3 @@ if (!input) { | ||
// Set modal min-height to disable scrolling inside the modal | ||
sweetAlert$1.recalculateHeight = debounce(function() { | ||
sweetAlert.recalculateHeight = debounce(function() { | ||
var modal = getModal(); | ||
@@ -1168,3 +1168,3 @@ var prevState = modal.style.display; | ||
// Show block with validation error | ||
sweetAlert$1.showValidationError = function(error) { | ||
sweetAlert.showValidationError = function(error) { | ||
var validationError = getValidationError(); | ||
@@ -1180,6 +1180,6 @@ validationError.innerHTML = error; | ||
// Hide block with validation error | ||
sweetAlert$1.resetValidationError = function() { | ||
sweetAlert.resetValidationError = function() { | ||
var validationError = getValidationError(); | ||
hide(validationError); | ||
sweetAlert$1.recalculateHeight(); | ||
sweetAlert.recalculateHeight(); | ||
@@ -1192,7 +1192,7 @@ var input = getInput(); | ||
sweetAlert$1.getProgressSteps = function() { | ||
sweetAlert.getProgressSteps = function() { | ||
return params.progressSteps; | ||
}; | ||
sweetAlert$1.setProgressSteps = function(progressSteps) { | ||
sweetAlert.setProgressSteps = function(progressSteps) { | ||
params.progressSteps = progressSteps; | ||
@@ -1202,13 +1202,13 @@ setParameters(params); | ||
sweetAlert$1.showProgressSteps = function() { | ||
sweetAlert.showProgressSteps = function() { | ||
show(getProgressSteps()); | ||
}; | ||
sweetAlert$1.hideProgressSteps = function() { | ||
sweetAlert.hideProgressSteps = function() { | ||
hide(getProgressSteps()); | ||
}; | ||
sweetAlert$1.enableButtons(); | ||
sweetAlert$1.hideLoading(); | ||
sweetAlert$1.resetValidationError(); | ||
sweetAlert.enableButtons(); | ||
sweetAlert.hideLoading(); | ||
sweetAlert.resetValidationError(); | ||
@@ -1360,5 +1360,5 @@ // inputs | ||
if (params.inputOptions instanceof Promise) { | ||
sweetAlert$1.showLoading(); | ||
sweetAlert.showLoading(); | ||
params.inputOptions.then(function(inputOptions) { | ||
sweetAlert$1.hideLoading(); | ||
sweetAlert.hideLoading(); | ||
populateInputOptions(inputOptions); | ||
@@ -1383,3 +1383,3 @@ }); | ||
if (typeof MutationObserver !== 'undefined' && !swal2Observer) { | ||
swal2Observer = new MutationObserver(sweetAlert$1.recalculateHeight); | ||
swal2Observer = new MutationObserver(sweetAlert.recalculateHeight); | ||
swal2Observer.observe(modal, {childList: true, characterData: true, subtree: true}); | ||
@@ -1391,8 +1391,8 @@ } | ||
// SweetAlert function | ||
function sweetAlert$1() { | ||
function sweetAlert() { | ||
// Copy arguments to the local args variable | ||
var args = arguments; | ||
if (sweetAlert$1.isVisible()) { | ||
sweetAlert$1.close(); | ||
if (sweetAlert.isVisible()) { | ||
sweetAlert.close(); | ||
} | ||
@@ -1406,3 +1406,3 @@ | ||
*/ | ||
sweetAlert$1.isVisible = function() { | ||
sweetAlert.isVisible = function() { | ||
var modal = getModal(); | ||
@@ -1415,3 +1415,3 @@ return isVisible(modal); | ||
*/ | ||
sweetAlert$1.queue = function(steps) { | ||
sweetAlert.queue = function(steps) { | ||
queue = steps; | ||
@@ -1428,3 +1428,3 @@ var modal = getModal(); | ||
sweetAlert$1(queue[i]).then(function() { | ||
sweetAlert(queue[i]).then(function() { | ||
step(i+1, callback); | ||
@@ -1446,3 +1446,3 @@ }, function(dismiss) { | ||
*/ | ||
sweetAlert$1.getQueueStep = function() { | ||
sweetAlert.getQueueStep = function() { | ||
return getModal().getAttribute('data-queue-step'); | ||
@@ -1454,3 +1454,3 @@ }; | ||
*/ | ||
sweetAlert$1.insertQueueStep = function(step, index) { | ||
sweetAlert.insertQueueStep = function(step, index) { | ||
if (index && index < queue.length) { | ||
@@ -1465,3 +1465,3 @@ return queue.splice(index, 0, step); | ||
*/ | ||
sweetAlert$1.deleteQueueStep = function(index) { | ||
sweetAlert.deleteQueueStep = function(index) { | ||
if (typeof queue[index] !== 'undefined') { | ||
@@ -1475,3 +1475,3 @@ queue.splice(index, 1); | ||
*/ | ||
sweetAlert$1.close = sweetAlert$1.closeModal = function(onComplete) { | ||
sweetAlert.close = sweetAlert.closeModal = function(onComplete) { | ||
var modal = getModal(); | ||
@@ -1522,3 +1522,3 @@ removeClass(modal, 'show-swal2'); | ||
*/ | ||
sweetAlert$1.clickConfirm = function() { | ||
sweetAlert.clickConfirm = function() { | ||
getConfirmButton().click(); | ||
@@ -1530,3 +1530,3 @@ }; | ||
*/ | ||
sweetAlert$1.clickCancel = function() { | ||
sweetAlert.clickCancel = function() { | ||
getCancelButton().click(); | ||
@@ -1539,3 +1539,3 @@ }; | ||
*/ | ||
sweetAlert$1.setDefaults = function(userParams) { | ||
sweetAlert.setDefaults = function(userParams) { | ||
if (!userParams) { | ||
@@ -1554,10 +1554,8 @@ throw new Error('userParams is required'); | ||
*/ | ||
sweetAlert$1.resetDefaults = function() { | ||
sweetAlert.resetDefaults = function() { | ||
modalParams = extend({}, defaultParams); | ||
}; | ||
sweetAlert$1.version = ''; | ||
sweetAlert.version = '5.2.0'; | ||
window.sweetAlert = window.swal = sweetAlert$1; | ||
if (typeof Promise === 'function') { | ||
@@ -1574,4 +1572,5 @@ Promise.prototype.done = Promise.prototype.done || function() { | ||
return sweetAlert$1; | ||
return sweetAlert; | ||
})); | ||
})); | ||
if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2; |
@@ -1,1 +0,1 @@ | ||
!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(){null===v.previousBodyPadding&&document.body.scrollHeight>window.innerHeight&&(v.previousBodyPadding=document.body.style.paddingRight,document.body.style.paddingRight=K()+"px")}function t(){null!==v.previousBodyPadding&&(document.body.style.paddingRight=v.previousBodyPadding,v.previousBodyPadding=null)}function n(){if(void 0===arguments[0])return console.error("SweetAlert2 expects at least 1 attribute!"),!1;var e=f({},U);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":f(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('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}Q(e);var t=g();return new Promise(function(n,i){function a(t,n){for(var o=A(e.focusCancel),r=0;r<o.length;r++){t+=n,t===o.length?t=0:-1===t&&(t=o.length-1);var i=o[t];if(O(i))return i.focus()}}function s(t){var n=t||window.event,r=n.keyCode||n.which;if(-1!==[9,13,32,27].indexOf(r)){for(var l=n.target||n.srcElement,s=A(e.focusCancel),c=-1,u=0;u<s.length;u++)if(l===s[u]){c=u;break}9===r?(n.shiftKey?a(c,-1):a(c,1),I(n)):13===r||32===r?-1===c&&(e.focusCancel?j(B,n):j(b,n)):27===r&&e.allowEscapeKey===!0&&(o.closeModal(e.onClose),i("esc"))}}e.timer&&(t.timeout=setTimeout(function(){o.closeModal(e.onClose),i("timer")},e.timer));var c=function(n){switch(n=n||e.input){case"select":case"textarea":case"file":return M(t,l[n]);case"checkbox":return t.querySelector("."+l.checkbox+" input");case"radio":return t.querySelector("."+l.radio+" input:checked")||t.querySelector("."+l.radio+" input:first-child");case"range":return t.querySelector("."+l.range+" input");default:return M(t,l.input)}},u=function(){var t=c();if(!t)return null;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=c();e&&P(e)},0);var d,f=function(t){e.showLoaderOnConfirm&&o.showLoading(),e.preConfirm?e.preConfirm(t,e.extraParams).then(function(r){o.closeModal(e.onClose),n(r||t)},function(e){o.hideLoading(),e&&o.showValidationError(e)}):(o.closeModal(e.onClose),n(t))},h=function(t){var n=t||window.event,r=n.target||n.srcElement,a=S(),l=x(),s=a===r||a.contains(r),c=l===r||l.contains(r);switch(n.type){case"mouseover":case"mouseup":e.buttonsStyling&&(s?a.style.backgroundColor=m(e.confirmButtonColor,-.1):c&&(l.style.backgroundColor=m(e.cancelButtonColor,-.1)));break;case"mouseout":e.buttonsStyling&&(s?a.style.backgroundColor=e.confirmButtonColor:c&&(l.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(s?a.style.backgroundColor=m(e.confirmButtonColor,-.2):c&&(l.style.backgroundColor=m(e.cancelButtonColor,-.2)));break;case"click":if(s&&o.isVisible())if(e.input){var d=u();e.inputValidator?(o.disableInput(),e.inputValidator(d,e.extraParams).then(function(){o.enableInput(),f(d)},function(e){o.enableInput(),e&&o.showValidationError(e)})):f(d)}else f(!0);else c&&o.isVisible()&&(o.closeModal(e.onClose),i("cancel"))}},y=t.querySelectorAll("button");for(d=0;d<y.length;d++)y[d].onclick=h,y[d].onmouseover=h,y[d].onmouseout=h,y[d].onmousedown=h;E().onclick=function(){o.closeModal(e.onClose),i("close")},r.onclick=function(t){t.target===r&&e.allowOutsideClick&&(o.closeModal(e.onClose),i("overlay"))};var b=S(),B=x();e.reverseButtons?b.parentNode.insertBefore(B,b):b.parentNode.insertBefore(b,B),v.previousWindowKeyDown=window.onkeydown,window.onkeydown=s,e.buttonsStyling&&(b.style.borderLeftColor=e.confirmButtonColor,b.style.borderRightColor=e.confirmButtonColor),o.showLoading=o.enableLoading=function(){V(w()),V(b,"inline-block"),q(b,"loading"),q(t,"loading"),b.disabled=!0,B.disabled=!0},o.hideLoading=o.disableLoading=function(){e.showConfirmButton||(T(b),e.showCancelButton||T(w())),L(b,"loading"),L(t,"loading"),b.disabled=!1,B.disabled=!1},o.enableButtons=function(){b.disabled=!1,B.disabled=!1},o.disableButtons=function(){b.disabled=!0,B.disabled=!0},o.enableConfirmButton=function(){b.disabled=!1},o.disableConfirmButton=function(){b.disabled=!0},o.enableInput=function(){var e=c();if(!e)return!1;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},o.disableInput=function(){var e=c();if(!e)return!1;if(e&&"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},o.recalculateHeight=R(function(){var e=g(),t=e.style.display;e.style.minHeight="",V(e),e.style.minHeight=e.scrollHeight+1+"px",e.style.display=t},50),o.showValidationError=function(e){var t=k();t.innerHTML=e,V(t);var n=c();P(n),q(n,"error")},o.resetValidationError=function(){var e=k();T(e),o.recalculateHeight();var t=c();t&&L(t,"error")},o.getProgressSteps=function(){return e.progressSteps},o.setProgressSteps=function(t){e.progressSteps=t,Q(e)},o.showProgressSteps=function(){V(C())},o.hideProgressSteps=function(){T(C())},o.enableButtons(),o.hideLoading(),o.resetValidationError();var H,N=["input","file","range","select","radio","checkbox","textarea"];for(d=0;d<N.length;d++){var W=l[N[d]],D=M(t,W);if(H=c(N[d])){for(var K in H.attributes)if(H.attributes.hasOwnProperty(K)){var U=H.attributes[K].name;"type"!==U&&"value"!==U&&H.removeAttribute(U)}for(var z in e.inputAttributes)H.setAttribute(z,e.inputAttributes[z])}D.className=W,e.inputClass&&q(D,e.inputClass),T(D)}var Z;switch(e.input){case"text":case"email":case"password":case"number":case"tel":H=M(t,l.input),H.value=e.inputValue,H.placeholder=e.inputPlaceholder,H.type=e.input,V(H);break;case"file":H=M(t,l.file),H.placeholder=e.inputPlaceholder,H.type=e.input,V(H);break;case"range":var F=M(t,l.range),J=F.querySelector("input"),$=F.querySelector("output");J.value=e.inputValue,J.type=e.input,$.value=e.inputValue,V(F);break;case"select":var _=M(t,l.select);if(_.innerHTML="",e.inputPlaceholder){var G=document.createElement("option");G.innerHTML=e.inputPlaceholder,G.value="",G.disabled=!0,G.selected=!0,_.appendChild(G)}Z=function(t){for(var n in t){var o=document.createElement("option");o.value=n,o.innerHTML=t[n],e.inputValue===n&&(o.selected=!0),_.appendChild(o)}V(_),_.focus()};break;case"radio":var X=M(t,l.radio);X.innerHTML="",Z=function(t){for(var n in t){var o=1,r=document.createElement("input"),i=document.createElement("label"),a=document.createElement("span");r.type="radio",r.name=l.radio,r.value=n,r.id=l.radio+"-"+o++,e.inputValue===n&&(r.checked=!0),a.innerHTML=t[n],i.appendChild(r),i.appendChild(a),i["for"]=r.id,X.appendChild(i)}V(X);var s=X.querySelectorAll("input");s.length&&s[0].focus()};break;case"checkbox":var ee=M(t,l.checkbox),te=c("checkbox");te.type="checkbox",te.value=1,te.id=l.checkbox,te.checked=Boolean(e.inputValue);var ne=ee.getElementsByTagName("span");ne.length&&ee.removeChild(ne[0]),ne=document.createElement("span"),ne.innerHTML=e.inputPlaceholder,ee.appendChild(ne),V(ee);break;case"textarea":var oe=M(t,l.textarea);oe.value=e.inputValue,oe.placeholder=e.inputPlaceholder,V(oe);break;case null:break;default:console.error('SweetAlert2: Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox", "textarea" or "file", got "'+e.input+'"')}"select"!==e.input&&"radio"!==e.input||(e.inputOptions instanceof Promise?(o.showLoading(),e.inputOptions.then(function(e){o.hideLoading(),Z(e)})):"object"==typeof e.inputOptions?Z(e.inputOptions):console.error("SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got "+typeof e.inputOptions)),Y(e.animation,e.onOpen),a(-1,1),r.scrollTop=0,"undefined"==typeof MutationObserver||p||(p=new MutationObserver(o.recalculateHeight),p.observe(t,{childList:!0,characterData:!0,subtree:!0}))})}function o(){var e=arguments;return o.isVisible()&&o.close(),n.apply(this,e)}var r,i="swal2-",a=function(e){var t={};for(var n in e)t[e[n]]=i+e[n];return t},l=a(["container","in","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","file","range","select","radio","checkbox","textarea","validationerror","progresssteps","activeprogressstep","progresscircle","progressline"]),s=a(["success","warning","info","question","error"]),c={title:"",text:"",html:"",type:null,customClass:"",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,focusCancel:!1,showCloseButton:!1,showLoaderOnConfirm:!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,progressSteps:[],currentProgressStep:null,progressStepsDistance:"40px",onOpen:null,onClose:null},u='<div class="'+l.modal+'" style="display: none" tabIndex="-1"><ul class="'+l.progresssteps+'"></ul><div class="'+l.icon+" "+s.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+l.icon+" "+s.question+'">?</div><div class="'+l.icon+" "+s.warning+'">!</div><div class="'+l.icon+" "+s.info+'">i</div><div class="'+l.icon+" "+s.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+l.image+'"><h2></h2><div class="'+l.content+'"></div><input class="'+l.input+'"><input type="file" class="'+l.file+'"><div class="'+l.range+'"><output></output><input type="range"></div><select class="'+l.select+'"></select><div class="'+l.radio+'"></div><label for="'+l.checkbox+'" class="'+l.checkbox+'"><input type="checkbox"></label><textarea class="'+l.textarea+'"></textarea><div class="'+l.validationerror+'"></div><hr class="'+l.spacer+'"><button type="button" class="'+l.confirm+'">OK</button><button type="button" class="'+l.cancel+'">Cancel</button><span class="'+l.close+'">×</span></div>',d=document.getElementsByClassName(l.container);d.length?r=d[0]:(r=document.createElement("div"),r.className=l.container,r.innerHTML=u);var p,f=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},m=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 r=parseInt(e.substr(2*o,2),16);r=Math.round(Math.min(Math.max(0,r+r*t),255)).toString(16),n+=("00"+r).substr(r.length)}return n},v={previousWindowKeyDown:null,previousActiveElement:null,previousBodyPadding:null},h=function(){if("undefined"==typeof document)return void console.error("SweetAlert2 requires document to initialize");if(!document.getElementsByClassName(l.container).length){document.body.appendChild(r);var e=g(),t=M(e,l.input),n=M(e,l.file),o=e.querySelector("."+l.range+" input"),i=M(e,l.select),a=e.querySelector("."+l.checkbox+" input"),s=M(e,l.textarea);return t.oninput=function(){sweetAlert.resetValidationError()},t.onkeyup=function(e){e.stopPropagation(),13===e.keyCode&&sweetAlert.clickConfirm()},n.onchange=function(){sweetAlert.resetValidationError()},o.oninput=function(){sweetAlert.resetValidationError(),o.previousSibling.value=o.value},o.onchange=function(){sweetAlert.resetValidationError(),o.previousSibling.value=o.value},i.onchange=function(){sweetAlert.resetValidationError()},a.onchange=function(){sweetAlert.resetValidationError()},s.oninput=function(){sweetAlert.resetValidationError()},e}},y=function(e){return r.querySelector("."+e)},g=function(){return document.body.querySelector("."+l.modal)||h()},b=function(){var e=g();return e.querySelectorAll("."+l.icon)},w=function(){return y(l.spacer)},C=function(){return y(l.progresssteps)},k=function(){return y(l.validationerror)},S=function(){return y(l.confirm)},x=function(){return y(l.cancel)},E=function(){return y(l.close)},A=function(e){var t=[S(),x()];return e&&t.reverse(),t.concat(Array.prototype.slice.call(g().querySelectorAll("button:not([class^="+i+"]), input:not([type=hidden]), textarea, select")))},B=function(e,t){return e.classList.contains(t)},P=function(e){if(e.focus(),"file"!==e.type){var t=e.value;e.value="",e.value=t}},q=function(e,t){if(e&&t){var n=t.split(/\s+/);n.forEach(function(t){e.classList.add(t)})}},L=function(e,t){if(e&&t){var n=t.split(/\s+/);n.forEach(function(t){e.classList.remove(t)})}},M=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(B(e.childNodes[n],t))return e.childNodes[n]},V=function(e,t){t||(t="block"),e.style.opacity="",e.style.display=t},T=function(e){e.style.opacity="",e.style.display="none"},H=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},O=function(e){return e.offsetWidth||e.offsetHeight||e.getClientRects().length},N=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},j=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()},I=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},W=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",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}(),D=function(){var e=g();window.onkeydown=v.previousWindowKeyDown,v.previousActiveElement&&v.previousActiveElement.focus&&v.previousActiveElement.focus(),clearTimeout(e.timeout)},K=function(){var e=document.createElement("div");e.style.width="50px",e.style.height="50px",e.style.overflow="scroll",document.body.appendChild(e);var t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t},R=function(e,t,n){var o;return function(){var r=this,i=arguments,a=function(){o=null,n||e.apply(r,i)},l=n&&!o;clearTimeout(o),o=setTimeout(a,t),l&&e.apply(r,i)}},U=f({},c),z=[],Q=function(e){var t=g();for(var n in e)c.hasOwnProperty(n)||"extraParams"===n||console.warn('SweetAlert2: Unknown parameter "'+n+'"');t.style.width="number"==typeof e.width?e.width+"px":e.width,t.style.padding=e.padding+"px",t.style.background=e.background;var r=t.querySelector("h2"),i=t.querySelector("."+l.content),a=S(),u=x(),d=t.querySelector("."+l.close);r.innerHTML=e.title.split("\n").join("<br>");var p;if(e.text||e.html){if("object"==typeof e.html)if(i.innerHTML="",0 in e.html)for(p=0;p in e.html;p++)i.appendChild(e.html[p].cloneNode(!0));else i.appendChild(e.html.cloneNode(!0));else i.innerHTML=e.html||e.text.split("\n").join("<br>");V(i)}else T(i);e.showCloseButton?V(d):T(d),t.className=l.modal,e.customClass&&q(t,e.customClass);var f=C(),m=parseInt(null===e.currentProgressStep?o.getQueueStep():e.currentProgressStep,10);e.progressSteps.length?(V(f),H(f),m>=e.progressSteps.length&&console.warn("SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),e.progressSteps.forEach(function(t,n){var o=document.createElement("li");if(q(o,l.progresscircle),o.innerHTML=t,n===m&&q(o,l.activeprogressstep),f.appendChild(o),n!==e.progressSteps.length-1){var r=document.createElement("li");q(r,l.progressline),r.style.width=e.progressStepsDistance,f.appendChild(r)}})):T(f);var v=b();for(p=0;p<v.length;p++)T(v[p]);if(e.type){var h=!1;for(var y in s)if(e.type===y){h=!0;break}if(!h)return console.error("SweetAlert2: Unknown alert type: "+e.type),!1;var k=t.querySelector("."+l.icon+"."+s[e.type]);switch(V(k),e.type){case"success":q(k,"animate"),q(k.querySelector(".tip"),"animate-success-tip"),q(k.querySelector(".long"),"animate-success-long");break;case"error":q(k,"animate-error-icon"),q(k.querySelector(".x-mark"),"animate-x-mark");break;case"warning":q(k,"pulse-warning")}}var E=t.querySelector("."+l.image);e.imageUrl?(E.setAttribute("src",e.imageUrl),V(E),e.imageWidth?E.setAttribute("width",e.imageWidth):E.removeAttribute("width"),e.imageHeight?E.setAttribute("height",e.imageHeight):E.removeAttribute("height"),E.className=l.image,e.imageClass&&q(E,e.imageClass)):T(E),e.showCancelButton?u.style.display="inline-block":T(u),e.showConfirmButton?N(a,"display"):T(a);var A=w();e.showConfirmButton||e.showCancelButton?V(A):T(A),a.innerHTML=e.confirmButtonText,u.innerHTML=e.cancelButtonText,e.buttonsStyling&&(a.style.backgroundColor=e.confirmButtonColor,u.style.backgroundColor=e.cancelButtonColor),a.className=l.confirm,q(a,e.confirmButtonClass),u.className=l.cancel,q(u,e.cancelButtonClass),e.buttonsStyling?(q(a,"styled"),q(u,"styled")):(L(a,"styled"),L(u,"styled"),a.style.backgroundColor=a.style.borderLeftColor=a.style.borderRightColor="",u.style.backgroundColor=u.style.borderLeftColor=u.style.borderRightColor=""),e.animation===!0?L(t,"no-animation"):q(t,"no-animation")},Y=function(t,n){var o=g();t?(q(o,"show-swal2"),q(r,"fade"),L(o,"hide-swal2")):L(o,"fade"),V(o),r.style.overflowY="hidden",W&&!B(o,"no-animation")?o.addEventListener(W,function i(){o.removeEventListener(W,i),r.style.overflowY="auto"}):r.style.overflowY="auto",q(r,"in"),q(document.body,l["in"]),e(),v.previousActiveElement=document.activeElement,null!==n&&"function"==typeof n&&n.call(this,o)};return o.isVisible=function(){var e=g();return O(e)},o.queue=function(e){z=e;var t=g(),n=function(){z=[],t.removeAttribute("data-queue-step")};return new Promise(function(e,r){!function i(a,l){a<z.length?(t.setAttribute("data-queue-step",a),o(z[a]).then(function(){i(a+1,l)},function(e){n(),r(e)})):(n(),e())}(0)})},o.getQueueStep=function(){return g().getAttribute("data-queue-step")},o.insertQueueStep=function(e,t){return t&&t<z.length?z.splice(t,0,e):z.push(e)},o.deleteQueueStep=function(e){"undefined"!=typeof z[e]&&z.splice(e,1)},o.close=o.closeModal=function(e){var n=g();L(n,"show-swal2"),q(n,"hide-swal2");var o=n.querySelector("."+l.icon+"."+s.success);L(o,"animate"),L(o.querySelector(".tip"),"animate-success-tip"),L(o.querySelector(".long"),"animate-success-long");var i=n.querySelector("."+l.icon+"."+s.error);L(i,"animate-error-icon"),L(i.querySelector(".x-mark"),"animate-x-mark");var a=n.querySelector("."+l.icon+"."+s.warning);L(a,"pulse-warning"),D(),W&&!B(n,"no-animation")?n.addEventListener(W,function c(){n.removeEventListener(W,c),B(n,"hide-swal2")&&(T(n),L(r,"in"),L(document.body,l["in"]),t())}):(T(n),L(r,"in"),L(document.body,l["in"]),t()),null!==e&&"function"==typeof e&&e.call(this,n)},o.clickConfirm=function(){S().click()},o.clickCancel=function(){x().click()},o.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");f(U,e)},o.resetDefaults=function(){U=f({},c)},o.version="",window.sweetAlert=window.swal=o,"function"==typeof Promise?Promise.prototype.done=Promise.prototype.done||function(){return this["catch"](function(){})}:console.warn("SweetAlert2: Please inlude Promise polyfill BEFORE including sweetalert2.js if IE10+ support needed."),o}); | ||
!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(){null===v.previousBodyPadding&&document.body.scrollHeight>window.innerHeight&&(v.previousBodyPadding=document.body.style.paddingRight,document.body.style.paddingRight=K()+"px")}function t(){null!==v.previousBodyPadding&&(document.body.style.paddingRight=v.previousBodyPadding,v.previousBodyPadding=null)}function n(){if(void 0===arguments[0])return console.error("SweetAlert2 expects at least 1 attribute!"),!1;var e=f({},U);switch(typeof arguments[0]){case"string":e.title=arguments[0],e.text=arguments[1]||"",e.type=arguments[2]||"";break;case"object":f(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('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got '+typeof arguments[0]),!1}Q(e);var t=g();return new Promise(function(n,i){function a(t,n){for(var o=B(e.focusCancel),r=0;r<o.length;r++){t+=n,t===o.length?t=0:-1===t&&(t=o.length-1);var i=o[t];if(O(i))return i.focus()}}function s(t){var n=t||window.event,r=n.keyCode||n.which;if(-1!==[9,13,32,27].indexOf(r)){for(var l=n.target||n.srcElement,s=B(e.focusCancel),c=-1,u=0;u<s.length;u++)if(l===s[u]){c=u;break}9===r?(n.shiftKey?a(c,-1):a(c,1),I(n)):13===r||32===r?-1===c&&(e.focusCancel?j(P,n):j(b,n)):27===r&&e.allowEscapeKey===!0&&(o.closeModal(e.onClose),i("esc"))}}e.timer&&(t.timeout=setTimeout(function(){o.closeModal(e.onClose),i("timer")},e.timer));var c=function(n){switch(n=n||e.input){case"select":case"textarea":case"file":return M(t,l[n]);case"checkbox":return t.querySelector("."+l.checkbox+" input");case"radio":return t.querySelector("."+l.radio+" input:checked")||t.querySelector("."+l.radio+" input:first-child");case"range":return t.querySelector("."+l.range+" input");default:return M(t,l.input)}},u=function(){var t=c();if(!t)return null;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=c();e&&A(e)},0);var d,f=function(t){e.showLoaderOnConfirm&&o.showLoading(),e.preConfirm?e.preConfirm(t,e.extraParams).then(function(r){o.closeModal(e.onClose),n(r||t)},function(e){o.hideLoading(),e&&o.showValidationError(e)}):(o.closeModal(e.onClose),n(t))},h=function(t){var n=t||window.event,r=n.target||n.srcElement,a=S(),l=x(),s=a===r||a.contains(r),c=l===r||l.contains(r);switch(n.type){case"mouseover":case"mouseup":e.buttonsStyling&&(s?a.style.backgroundColor=m(e.confirmButtonColor,-.1):c&&(l.style.backgroundColor=m(e.cancelButtonColor,-.1)));break;case"mouseout":e.buttonsStyling&&(s?a.style.backgroundColor=e.confirmButtonColor:c&&(l.style.backgroundColor=e.cancelButtonColor));break;case"mousedown":e.buttonsStyling&&(s?a.style.backgroundColor=m(e.confirmButtonColor,-.2):c&&(l.style.backgroundColor=m(e.cancelButtonColor,-.2)));break;case"click":if(s&&o.isVisible())if(e.input){var d=u();e.inputValidator?(o.disableInput(),e.inputValidator(d,e.extraParams).then(function(){o.enableInput(),f(d)},function(e){o.enableInput(),e&&o.showValidationError(e)})):f(d)}else f(!0);else c&&o.isVisible()&&(o.closeModal(e.onClose),i("cancel"))}},y=t.querySelectorAll("button");for(d=0;d<y.length;d++)y[d].onclick=h,y[d].onmouseover=h,y[d].onmouseout=h,y[d].onmousedown=h;E().onclick=function(){o.closeModal(e.onClose),i("close")},r.onclick=function(t){t.target===r&&e.allowOutsideClick&&(o.closeModal(e.onClose),i("overlay"))};var b=S(),P=x();e.reverseButtons?b.parentNode.insertBefore(P,b):b.parentNode.insertBefore(b,P),v.previousWindowKeyDown=window.onkeydown,window.onkeydown=s,e.buttonsStyling&&(b.style.borderLeftColor=e.confirmButtonColor,b.style.borderRightColor=e.confirmButtonColor),o.showLoading=o.enableLoading=function(){V(w()),V(b,"inline-block"),q(b,"loading"),q(t,"loading"),b.disabled=!0,P.disabled=!0},o.hideLoading=o.disableLoading=function(){e.showConfirmButton||(T(b),e.showCancelButton||T(w())),L(b,"loading"),L(t,"loading"),b.disabled=!1,P.disabled=!1},o.enableButtons=function(){b.disabled=!1,P.disabled=!1},o.disableButtons=function(){b.disabled=!0,P.disabled=!0},o.enableConfirmButton=function(){b.disabled=!1},o.disableConfirmButton=function(){b.disabled=!0},o.enableInput=function(){var e=c();if(!e)return!1;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},o.disableInput=function(){var e=c();if(!e)return!1;if(e&&"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},o.recalculateHeight=R(function(){var e=g(),t=e.style.display;e.style.minHeight="",V(e),e.style.minHeight=e.scrollHeight+1+"px",e.style.display=t},50),o.showValidationError=function(e){var t=k();t.innerHTML=e,V(t);var n=c();A(n),q(n,"error")},o.resetValidationError=function(){var e=k();T(e),o.recalculateHeight();var t=c();t&&L(t,"error")},o.getProgressSteps=function(){return e.progressSteps},o.setProgressSteps=function(t){e.progressSteps=t,Q(e)},o.showProgressSteps=function(){V(C())},o.hideProgressSteps=function(){T(C())},o.enableButtons(),o.hideLoading(),o.resetValidationError();var H,N=["input","file","range","select","radio","checkbox","textarea"];for(d=0;d<N.length;d++){var W=l[N[d]],D=M(t,W);if(H=c(N[d])){for(var K in H.attributes)if(H.attributes.hasOwnProperty(K)){var U=H.attributes[K].name;"type"!==U&&"value"!==U&&H.removeAttribute(U)}for(var z in e.inputAttributes)H.setAttribute(z,e.inputAttributes[z])}D.className=W,e.inputClass&&q(D,e.inputClass),T(D)}var Z;switch(e.input){case"text":case"email":case"password":case"number":case"tel":H=M(t,l.input),H.value=e.inputValue,H.placeholder=e.inputPlaceholder,H.type=e.input,V(H);break;case"file":H=M(t,l.file),H.placeholder=e.inputPlaceholder,H.type=e.input,V(H);break;case"range":var F=M(t,l.range),J=F.querySelector("input"),$=F.querySelector("output");J.value=e.inputValue,J.type=e.input,$.value=e.inputValue,V(F);break;case"select":var _=M(t,l.select);if(_.innerHTML="",e.inputPlaceholder){var G=document.createElement("option");G.innerHTML=e.inputPlaceholder,G.value="",G.disabled=!0,G.selected=!0,_.appendChild(G)}Z=function(t){for(var n in t){var o=document.createElement("option");o.value=n,o.innerHTML=t[n],e.inputValue===n&&(o.selected=!0),_.appendChild(o)}V(_),_.focus()};break;case"radio":var X=M(t,l.radio);X.innerHTML="",Z=function(t){for(var n in t){var o=1,r=document.createElement("input"),i=document.createElement("label"),a=document.createElement("span");r.type="radio",r.name=l.radio,r.value=n,r.id=l.radio+"-"+o++,e.inputValue===n&&(r.checked=!0),a.innerHTML=t[n],i.appendChild(r),i.appendChild(a),i["for"]=r.id,X.appendChild(i)}V(X);var s=X.querySelectorAll("input");s.length&&s[0].focus()};break;case"checkbox":var ee=M(t,l.checkbox),te=c("checkbox");te.type="checkbox",te.value=1,te.id=l.checkbox,te.checked=Boolean(e.inputValue);var ne=ee.getElementsByTagName("span");ne.length&&ee.removeChild(ne[0]),ne=document.createElement("span"),ne.innerHTML=e.inputPlaceholder,ee.appendChild(ne),V(ee);break;case"textarea":var oe=M(t,l.textarea);oe.value=e.inputValue,oe.placeholder=e.inputPlaceholder,V(oe);break;case null:break;default:console.error('SweetAlert2: Unexpected type of input! Expected "text" or "email" or "password", "select", "checkbox", "textarea" or "file", got "'+e.input+'"')}"select"!==e.input&&"radio"!==e.input||(e.inputOptions instanceof Promise?(o.showLoading(),e.inputOptions.then(function(e){o.hideLoading(),Z(e)})):"object"==typeof e.inputOptions?Z(e.inputOptions):console.error("SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got "+typeof e.inputOptions)),Y(e.animation,e.onOpen),a(-1,1),r.scrollTop=0,"undefined"==typeof MutationObserver||p||(p=new MutationObserver(o.recalculateHeight),p.observe(t,{childList:!0,characterData:!0,subtree:!0}))})}function o(){var e=arguments;return o.isVisible()&&o.close(),n.apply(this,e)}var r,i="swal2-",a=function(e){var t={};for(var n in e)t[e[n]]=i+e[n];return t},l=a(["container","in","modal","overlay","close","content","spacer","confirm","cancel","icon","image","input","file","range","select","radio","checkbox","textarea","validationerror","progresssteps","activeprogressstep","progresscircle","progressline"]),s=a(["success","warning","info","question","error"]),c={title:"",text:"",html:"",type:null,customClass:"",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,focusCancel:!1,showCloseButton:!1,showLoaderOnConfirm:!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,progressSteps:[],currentProgressStep:null,progressStepsDistance:"40px",onOpen:null,onClose:null},u='<div class="'+l.modal+'" style="display: none" tabIndex="-1"><ul class="'+l.progresssteps+'"></ul><div class="'+l.icon+" "+s.error+'"><span class="x-mark"><span class="line left"></span><span class="line right"></span></span></div><div class="'+l.icon+" "+s.question+'">?</div><div class="'+l.icon+" "+s.warning+'">!</div><div class="'+l.icon+" "+s.info+'">i</div><div class="'+l.icon+" "+s.success+'"><span class="line tip"></span> <span class="line long"></span><div class="placeholder"></div> <div class="fix"></div></div><img class="'+l.image+'"><h2></h2><div class="'+l.content+'"></div><input class="'+l.input+'"><input type="file" class="'+l.file+'"><div class="'+l.range+'"><output></output><input type="range"></div><select class="'+l.select+'"></select><div class="'+l.radio+'"></div><label for="'+l.checkbox+'" class="'+l.checkbox+'"><input type="checkbox"></label><textarea class="'+l.textarea+'"></textarea><div class="'+l.validationerror+'"></div><hr class="'+l.spacer+'"><button type="button" class="'+l.confirm+'">OK</button><button type="button" class="'+l.cancel+'">Cancel</button><span class="'+l.close+'">×</span></div>',d=document.getElementsByClassName(l.container);d.length?r=d[0]:(r=document.createElement("div"),r.className=l.container,r.innerHTML=u);var p,f=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},m=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 r=parseInt(e.substr(2*o,2),16);r=Math.round(Math.min(Math.max(0,r+r*t),255)).toString(16),n+=("00"+r).substr(r.length)}return n},v={previousWindowKeyDown:null,previousActiveElement:null,previousBodyPadding:null},h=function(){if("undefined"==typeof document)return void console.error("SweetAlert2 requires document to initialize");if(!document.getElementsByClassName(l.container).length){document.body.appendChild(r);var e=g(),t=M(e,l.input),n=M(e,l.file),i=e.querySelector("."+l.range+" input"),a=M(e,l.select),s=e.querySelector("."+l.checkbox+" input"),c=M(e,l.textarea);return t.oninput=function(){o.resetValidationError()},t.onkeyup=function(e){e.stopPropagation(),13===e.keyCode&&o.clickConfirm()},n.onchange=function(){o.resetValidationError()},i.oninput=function(){o.resetValidationError(),i.previousSibling.value=i.value},i.onchange=function(){o.resetValidationError(),i.previousSibling.value=i.value},a.onchange=function(){o.resetValidationError()},s.onchange=function(){o.resetValidationError()},c.oninput=function(){o.resetValidationError()},e}},y=function(e){return r.querySelector("."+e)},g=function(){return document.body.querySelector("."+l.modal)||h()},b=function(){var e=g();return e.querySelectorAll("."+l.icon)},w=function(){return y(l.spacer)},C=function(){return y(l.progresssteps)},k=function(){return y(l.validationerror)},S=function(){return y(l.confirm)},x=function(){return y(l.cancel)},E=function(){return y(l.close)},B=function(e){var t=[S(),x()];return e&&t.reverse(),t.concat(Array.prototype.slice.call(g().querySelectorAll("button:not([class^="+i+"]), input:not([type=hidden]), textarea, select")))},P=function(e,t){return e.classList.contains(t)},A=function(e){if(e.focus(),"file"!==e.type){var t=e.value;e.value="",e.value=t}},q=function(e,t){if(e&&t){var n=t.split(/\s+/);n.forEach(function(t){e.classList.add(t)})}},L=function(e,t){if(e&&t){var n=t.split(/\s+/);n.forEach(function(t){e.classList.remove(t)})}},M=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(P(e.childNodes[n],t))return e.childNodes[n]},V=function(e,t){t||(t="block"),e.style.opacity="",e.style.display=t},T=function(e){e.style.opacity="",e.style.display="none"},H=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},O=function(e){return e.offsetWidth||e.offsetHeight||e.getClientRects().length},N=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},j=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()},I=function(e){"function"==typeof e.stopPropagation?(e.stopPropagation(),e.preventDefault()):window.event&&window.event.hasOwnProperty("cancelBubble")&&(window.event.cancelBubble=!0)},W=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",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}(),D=function(){var e=g();window.onkeydown=v.previousWindowKeyDown,v.previousActiveElement&&v.previousActiveElement.focus&&v.previousActiveElement.focus(),clearTimeout(e.timeout)},K=function(){var e=document.createElement("div");e.style.width="50px",e.style.height="50px",e.style.overflow="scroll",document.body.appendChild(e);var t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t},R=function(e,t,n){var o;return function(){var r=this,i=arguments,a=function(){o=null,n||e.apply(r,i)},l=n&&!o;clearTimeout(o),o=setTimeout(a,t),l&&e.apply(r,i)}},U=f({},c),z=[],Q=function(e){var t=g();for(var n in e)c.hasOwnProperty(n)||"extraParams"===n||console.warn('SweetAlert2: Unknown parameter "'+n+'"');t.style.width="number"==typeof e.width?e.width+"px":e.width,t.style.padding=e.padding+"px",t.style.background=e.background;var r=t.querySelector("h2"),i=t.querySelector("."+l.content),a=S(),u=x(),d=t.querySelector("."+l.close);r.innerHTML=e.title.split("\n").join("<br>");var p;if(e.text||e.html){if("object"==typeof e.html)if(i.innerHTML="",0 in e.html)for(p=0;p in e.html;p++)i.appendChild(e.html[p].cloneNode(!0));else i.appendChild(e.html.cloneNode(!0));else i.innerHTML=e.html||e.text.split("\n").join("<br>");V(i)}else T(i);e.showCloseButton?V(d):T(d),t.className=l.modal,e.customClass&&q(t,e.customClass);var f=C(),m=parseInt(null===e.currentProgressStep?o.getQueueStep():e.currentProgressStep,10);e.progressSteps.length?(V(f),H(f),m>=e.progressSteps.length&&console.warn("SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),e.progressSteps.forEach(function(t,n){var o=document.createElement("li");if(q(o,l.progresscircle),o.innerHTML=t,n===m&&q(o,l.activeprogressstep),f.appendChild(o),n!==e.progressSteps.length-1){var r=document.createElement("li");q(r,l.progressline),r.style.width=e.progressStepsDistance,f.appendChild(r)}})):T(f);var v=b();for(p=0;p<v.length;p++)T(v[p]);if(e.type){var h=!1;for(var y in s)if(e.type===y){h=!0;break}if(!h)return console.error("SweetAlert2: Unknown alert type: "+e.type),!1;var k=t.querySelector("."+l.icon+"."+s[e.type]);switch(V(k),e.type){case"success":q(k,"animate"),q(k.querySelector(".tip"),"animate-success-tip"),q(k.querySelector(".long"),"animate-success-long");break;case"error":q(k,"animate-error-icon"),q(k.querySelector(".x-mark"),"animate-x-mark");break;case"warning":q(k,"pulse-warning")}}var E=t.querySelector("."+l.image);e.imageUrl?(E.setAttribute("src",e.imageUrl),V(E),e.imageWidth?E.setAttribute("width",e.imageWidth):E.removeAttribute("width"),e.imageHeight?E.setAttribute("height",e.imageHeight):E.removeAttribute("height"),E.className=l.image,e.imageClass&&q(E,e.imageClass)):T(E),e.showCancelButton?u.style.display="inline-block":T(u),e.showConfirmButton?N(a,"display"):T(a);var B=w();e.showConfirmButton||e.showCancelButton?V(B):T(B),a.innerHTML=e.confirmButtonText,u.innerHTML=e.cancelButtonText,e.buttonsStyling&&(a.style.backgroundColor=e.confirmButtonColor,u.style.backgroundColor=e.cancelButtonColor),a.className=l.confirm,q(a,e.confirmButtonClass),u.className=l.cancel,q(u,e.cancelButtonClass),e.buttonsStyling?(q(a,"styled"),q(u,"styled")):(L(a,"styled"),L(u,"styled"),a.style.backgroundColor=a.style.borderLeftColor=a.style.borderRightColor="",u.style.backgroundColor=u.style.borderLeftColor=u.style.borderRightColor=""),e.animation===!0?L(t,"no-animation"):q(t,"no-animation")},Y=function(t,n){var o=g();t?(q(o,"show-swal2"),q(r,"fade"),L(o,"hide-swal2")):L(o,"fade"),V(o),r.style.overflowY="hidden",W&&!P(o,"no-animation")?o.addEventListener(W,function i(){o.removeEventListener(W,i),r.style.overflowY="auto"}):r.style.overflowY="auto",q(r,"in"),q(document.body,l["in"]),e(),v.previousActiveElement=document.activeElement,null!==n&&"function"==typeof n&&n.call(this,o)};return o.isVisible=function(){var e=g();return O(e)},o.queue=function(e){z=e;var t=g(),n=function(){z=[],t.removeAttribute("data-queue-step")};return new Promise(function(e,r){!function i(a,l){a<z.length?(t.setAttribute("data-queue-step",a),o(z[a]).then(function(){i(a+1,l)},function(e){n(),r(e)})):(n(),e())}(0)})},o.getQueueStep=function(){return g().getAttribute("data-queue-step")},o.insertQueueStep=function(e,t){return t&&t<z.length?z.splice(t,0,e):z.push(e)},o.deleteQueueStep=function(e){"undefined"!=typeof z[e]&&z.splice(e,1)},o.close=o.closeModal=function(e){var n=g();L(n,"show-swal2"),q(n,"hide-swal2");var o=n.querySelector("."+l.icon+"."+s.success);L(o,"animate"),L(o.querySelector(".tip"),"animate-success-tip"),L(o.querySelector(".long"),"animate-success-long");var i=n.querySelector("."+l.icon+"."+s.error);L(i,"animate-error-icon"),L(i.querySelector(".x-mark"),"animate-x-mark");var a=n.querySelector("."+l.icon+"."+s.warning);L(a,"pulse-warning"),D(),W&&!P(n,"no-animation")?n.addEventListener(W,function c(){n.removeEventListener(W,c),P(n,"hide-swal2")&&(T(n),L(r,"in"),L(document.body,l["in"]),t())}):(T(n),L(r,"in"),L(document.body,l["in"]),t()),null!==e&&"function"==typeof e&&e.call(this,n)},o.clickConfirm=function(){S().click()},o.clickCancel=function(){x().click()},o.setDefaults=function(e){if(!e)throw new Error("userParams is required");if("object"!=typeof e)throw new Error("userParams has to be a object");f(U,e)},o.resetDefaults=function(){U=f({},c)},o.version="5.2.0","function"==typeof Promise?Promise.prototype.done=Promise.prototype.done||function(){return this["catch"](function(){})}:console.warn("SweetAlert2: Please inlude Promise polyfill BEFORE including sweetalert2.js if IE10+ support needed."),o}),window.Sweetalert2&&(window.sweetAlert=window.swal=window.Sweetalert2); |
{ | ||
"name": "sweetalert2", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"repository": "https://github.com/limonte/sweetalert2.git", | ||
@@ -8,2 +8,3 @@ "homepage": "https://limonte.github.io/sweetalert2/", | ||
"main": "dist/sweetalert2.js", | ||
"jsnext:main": "src/sweetalert2.js", | ||
"dependencies": { | ||
@@ -10,0 +11,0 @@ "es6-promise": "latest" |
@@ -49,3 +49,13 @@ SweetAlert2 [![Build Status](https://travis-ci.org/limonte/sweetalert2.svg?branch=master)](https://travis-ci.org/limonte/sweetalert2) | ||
Or: | ||
```javascript | ||
// ES6 Modules | ||
import { default as swal } from 'sweetalert2' | ||
// CommonJS | ||
const swal = require('sweetalert2') | ||
``` | ||
Examples | ||
@@ -52,0 +62,0 @@ -------- |
@@ -1067,4 +1067,2 @@ 'use strict'; | ||
window.sweetAlert = window.swal = sweetAlert; | ||
if (typeof Promise === 'function') { | ||
@@ -1071,0 +1069,0 @@ Promise.prototype.done = Promise.prototype.done || function() { |
@@ -0,1 +1,2 @@ | ||
import { default as sweetAlert } from '../sweetalert2.js'; | ||
import { swalPrefix, swalClasses } from './classes.js'; | ||
@@ -2,0 +3,0 @@ import { sweetContainer } from './default.js'; |
Sorry, the diff of this file is not supported yet
244
226877