set items to read on click/middle-click of external link
This commit is contained in:
parent
d9f91fd919
commit
cc888e2a55
2 changed files with 26 additions and 2 deletions
|
@ -12,6 +12,19 @@ function onClick(selector, callback, noPreventDefault) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onAuxClick(selector, callback, noPreventDefault) {
|
||||||
|
let elements = document.querySelectorAll(selector);
|
||||||
|
elements.forEach((element) => {
|
||||||
|
element.onauxclick = (event) => {
|
||||||
|
if (!noPreventDefault) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(event);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Show and hide the main menu on mobile devices.
|
// Show and hide the main menu on mobile devices.
|
||||||
function toggleMainMenu() {
|
function toggleMainMenu() {
|
||||||
let menu = document.querySelector(".header nav ul");
|
let menu = document.querySelector(".header nav ul");
|
||||||
|
@ -115,11 +128,13 @@ function markPageAsRead() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle entry status changes from the list view and entry view.
|
// Handle entry status changes from the list view and entry view.
|
||||||
function handleEntryStatus(element) {
|
function handleEntryStatus(element, setToRead) {
|
||||||
let toasting = !element;
|
let toasting = !element;
|
||||||
let currentEntry = findEntry(element);
|
let currentEntry = findEntry(element);
|
||||||
if (currentEntry) {
|
if (currentEntry) {
|
||||||
|
if (!setToRead || currentEntry.querySelector("a[data-toggle-status]").dataset.value == "unread") {
|
||||||
toggleEntryStatus(currentEntry, toasting);
|
toggleEntryStatus(currentEntry, toasting);
|
||||||
|
}
|
||||||
if (isListView() && currentEntry.classList.contains('current-item')) {
|
if (isListView() && currentEntry.classList.contains('current-item')) {
|
||||||
goToNextListItem();
|
goToNextListItem();
|
||||||
}
|
}
|
||||||
|
|
9
ui/static/js/bootstrap.js
vendored
9
ui/static/js/bootstrap.js
vendored
|
@ -61,6 +61,15 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
request.execute();
|
request.execute();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
onClick("a[data-original-link]", (event) => {
|
||||||
|
handleEntryStatus(event.target, true);
|
||||||
|
}, true);
|
||||||
|
onAuxClick("a[data-original-link]", (event) => {
|
||||||
|
if (event.button == 1) {
|
||||||
|
handleEntryStatus(event.target, true);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
if (document.documentElement.clientWidth < 600) {
|
if (document.documentElement.clientWidth < 600) {
|
||||||
onClick(".logo", () => toggleMainMenu());
|
onClick(".logo", () => toggleMainMenu());
|
||||||
onClick(".header nav li", (event) => onClickMainMenuListItem(event));
|
onClick(".header nav li", (event) => onClickMainMenuListItem(event));
|
||||||
|
|
Loading…
Reference in a new issue