cd score layout modern fixes

This commit is contained in:
2026-05-24 22:04:07 +02:00
parent f9e45327bf
commit b2584763ee
4 changed files with 48 additions and 11 deletions

View File

@@ -12866,6 +12866,11 @@ textarea#profile_description {
flex-wrap: wrap;
}
body.layout-modern .xd-score-wrapper {
margin: 0;
padding: 0px 5px 0px 5px;
}
@keyframes xd-pulse {
0%,

View File

@@ -1262,9 +1262,34 @@ class CommentSystem {
}
// Save xd-score-wrapper before innerHTML wipe.
// On first load it lives as a previous sibling (server-rendered); afterwards inside.
let xdWrapperHtml = null;
const xdInside = this.container.querySelector('.xd-score-wrapper');
if (xdInside) {
xdWrapperHtml = xdInside.outerHTML;
} else {
const prev = this.container.previousElementSibling;
if (prev && prev.classList.contains('xd-score-wrapper')) {
xdWrapperHtml = prev.outerHTML;
prev.remove();
}
}
const mediaState = this.saveMediaState();
this.container.innerHTML = html;
this.restoreMediaState(mediaState);
// Re-inject xd-score-wrapper between the comment input and the comments list
if (xdWrapperHtml) {
const commentsList = this.container.querySelector('.comments-list');
if (commentsList) {
const tmp = document.createElement('div');
tmp.innerHTML = xdWrapperHtml;
const xdEl = tmp.firstElementChild;
if (xdEl) this.container.insertBefore(xdEl, commentsList);
}
}
this.syncSubscribeButton(isSubscribed);
CommentSystem.autoplayConvertedGifs(this.container);

View File

@@ -4923,9 +4923,6 @@ window.cancelAnimFrame = (function () {
const pageItemId = container.dataset.itemId;
if (pageItemId && String(pageItemId) !== String(itemId)) return;
const favs = document.getElementById('favs');
if (!favs) return;
document.querySelectorAll('.xd-score-wrapper').forEach(w => w.remove());
if (score <= 0) return;
@@ -4935,7 +4932,15 @@ window.cancelAnimFrame = (function () {
const newWrapper = document.createElement('div');
newWrapper.className = 'xd-score-wrapper';
newWrapper.innerHTML = `<span class="xd-score-badge ${meta.cls}" tooltip="xD Score: ${score} pts" flow="up">${meta.label} <span class="xd-score-num">${score}</span></span>`;
favs.parentNode.insertBefore(newWrapper, favs.nextSibling);
// Insert inside container, before .comments-list — matching the position
// that comments.js uses after each render.
const commentsList = container.querySelector('.comments-list');
if (commentsList) {
container.insertBefore(newWrapper, commentsList);
} else {
container.parentNode.insertBefore(newWrapper, container);
}
};
window.updateXdBadgeFromScore = (itemId, score) => {

View File

@@ -5,6 +5,14 @@
{{-- LEFT SIDEBAR: comments + tags --}}
<div class="item-sidebar-left">
@if(enable_xd_score && item.xd_score > 0)
<div class="xd-score-wrapper">
<span class="xd-score-badge xd-tier-{{ item.xd_tier }}" tooltip="xD Score: {{ item.xd_score }} pts" flow="up">
{{ item.xd_label }} <span class="xd-score-num">{{ item.xd_score }}</span>
</span>
</div>
@endif
@if(session || !hide_comments_from_public)
<div id="comments-container"
data-item-id="{{ item.id }}"
@@ -148,13 +156,7 @@
<a href="/user/{{ fav.user.toLowerCase() }}" tooltip="{!! fav.display_name || fav.user !!}" flow="up"><img src="@if(fav.avatar_file)/a/{{ fav.avatar_file }}@elseif(fav.avatar)/t/{{ fav.avatar }}.webp@else/a/default.png@endif" style="height: 32px; width: 32px@if(fav.username_color); border-color: {{ fav.username_color }}@endif" loading="lazy" /></a>
@endeach
</span>
@if(enable_xd_score && item.xd_score > 0)
<div class="xd-score-wrapper">
<span class="xd-score-badge xd-tier-{{ item.xd_tier }}" tooltip="xD Score: {{ item.xd_score }} pts" flow="up">
{{ item.xd_label }} <span class="xd-score-num">{{ item.xd_score }}</span>
</span>
</div>
@endif
</div>
</div>