You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1001 B
36 lines
1001 B
import Swal from "sweetalert2";
|
|
import "../../scss/plugin/sweetalert.scss";
|
|
|
|
window.Swal = Swal.mixin({
|
|
target: '#swal-container',
|
|
})
|
|
|
|
window.toast = function (text, type = 'success') {
|
|
window.Swal.fire({
|
|
icon: type,
|
|
text: text,
|
|
toast: true,
|
|
position: "top-end",
|
|
showConfirmButton: false,
|
|
timer: 3000,
|
|
timerProgressBar: true,
|
|
didOpen: () => {
|
|
const popup = Swal.getPopup();
|
|
|
|
// Pause timer when mouse enters
|
|
popup.addEventListener("mouseenter", Swal.stopTimer);
|
|
|
|
// Resume timer when mouse leaves
|
|
popup.addEventListener("mouseleave", Swal.resumeTimer);
|
|
},
|
|
});
|
|
}
|
|
|
|
|
|
document.addEventListener('livewire:navigating', () => {
|
|
// If a user clicks a link while a SweetAlert is processing/open,
|
|
// cleanly destroy it so the overlay doesn't carry over to the new page.
|
|
if (window.Swal && window.Swal.isVisible()) {
|
|
window.Swal.close();
|
|
}
|
|
});
|
|
|