]> git.wh0rd.org - tt-rss.git/blobdiff - js/viewfeed.js
js: remove current_top_id global
[tt-rss.git] / js / viewfeed.js
index 9672c47ba6acdebbf5998d6f8b5fdc34992f0c67..5c437c7b8c802e47b2bf1ef1dcfe189e655f4a59 100644 (file)
@@ -56,7 +56,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                if (infscroll_req == false) {
                                        $("headlines-frame").scrollTop = 0;
 
-                                       Element.hide("floatingTitle");
+                                       $("floatingTitle").style.visibility = "hidden";
                                        $("floatingTitle").setAttribute("rowid", 0);
                                        $("floatingTitle").innerHTML = "";
                                }
@@ -108,6 +108,10 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                                initHeadlinesMenu();
 
+                               if (_infscroll_disable)
+                                       hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                               __("Click to open next unread feed.") + "</a>";
+
                                if (_search_query) {
                                        $("feed_title").innerHTML += "<span id='cancel_search'>" +
                                                " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
@@ -147,9 +151,9 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                                        if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
 
-                                       if (getInitParam("cdm_auto_catchup") == 1) {
+//                                     if (getInitParam("cdm_auto_catchup") == 1) {
                                                c.domNode.appendChild(hsp);
-                                       }
+//                                     }
 
                                        console.log("added " + new_elems.size() + " headlines");
 
@@ -174,9 +178,22 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                } else {
                                        console.log("no new headlines received");
 
+                                       var top_id_changed = reply['headlines']['top_id_changed'];
+                                       console.log("top id changed:" + top_id_changed);
+
                                        var hsp = $("headlines-spacer");
 
-                                       if (hsp) hsp.innerHTML = "";
+                                       if (hsp) {
+                                               if (top_id_changed) {
+                                                       hsp.innerHTML = "<a href='#' onclick='viewCurrentFeed()'>" +
+                                                       __("New articles found, reload feed to continue.") + "</a>";
+                                               } else {
+                                                       hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                                       __("Click to open next unread feed.") + "</a>";
+                                               }
+
+                                       }
+
                                }
                        }
 
@@ -1307,15 +1324,21 @@ function headlines_scroll_handler(e) {
                                                ((e.scrollTop + e.offsetHeight) / e.scrollHeight >= 0.7))) {
 
                                if (hsp)
-                                       hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
-                                               __("Loading, please wait...");
+                                       hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
+                                               __("Loading, please wait...") + "</span>";
 
                                loadMoreHeadlines();
                                return;
 
                        }
-               } else {
-                       if (hsp) hsp.innerHTML = "";
+               /*} else {
+                       if (hsp) {
+                               if (_infscroll_disable)
+                                       hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                               __("Click to open next unread feed.") + "</a>";
+                               else
+                                       hsp.innerHTML = "";
+                       }*/
                }
 
                if (isCdmMode()) {
@@ -1351,6 +1374,20 @@ function headlines_scroll_handler(e) {
                                                500);
                                }
                        }
+
+                       if (_infscroll_disable) {
+                               var child = $$("#headlines-frame div[id*=RROW]").last();
+
+                               if (child && $("headlines-frame").scrollTop >
+                                               (child.offsetTop + child.offsetHeight - 50)) {
+
+                                       console.log("we seem to be at an end");
+
+                                       if (getInitParam("on_catchup_show_next_feed") == "1") {
+                                               openNextUnreadFeed();
+                                       }
+                               }
+                       }
                }
 
        } catch (e) {
@@ -1358,6 +1395,16 @@ function headlines_scroll_handler(e) {
        }
 }
 
+function openNextUnreadFeed() {
+       try {
+               var is_cat = activeFeedIsCat();
+               var nuf = getNextUnreadFeed(getActiveFeedId(), is_cat);
+               if (nuf) viewfeed(nuf, '', is_cat);
+       } catch (e) {
+               exception_error("openNextUnreadFeed", e);
+       }
+}
+
 function catchupBatchedArticles() {
        try {
                if (catchup_id_batch.length > 0 && !_infscroll_request_sent) {
@@ -1498,7 +1545,7 @@ function cdmCollapseArticle(event, id, unmark) {
                        if (row.offsetTop < $("headlines-frame").scrollTop)
                                scrollToRowId(row.id);
 
-                       Element.hide("floatingTitle");
+                       $("floatingTitle").style.visibility = "hidden";
                        $("floatingTitle").setAttribute("rowid", false);
                }
 
@@ -2259,6 +2306,34 @@ function setSelectionScore() {
        }
 }
 
+function updateScore(id) {
+       try {
+               var pic = $$("#RROW-" + id + " .hlScorePic")[0];
+
+               if (pic) {
+
+                       var query = "op=article&method=getScore&id=" + param_escape(id);
+
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) {
+                                       console.log(transport.responseText);
+
+                                       var reply = JSON.parse(transport.responseText);
+
+                                       if (reply) {
+                                               pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
+                                               pic.setAttribute("score", reply["score"]);
+                                               pic.setAttribute("title", reply["score"]);
+                                       }
+                               } });
+               }
+
+       } catch (e) {
+               exception_error("updateScore", e);
+       }
+}
+
 function changeScore(id, pic) {
        try {
                var score = pic.getAttribute("score");
@@ -2278,6 +2353,7 @@ function changeScore(id, pic) {
                                        if (reply) {
                                                pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
                                                pic.setAttribute("score", new_score);
+                                               pic.setAttribute("title", new_score);
                                        }
                                } });
                }
@@ -2323,7 +2399,7 @@ function scrollToRowId(id) {
                var row = $(id);
 
                if (row)
-                       $("headlines-frame").scrollTop = row.offsetTop;
+                       $("headlines-frame").scrollTop = row.offsetTop - 4;
 
        } catch (e) {
                exception_error("scrollToRowId", e);
@@ -2368,11 +2444,12 @@ function updateFloatingTitle(unread_only) {
                                        PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, child);
                                }
 
-                               if (child.offsetTop < hf.scrollTop - header.offsetHeight &&
-                                               child.offsetTop + child.offsetHeight - hf.scrollTop > header.offsetHeight)
-                                       Element.show("floatingTitle");
+                               $("floatingTitle").style.marginRight = hf.offsetWidth - child.offsetWidth + "px";
+                               if (header.offsetTop + header.offsetHeight < hf.scrollTop + $("floatingTitle").offsetHeight - 5 &&
+                                   child.offsetTop + child.offsetHeight >= hf.scrollTop + $("floatingTitle").offsetHeight - 5)
+                                       $("floatingTitle").style.visibility = "visible";
                                else
-                                       Element.hide("floatingTitle");
+                                       $("floatingTitle").style.visibility = "hidden";
 
                                return;
 
@@ -2383,3 +2460,7 @@ function updateFloatingTitle(unread_only) {
                exception_error("updateFloatingTitle", e);
        }
 }
+
+function cdmFooterClick(event) {
+       event.stopPropagation();
+}
\ No newline at end of file