mirror of
https://github.com/slawkens/myaac.git
synced 2026-02-06 13:16:22 +01:00
Settings: Possibility to navigate tabs through link
This commit is contained in:
@@ -152,9 +152,10 @@ class Settings implements \ArrayAccess
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($setting['type'] === 'category') {
|
if ($setting['type'] === 'category') {
|
||||||
|
$title = strtolower(str_replace(' ', '', $setting['title']));
|
||||||
?>
|
?>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link<?= ($i === 0 ? ' active' : ''); ?>" id="home-tab-<?= $i++; ?>" data-toggle="tab" href="#tab-<?= str_replace(' ', '', $setting['title']); ?>" type="button"><?= $setting['title']; ?></a>
|
<a class="nav-link<?= ($i === 0 ? ' active' : ''); ?>" id="home-tab-<?= $i++; ?>" data-toggle="tab" href="#tab-<?= $title; ?>" type="button"><?= $setting['title']; ?></a>
|
||||||
</li>
|
</li>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -175,8 +176,10 @@ class Settings implements \ArrayAccess
|
|||||||
if ($j++ !== 0) { // close previous category
|
if ($j++ !== 0) { // close previous category
|
||||||
echo '</tbody></table></div>';
|
echo '</tbody></table></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$title = strtolower(str_replace(' ', '', $setting['title']));
|
||||||
?>
|
?>
|
||||||
<div class="tab-pane fade show<?= ($j === 1 ? ' active' : ''); ?>" id="tab-<?= str_replace(' ', '', $setting['title']); ?>">
|
<div class="tab-pane fade show<?= ($j === 1 ? ' active' : ''); ?>" id="tab-<?= $title; ?>">
|
||||||
<?php
|
<?php
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,3 +165,31 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</script>
|
</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