From 51614600487bea4f85c78240c6506ff936956f15 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 13 Feb 2017 23:36:58 +0300 Subject: [PATCH] bind headlines menu to a selector to avoid remaking it unnecessarily --- classes/feeds.php | 4 +- js/tt-rss.js | 1 + js/viewfeed.js | 168 ++++++++++++++++------------------------------ 3 files changed, 60 insertions(+), 113 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index 6b96d8364..500c50a74 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -484,7 +484,7 @@ class Feeds extends Handler_Protected { $mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'"; - $reply['content'] .= "
"; + $reply['content'] .= "
"; $reply['content'] .= "
"; @@ -613,7 +613,7 @@ class Feeds extends Handler_Protected { $reply['content'] .= " + class=\"titleWrap hlMenuAttach $hlc_suffix\"> div[id*=RROW]"); - } else { - nodes = $$("#headlines-frame span[id*=RTITLE]"); - } - - nodes.each(function (node) { - ids.push(node.id); - }); + if (!dijit.byId("headlinesMenu")) { var menu = new dijit.Menu({ id: "headlinesMenu", - targetNodeIds: ids + targetNodeIds: ["headlines-frame"], + selector: ".hlMenuAttach" }); var tmph = dojo.connect(menu, '_openMyself', function (event) { @@ -2033,96 +2007,68 @@ function initHeadlinesMenu(append_rows) { headlinesMenuCommon(menu); 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) { + if (!dijit.byId("headlinesFeedTitleMenu")) { - var nodes = $$("#headlines-frame > div[class='cdmFeedTitle']"); - var ids = []; - - nodes.each(function(node) { - ids.push(node.id); + var menu = new dijit.Menu({ + id: "headlinesFeedTitleMenu", + targetNodeIds: ["headlines-frame"], + selector: "div.cdmFeedTitle" }); - if (ids.length > 0) { - if (dijit.byId("headlinesFeedTitleMenu")) - dijit.byId("headlinesFeedTitleMenu").destroyRecursive(); + var tmph = dojo.connect(menu, '_openMyself', function (event) { + var callerNode = event.target, match = null, tries = 0; - 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"); - - append_rows.each(function (row) { - if (row.hasClassName("cdmFeedTitle")) { - menu.bindDomNode(row); + 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(); } } catch (e) {