mirror of
https://github.com/slawkens/myaac.git
synced 2026-02-06 21:26:22 +01:00
Settings: Possibility to navigate tabs through link
This commit is contained in:
@@ -165,3 +165,31 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
if ($('.tab-content').length) {
|
||||
|
||||
let url = window.location.href;
|
||||
let activeTab = url.substring(url.indexOf("#") + 1);
|
||||
|
||||
let $selector = $('[href="#' + activeTab + '"]')
|
||||
if ($selector.length) {
|
||||
$selector.tab('show');
|
||||
}
|
||||
}
|
||||
|
||||
let url = location.href.replace(/\/$/, "");
|
||||
$('a[data-toggle="tab"]').on("click", function() {
|
||||
let newUrl;
|
||||
const hash = $(this).attr("href");
|
||||
if(hash === "#home") {
|
||||
newUrl = url.split("#")[0];
|
||||
} else {
|
||||
newUrl = url.split("#")[0] + hash;
|
||||
}
|
||||
|
||||
history.replaceState(null, null, newUrl);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user