tweak Headlines.click: ctrl-click toggles selection, shift-click selects range
This commit is contained in:
parent
3906b27781
commit
d876cca22a
|
@ -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);
|
||||
|
||||
console.log(Article.getActive(), id, ids);
|
||||
|
||||
for (let i = 0; i < ids.length; i++)
|
||||
Headlines.select('all', ids[i]);
|
||||
|
||||
} else if (event.ctrlKey) {
|
||||
Headlines.select('invert', id);
|
||||
} else {
|
||||
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 {
|
||||
if (event.ctrlKey) {
|
||||
Article.openInNewWindow(id);
|
||||
Headlines.toggleUnread(id, 0);
|
||||
} else {
|
||||
Article.view(id);
|
||||
}
|
||||
}
|
||||
|
||||
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]";
|
||||
|
|
Loading…
Reference in New Issue