Dokumentum helye
cript>
(function(){
// ha van ragadós fejléced, írd át a szelektort vagy a fix pixelt
var HEADER_SELECTOR = '.navbar';
function headerOffset(){
var h = document.querySelector(HEADER_SELECTOR);
return h ? Math.ceil(h.getBoundingClientRect().height) : 0;
}
function findTarget(id){
if(!id) return null;
id = id.replace(/^#/, '');
return document.getElementById(id) || document.querySelector('[name="'+CSS.escape(id)+'"]');
}
function smoothTo(hash){
var el = findTarget(hash);
if(!el) return false;
var top = el.getBoundingClientRect().top + window.pageYOffset - headerOffset() - 8;
window.scrollTo({ top: top, behavior: 'smooth' });
return true;
}
function wireLinks(){
// csak az Adatkezelési beágyazott dobozban lévő linkekre
$('#gendoc_ws_at').on('click', 'a[href*="#"]', function(e){
var href = $(this).attr('href') || '';
var hash = href.split('#').pop();
if(!hash) return; // nincs hash
// próbáljunk meg saját görgetést – csak akkor preventDefault, ha van tényleges célpont
if (smoothTo(hash)) {
e.preventDefault();
if (history.pushState) history.pushState(null, '', '#'+hash);
}
});
}
function onLoaded(){
// hash-sel érkezéskor is igazítsuk helyre
if (window.location.hash) {
setTimeout(function(){ smoothTo(window.location.hash); }, 50);
}
// biztonsági CSS: natív ugrásoknál is legyen offset
var style = document.createElement('style');
style.textContent = '#gendoc_ws_at [id], #gendoc_ws_at [name]{scroll-margin-top:'+(headerOffset()+8)+'px}';
document.head.appendChild(style);
wireLinks();
window.addEventListener('hashchange', function(){ smoothTo(window.location.hash); });
}
// ha a Fogyasztóbarát tartalom már betöltődött, a #gendoc_ws_at tele van HTML-lel
// kicsi késleltetéssel futtassuk
document.addEventListener('DOMContentLoaded', function(){ setTimeout(onLoaded, 100); });
})();