]> git.wh0rd.org Git - tt-rss.git/commitdiff
support headlines context menu in floating title
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 11 Jul 2013 12:49:25 +0000 (16:49 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 11 Jul 2013 12:49:25 +0000 (16:49 +0400)
classes/feeds.php
js/viewfeed.js

index c57328fe7e57ffdcb613aa87ceb67a2120158f1d..e71be4e559c98e14997dfd4c26129f3c04f2dc69 100644 (file)
@@ -316,7 +316,7 @@ class Feeds extends Handler_Protected {
 
                                if (!is_array($labels)) $labels = get_article_labels($id);
 
-                               $labels_str = "<span id=\"HLLCTR-$id\">";
+                               $labels_str = "<span class=\"HLLCTR-$id\">";
                                $labels_str .= format_article_labels($labels, $id);
                                $labels_str .= "</span>";
 
index 1785fe3f5fd1d16dd0f4ec84822b7b01d9dfe256..57989eed3982d62ef712138a2600455b85910892 100644 (file)
@@ -1599,9 +1599,9 @@ function show_labels_in_headlines(transport) {
 
                if (data) {
                        data['info-for-headlines'].each(function(elem) {
-                               var ctr = $("HLLCTR-" + elem.id);
-
-                               if (ctr) ctr.innerHTML = elem.labels;
+                               $$(".HLLCTR-" + elem.id).each(function(ctr) {
+                                       ctr.innerHTML = elem.labels;
+                               });
                        });
                }
        } catch (e) {
@@ -1916,58 +1916,39 @@ function closeArticlePanel() {
                        dijit.byId("content-insert"));
 }
 
-function initHeadlinesMenu() {
+function initFloatingMenu() {
        try {
-               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("floatingMenu"))
+                       dijit.byId("floatingMenu").destroyRecursive();
 
-               var menu = new dijit.Menu({
-                       id: "headlinesMenu",
-                       targetNodeIds: ids,
-               });
+                       var menu = new dijit.Menu({
+                               id: "floatingMenu",
+                               targetNodeIds: ["floatingTitle"]
+                       });
 
-               var tmph = dojo.connect(menu, '_openMyself', function (event) {
-                       var callerNode = event.target, match = null, tries = 0;
+                       var id = $("floatingTitle").getAttribute("rowid").replace("RROW-", "");
 
-                       while (match == null && callerNode && tries <= 3) {
-                               match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$");
-                               callerNode = callerNode.parentNode;
-                               ++tries;
-                       }
+                       headlinesMenuCommon(menu, id);
 
-                       if (match) this.callerRowId = parseInt(match[1]);
-
-               });
+                       menu.startup();
+       } catch (e) {
+               exception_error("initFloatingMenu", e);
+       }
+}
 
-/*             if (!isCdmMode())
-                       menu.addChild(new dijit.MenuItem({
-                               label: __("View article"),
-                               onClick: function(event) {
-                                       view(this.getParent().callerRowId);
-                               }})); */
+function headlinesMenuCommon(menu, base_id) {
+       try {
 
                menu.addChild(new dijit.MenuItem({
                        label: __("Open original article"),
                        onClick: function(event) {
-                               openArticleInNewWindow(this.getParent().callerRowId);
+                               openArticleInNewWindow(base_id ? base_id : this.getParent().callerRowId);
                        }}));
 
                menu.addChild(new dijit.MenuItem({
                        label: __("Display article URL"),
                        onClick: function(event) {
-                               displayArticleUrl(this.getParent().callerRowId);
+                               displayArticleUrl(base_id ? base_id : this.getParent().callerRowId);
                        }}));
 
                menu.addChild(new dijit.MenuSeparator());
@@ -1977,7 +1958,7 @@ function initHeadlinesMenu() {
                        onClick: function(event) {
                                var ids = getSelectedArticleIds2();
                                // cast to string
-                               var id = this.getParent().callerRowId + "";
+                               var id = (base_id ? base_id : this.getParent().callerRowId) + "";
                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
                                selectionToggleUnread(undefined, false, true, ids);
@@ -1988,7 +1969,7 @@ function initHeadlinesMenu() {
                        onClick: function(event) {
                                var ids = getSelectedArticleIds2();
                                // cast to string
-                               var id = this.getParent().callerRowId + "";
+                               var id = (base_id ? base_id : this.getParent().callerRowId) + "";
                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
                                selectionToggleMarked(undefined, false, true, ids);
@@ -1999,7 +1980,7 @@ function initHeadlinesMenu() {
                        onClick: function(event) {
                                var ids = getSelectedArticleIds2();
                                // cast to string
-                               var id = this.getParent().callerRowId + "";
+                               var id = (base_id ? base_id : this.getParent().callerRowId) + "";
                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
                                selectionTogglePublished(undefined, false, true, ids);
@@ -2010,13 +1991,13 @@ function initHeadlinesMenu() {
                menu.addChild(new dijit.MenuItem({
                        label: __("Mark above as read"),
                        onClick: function(event) {
-                               catchupRelativeToArticle(0, this.getParent().callerRowId);
+                               catchupRelativeToArticle(0, base_id ? base_id : this.getParent().callerRowId);
                                }}));
 
                menu.addChild(new dijit.MenuItem({
                        label: __("Mark below as read"),
                        onClick: function(event) {
-                               catchupRelativeToArticle(1, this.getParent().callerRowId);
+                               catchupRelativeToArticle(1, base_id ? base_id : this.getParent().callerRowId);
                                }}));
 
 
@@ -2042,7 +2023,7 @@ function initHeadlinesMenu() {
                                        onClick: function(event) {
                                                var ids = getSelectedArticleIds2();
                                                // cast to string
-                                               var id = this.getParent().ownerMenu.callerRowId + "";
+                                               var id = (base_id ? base_id : this.getParent().ownerMenu.callerRowId) + "";
 
                                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
@@ -2055,7 +2036,7 @@ function initHeadlinesMenu() {
                                        onClick: function(event) {
                                                var ids = getSelectedArticleIds2();
                                                // cast to string
-                                               var id = this.getParent().ownerMenu.callerRowId + "";
+                                               var id = (base_id ? base_id : this.getParent().ownerMenu.callerRowId) + "";
 
                                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
@@ -2076,6 +2057,49 @@ function initHeadlinesMenu() {
 
                }
 
+
+       } catch (e) {
+               exception_error("headlinesMenuCommon", e);
+       }
+}
+
+function initHeadlinesMenu() {
+       try {
+               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({
+                       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.id.match("^[A-Z]+[-]([0-9]+)$");
+                               callerNode = callerNode.parentNode;
+                               ++tries;
+                       }
+
+                       if (match) this.callerRowId = parseInt(match[1]);
+
+               });
+
+               headlinesMenuCommon(menu, false);
+
                menu.startup();
 
        } catch (e) {
@@ -2252,6 +2276,8 @@ function updateFloatingTitle() {
                                        $("floatingTitle").innerHTML = header.innerHTML;
                                        $("floatingTitle").firstChild.innerHTML = "<img class='anchor markedPic' src='images/page_white_go.png' onclick=\"scrollToRowId('"+child.id+"')\">" + $("floatingTitle").firstChild.innerHTML;
 
+                                       initFloatingMenu();
+
                                        PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, child);
                                }