Refine anchors

This commit is contained in:
Hillel Coren 2017-03-11 23:43:38 +02:00
parent e8daf15480
commit 261e65d918

View File

@ -333,15 +333,27 @@
} }
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if (isStorageSupported() && /\/settings\//.test(location.href)) {
var target = $(e.target).attr("href") // activated tab var target = $(e.target).attr("href") // activated tab
if (history.pushState) { if (history.pushState) {
history.pushState(null, null, target); history.pushState(null, null, target);
} }
if (isStorageSupported() && /\/settings\//.test(location.href)) { localStorage.setItem('last:settings_page', location.href.replace(location.hash, ''));
localStorage.setItem('last:settings_page', location.href);
} }
}); });
// set timeout onDomReady
setTimeout(delayedFragmentTargetOffset, 500);
// add scroll offset to fragment target (if there is one)
function delayedFragmentTargetOffset(){
var offset = $(':target').offset();
if (offset) {
var scrollto = offset.top - 180; // minus fixed header height
$('html, body').animate({scrollTop:scrollto}, 0);
}
}
}); });
</script> </script>