]> git.wh0rd.org - tt-rss.git/commitdiff
bind headlines menu to a selector to avoid remaking it unnecessarily
authorAndrew Dolgov <noreply@fakecake.org>
Mon, 13 Feb 2017 20:36:58 +0000 (23:36 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Mon, 13 Feb 2017 20:36:58 +0000 (23:36 +0300)
classes/feeds.php
js/tt-rss.js
js/viewfeed.js

index 6b96d8364d914c13f6e31e31009f31869c86b64a..500c50a74c1e962c3918a3aad0a7e0952b05ead3 100755 (executable)
@@ -484,7 +484,7 @@ class Feeds extends Handler_Protected {
                                        $mouseover_attrs = "onmouseover='postMouseIn(event, $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'>";
 
@@ -613,7 +613,7 @@ class Feeds extends Handler_Protected {
 
                                        $reply['content'] .= "<span id=\"RTITLE-$id\"
                                                onclick=\"return cdmClicked(event, $id);\"
-                                               class=\"titleWrap $hlc_suffix\">
+                                               class=\"titleWrap hlMenuAttach $hlc_suffix\">
                                                <a class=\"title $hlc_suffix\"
                                                title=\"".htmlspecialchars($line["title"])."\"
                                                target=\"_blank\" rel=\"noopener noreferrer\" href=\"".
index 4ed89d4b2e848229f8c36702ee4662bb5f945b2d..f481d39a3872ef6b588ba9db1e058b93dba3a457 100644 (file)
@@ -226,6 +226,7 @@ function init() {
                                "dojo/parser",
                                "dojo/_base/loader",
                                "dojo/_base/html",
+                               "dojo/query",
                                "dijit/ProgressBar",
                                "dijit/ColorPalette",
                                "dijit/Dialog",
index 15cd2e304a311ef4027ac808f21f42ecf0d9375b..d8b49c601949de88cf35a13725064e9695e65f82 100755 (executable)
@@ -150,8 +150,6 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                        tmp.innerHTML = reply['headlines']['content'];
                                        dojo.parser.parse(tmp);
 
-                                       var new_rows = [];
-
                                        while (tmp.hasChildNodes()) {
                                                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);
 
                                                        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]);
                                        }
 
-                                       initHeadlinesMenu(new_rows);
+                                       initHeadlinesMenu();
 
                                        if (_infscroll_disable) {
                                                hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
@@ -1992,28 +1980,14 @@ function headlinesMenuCommon(menu) {
        }
 }
 
-function initHeadlinesMenu(append_rows) {
+function initHeadlinesMenu() {
        try {
-               if (!append_rows) {
-
-                       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);
-                       });
+               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) {
-
-                       var nodes = $$("#headlines-frame > div[class='cdmFeedTitle']");
-                       var ids = [];
+               if (!dijit.byId("headlinesFeedTitleMenu")) {
 
-                       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 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;
+                       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;
+                               }
 
-                               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 + "']");
+                               if (match) this.callerRowId = match;
 
-                                       }
-                               }));
+                       });
 
-                               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 + "']");
+                       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 + "']");
 
-                                               catchupSelection();
-                                       }
-                               }));
+                               }
+                       }));
 
-                               menu.addChild(new dijit.MenuItem({
-                                       label: __("Mark feed as read"),
-                                       onClick: function (event) {
-                                               catchupFeedInGroup(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 + "']");
 
-                               menu.addChild(new dijit.MenuItem({
-                                       label: __("Edit feed"),
-                                       onClick: function (event) {
-                                               editFeed(menu.callerRowId);
-                                       }
-                               }));
+                                       catchupSelection();
+                               }
+                       }));
 
-                               menu.startup();
-                       }
-               } else {
-                       var menu = dijit.byId("headlinesFeedTitleMenu");
+                       menu.addChild(new dijit.MenuItem({
+                               label: __("Mark feed as read"),
+                               onClick: function (event) {
+                                       catchupFeedInGroup(menu.callerRowId);
+                               }
+                       }));
 
-                       append_rows.each(function (row) {
-                               if (row.hasClassName("cdmFeedTitle")) {
-                                       menu.bindDomNode(row);
+                       menu.addChild(new dijit.MenuItem({
+                               label: __("Edit feed"),
+                               onClick: function (event) {
+                                       editFeed(menu.callerRowId);
                                }
-                       });
+                       }));
+
+                       menu.startup();
                }
 
        } catch (e) {