mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 15:15:56 +00:00
reuse menu objects while appending headline rows
This commit is contained in:
192
js/viewfeed.js
192
js/viewfeed.js
@@ -150,6 +150,8 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
|
|||||||
tmp.innerHTML = reply['headlines']['content'];
|
tmp.innerHTML = reply['headlines']['content'];
|
||||||
dojo.parser.parse(tmp);
|
dojo.parser.parse(tmp);
|
||||||
|
|
||||||
|
var new_rows = [];
|
||||||
|
|
||||||
while (tmp.hasChildNodes()) {
|
while (tmp.hasChildNodes()) {
|
||||||
var row = tmp.removeChild(tmp.firstChild);
|
var row = tmp.removeChild(tmp.firstChild);
|
||||||
|
|
||||||
@@ -157,6 +159,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
|
|||||||
dijit.byId("headlines-frame").domNode.appendChild(row);
|
dijit.byId("headlines-frame").domNode.appendChild(row);
|
||||||
|
|
||||||
loaded_article_ids.push(row.id);
|
loaded_article_ids.push(row.id);
|
||||||
|
new_rows.push(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +174,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
|
|||||||
markHeadline(ids[i]);
|
markHeadline(ids[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
initHeadlinesMenu();
|
initHeadlinesMenu(new_rows);
|
||||||
|
|
||||||
if (_infscroll_disable) {
|
if (_infscroll_disable) {
|
||||||
hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
|
hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
|
||||||
@@ -1978,61 +1981,27 @@ function headlinesMenuCommon(menu) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initHeadlinesMenu() {
|
function initHeadlinesMenu(append_rows) {
|
||||||
try {
|
try {
|
||||||
if (dijit.byId("headlinesMenu"))
|
if (!append_rows) {
|
||||||
dijit.byId("headlinesMenu").destroyRecursive();
|
|
||||||
|
|
||||||
var ids = [];
|
if (dijit.byId("headlinesMenu"))
|
||||||
|
dijit.byId("headlinesMenu").destroyRecursive();
|
||||||
|
|
||||||
if (!isCdmMode()) {
|
var ids = [];
|
||||||
nodes = $$("#headlines-frame > div[id*=RROW]");
|
|
||||||
} else {
|
|
||||||
nodes = $$("#headlines-frame span[id*=RTITLE]");
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.each(function(node) {
|
if (!isCdmMode()) {
|
||||||
ids.push(node.id);
|
nodes = $$("#headlines-frame > div[id*=RROW]");
|
||||||
});
|
} else {
|
||||||
|
nodes = $$("#headlines-frame span[id*=RTITLE]");
|
||||||
var menu = new dijit.Menu({
|
|
||||||
id: "headlinesMenu",
|
|
||||||
targetNodeIds: ids
|
|
||||||
});
|
|
||||||
|
|
||||||
var tmph = dojo.connect(menu, '_openMyself', function (event) {
|
|
||||||
var callerNode = event.target, match = null, tries = 0;
|
|
||||||
|
|
||||||
while (match == null && callerNode && tries <= 3) {
|
|
||||||
|
|
||||||
match = callerNode.getAttribute("data-article-id")
|
|
||||||
callerNode = callerNode.parentNode;
|
|
||||||
++tries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match) this.callerRowId = match;
|
nodes.each(function (node) {
|
||||||
|
ids.push(node.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
headlinesMenuCommon(menu);
|
|
||||||
|
|
||||||
menu.startup();
|
|
||||||
|
|
||||||
/* vgroup feed title menu */
|
|
||||||
|
|
||||||
var nodes = $$("#headlines-frame > div[class='cdmFeedTitle']");
|
|
||||||
var ids = [];
|
|
||||||
|
|
||||||
nodes.each(function(node) {
|
|
||||||
ids.push(node.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (ids.length > 0) {
|
|
||||||
if (dijit.byId("headlinesFeedTitleMenu"))
|
|
||||||
dijit.byId("headlinesFeedTitleMenu").destroyRecursive();
|
|
||||||
|
|
||||||
var menu = new dijit.Menu({
|
var menu = new dijit.Menu({
|
||||||
id: "headlinesFeedTitleMenu",
|
id: "headlinesMenu",
|
||||||
targetNodeIds: ids
|
targetNodeIds: ids
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2040,7 +2009,8 @@ function initHeadlinesMenu() {
|
|||||||
var callerNode = event.target, match = null, tries = 0;
|
var callerNode = event.target, match = null, tries = 0;
|
||||||
|
|
||||||
while (match == null && callerNode && tries <= 3) {
|
while (match == null && callerNode && tries <= 3) {
|
||||||
match = callerNode.getAttribute("data-feed-id")
|
|
||||||
|
match = callerNode.getAttribute("data-article-id")
|
||||||
callerNode = callerNode.parentNode;
|
callerNode = callerNode.parentNode;
|
||||||
++tries;
|
++tries;
|
||||||
}
|
}
|
||||||
@@ -2049,41 +2019,101 @@ function initHeadlinesMenu() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
menu.addChild(new dijit.MenuItem({
|
headlinesMenuCommon(menu);
|
||||||
label: __("Select articles in group"),
|
|
||||||
onClick: function(event) {
|
|
||||||
selectArticles("all",
|
|
||||||
"#headlines-frame > div[id*=RROW]"+
|
|
||||||
"[data-orig-feed-id='"+menu.callerRowId+"']");
|
|
||||||
|
|
||||||
}}));
|
|
||||||
|
|
||||||
menu.addChild(new dijit.MenuItem({
|
|
||||||
label: __("Mark group as read"),
|
|
||||||
onClick: function(event) {
|
|
||||||
selectArticles("none");
|
|
||||||
selectArticles("all",
|
|
||||||
"#headlines-frame > div[id*=RROW]"+
|
|
||||||
"[data-orig-feed-id='"+menu.callerRowId+"']");
|
|
||||||
|
|
||||||
catchupSelection();
|
|
||||||
}}));
|
|
||||||
|
|
||||||
|
|
||||||
menu.addChild(new dijit.MenuItem({
|
|
||||||
label: __("Mark feed as read"),
|
|
||||||
onClick: function(event) {
|
|
||||||
catchupFeedInGroup(menu.callerRowId);
|
|
||||||
}}));
|
|
||||||
|
|
||||||
menu.addChild(new dijit.MenuItem({
|
|
||||||
label: __("Edit feed"),
|
|
||||||
onClick: function(event) {
|
|
||||||
editFeed(menu.callerRowId);
|
|
||||||
}}));
|
|
||||||
|
|
||||||
menu.startup();
|
menu.startup();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var menu = dijit.byId("headlinesMenu");
|
||||||
|
|
||||||
|
append_rows.each(function (row) {
|
||||||
|
if (!row.hasClassName("cdmFeedTitle")) {
|
||||||
|
menu.bindDomNode(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vgroup feed title menu */
|
||||||
|
|
||||||
|
if (!append_rows) {
|
||||||
|
|
||||||
|
var nodes = $$("#headlines-frame > div[class='cdmFeedTitle']");
|
||||||
|
var ids = [];
|
||||||
|
|
||||||
|
nodes.each(function(node) {
|
||||||
|
ids.push(node.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ids.length > 0) {
|
||||||
|
if (dijit.byId("headlinesFeedTitleMenu"))
|
||||||
|
dijit.byId("headlinesFeedTitleMenu").destroyRecursive();
|
||||||
|
|
||||||
|
var menu = new dijit.Menu({
|
||||||
|
id: "headlinesFeedTitleMenu",
|
||||||
|
targetNodeIds: ids
|
||||||
|
});
|
||||||
|
|
||||||
|
var tmph = dojo.connect(menu, '_openMyself', function (event) {
|
||||||
|
var callerNode = event.target, match = null, tries = 0;
|
||||||
|
|
||||||
|
while (match == null && callerNode && tries <= 3) {
|
||||||
|
match = callerNode.getAttribute("data-feed-id")
|
||||||
|
callerNode = callerNode.parentNode;
|
||||||
|
++tries;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (match) this.callerRowId = match;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
menu.addChild(new dijit.MenuItem({
|
||||||
|
label: __("Select articles in group"),
|
||||||
|
onClick: function (event) {
|
||||||
|
selectArticles("all",
|
||||||
|
"#headlines-frame > div[id*=RROW]" +
|
||||||
|
"[data-orig-feed-id='" + menu.callerRowId + "']");
|
||||||
|
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
menu.addChild(new dijit.MenuItem({
|
||||||
|
label: __("Mark group as read"),
|
||||||
|
onClick: function (event) {
|
||||||
|
selectArticles("none");
|
||||||
|
selectArticles("all",
|
||||||
|
"#headlines-frame > div[id*=RROW]" +
|
||||||
|
"[data-orig-feed-id='" + menu.callerRowId + "']");
|
||||||
|
|
||||||
|
catchupSelection();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
menu.addChild(new dijit.MenuItem({
|
||||||
|
label: __("Mark feed as read"),
|
||||||
|
onClick: function (event) {
|
||||||
|
catchupFeedInGroup(menu.callerRowId);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
menu.addChild(new dijit.MenuItem({
|
||||||
|
label: __("Edit feed"),
|
||||||
|
onClick: function (event) {
|
||||||
|
editFeed(menu.callerRowId);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
menu.startup();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var menu = dijit.byId("headlinesFeedTitleMenu");
|
||||||
|
|
||||||
|
console.log(append_rows);
|
||||||
|
|
||||||
|
append_rows.each(function (row) {
|
||||||
|
if (row.hasClassName("cdmFeedTitle")) {
|
||||||
|
menu.bindDomNode(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user