-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsweetalert.php
More file actions
53 lines (48 loc) · 1.66 KB
/
sweetalert.php
File metadata and controls
53 lines (48 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php if(isset($_SESSION['sweet_alert'])): ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true
});
let alertConfig = {
icon: '<?php echo $_SESSION['sweet_alert']['type']; ?>',
title: '<?php echo $_SESSION['sweet_alert']['title']; ?>',
text: '<?php echo $_SESSION['sweet_alert']['text']; ?>',
customClass: {
popup: 'colored-toast'
},
showConfirmButton: true,
confirmButtonColor: '#4CAF50',
allowOutsideClick: false
};
<?php if(isset($_SESSION['sweet_alert']['footer'])): ?>
alertConfig.footer = '<?php echo $_SESSION['sweet_alert']['footer']; ?>';
<?php endif; ?>
<?php if(isset($_SESSION['sweet_alert']['redirect'])): ?>
alertConfig.willClose = () => {
window.location.href = '<?php echo $_SESSION['sweet_alert']['redirect']; ?>';
}
<?php endif; ?>
switch('<?php echo $_SESSION['sweet_alert']['type']; ?>') {
case 'success':
alertConfig.timer = 2000;
alertConfig.timerProgressBar = true;
break;
case 'error':
alertConfig.timer = null;
break;
case 'warning':
alertConfig.timer = 4000;
break;
}
Swal.fire(alertConfig);
});
</script>
<?php
unset($_SESSION['sweet_alert']);
endif;
?>