forked from rDrama/rDrama
make post navigation buttons appear faster
parent
65e656b79f
commit
9e0cb818d3
|
@ -32,38 +32,3 @@ if (fake_textarea) {
|
|||
location.href = fake_textarea.dataset.href;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//POST NAVIGATION
|
||||
|
||||
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_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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
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_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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
|
@ -307,6 +307,8 @@
|
|||
</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">
|
||||
|
|
Loading…
Reference in New Issue