gfsd
This commit is contained in:
+26
-9
@@ -1638,6 +1638,9 @@ window.cancelAnimFrame = (function () {
|
||||
}
|
||||
modal._isClosing = false;
|
||||
document.body.classList.add('onara-modal-open');
|
||||
if (document.querySelector('.index-container') && window.scrollY !== 0) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
modal.style.display = 'flex';
|
||||
modal.setAttribute('aria-hidden', 'false');
|
||||
modal.classList.remove('onara-fade-out');
|
||||
@@ -1647,6 +1650,27 @@ window.cancelAnimFrame = (function () {
|
||||
};
|
||||
window.openOnaraModal = openOnaraModal;
|
||||
|
||||
const scrollOnaraThumbIntoView = (thumb, forceCenter = false) => {
|
||||
if (!thumb) return;
|
||||
const container = thumb.closest('.index-container');
|
||||
if (container) {
|
||||
const cRect = container.getBoundingClientRect();
|
||||
const tRect = thumb.getBoundingClientRect();
|
||||
const navbarH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--navbar-h')) || 50;
|
||||
const vh = window.innerHeight || document.documentElement.clientHeight;
|
||||
const isVisible = tRect.bottom > navbarH && tRect.top < vh;
|
||||
if (!isVisible || forceCenter) {
|
||||
const targetScrollTop = container.scrollTop + (tRect.top - cRect.top) - (container.clientHeight / 2) + (tRect.height / 2);
|
||||
container.scrollTop = Math.max(0, targetScrollTop);
|
||||
}
|
||||
} else {
|
||||
thumb.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
|
||||
}
|
||||
if (document.querySelector('.index-container') && window.scrollY !== 0) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
const updateOnaraActiveItem = (itemid, url, forceScroll = false, slug = null) => {
|
||||
if (!isOnaraActive()) return null;
|
||||
// Clear onara-active from any and all elements to guarantee only 1 item is selected
|
||||
@@ -1673,14 +1697,7 @@ window.cancelAnimFrame = (function () {
|
||||
|
||||
if (targetThumb) {
|
||||
targetThumb.classList.add('onara-active');
|
||||
const rect = targetThumb.getBoundingClientRect();
|
||||
const navbarH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--navbar-h')) || 50;
|
||||
const vh = window.innerHeight || document.documentElement.clientHeight;
|
||||
// If any part of the thumbnail is already visible in the viewport, do not scroll
|
||||
const isVisible = rect.bottom > navbarH && rect.top < vh;
|
||||
if (!isVisible || forceScroll) {
|
||||
targetThumb.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
|
||||
}
|
||||
scrollOnaraThumbIntoView(targetThumb, forceScroll);
|
||||
}
|
||||
return targetThumb;
|
||||
};
|
||||
@@ -1804,7 +1821,7 @@ window.cancelAnimFrame = (function () {
|
||||
synthThumb.innerHTML = '<div class="thumb-indicators"></div><p></p>';
|
||||
oldPosts.prepend(synthThumb);
|
||||
if (typeof window.initLazyLoading === 'function') window.initLazyLoading();
|
||||
synthThumb.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'instant' });
|
||||
scrollOnaraThumbIntoView(synthThumb, true);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('[ONARA] Failed to sync background grid:', err);
|
||||
|
||||
+51
-16
@@ -2670,6 +2670,7 @@ window.initUploadForm = (selector) => {
|
||||
|
||||
let successCount = 0;
|
||||
let lastData = null;
|
||||
const uploadedResults = [];
|
||||
|
||||
for (let i = 0; i < selectedFiles.length; i++) {
|
||||
const item = selectedFiles[i];
|
||||
@@ -2765,6 +2766,7 @@ window.initUploadForm = (selector) => {
|
||||
if (res.success) {
|
||||
successCount++;
|
||||
lastData = res;
|
||||
uploadedResults.push(res);
|
||||
if (res.pending) {
|
||||
// Background URL download — show tracker widget entry
|
||||
if (window.urlUploadTracker) {
|
||||
@@ -2830,30 +2832,63 @@ window.initUploadForm = (selector) => {
|
||||
|
||||
if (successCount > 0) {
|
||||
if (dragModal) dragModal.classList.remove('show');
|
||||
const dropModal = document.getElementById('upload-drag-modal');
|
||||
if (dropModal) dropModal.classList.remove('show');
|
||||
form._f0ckUploader.reset();
|
||||
if (isShitpost) {
|
||||
if (lastData?.manual_approval && typeof window.flashMessage === 'function') {
|
||||
window.flashMessage(window.f0ckI18n?.upload_pending_approval_patient || 'Upload awaits approval', 3000, 'warning');
|
||||
}
|
||||
} else {
|
||||
if (lastData?.manual_approval) {
|
||||
if (typeof window.flashMessage === 'function') {
|
||||
window.flashMessage(window.f0ckI18n?.upload_pending_approval_patient || 'Upload awaits approval', 3000, 'warning');
|
||||
}
|
||||
} else if (!dragModal && statusDiv) {
|
||||
statusDiv.innerHTML = '✓ ' + (lastData?.msg || 'Upload successful');
|
||||
statusDiv.className = 'upload-status success';
|
||||
}
|
||||
}
|
||||
|
||||
// URL background uploads do not redirect; standard file uploads redirect back to main page ('/')
|
||||
const isBgUrlUpload = lastData?.pending && selectedFiles.every(i => i.type === 'url');
|
||||
if (isBgUrlUpload) {
|
||||
if (typeof window.flashMessage === 'function') {
|
||||
window.flashMessage((window.f0ckI18n && window.f0ckI18n.url_upload_started) || 'Background upload started', 3000, 'info');
|
||||
}
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
if (lastData?.manual_approval) {
|
||||
if (typeof window.flashMessage === 'function') {
|
||||
window.flashMessage(window.f0ckI18n?.upload_pending_approval_patient || 'Upload awaits approval', 3000, 'warning');
|
||||
}
|
||||
} else {
|
||||
const successMsg = successCount > 1
|
||||
? `${successCount} items uploaded successfully!`
|
||||
: (lastData?.msg || 'Upload successful');
|
||||
if (typeof window.flashMessage === 'function') {
|
||||
window.flashMessage(successMsg, 3000, 'success');
|
||||
} else if (!dragModal && statusDiv) {
|
||||
statusDiv.innerHTML = '✓ ' + successMsg;
|
||||
statusDiv.className = 'upload-status success';
|
||||
}
|
||||
}
|
||||
|
||||
// Seamless live injection without hard reload
|
||||
if (window.location.pathname === '/upload') {
|
||||
if (typeof window.loadPageAjax === 'function') {
|
||||
window.loadPageAjax('/', true, { bypassCache: true });
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
}
|
||||
} else {
|
||||
// Prepend items to live grid seamlessly
|
||||
if (window.NotificationSystemInstance && typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
||||
for (const up of uploadedResults) {
|
||||
if (!up.manual_approval && !up.pending && up.itemid) {
|
||||
window.NotificationSystemInstance.handleNewItem({
|
||||
id: up.itemid,
|
||||
dest: up.dest,
|
||||
mime: up.mime,
|
||||
username: up.username || window.f0ckSession?.user || '',
|
||||
display_name: up.display_name || window.f0ckSession?.display_name || null,
|
||||
tag_id: up.tag_id ?? 0,
|
||||
is_oc: !!up.is_oc,
|
||||
slug: up.slug,
|
||||
visibility: up.visibility || 0
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Refresh grid & pagination seamlessly in background without reload
|
||||
if (typeof window.loadPageAjax === 'function') {
|
||||
window.loadPageAjax(window.location.pathname + window.location.search, true, { bypassCache: true, skipPush: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
restoreBtn();
|
||||
|
||||
Reference in New Issue
Block a user