alotta good shit
This commit is contained in:
+113
-10
@@ -396,18 +396,48 @@
|
||||
}
|
||||
};
|
||||
|
||||
const deleteButtonEvent = async e => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
const ctx = getContext();
|
||||
if (!ctx) return;
|
||||
const { postid, poster, authorId } = ctx;
|
||||
|
||||
const deleteSubItemEvent = async (subf0ck, postid) => {
|
||||
if (!subf0ck || !postid) return;
|
||||
if (typeof ModAction === 'undefined') return alert('Error: ModAction module not loaded');
|
||||
|
||||
const subDesc = subf0ck.display_index
|
||||
? `Slide #${subf0ck.display_index}`
|
||||
: `Slide (${subf0ck.slug || subf0ck.id})`;
|
||||
|
||||
ModAction.confirm(
|
||||
'Delete Slide from Album',
|
||||
`Are you sure you want to delete <strong style="color:#d9534f">${subDesc}</strong> from this album?<br><small style="opacity:0.8;">The rest of the album will remain intact.</small>`,
|
||||
async (reason) => {
|
||||
const res = await post("/api/v2/admin/delete-album-item", {
|
||||
postid: postid,
|
||||
sub_id: subf0ck.id,
|
||||
sub_slug: subf0ck.slug,
|
||||
order_index: subf0ck.order_index,
|
||||
reason: reason
|
||||
});
|
||||
if (!res.success) {
|
||||
throw new Error(res.msg || 'Failed to delete album item');
|
||||
}
|
||||
if (res.post_deleted) {
|
||||
if (window.flashMessage) window.flashMessage('Album deleted (no remaining items)', 2500, 'info');
|
||||
const mediaObj = document.querySelector('.media-object');
|
||||
if (mediaObj) {
|
||||
mediaObj.innerHTML = '<div style="padding: 100px; text-align: center; color: #d9534f;"><h1>Album Deleted</h1><p>The album has been removed.</p></div>';
|
||||
}
|
||||
} else {
|
||||
if (window.albumGallery && typeof window.albumGallery.removeSubf0ck === 'function') {
|
||||
window.albumGallery.removeSubf0ck(subf0ck.id || subf0ck.slug || subf0ck.order_index);
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
if (window.flashMessage) window.flashMessage('Slide deleted from album', 2500, 'success');
|
||||
}
|
||||
},
|
||||
{ allowEmpty: window.f0ckSession?.is_admin, confirmText: 'Delete Slide' }
|
||||
);
|
||||
};
|
||||
|
||||
const deleteEntirePost = (postid, poster, authorId) => {
|
||||
const i18n = window.f0ckI18n || {};
|
||||
const confirmTitle = i18n.item_delete_title || 'Delete Item';
|
||||
const posterStr = poster
|
||||
@@ -438,6 +468,68 @@
|
||||
}, { allowEmpty: window.f0ckSession?.is_admin });
|
||||
};
|
||||
|
||||
const deleteButtonEvent = async e => {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
const ctx = getContext();
|
||||
if (!ctx) return;
|
||||
const { postid, poster, authorId } = ctx;
|
||||
|
||||
if (typeof ModAction === 'undefined') return alert('Error: ModAction module not loaded');
|
||||
|
||||
const isAlbum = !!(window.albumGallery && typeof window.albumGallery.getCurrentSubf0ck === 'function');
|
||||
const curSub = isAlbum ? window.albumGallery.getCurrentSubf0ck() : null;
|
||||
|
||||
if (isAlbum && curSub) {
|
||||
const subDesc = curSub.display_index ? `Slide ${curSub.display_index}` : 'Current Slide';
|
||||
const choiceHtml = `
|
||||
<div style="margin-bottom: 15px; font-size: 1.05rem;">
|
||||
This post is an album containing multiple slides. What would you like to delete?
|
||||
</div>
|
||||
<div style="display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;">
|
||||
<button type="button" id="btn-choice-delete-sub" class="btn btn-warning" style="padding: 8px 16px; font-weight: 600; cursor: pointer;">
|
||||
<i class="fa-solid fa-trash-can"></i> Delete ${subDesc} Only
|
||||
</button>
|
||||
<button type="button" id="btn-choice-delete-album" class="btn btn-danger" style="padding: 8px 16px; font-weight: 600; cursor: pointer;">
|
||||
<i class="fa-solid fa-layer-group"></i> Delete Entire Album
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
ModAction.confirm('Delete Options', choiceHtml, () => {}, {
|
||||
hideReason: true,
|
||||
hideConfirm: true,
|
||||
unsafeContent: true,
|
||||
cancelText: 'Cancel'
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
const modal = document.getElementById('mod-action-modal');
|
||||
if (!modal) return;
|
||||
const subBtn = modal.querySelector('#btn-choice-delete-sub');
|
||||
const albumBtn = modal.querySelector('#btn-choice-delete-album');
|
||||
if (subBtn) {
|
||||
subBtn.onclick = () => {
|
||||
modal.style.display = 'none';
|
||||
deleteSubItemEvent(curSub, postid);
|
||||
};
|
||||
}
|
||||
if (albumBtn) {
|
||||
albumBtn.onclick = () => {
|
||||
modal.style.display = 'none';
|
||||
deleteEntirePost(postid, poster, authorId);
|
||||
};
|
||||
}
|
||||
}, 50);
|
||||
return;
|
||||
}
|
||||
|
||||
deleteEntirePost(postid, poster, authorId);
|
||||
};
|
||||
|
||||
let tmptt = null;
|
||||
const editTagEvent = async e => {
|
||||
e.preventDefault();
|
||||
@@ -504,6 +596,17 @@
|
||||
addtagClick(e);
|
||||
} else if (target.closest("#a_delete")) {
|
||||
deleteButtonEvent(e);
|
||||
} else if (target.closest(".album-sub-delete-btn, #a_delete_sub")) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
const ctx = getContext();
|
||||
const curSub = (window.albumGallery && typeof window.albumGallery.getCurrentSubf0ck === 'function')
|
||||
? window.albumGallery.getCurrentSubf0ck()
|
||||
: null;
|
||||
if (ctx && curSub) {
|
||||
deleteSubItemEvent(curSub, ctx.postid);
|
||||
}
|
||||
} else if (target.matches('#tags .badge > a[href*="/tag/"]')) {
|
||||
editTagEvent(e);
|
||||
} else if (target.closest('.admin-deltag') || target.closest('.removetag')) {
|
||||
|
||||
Reference in New Issue
Block a user