bind headlines menu to a selector to avoid remaking it unnecessarily

This commit is contained in:
Andrew Dolgov 2017-02-13 23:36:58 +03:00
parent 3eec1de393
commit 5161460048
3 changed files with 60 additions and 113 deletions

View file

@ -484,7 +484,7 @@ class Feeds extends Handler_Protected {
$mouseover_attrs = "onmouseover='postMouseIn(event, $id)' $mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
onmouseout='postMouseOut($id)'"; onmouseout='postMouseOut($id)'";
$reply['content'] .= "<div class='hl $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>"; $reply['content'] .= "<div class='hl hlMenuAttach $class' data-orig-feed-id='$feed_id' data-article-id='$id' id='RROW-$id' $mouseover_attrs>";
$reply['content'] .= "<div class='hlLeft'>"; $reply['content'] .= "<div class='hlLeft'>";
@ -613,7 +613,7 @@ class Feeds extends Handler_Protected {
$reply['content'] .= "<span id=\"RTITLE-$id\" $reply['content'] .= "<span id=\"RTITLE-$id\"
onclick=\"return cdmClicked(event, $id);\" onclick=\"return cdmClicked(event, $id);\"
class=\"titleWrap $hlc_suffix\"> class=\"titleWrap hlMenuAttach $hlc_suffix\">
<a class=\"title $hlc_suffix\" <a class=\"title $hlc_suffix\"
title=\"".htmlspecialchars($line["title"])."\" title=\"".htmlspecialchars($line["title"])."\"
target=\"_blank\" rel=\"noopener noreferrer\" href=\"". target=\"_blank\" rel=\"noopener noreferrer\" href=\"".

View file

@ -226,6 +226,7 @@ function init() {
"dojo/parser", "dojo/parser",
"dojo/_base/loader", "dojo/_base/loader",
"dojo/_base/html", "dojo/_base/html",
"dojo/query",
"dijit/ProgressBar", "dijit/ProgressBar",
"dijit/ColorPalette", "dijit/ColorPalette",
"dijit/Dialog", "dijit/Dialog",

View file

@ -150,8 +150,6 @@ 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);
@ -159,16 +157,6 @@ 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);
if (!isCdmMode() || row.hasClassName("cdmFeedTitle")) {
new_rows.push(row);
} else if (isCdmMode()) {
var titleWrap = $$("#" + row.id + " .titleWrap")[0];
if (titleWrap) {
new_rows.push(titleWrap);
}
}
} }
} }
@ -183,7 +171,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
markHeadline(ids[i]); markHeadline(ids[i]);
} }
initHeadlinesMenu(new_rows); initHeadlinesMenu();
if (_infscroll_disable) { if (_infscroll_disable) {
hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" + hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
@ -1992,28 +1980,14 @@ function headlinesMenuCommon(menu) {
} }
} }
function initHeadlinesMenu(append_rows) { function initHeadlinesMenu() {
try { try {
if (!append_rows) { if (!dijit.byId("headlinesMenu")) {
if (dijit.byId("headlinesMenu"))
dijit.byId("headlinesMenu").destroyRecursive();
var ids = [];
if (!isCdmMode()) {
nodes = $$("#headlines-frame > div[id*=RROW]");
} else {
nodes = $$("#headlines-frame span[id*=RTITLE]");
}
nodes.each(function (node) {
ids.push(node.id);
});
var menu = new dijit.Menu({ var menu = new dijit.Menu({
id: "headlinesMenu", id: "headlinesMenu",
targetNodeIds: ids targetNodeIds: ["headlines-frame"],
selector: ".hlMenuAttach"
}); });
var tmph = dojo.connect(menu, '_openMyself', function (event) { var tmph = dojo.connect(menu, '_openMyself', function (event) {
@ -2033,35 +2007,16 @@ function initHeadlinesMenu(append_rows) {
headlinesMenuCommon(menu); headlinesMenuCommon(menu);
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 */ /* vgroup feed title menu */
if (!append_rows) { if (!dijit.byId("headlinesFeedTitleMenu")) {
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: "headlinesFeedTitleMenu",
targetNodeIds: ids targetNodeIds: ["headlines-frame"],
selector: "div.cdmFeedTitle"
}); });
var tmph = dojo.connect(menu, '_openMyself', function (event) { var tmph = dojo.connect(menu, '_openMyself', function (event) {
@ -2115,15 +2070,6 @@ function initHeadlinesMenu(append_rows) {
menu.startup(); menu.startup();
} }
} else {
var menu = dijit.byId("headlinesFeedTitleMenu");
append_rows.each(function (row) {
if (row.hasClassName("cdmFeedTitle")) {
menu.bindDomNode(row);
}
});
}
} catch (e) { } catch (e) {
exception_error("initHeadlinesMenu", e); exception_error("initHeadlinesMenu", e);