updateFloatingTitle: sync row marked/published status

This commit is contained in:
Andrew Dolgov 2018-12-07 09:09:09 +03:00
parent 8458dc2082
commit c4b01dd547
1 changed files with 16 additions and 3 deletions

View File

@ -155,7 +155,7 @@ define(["dojo/_base/declare"], function (declare) {
console.warn("scrollHandler", e); console.warn("scrollHandler", e);
} }
}, },
updateFloatingTitle: function (unread_only) { updateFloatingTitle: function (status_only) {
if (!App.isCombinedMode()/* || !App.getInitParam("cdm_expanded")*/) return; if (!App.isCombinedMode()/* || !App.getInitParam("cdm_expanded")*/) return;
const hf = $("headlines-frame"); const hf = $("headlines-frame");
@ -170,7 +170,7 @@ define(["dojo/_base/declare"], function (declare) {
const header = row.select(".header")[0]; const header = row.select(".header")[0];
const id = row.getAttribute("data-article-id"); const id = row.getAttribute("data-article-id");
if (unread_only || id != ft.getAttribute("data-article-id")) { if (status_only || id != ft.getAttribute("data-article-id")) {
if (id != ft.getAttribute("data-article-id")) { if (id != ft.getAttribute("data-article-id")) {
ft.setAttribute("data-article-id", id); ft.setAttribute("data-article-id", id);
@ -187,6 +187,16 @@ define(["dojo/_base/declare"], function (declare) {
else else
ft.removeClassName("Unread"); ft.removeClassName("Unread");
if (row.hasClassName("marked"))
ft.addClassName("marked");
else
ft.removeClassName("marked");
if (row.hasClassName("published"))
ft.addClassName("published");
else
ft.removeClassName("published");
PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, row); PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, row);
} }
@ -495,10 +505,11 @@ define(["dojo/_base/declare"], function (declare) {
const row = $("RROW-" + id); const row = $("RROW-" + id);
if (row) { if (row) {
row.toggleClassName("marked"); row.toggleClassName("marked");
query.mark = row.hasClassName("marked") ? 1 : 0; query.mark = row.hasClassName("marked") ? 1 : 0;
Headlines.updateFloatingTitle(true);
if (!client_only) if (!client_only)
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
App.handleRpcJson(transport); App.handleRpcJson(transport);
@ -514,6 +525,8 @@ define(["dojo/_base/declare"], function (declare) {
row.toggleClassName("published"); row.toggleClassName("published");
query.pub = row.hasClassName("published") ? 1 : 0; query.pub = row.hasClassName("published") ? 1 : 0;
Headlines.updateFloatingTitle(true);
if (!client_only) if (!client_only)
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
App.handleRpcJson(transport); App.handleRpcJson(transport);