feat(frontend): align single post page 1:1 with Zibll
Restore Zibll float dual-column shell, fix single settings DTO key mapping, reorder article footer/actions, and match author bar, prev/next, title/body typography, and limit-height expand UX.
This commit is contained in:
1 parent
a651bd6d2d
commit
5ae1a9ad93
12 files changed
+626
-218
No files matched your search
+44
-32
@@ -190,15 +190,27 @@
|
||||
}
|
||||
|
||||
function initContentExpand() {
|
||||
document.querySelectorAll('.entry-content[data-nav]').forEach(function (content) {
|
||||
// Zibll-style: inject .read-more inside .limit-height and expand on click.
|
||||
document.querySelectorAll('.wp-posts-content.limit-height, .limit-height[data-nav]').forEach(function (content) {
|
||||
if (content.dataset.aksrtExpandBound === '1') return;
|
||||
content.dataset.aksrtExpandBound = '1';
|
||||
|
||||
// Only expand when server enabled maxheight (data-maxheight > 0).
|
||||
var customMax = parseInt(content.getAttribute('data-maxheight') || content.dataset.maxheight || '0', 10);
|
||||
if (!(customMax > 0)) return;
|
||||
var limit = customMax;
|
||||
if (content.scrollHeight <= limit) {
|
||||
// data-maxheight may be maxheight-80 (Zibll) or absolute maxheight; prefer style max-height.
|
||||
var styleMax = 0;
|
||||
if (content.style && content.style.maxHeight) {
|
||||
styleMax = parseInt(content.style.maxHeight, 10) || 0;
|
||||
}
|
||||
var limit = styleMax > 0 ? styleMax : (customMax > 0 ? customMax + 80 : 0);
|
||||
if (!(limit > 0) && customMax > 0) {
|
||||
limit = customMax;
|
||||
}
|
||||
if (!(limit > 0)) {
|
||||
content.classList.remove('limit-height');
|
||||
return;
|
||||
}
|
||||
|
||||
if (content.scrollHeight <= limit + 40) {
|
||||
content.classList.remove('limit-height');
|
||||
content.style.maxHeight = '';
|
||||
return;
|
||||
@@ -207,37 +219,37 @@
|
||||
content.classList.add('limit-height');
|
||||
content.style.maxHeight = limit + 'px';
|
||||
|
||||
var existingBtn = content.nextElementSibling;
|
||||
if (existingBtn && existingBtn.classList && existingBtn.classList.contains('content-expand-btn')) {
|
||||
return;
|
||||
}
|
||||
if (content.querySelector('.read-more')) return;
|
||||
|
||||
var button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'content-expand-btn';
|
||||
button.innerHTML = '<i class="fas fa-chevron-down" aria-hidden="true"></i> <span>展开阅读全文</span>';
|
||||
content.parentNode.insertBefore(button, content.nextSibling);
|
||||
var wrap = document.createElement('div');
|
||||
wrap.className = 'read-more';
|
||||
var link = document.createElement('a');
|
||||
link.href = 'javascript:;';
|
||||
link.className = 'read-more-open';
|
||||
link.innerHTML = '展开阅读全文<i class="fa ml10 fa-angle-down" aria-hidden="true"></i>';
|
||||
wrap.appendChild(link);
|
||||
content.appendChild(wrap);
|
||||
|
||||
button.addEventListener('click', function () {
|
||||
var expanded = content.classList.contains('is-expanded');
|
||||
if (expanded) {
|
||||
content.classList.remove('is-expanded');
|
||||
content.style.maxHeight = limit + 'px';
|
||||
button.classList.remove('is-expanded');
|
||||
button.querySelector('span').textContent = '展开阅读全文';
|
||||
content.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'start'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
content.classList.add('is-expanded');
|
||||
content.style.maxHeight = content.scrollHeight + 'px';
|
||||
button.classList.add('is-expanded');
|
||||
button.querySelector('span').textContent = '收起';
|
||||
link.addEventListener('click', function (event) {
|
||||
event.preventDefault();
|
||||
content.classList.remove('limit-height');
|
||||
content.style.maxHeight = '';
|
||||
wrap.remove();
|
||||
});
|
||||
});
|
||||
|
||||
// Compatibility: old external expand buttons.
|
||||
document.addEventListener('click', function (event) {
|
||||
var open = event.target.closest && event.target.closest('.read-more-open');
|
||||
if (!open) return;
|
||||
var limitBox = open.closest('.limit-height');
|
||||
if (!limitBox) return;
|
||||
event.preventDefault();
|
||||
limitBox.classList.remove('limit-height');
|
||||
limitBox.style.maxHeight = '';
|
||||
var more = open.closest('.read-more');
|
||||
if (more) more.remove();
|
||||
});
|
||||
}
|
||||
|
||||
function initFlashQueryCleanup() {
|
||||
|
||||
Reference in new issue
Block a user