mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 23:00:16 +00:00
Add viewport-aware keyboard navigation site-wide
Added global KJVNav helpers to base.html and updated 32 templates to start keyboard selection from the viewport when the current selection is off-screen. This provides a more intuitive navigation experience - pressing up/down after scrolling starts from what's visible rather than jumping to an off-screen location. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1613,6 +1613,26 @@
|
||||
});
|
||||
})();
|
||||
|
||||
// Global viewport helpers for keyboard navigation
|
||||
window.KJVNav = {
|
||||
isInViewport: function(el) {
|
||||
if (!el) return false;
|
||||
var rect = el.getBoundingClientRect();
|
||||
return rect.top < window.innerHeight && rect.bottom > 0;
|
||||
},
|
||||
findFirstVisibleIndex: function(elements) {
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
if (this.isInViewport(elements[i])) return i;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
isSelectionOffScreen: function(elements, selectedIndex) {
|
||||
if (selectedIndex < 0) return true;
|
||||
if (selectedIndex >= elements.length) return true;
|
||||
return !this.isInViewport(elements[selectedIndex]);
|
||||
}
|
||||
};
|
||||
|
||||
// Keyboard shortcuts
|
||||
document.addEventListener('keydown', function(e) {
|
||||
// Don't trigger if user is typing in an input field
|
||||
|
||||
@@ -323,11 +323,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -321,11 +321,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -321,11 +321,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -372,11 +372,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -319,11 +319,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -403,13 +403,21 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// Up arrow or k: Previous chapter
|
||||
if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
selectChapter(selectedChapterIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(chapterLinks, selectedChapterIndex)) {
|
||||
selectChapter(KJVNav.findFirstVisibleIndex(chapterLinks));
|
||||
} else {
|
||||
selectChapter(selectedChapterIndex - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Down arrow or j: Next chapter
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectChapter(selectedChapterIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(chapterLinks, selectedChapterIndex)) {
|
||||
selectChapter(KJVNav.findFirstVisibleIndex(chapterLinks));
|
||||
} else {
|
||||
selectChapter(selectedChapterIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Enter: Go to selected chapter
|
||||
|
||||
@@ -464,13 +464,21 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// Up arrow or k: Previous verse
|
||||
if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
selectVerse(selectedVerseIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(verses, selectedVerseIndex)) {
|
||||
selectVerse(KJVNav.findFirstVisibleIndex(verses));
|
||||
} else {
|
||||
selectVerse(selectedVerseIndex - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Down arrow or j: Next verse
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectVerse(selectedVerseIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(verses, selectedVerseIndex)) {
|
||||
selectVerse(KJVNav.findFirstVisibleIndex(verses));
|
||||
} else {
|
||||
selectVerse(selectedVerseIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Enter: Go to selected verse page
|
||||
|
||||
@@ -532,11 +532,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectCard(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(verseCards, selectedIndex)) {
|
||||
selectCard(KJVNav.findFirstVisibleIndex(verseCards));
|
||||
} else {
|
||||
selectCard(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectCard(0);
|
||||
else selectCard(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(verseCards, selectedIndex)) {
|
||||
selectCard(KJVNav.findFirstVisibleIndex(verseCards));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectCard(0);
|
||||
} else {
|
||||
selectCard(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -171,11 +171,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectNode(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(nodes, selectedIndex)) {
|
||||
selectNode(KJVNav.findFirstVisibleIndex(nodes));
|
||||
} else {
|
||||
selectNode(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectNode(0);
|
||||
else selectNode(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(nodes, selectedIndex)) {
|
||||
selectNode(KJVNav.findFirstVisibleIndex(nodes));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectNode(0);
|
||||
} else {
|
||||
selectNode(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -173,11 +173,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectNode(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(nodes, selectedIndex)) {
|
||||
selectNode(KJVNav.findFirstVisibleIndex(nodes));
|
||||
} else {
|
||||
selectNode(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectNode(0);
|
||||
else selectNode(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(nodes, selectedIndex)) {
|
||||
selectNode(KJVNav.findFirstVisibleIndex(nodes));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectNode(0);
|
||||
} else {
|
||||
selectNode(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -444,11 +444,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectCard(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(cards, selectedIndex)) {
|
||||
selectCard(KJVNav.findFirstVisibleIndex(cards));
|
||||
} else {
|
||||
selectCard(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectCard(0);
|
||||
else selectCard(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(cards, selectedIndex)) {
|
||||
selectCard(KJVNav.findFirstVisibleIndex(cards));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectCard(0);
|
||||
} else {
|
||||
selectCard(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
// Go to previous generation or back
|
||||
|
||||
@@ -704,11 +704,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectSection(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(sections, selectedIndex)) {
|
||||
selectSection(KJVNav.findFirstVisibleIndex(sections));
|
||||
} else {
|
||||
selectSection(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectSection(0);
|
||||
else selectSection(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(sections, selectedIndex)) {
|
||||
selectSection(KJVNav.findFirstVisibleIndex(sections));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectSection(0);
|
||||
} else {
|
||||
selectSection(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -75,11 +75,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectResult(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(results, selectedIndex)) {
|
||||
selectResult(KJVNav.findFirstVisibleIndex(results));
|
||||
} else {
|
||||
selectResult(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectResult(0);
|
||||
else selectResult(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(results, selectedIndex)) {
|
||||
selectResult(KJVNav.findFirstVisibleIndex(results));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectResult(0);
|
||||
} else {
|
||||
selectResult(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -325,11 +325,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -319,11 +319,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -140,11 +140,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else {
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectElement(0);
|
||||
else selectElement(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectElement(0);
|
||||
} else {
|
||||
selectElement(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -333,11 +333,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -244,11 +244,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else {
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectElement(0);
|
||||
else selectElement(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectElement(0);
|
||||
} else {
|
||||
selectElement(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -194,11 +194,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else {
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectElement(0);
|
||||
else selectElement(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectElement(0);
|
||||
} else {
|
||||
selectElement(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -376,12 +376,21 @@ hr.story-divider::before {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
// Start at first paragraph, not metadata
|
||||
selectElement(selectedIndex < 0 ? firstParagraphIndex : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else {
|
||||
// Start at first paragraph, not metadata
|
||||
selectElement(selectedIndex < 0 ? firstParagraphIndex : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectElement(0);
|
||||
else selectElement(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectElement(0);
|
||||
} else {
|
||||
selectElement(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -397,12 +397,21 @@ hr.story-divider::before {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
// Start at first paragraph, not metadata
|
||||
selectElement(selectedIndex < 0 ? firstParagraphIndex : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else {
|
||||
// Start at first paragraph, not metadata
|
||||
selectElement(selectedIndex < 0 ? firstParagraphIndex : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectElement(0);
|
||||
else selectElement(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectElement(0);
|
||||
} else {
|
||||
selectElement(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -354,11 +354,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectItem(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(allItems, selectedIndex)) {
|
||||
selectItem(KJVNav.findFirstVisibleIndex(allItems));
|
||||
} else {
|
||||
selectItem(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectItem(0);
|
||||
else selectItem(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(allItems, selectedIndex)) {
|
||||
selectItem(KJVNav.findFirstVisibleIndex(allItems));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectItem(0);
|
||||
} else {
|
||||
selectItem(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -322,11 +322,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -245,11 +245,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectSection(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(sections, selectedIndex)) {
|
||||
selectSection(KJVNav.findFirstVisibleIndex(sections));
|
||||
} else {
|
||||
selectSection(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectSection(0);
|
||||
else selectSection(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(sections, selectedIndex)) {
|
||||
selectSection(KJVNav.findFirstVisibleIndex(sections));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectSection(0);
|
||||
} else {
|
||||
selectSection(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -64,11 +64,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectLink(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(links, selectedIndex)) {
|
||||
selectLink(KJVNav.findFirstVisibleIndex(links));
|
||||
} else {
|
||||
selectLink(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectLink(0);
|
||||
else selectLink(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(links, selectedIndex)) {
|
||||
selectLink(KJVNav.findFirstVisibleIndex(links));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectLink(0);
|
||||
} else {
|
||||
selectLink(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -196,11 +196,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectSection(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(sections, selectedIndex)) {
|
||||
selectSection(KJVNav.findFirstVisibleIndex(sections));
|
||||
} else {
|
||||
selectSection(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectSection(0);
|
||||
else selectSection(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(sections, selectedIndex)) {
|
||||
selectSection(KJVNav.findFirstVisibleIndex(sections));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectSection(0);
|
||||
} else {
|
||||
selectSection(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -222,11 +222,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else {
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectElement(0);
|
||||
else selectElement(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectElement(0);
|
||||
} else {
|
||||
selectElement(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -321,11 +321,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -982,11 +982,20 @@
|
||||
// Normal navigation mode
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else {
|
||||
selectElement(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectElement(0);
|
||||
else selectElement(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(elements, selectedIndex)) {
|
||||
selectElement(KJVNav.findFirstVisibleIndex(elements));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectElement(0);
|
||||
} else {
|
||||
selectElement(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
// If on interlinear, enter word mode
|
||||
|
||||
@@ -70,11 +70,20 @@
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectRow(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(rows, selectedIndex)) {
|
||||
selectRow(KJVNav.findFirstVisibleIndex(rows));
|
||||
} else {
|
||||
selectRow(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectRow(0);
|
||||
else selectRow(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(rows, selectedIndex)) {
|
||||
selectRow(KJVNav.findFirstVisibleIndex(rows));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectRow(0);
|
||||
} else {
|
||||
selectRow(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
@@ -321,11 +321,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
if (e.key === 'ArrowDown' || e.key === 'j') {
|
||||
e.preventDefault();
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else {
|
||||
selectEntry(selectedIndex < 0 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowUp' || e.key === 'k') {
|
||||
e.preventDefault();
|
||||
if (selectedIndex <= 0) selectEntry(0);
|
||||
else selectEntry(selectedIndex - 1);
|
||||
if (KJVNav.isSelectionOffScreen(entries, selectedIndex)) {
|
||||
selectEntry(KJVNav.findFirstVisibleIndex(entries));
|
||||
} else if (selectedIndex <= 0) {
|
||||
selectEntry(0);
|
||||
} else {
|
||||
selectEntry(selectedIndex - 1);
|
||||
}
|
||||
} else if (e.key === 'ArrowLeft' || e.key === 'h') {
|
||||
e.preventDefault();
|
||||
history.back();
|
||||
|
||||
Reference in New Issue
Block a user