mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
Add toggle status button to entry page
This commit is contained in:
parent
4f62a704e2
commit
5341bbcbe2
11 changed files with 57 additions and 30 deletions
6
ui/static/js/bootstrap.js
vendored
6
ui/static/js/bootstrap.js
vendored
|
@ -46,7 +46,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
mouseHandler.onClick("a[data-toggle-status]", (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
let currentItem = DomHelper.findParent(event.target, "item");
|
||||
let currentItem = DomHelper.findParent(event.target, "entry");
|
||||
if (! currentItem) {
|
||||
currentItem = DomHelper.findParent(event.target, "item");
|
||||
}
|
||||
|
||||
if (currentItem) {
|
||||
EntryHandler.toggleEntryStatus(currentItem);
|
||||
}
|
||||
|
|
|
@ -15,35 +15,25 @@ class EntryHandler {
|
|||
|
||||
static toggleEntryStatus(element) {
|
||||
let entryID = parseInt(element.dataset.id, 10);
|
||||
let statuses = {read: "unread", unread: "read"};
|
||||
let link = element.querySelector("a[data-toggle-status]");
|
||||
|
||||
for (let currentStatus in statuses) {
|
||||
let newStatus = statuses[currentStatus];
|
||||
let currentStatus = link.dataset.value;
|
||||
let newStatus = currentStatus === "read" ? "unread" : "read";
|
||||
|
||||
if (element.classList.contains("item-status-" + currentStatus)) {
|
||||
element.classList.remove("item-status-" + currentStatus);
|
||||
element.classList.add("item-status-" + newStatus);
|
||||
this.updateEntriesStatus([entryID], newStatus);
|
||||
|
||||
this.updateEntriesStatus([entryID], newStatus);
|
||||
|
||||
let link = element.querySelector("a[data-toggle-status]");
|
||||
if (link) {
|
||||
this.toggleLinkStatus(link);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static toggleLinkStatus(link) {
|
||||
if (link.dataset.value === "read") {
|
||||
if (currentStatus === "read") {
|
||||
link.innerHTML = link.dataset.labelRead;
|
||||
link.dataset.value = "unread";
|
||||
} else {
|
||||
link.innerHTML = link.dataset.labelUnread;
|
||||
link.dataset.value = "read";
|
||||
}
|
||||
|
||||
if (element.classList.contains("item-status-" + currentStatus)) {
|
||||
element.classList.remove("item-status-" + currentStatus);
|
||||
element.classList.add("item-status-" + newStatus);
|
||||
}
|
||||
}
|
||||
|
||||
static toggleBookmark(element) {
|
||||
|
|
|
@ -71,6 +71,11 @@ class NavHandler {
|
|||
}
|
||||
|
||||
toggleEntryStatus() {
|
||||
if (! this.isListView()) {
|
||||
EntryHandler.toggleEntryStatus(document.querySelector(".entry"));
|
||||
return;
|
||||
}
|
||||
|
||||
let currentItem = document.querySelector(".current-item");
|
||||
if (currentItem !== null) {
|
||||
// The order is important here,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue