forked from rDrama/rDrama
1
0
Fork 0

move "next post" to navbar

master
Aevann 2024-01-31 20:52:22 +02:00
parent d9b0c97930
commit 3150a4c3ec
3 changed files with 10 additions and 37 deletions

View File

@ -2,30 +2,9 @@ const post_permalinks = sessionStorage.getItem("post_permalinks").split(', ');
const current_index = post_permalinks.indexOf(`'${location.href}'`)
if (current_index > -1) {
const id_after = post_permalinks[current_index+1]
const id_before = post_permalinks[current_index-1]
if (id_before || id_after) {
document.getElementById('post_navigation').classList.remove('d-none')
}
if (id_before) {
document.getElementById('post_before').classList.remove('disabled')
document.getElementById('post_before').href = id_before.slice(1, -1)
}
if (id_after) {
document.getElementById('post_after').classList.remove('disabled')
document.getElementById('post_navigation').classList.remove('d-none')
document.getElementById('post_after').href = id_after.slice(1, -1)
}
document.addEventListener('keydown', (e) => {
if (document.activeElement.tagName != 'TEXTAREA' && document.activeElement.tagName != 'INPUT') {
if (id_before && e.key == 'ArrowLeft') {
location.href = id_before.slice(1, -1)
}
else if (id_after && e.key == 'ArrowRight') {
location.href = id_after.slice(1, -1)
}
}
})
}

View File

@ -243,6 +243,15 @@
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto d-none d-md-flex mr-3">
{% if request.path.startswith('/post/') and p %}
<li id="post_navigation" class="d-none nav-item d-flex align-items-center text-center justify-content-center mx-1">
<a id="post_after" class="nav-link" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Next Post">
<i class="fas fa-arrow-right"></i>
</a>
</li>
<script src="{{'js/post_navigation.js' | asset}}"></script>
{% endif %}
{% if not (v and v.patron) %}
<li id="header--donate--item" class="nav-item d-flex align-items-center justify-content-center mx-1 mr-2">
<a class="btn btn-primary" href="/donate">Donate</a>

View File

@ -294,21 +294,6 @@
<div autocomplete="off" class="markdown d-none border my-2 p-3 rounded" id="markdown-{{p.fullname}}" readonly>{{p.body.strip()}}</div>
{% endif %}
<div id="post_navigation" class="row d-none my-2 my-md-4" style="justify-content: center">
<a id="post_before" class="disabled btn btn-primary btn-block m-0 shop-tab award-tab">
<span class="mr-auto ml-auto">
<i class="fas fa-arrow-left"></i> Previous Post
</span>
</a>
<a id="post_after" class="disabled btn btn-primary btn-block m-0 shop-tab award-tab">
<span class="mr-auto ml-auto">
<i class="fas fa-arrow-right"></i> Next Post
</span>
</a>
</div>
<script src="{{'js/post_navigation.js' | asset}}"></script>
<div class="row border-md-0 comment-section pb-3">
<div class="col border-top">
<div class="comments-count py-3">