diff options
author | 2018-10-14 16:28:24 +0200 | |
---|---|---|
committer | 2018-10-21 11:53:17 -0700 | |
commit | 8c65c78904225e92df045cac43700210936ca148 (patch) | |
tree | d98749eab3757161d9961bed5226e05e0eea1163 /ui/static/js | |
parent | 74c35ad000a09d689e501f5995a109708fb4ff00 (diff) | |
download | v2-8c65c78904225e92df045cac43700210936ca148.tar.gz v2-8c65c78904225e92df045cac43700210936ca148.tar.zst v2-8c65c78904225e92df045cac43700210936ca148.zip |
NavHandler: Make "g f" go to feed, or list of feeds
When you're reading an entry, you may want to go to the feed first,
before quickly continuing to reading all of the feeds with another "g
f".
Diffstat (limited to 'ui/static/js')
-rw-r--r-- | ui/static/js/bootstrap.js | 2 | ||||
-rw-r--r-- | ui/static/js/nav_handler.js | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/ui/static/js/bootstrap.js b/ui/static/js/bootstrap.js index 3c2bb359..5c0bfac9 100644 --- a/ui/static/js/bootstrap.js +++ b/ui/static/js/bootstrap.js @@ -9,7 +9,7 @@ document.addEventListener("DOMContentLoaded", function() { keyboardHandler.on("g u", () => navHandler.goToPage("unread")); keyboardHandler.on("g b", () => navHandler.goToPage("starred")); keyboardHandler.on("g h", () => navHandler.goToPage("history")); - keyboardHandler.on("g f", () => navHandler.goToPage("feeds")); + keyboardHandler.on("g f", () => navHandler.goToFeedOrFeeds()); keyboardHandler.on("g c", () => navHandler.goToPage("categories")); keyboardHandler.on("g s", () => navHandler.goToPage("settings")); keyboardHandler.on("ArrowLeft", () => navHandler.goToPrevious()); diff --git a/ui/static/js/nav_handler.js b/ui/static/js/nav_handler.js index 5f611e0a..dd106074 100644 --- a/ui/static/js/nav_handler.js +++ b/ui/static/js/nav_handler.js @@ -173,6 +173,17 @@ class NavHandler { } } + goToFeedOrFeeds() { + if (this.isEntry()) { + let feedAnchor = document.querySelector("span.entry-website a"); + if (feedAnchor !== null) { + window.location.href = feedAnchor.href; + } + } else { + this.goToPage('feeds'); + } + } + goToPreviousListItem() { let items = DomHelper.getVisibleElements(".items .item"); if (items.length === 0) { @@ -228,6 +239,10 @@ class NavHandler { } } + isEntry() { + return document.querySelector("section.entry") !== null; + } + isListView() { return document.querySelector(".items") !== null; } |