49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
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'),
|
|
success: (data) => {
|
|
$('.modal-body', modal).removeClass('text-center').html(data);
|
|
registerPostEvents();
|
|
|
|
addReplyButtonListener();
|
|
addPostMediaListener();
|
|
},
|
|
error: console.log
|
|
});
|
|
}
|
|
|
|
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;
|
|
})
|
|
});
|
|
} |