This commit is contained in:
Flatlogic Bot 2026-04-02 08:12:45 +00:00
parent b0a261b00c
commit 2a3b8e3c71
4 changed files with 69 additions and 0 deletions

View File

@ -13,6 +13,16 @@
return new bootstrap.Dropdown(dropdownToggleEl)
});
// Override global alert
window.alert = function(message) {
Swal.fire({
title: 'Notification',
text: message,
icon: 'info',
confirmButtonColor: '#3085d6'
});
};
// Global SweetAlert2 replacement for confirm()
const confirmLinks = document.querySelectorAll('a[onclick^="return confirm"]');
@ -45,6 +55,33 @@
});
});
// Intercept confirm in form onsubmit
const confirmForms = document.querySelectorAll('form[onsubmit^="return confirm"]');
confirmForms.forEach(form => {
const originalOnSubmit = form.getAttribute('onsubmit');
const match = originalOnSubmit.match(/confirm\(['"](.+?)['"]\)/);
const message = match ? match[1] : 'Are you sure?';
form.removeAttribute('onsubmit');
form.addEventListener('submit', function(e) {
e.preventDefault();
Swal.fire({
title: 'Are you sure?',
text: message,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, proceed!'
}).then((result) => {
if (result.isConfirmed) {
form.submit();
}
});
});
});
});
</script>
</body>

View File

@ -462,5 +462,15 @@ setInterval(fetchOrders, 10000);
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
window.alert = function(message) {
Swal.fire({
title: "Notification",
text: message,
icon: "info",
confirmButtonColor: "var(--accent-color, #3085d6)"
});
};
</script>
</body>
</html>

View File

@ -472,6 +472,17 @@ foreach ($variants_by_product as $pid => $vars) {
}
.qty-val { width: 30px; text-align: center; font-weight: 600; }
</style>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
window.alert = function(message) {
Swal.fire({
title: "Notification",
text: message,
icon: "info",
confirmButtonColor: "var(--accent-color, #3085d6)"
});
};
</script>
</head>
<body>

View File

@ -364,6 +364,17 @@ foreach ($variants_raw as $v) {
}
.qty-val { width: 30px; text-align: center; font-weight: 600; }
</style>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
window.alert = function(message) {
Swal.fire({
title: "Notification",
text: message,
icon: "info",
confirmButtonColor: "var(--accent-color, #3085d6)"
});
};
</script>
</head>
<body>