]> git.wh0rd.org - tt-rss.git/blobdiff - js/viewfeed.js
rework floatingtitle
[tt-rss.git] / js / viewfeed.js
index eee6bf766980f4e651c6c2dd661edff8aa4495d0..ec7706547d47893d6e3568397acbb6c0ba2c5a44 100644 (file)
@@ -55,6 +55,10 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                        try {
                                if (infscroll_req == false) {
                                        $("headlines-frame").scrollTop = 0;
+
+                                       Element.hide("floatingTitle");
+                                       $("floatingTitle").setAttribute("rowid", 0);
+                                       $("floatingTitle").innerHTML = "";
                                }
                        } catch (e) { };
 
@@ -1269,14 +1273,17 @@ function headlines_scroll_handler(e) {
                unpackVisibleHeadlines();
 
                // set topmost child in the buffer as active
-               if (getInitParam("cdm_auto_catchup") == 1) {
+               if (getInitParam("cdm_auto_catchup") == 1 &&
+                               getSelectedArticleIds2().length <= 1 &&
+                               (!isCdmMode() || getInitParam("cdm_expanded"))) {
                        var rows = $$("#headlines-frame > div[id*=RROW]");
 
                        for (var i = 0; i < rows.length; i++) {
                                var child = rows[i];
 
                                if ($("headlines-frame").scrollTop < child.offsetTop &&
-                                       child.offsetTop - $("headlines-frame").scrollTop < 100) {
+                                       child.offsetTop - $("headlines-frame").scrollTop < 100 &&
+                                       child.id.replace("RROW-", "") != _active_article_id) {
 
                                        if (_active_article_id) {
                                                var row = $("RROW-" + _active_article_id);
@@ -1606,6 +1613,12 @@ function dismissArticle(id) {
 
                new Effect.Fade(elem, {duration : 0.5});
 
+               // Remove the content, too
+               var elem_content = $("CICD-" + id);
+               if (elem_content) {
+                       Element.remove(elem_content);
+               }
+
                if (id == getActiveArticleId()) {
                        setActiveArticleId(0);
                }
@@ -1629,6 +1642,12 @@ function dismissSelectedArticles() {
                                        ids[i] != getActiveArticleId()) {
                                new Effect.Fade(elem, {duration : 0.5});
                                sel.push(ids[i]);
+
+                               // Remove the content, too
+                               var elem_content = $("CICD-" + ids[i]);
+                               if (elem_content) {
+                                       Element.remove(elem_content);
+                               }
                        } else {
                                tmp.push(ids[i]);
                        }
@@ -1656,13 +1675,19 @@ function dismissReadArticles() {
                                        !elem.hasClassName("Selected")) {
 
                                new Effect.Fade(elem, {duration : 0.5});
+
+                               // Remove the content, too
+                               var elem_content = $("CICD-" + ids[i]);
+                               if (elem_content) {
+                                       Element.remove(elem_content);
+                               }
                        } else {
                                tmp.push(ids[i]);
                        }
                }
 
        } catch (e) {
-               exception_error("dismissSelectedArticles", e);
+               exception_error("dismissReadArticles", e);
        }
 }
 
@@ -2190,32 +2215,56 @@ function openSelectedAttachment(elem) {
        }
 }
 
+function scrollToRowId(id) {
+       try {
+               var row = $(id);
+
+               if (row)
+                       $("headlines-frame").scrollTop = row.offsetTop;
+
+       } catch (e) {
+               exception_error("scrollToRowId", e);
+       }
+}
+
 function updateFloatingTitle() {
        try {
                var hf = $("headlines-frame");
+               var child = $("RROW-" + _active_article_id);
 
-               var elems = $$("#headlines-frame > div[id*=RROW]");
+               var elems;
+
+               if (getInitParam("cdm_auto_catchup"))
+                       elems = [$$("RROW-" + _active_article_id)];
+               else
+                       elems = $$("#headlines-frame > div[id*=RROW]");
 
                for (var i = 0; i < elems.length; i++) {
+
                        var child = elems[i];
 
-                       if (child.offsetTop + child.offsetHeight > hf.scrollTop) {
+                       if (child && child.offsetTop + child.offsetHeight > hf.scrollTop) {
 
                                var header = child.getElementsByClassName("cdmHeader")[0];
 
-                               $("floatingTitle").setAttribute("rowid", child.id);
-                               $("floatingTitle").innerHTML =
-                                       header.innerHTML;
+                               if (child.id != $("floatingTitle").getAttribute("rowid")) {
+                                       $("floatingTitle").setAttribute("rowid", child.id);
+                                       $("floatingTitle").innerHTML = header.innerHTML;
+                                       $("floatingTitle").firstChild.innerHTML = "<img class='anchor markedPic' src='images/page_white_go.png' onclick=\"scrollToRowId('"+child.id+"')\">" + $("floatingTitle").firstChild.innerHTML;
 
-                               if (child.offsetTop < hf.scrollTop - header.offsetHeight - 100 &&
-                                               child.offsetTop + child.offsetHeight - hf.scrollTop > 100)
+                                       PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, child);
+                               }
+
+                               if (child.offsetTop < hf.scrollTop - header.offsetHeight)
                                        Element.show("floatingTitle");
                                else
                                        Element.hide("floatingTitle");
 
-                               break;
+                               return;
+
                        }
                }
+
        } catch (e) {
                exception_error("updateFloatingTitle", e);
        }