Skip to content

Commit

Permalink
Merge branch 'hoRacy-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
realrashid committed Jun 15, 2024
2 parents 0d830db + 4fc3678 commit 9d6ede2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
56 changes: 29 additions & 27 deletions resources/views/alert.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@if (Session::has('alert.config') || Session::has('alert.delete'))
@if (config('sweetalert.alwaysLoadJS') === true || Session::has('alert.config') || Session::has('alert.delete'))
@if (config('sweetalert.animation.enable'))
<link rel="stylesheet" href="{{ config('sweetalert.animatecss') }}">
@endif
Expand All @@ -7,34 +7,36 @@
<link href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-{{ config('sweetalert.theme') }}" rel="stylesheet">
@endif

@if (config('sweetalert.alwaysLoadJS') === true && config('sweetalert.neverLoadJS') === false)
@if (config('sweetalert.neverLoadJS') === false)
<script src="{{ $cdn ?? asset('vendor/sweetalert/sweetalert.all.js') }}"></script>
@endif

<script>
@if (Session::has('alert.delete'))
document.addEventListener('click', function(event) {
if (event.target.matches('[data-confirm-delete]')) {
event.preventDefault();
Swal.fire({!! Session::pull('alert.delete') !!}).then(function(result) {
if (result.isConfirmed) {
var form = document.createElement('form');
form.action = event.target.href;
form.method = 'POST';
form.innerHTML = `
@csrf
@method('DELETE')
`;
document.body.appendChild(form);
form.submit();
}
});
}
});
@endif
@if (Session::has('alert.delete') || Session::has('alert.config'))
<script>
@if (Session::has('alert.delete'))
document.addEventListener('click', function(event) {
if (event.target.matches('[data-confirm-delete]')) {
event.preventDefault();
Swal.fire({!! Session::pull('alert.delete') !!}).then(function(result) {
if (result.isConfirmed) {
var form = document.createElement('form');
form.action = event.target.href;
form.method = 'POST';
form.innerHTML = `
@csrf
@method('DELETE')
`;
document.body.appendChild(form);
form.submit();
}
});
}
});
@endif
@if (Session::has('alert.config'))
Swal.fire({!! Session::pull('alert.config') !!});
@endif
</script>
@if (Session::has('alert.config'))
Swal.fire({!! Session::pull('alert.config') !!});
@endif
</script>
@endif
@endif
2 changes: 0 additions & 2 deletions src/config/sweetalert.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
| If you want to handle the sweet alert js package by yourself
| (for eg. you might want to use laravel mix) then this can be
| handy.
| If you set always load js to true & never load js to false,
| it's going to prioritize the never load js.
|
| alwaysLoadJs = true & neverLoadJs = true => js will not be loaded
| alwaysLoadJs = true & neverLoadJs = false => js will be loaded
Expand Down

0 comments on commit 9d6ede2

Please sign in to comment.