tweak Headlines.click: ctrl-click toggles selection, shift-click selects range

This commit is contained in:
Andrew Dolgov 2019-03-07 10:35:48 +03:00
parent 3906b27781
commit d876cca22a
1 changed files with 47 additions and 20 deletions

View File

@ -153,35 +153,38 @@ define(["dojo/_base/declare"], function (declare) {
click: function (event, id, in_body) {
in_body = in_body || false;
if (App.isCombinedMode()) {
if (event.shiftKey && Article.getActive()) {
Headlines.select('none');
if (!in_body && (event.ctrlKey || id == Article.getActive() || App.getInitParam("cdm_expanded"))) {
Article.openInNewWindow(id);
Headlines.toggleUnread(id, 0);
return false;
}
const ids = Headlines.getRange(Article.getActive(), id);
if (Article.getActive() != id) {
Article.setActive(id);
console.log(Article.getActive(), id, ids);
if (!App.getInitParam("cdm_expanded"))
Article.cdmScrollToId(id);
} else if (in_body) {
Headlines.toggleUnread(id, 0);
}
return in_body;
for (let i = 0; i < ids.length; i++)
Headlines.select('all', ids[i]);
} else if (event.ctrlKey) {
Headlines.select('invert', id);
} else {
if (event.ctrlKey) {
Article.openInNewWindow(id);
Headlines.toggleUnread(id, 0);
if (App.isCombinedMode()) {
if (Article.getActive() != id) {
Article.setActive(id);
if (!App.getInitParam("cdm_expanded"))
Article.cdmScrollToId(id);
} else if (in_body) {
Headlines.toggleUnread(id, 0);
}
return in_body;
} else {
Article.view(id);
}
return false;
}
return false;
},
initScrollHandler: function () {
$("headlines-frame").onscroll = (event) => {
@ -997,6 +1000,30 @@ define(["dojo/_base/declare"], function (declare) {
row.removeClassName("Selected");
}
},
getRange: function (start, stop) {
const rows = $$("#headlines-frame > div[id*=RROW]");
const results = [];
let collecting = false;
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
const id = row.getAttribute('data-article-id');
if (id == start || id == stop) {
if (!collecting) {
collecting = true;
} else {
results.push(id);
break;
}
}
if (collecting)
results.push(id);
}
return results;
},
select: function (mode, articleId) {
// mode = all,none,unread,invert,marked,published
let query = "#headlines-frame > div[id*=RROW]";