sync article selected status via mutation observer
remove all rchk-related hacks
This commit is contained in:
parent
c97c755195
commit
ad5a43bf66
|
@ -79,12 +79,6 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
|
||||
if (row) {
|
||||
row.removeClassName("active");
|
||||
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
|
||||
|
||||
if (cb && !row.hasClassName("Selected"))
|
||||
cb.attr("checked", false);
|
||||
|
||||
Article.setActive(0);
|
||||
|
||||
if (event)
|
||||
event.stopPropagation();
|
||||
|
@ -282,11 +276,6 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
|
||||
$$("div[id*=RROW][class*=active]").each((e) => {
|
||||
e.removeClassName("active");
|
||||
|
||||
if (!e.hasClassName("Selected")) {
|
||||
const cb = dijit.getEnclosingWidget(e.select(".rchk")[0]);
|
||||
if (cb) cb.attr("checked", false);
|
||||
}
|
||||
});
|
||||
|
||||
const row = $("RROW-" + id);
|
||||
|
@ -294,21 +283,11 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
if (row) {
|
||||
Article.unpack(row);
|
||||
|
||||
if (row.hasClassName("Unread")) {
|
||||
Headlines.toggleUnread(id, 0);
|
||||
}
|
||||
|
||||
row.removeClassName("Unread");
|
||||
row.addClassName("active");
|
||||
|
||||
if (!row.hasClassName("Selected")) {
|
||||
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
|
||||
if (cb) cb.attr("checked", true);
|
||||
}
|
||||
|
||||
PluginHost.run(PluginHost.HOOK_ARTICLE_SET_ACTIVE, row.getAttribute("data-article-id"));
|
||||
}
|
||||
|
||||
//Headlines.updateSelectedPrompt();
|
||||
},
|
||||
getActive: function () {
|
||||
const row = document.querySelector("#headlines-frame > div[id*=RROW][class*=active]");
|
||||
|
|
|
@ -29,7 +29,7 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
hl.selected = row.hasClassName("Selected");
|
||||
hl.active = row.hasClassName("active");
|
||||
|
||||
modified.push({id: hl.id, new: hl, old: hl_old});
|
||||
modified.push({id: hl.id, new: hl, old: hl_old, row: row});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,10 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
tpub: [],
|
||||
read: [],
|
||||
unread: [],
|
||||
select: [],
|
||||
deselect: [],
|
||||
activate: [],
|
||||
deactivate: [],
|
||||
};
|
||||
|
||||
modified.each(function(m) {
|
||||
|
@ -57,6 +61,40 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
|
||||
if (m.old.unread != m.new.unread)
|
||||
m.new.unread ? ops.unread.push(m.id) : ops.read.push(m.id);
|
||||
|
||||
if (m.old.selected != m.new.selected)
|
||||
m.new.selected ? ops.select.push(m.row) : ops.deselect.push(m.row);
|
||||
|
||||
if (m.old.active != m.new.active)
|
||||
m.new.active ? ops.activate.push(m.row) : ops.deactivate.push(m.row);
|
||||
});
|
||||
|
||||
ops.select.each((row) => {
|
||||
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
|
||||
|
||||
if (cb)
|
||||
cb.attr('checked', true);
|
||||
});
|
||||
|
||||
ops.deselect.each((row) => {
|
||||
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
|
||||
|
||||
if (cb && !row.hasClassName("active"))
|
||||
cb.attr('checked', false);
|
||||
});
|
||||
|
||||
ops.activate.each((row) => {
|
||||
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
|
||||
|
||||
if (cb)
|
||||
cb.attr('checked', true);
|
||||
});
|
||||
|
||||
ops.deactivate.each((row) => {
|
||||
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
|
||||
|
||||
if (cb && !row.hasClassName("Selected"))
|
||||
cb.attr('checked', false);
|
||||
});
|
||||
|
||||
if (ops.tmark.length != 0)
|
||||
|
@ -924,8 +962,6 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
} else {
|
||||
row.removeClassName("Selected");
|
||||
}
|
||||
|
||||
//this.updateSelectedPrompt();
|
||||
},
|
||||
select: function (mode, articleId) {
|
||||
// mode = all,none,unread,invert,marked,published
|
||||
|
@ -955,32 +991,17 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = rows[i];
|
||||
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
|
||||
|
||||
switch (mode) {
|
||||
case "none":
|
||||
row.removeClassName("Selected");
|
||||
|
||||
if (!row.hasClassName("active"))
|
||||
cb.attr("checked", false);
|
||||
break;
|
||||
case "invert":
|
||||
if (row.hasClassName("Selected")) {
|
||||
row.removeClassName("Selected");
|
||||
|
||||
if (!row.hasClassName("active"))
|
||||
cb.attr("checked", false);
|
||||
} else {
|
||||
row.addClassName("Selected");
|
||||
cb.attr("checked", true);
|
||||
}
|
||||
row.toggleClassName("Selected");
|
||||
break;
|
||||
default:
|
||||
row.addClassName("Selected");
|
||||
cb.attr("checked", true);
|
||||
}
|
||||
|
||||
//Headlines.updateSelectedPrompt();
|
||||
}
|
||||
},
|
||||
archiveSelection: function () {
|
||||
|
@ -1090,15 +1111,6 @@ define(["dojo/_base/declare"], function (declare) {
|
|||
var e = $("RROW-" + ids_to_mark[i]);
|
||||
e.removeClassName("Unread");
|
||||
}
|
||||
|
||||
const query = {
|
||||
op: "rpc", method: "catchupSelected",
|
||||
cmode: 0, ids: ids_to_mark.toString()
|
||||
};
|
||||
|
||||
xhrPost("backend.php", query, (transport) => {
|
||||
App.handleRpcJson(transport);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
14
js/tt-rss.js
14
js/tt-rss.js
|
@ -396,18 +396,8 @@ require(["dojo/_base/kernel",
|
|||
if (id) {
|
||||
const row = $("RROW-" + id);
|
||||
|
||||
if (row) {
|
||||
const cb = dijit.getEnclosingWidget(
|
||||
row.select(".rchk")[0]);
|
||||
|
||||
if (cb) {
|
||||
if (!row.hasClassName("active"))
|
||||
cb.attr("checked", !cb.attr("checked"));
|
||||
|
||||
Headlines.onRowChecked(cb);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (row)
|
||||
row.toggleClassName("Selected");
|
||||
}
|
||||
};
|
||||
this.hotkey_actions["create_label"] = function () {
|
||||
|
|
Loading…
Reference in New Issue