MarseyWorld/files/templates/delete_post_modal.html

81 lines
2.6 KiB
HTML
Raw Normal View History

2021-09-25 21:13:52 +00:00
<script>
2021-09-27 19:06:27 +00:00
function post(url, callback, errortext) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
var form = new FormData()
form.append("formkey", formkey());
xhr.withCredentials=true;
xhr.onerror=function() { alert(errortext); };
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
callback();
} else {
xhr.onerror();
}
};
xhr.send(form);
};
2021-09-25 21:13:52 +00:00
2021-09-27 19:06:27 +00:00
function delete_postModal(id) {
2021-09-25 21:13:52 +00:00
document.getElementById("deletePostButton-mobile").addEventListener("click", delete_post);
document.getElementById("deletePostButton").addEventListener("click", delete_post);
function delete_post(){
this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Deleting post';
this.disabled = true;
post('/delete_post/' + id,
callback = function() {
location.reload();
}
)
}
};
</script>
2021-07-21 01:12:26 +00:00
<!-- Delete Post Modal -->
<div class="modal fade modal-sm-bottom" id="deletePostModal" tabindex="-1" role="dialog" aria-labelledby="deletePostModalTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header d-none d-md-flex">
<h5 class="modal-title">Delete post?</h5>
2021-09-26 09:04:49 +00:00
<button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
2021-07-21 01:12:26 +00:00
<span aria-hidden="true"><i class="far fa-times"></i></span>
</button>
</div>
<div class="modal-body text-center">
<div class="py-4">
<i class="fad fa-trash-alt text-muted d-none d-md-block" style="font-size: 3.5rem;"></i>
<span class="fa-stack fa-2x text-muted d-md-none">
<i class="fas fa-circle text-danger opacity-25 fa-stack-2x"></i>
<i class="fas text-danger fa-trash-alt fa-stack-1x"></i>
</span>
</div>
<div class="h4 d-md-none">Delete post?</div>
2021-09-08 10:57:56 +00:00
<p class="d-none d-md-block">Your post will be removed everywhere on {{'SITE_NAME' | app_config}}. This action can be undone.</p>
2021-07-21 01:12:26 +00:00
2021-09-08 10:57:56 +00:00
<p class="text-muted d-md-none">Your post will be removed everywhere on {{'SITE_NAME' | app_config}}. This action can be undone.</p>
2021-07-21 01:12:26 +00:00
<div class="d-md-none">
<button type="button" id="deletePostButton-mobile" class="btn btn-danger btn-block btn-lg">Delete post</button>
2021-09-26 09:04:49 +00:00
<button type="button" class="btn btn-secondary btn-block btn-lg" data-bs-dismiss="modal">Cancel</button>
2021-07-21 01:12:26 +00:00
</div>
</div>
<div class="modal-footer d-none d-md-flex">
2021-09-26 09:04:49 +00:00
<button type="button" class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
2021-07-21 01:12:26 +00:00
<button type="button" id="deletePostButton" class="btn btn-danger">Delete post</button>
</div>
</div>
</div>
</div>