]> git.wh0rd.org - tt-rss.git/blobdiff - js/viewfeed.js
rework floatingtitle
[tt-rss.git] / js / viewfeed.js
index 84230f61a11cee5ab02ee56fde7963ce73df2cb1..ec7706547d47893d6e3568397acbb6c0ba2c5a44 100644 (file)
@@ -1274,6 +1274,7 @@ function headlines_scroll_handler(e) {
 
                // set topmost child in the buffer as active
                if (getInitParam("cdm_auto_catchup") == 1 &&
+                               getSelectedArticleIds2().length <= 1 &&
                                (!isCdmMode() || getInitParam("cdm_expanded"))) {
                        var rows = $$("#headlines-frame > div[id*=RROW]");
 
@@ -1281,7 +1282,8 @@ function headlines_scroll_handler(e) {
                                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);
@@ -2213,33 +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];
 
                                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;
+
+                                       PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, child);
                                }
 
-                               if (child.offsetTop < hf.scrollTop - header.offsetHeight - 100 &&
-                                               child.offsetTop + child.offsetHeight - hf.scrollTop > 100)
+                               if (child.offsetTop < hf.scrollTop - header.offsetHeight)
                                        Element.show("floatingTitle");
                                else
                                        Element.hide("floatingTitle");
 
-                               break;
+                               return;
+
                        }
                }
+
        } catch (e) {
                exception_error("updateFloatingTitle", e);
        }