JS
/**
* Dependent File
* sweetalert.css
* sweetalert.js
**/
$('.simple-alert').on('click', function (e) {
e.preventDefault();
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
confirmButtonColor: "#DD6B55"
});
});
$('.success-alert').on('click', function (e) {
e.preventDefault();
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "success",
confirmButtonColor: "#4caf50"
});
});
$('.warning-btn-ok').on('click', function (e) {
e.preventDefault();
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
}, function () {
swal({
title: "Your imaginary file has been deleted.",
type: "success",
confirmButtonColor: "#4caf50"
});
});
});
$('.warning-btn-cancel').on('click', function (e) {
e.preventDefault();
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
}, function (isConfirm) {
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
});
$('.warning-custom-icon').on('click', function (e) {
e.preventDefault();
swal({
title: "Sweet!",
text: "Here's a custom image.",
imageUrl: "images/avatar/jaman-01.jpg"
});
});
$('.warning-custom-html').on('click', function (e) {
e.preventDefault();
swal({
title: "HTML <small>Title</small>!",
text: 'A custom <span style="color:#F8BB86">html<span> message.',
html: true
});
});
$('.warning-auto-close').on('click', function (e) {
e.preventDefault();
swal({
title: "Auto close alert!",
text: "I will close in 3 seconds.",
timer: 3000,
showConfirmButton: false
});
});
$('.warning-prompt').on('click', function (e) {
e.preventDefault();
swal({
title: "An input!",
text: "Write something interesting:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
animation: "slide-from-top",
inputPlaceholder: "Write something"
}, function (inputValue) {
if (inputValue === false) return false;
if (inputValue === "") {
swal.showInputError("You need to write something!");
return false
}
swal("Nice!", "You wrote: " + inputValue, "success");
});
});