fix quick nav highlight
This commit is contained in:
@@ -14262,6 +14262,40 @@ body.scroller-active #gchat-reopen-bubble {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Settings quick-nav bar */
|
||||||
|
#settings-quicknav {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
padding: 8px 14px;
|
||||||
|
background: rgba(20,20,20,0.92);
|
||||||
|
border-bottom: 1px solid var(--nav-border-color);
|
||||||
|
position: fixed;
|
||||||
|
top: var(--navbar-h, 50px);
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 200;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
-webkit-backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
#settings-quicknav a {
|
||||||
|
font-size: 0.82em;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 4px 12px;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1px solid var(--nav-border-color);
|
||||||
|
color: var(--text-muted);
|
||||||
|
text-decoration: none;
|
||||||
|
transition: background 0.15s, color 0.15s, border-color 0.15s;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
#settings-quicknav a:hover,
|
||||||
|
#settings-quicknav a.active {
|
||||||
|
background: var(--accent);
|
||||||
|
color: #fff;
|
||||||
|
border-color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
@media (max-width: 600px) {
|
||||||
.settings {
|
.settings {
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
|
|||||||
@@ -23,40 +23,8 @@
|
|||||||
@endif
|
@endif
|
||||||
</nav>
|
</nav>
|
||||||
<style>
|
<style>
|
||||||
#settings-quicknav {
|
/* Push content down so the fixed nav doesn't overlap section headings */
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 6px;
|
|
||||||
padding: 8px 14px;
|
|
||||||
background: rgba(20,20,20,0.92);
|
|
||||||
border-bottom: 1px solid var(--nav-border-color);
|
|
||||||
position: fixed;
|
|
||||||
top: var(--navbar-h, 50px); /* sit just below the site navbar */
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
z-index: 200;
|
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
-webkit-backdrop-filter: blur(10px);
|
|
||||||
}
|
|
||||||
/* Push content down so the fixed nav doesn't overlap headings */
|
|
||||||
.settings { padding-top: 56px; }
|
.settings { padding-top: 56px; }
|
||||||
#settings-quicknav a {
|
|
||||||
font-size: 0.82em;
|
|
||||||
font-weight: 600;
|
|
||||||
padding: 4px 12px;
|
|
||||||
border-radius: 20px;
|
|
||||||
border: 1px solid var(--nav-border-color);
|
|
||||||
color: var(--text-muted);
|
|
||||||
text-decoration: none;
|
|
||||||
transition: background 0.15s, color 0.15s, border-color 0.15s;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
#settings-quicknav a:hover,
|
|
||||||
#settings-quicknav a.active {
|
|
||||||
background: var(--accent);
|
|
||||||
color: #fff;
|
|
||||||
border-color: var(--accent);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
(function(){
|
(function(){
|
||||||
@@ -69,48 +37,43 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set initial active from hash or default to first
|
function highlightTarget(hash) {
|
||||||
var initHash = location.hash;
|
if (!hash) return;
|
||||||
var links = nav.querySelectorAll('a[href^="#"]');
|
var el = document.querySelector(hash);
|
||||||
var firstLink = links[0];
|
if (!el) return;
|
||||||
if (initHash && nav.querySelector('a[href="' + initHash + '"]')) {
|
document.querySelectorAll('.comment-highlighted').forEach(function(c) {
|
||||||
setActive(initHash);
|
c.classList.remove('comment-highlighted');
|
||||||
} else if (firstLink) {
|
});
|
||||||
setActive(firstLink.getAttribute('href'));
|
el.classList.add('comment-highlighted');
|
||||||
}
|
}
|
||||||
|
|
||||||
// On load with a hash: highlight the target heading
|
function initFromHash() {
|
||||||
if (initHash) {
|
var hash = location.hash;
|
||||||
var target = document.querySelector(initHash);
|
if (hash && nav.querySelector('a[href="' + hash + '"]')) {
|
||||||
if (target) {
|
setActive(hash);
|
||||||
// Use rAF so the browser has scrolled to the target first
|
highlightTarget(hash);
|
||||||
requestAnimationFrame(function() {
|
} else {
|
||||||
document.querySelectorAll('.comment-highlighted').forEach(function(el) {
|
var first = nav.querySelector('a[href^="#"]');
|
||||||
el.classList.remove('comment-highlighted');
|
if (first) setActive(first.getAttribute('href'));
|
||||||
});
|
|
||||||
target.classList.add('comment-highlighted');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delegated click on the nav container — fires before document-level handlers
|
// Run now (direct page load) and after a tick (AJAX: URL updated after script runs)
|
||||||
|
initFromHash();
|
||||||
|
setTimeout(initFromHash, 50);
|
||||||
|
|
||||||
|
// Click: set active + highlight target immediately
|
||||||
nav.addEventListener('click', function(e) {
|
nav.addEventListener('click', function(e) {
|
||||||
var link = e.target.closest('a[href^="#"]');
|
var link = e.target.closest('a[href^="#"]');
|
||||||
if (!link) return;
|
if (!link) return;
|
||||||
setActive(link.getAttribute('href'));
|
|
||||||
// Highlight the target section
|
|
||||||
var href = link.getAttribute('href');
|
var href = link.getAttribute('href');
|
||||||
var el = document.querySelector(href);
|
setActive(href);
|
||||||
if (el) {
|
requestAnimationFrame(function() { highlightTarget(href); });
|
||||||
document.querySelectorAll('.comment-highlighted').forEach(function(c) {
|
|
||||||
c.classList.remove('comment-highlighted');
|
|
||||||
});
|
|
||||||
el.classList.add('comment-highlighted');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<!-- ═══════════════════════════════ PROFILE ═══════════════════════════════ -->
|
<!-- ═══════════════════════════════ PROFILE ═══════════════════════════════ -->
|
||||||
<h2 id="profile">{{ t('settings.profile') }}</h2>
|
<h2 id="profile">{{ t('settings.profile') }}</h2>
|
||||||
<fieldset style="border: 1px solid var(--nav-border-color); padding: 10px; border-radius: 4px; margin-bottom: 15px;">
|
<fieldset style="border: 1px solid var(--nav-border-color); padding: 10px; border-radius: 4px; margin-bottom: 15px;">
|
||||||
|
|||||||
Reference in New Issue
Block a user