logo fix attempt 1
This commit is contained in:
1 parent
36df765000
commit
3674f07716
2 files changed
+40
-12
No files matched your search
@@ -111,6 +111,27 @@
|
||||
pushDownTopBars(offset);
|
||||
}
|
||||
|
||||
// Hide the default server-name text next to the top-bar logo icon, leaving
|
||||
// just the (now custom) logo image in place. "icon-transparent" matches the
|
||||
// filename inject-banner.sh replaces for the top-bar logo; keep these two
|
||||
// in sync if that ever changes again.
|
||||
const LOGO_IMG_MATCH = 'icon-transparent';
|
||||
|
||||
function hideLogoText() {
|
||||
const logoImg = document.querySelector('img[src*="' + LOGO_IMG_MATCH + '"]');
|
||||
if (!logoImg) return;
|
||||
const container = logoImg.parentElement;
|
||||
if (!container) return;
|
||||
Array.prototype.forEach.call(container.childNodes, function (node) {
|
||||
if (node === logoImg) return;
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
if (node.textContent.trim()) node.textContent = '';
|
||||
} else if (node.nodeType === Node.ELEMENT_NODE && node.style.display !== 'none') {
|
||||
node.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isHomePage() {
|
||||
const h = window.location.hash;
|
||||
return h === '' || h === '#' || h === '#/home' || h === '#!'
|
||||
@@ -160,22 +181,24 @@
|
||||
debounceTimer = setTimeout(function () {
|
||||
update();
|
||||
applyOffset();
|
||||
hideLogoText();
|
||||
}, delay || 150);
|
||||
}
|
||||
|
||||
// React to SPA navigation
|
||||
window.addEventListener('hashchange', update);
|
||||
window.addEventListener('hashchange', function () { update(); hideLogoText(); });
|
||||
window.addEventListener('resize', function () { scheduleUpdate(); });
|
||||
|
||||
// Watch for Jellyfin's deferred body rendering (SPA bootstraps after
|
||||
// DOMContentLoaded) and re-run on DOM churn, since the nav bar can be
|
||||
// unmounted/remounted by the SPA router.
|
||||
// DOMContentLoaded) and re-run on DOM churn, since the nav bar (and the
|
||||
// logo it contains) can be unmounted/remounted by the SPA router.
|
||||
const observer = new MutationObserver(function () { scheduleUpdate(); });
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
update();
|
||||
hideLogoText();
|
||||
});
|
||||
|
||||
// Fallback: run immediately if DOMContentLoaded already fired
|
||||
if (document.readyState !== 'loading') update();
|
||||
if (document.readyState !== 'loading') { update(); hideLogoText(); }
|
||||
})();
|
||||
Reference in new issue
Block a user