Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/assets/js/single-post-page.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-10-16 16:28:42 +00:00
let allowRedirect = true;
const modal = $('#userPostModal');
$(document).ready(() => {
modal.modal('show');
loadPostData();
modal.on('hidden.bs.modal', () => {
if (allowRedirect)
window.location.href = modal.data('origin');
});
});
function loadPostData() {
$.ajax({
url: "/user/single_post_data/" + modal.data('username') + "/" + modal.data('uuid'),
2018-10-16 16:28:42 +00:00
success: (data) => {
$('.modal-body', modal).removeClass('text-center').html(data);
registerPostEvents();
addReplyButtonListener();
addPostMediaListener();
},
});
}
function addReplyButtonListener() {
$('.action-btn.reply-button').click(() => {
allowRedirect = false;
$('#postModal').on('hide.bs.modal', () => {
modal.modal('show');
allowRedirect = true;
loadPostData();
});
});
}
function addPostMediaListener() {
$('.post-media').click(() => {
allowRedirect = false;
$('#imageFullviewModal').on('hide.bs.modal', () => {
modal.modal('show');
allowRedirect = true;
})
});
}