✨ A beautiful, responsive, highly customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies. 🇺🇦
MIT License
Published by limonte over 8 years ago
SweetAlert2 now rejects Promise reject(dismiss)
in cases:
"cancel"
)"overlay"
)"esc"
)"timer"
)Before 4.0.0 Promise handling:
swal({title: 'Are you sure?', showCancelButton: true}).then(
function(isConfirm) {
if (isConfirm === true) {
// handle Confirm button click
} else if (isConfirm === false) {
// handle Cancel button click
} else {
// Esc, close button or outside click, isConfirm is undefined
}
}
);
Starting with v4.0.0 Promise will be resolved in case of Confirm button was clicked and rejected with dismiss
parameter on all other cases:
swal({title: 'Are you sure?', showCancelButton: true}).then(
function(result) {
// handle Confirm button click
// result is an optional parameter, needed for modals with input
}, function(dismiss) {
// dismiss can be 'cancel', 'overlay', 'esc' or 'timer'
}
);
resetDefaults()
methodPublished by limonte over 8 years ago
Helper functions and some static data are moved out of the main source file and into their own respective utils/*.js
files. This kind of approach will help in the long run as more features are added, the main scope isn't going to be completely bloated.
The main lengthy block of code that sets the users provided options is replaced it with the extend()
helper.
Published by limonte over 8 years ago
If window is detected it will automatically extend it with sweetAlert and swal
Many thanks to @Tonkpils