diff options
Diffstat (limited to 'js/viewfeed.js')
-rw-r--r-- | js/viewfeed.js | 116 |
1 files changed, 97 insertions, 19 deletions
diff --git a/js/viewfeed.js b/js/viewfeed.js index 622a8109f..5567c717a 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -205,6 +205,8 @@ function headlines_callback2(transport, offset, background, infscroll_req) { _infscroll_request_sent = 0; + headlines_scroll_handler($("headlines-frame")); + notify(""); } catch (e) { @@ -541,7 +543,7 @@ function moveToPost(mode, noscroll) { } else if (next_id) { cdmExpandArticle(next_id); - cdmScrollToArticleId(next_id, noscroll); + cdmScrollToArticleId(next_id, true); } } else if (next_id) { @@ -559,16 +561,28 @@ function moveToPost(mode, noscroll) { var prev_article = $("RROW-" + prev_id); var ctr = $("headlines-frame"); - if (!noscroll && article && article.offsetTop < ctr.scrollTop) { - scrollArticle(-ctr.offsetHeight/2); - } else if (!noscroll && prev_article && - prev_article.offsetTop < ctr.scrollTop) { - cdmExpandArticle(prev_id); - scrollArticle(-ctr.offsetHeight/2); - } else if (prev_id) { - cdmExpandArticle(prev_id); - cdmScrollToArticleId(prev_id, noscroll); + if (!getInitParam("cdm_expanded")) { + + if (!noscroll && article.offsetTop < ctr.scrollTop) { + scrollArticle(-ctr.offsetHeight/3); + } else { + cdmExpandArticle(prev_id); + cdmScrollToArticleId(prev_id, true); + } + } else { + + if (!noscroll && article && article.offsetTop < ctr.scrollTop) { + scrollArticle(-ctr.offsetHeight/3); + } else if (!noscroll && prev_article && + prev_article.offsetTop < ctr.scrollTop) { + cdmExpandArticle(prev_id); + scrollArticle(-ctr.offsetHeight/3); + } else if (prev_id) { + cdmExpandArticle(prev_id); + cdmScrollToArticleId(prev_id, noscroll); + } } + } else if (prev_id) { correctHeadlinesOffset(prev_id); view(prev_id, getActiveFeedId()); @@ -1164,6 +1178,23 @@ function headlines_scroll_handler(e) { try { var hsp = $("headlines-spacer"); + $$("#headlines-frame > div[id*=RROW]").each( + function(child) { + if (child.offsetTop <= $("headlines-frame").scrollTop + + $("headlines-frame").offsetHeight) { + + var cencw = $("CENCW-" + child.id.replace("RROW-", "")); + + if (cencw) { + cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML); + cencw.setAttribute('id', ''); + Element.show(cencw); + } + } + } + ); + + if (!_infscroll_disable) { if ((hsp && e.scrollTop + e.offsetHeight >= hsp.offsetTop - hsp.offsetHeight) || (e.scrollHeight != 0 && @@ -1185,7 +1216,7 @@ function headlines_scroll_handler(e) { $$("#headlines-frame > div[id*=RROW][class*=Unread]").each( function(child) { - if ($("headlines-frame").scrollTop > + if (child.hasClassName("Unread") && $("headlines-frame").scrollTop > (child.offsetTop + child.offsetHeight/2)) { var id = child.id.replace("RROW-", ""); @@ -1312,8 +1343,36 @@ function catchupRelativeToArticle(below, id) { } } +function cdmCollapseArticle(event, id) { + try { + var row = $("RROW-" + id); + var elem = $("CICD-" + id); + + if (elem && row) { + var collapse = $$("div#RROW-" + id + + " span[class='collapseBtn']")[0]; + + Element.hide(elem); + Element.show("CEXC-" + id); + Element.hide(collapse); + + markHeadline(id, false); + + if (id == getActiveArticleId()) { + setActiveArticleId(0); + } + + if (event) Event.stop(event); + } + + } catch (e) { + exception_error("cdmCollapseArticle", e); + } +} + function cdmExpandArticle(id) { try { + console.log("cdmExpandArticle " + id); hideAuxDlg(); @@ -1327,25 +1386,39 @@ function cdmExpandArticle(id) { var old_offset = $("RROW-" + id).offsetTop; if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) { + var collapse = $$("div#RROW-" + getActiveArticleId() + + " span[class='collapseBtn']")[0]; + Element.hide(elem); Element.show("CEXC-" + getActiveArticleId()); + Element.hide(collapse); } setActiveArticleId(id); elem = $("CICD-" + id); + var collapse = $$("div#RROW-" + id + + " span[class='collapseBtn']")[0]; + + var cencw = $("CENCW-" + id); + if (!Element.visible(elem)) { + if (cencw) { + cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML); + cencw.setAttribute('id', ''); + Element.show(cencw); + } + Element.show(elem); Element.hide("CEXC-" + id); + Element.show(collapse); } - /* var new_offset = $("RROW-" + id).offsetTop; + var new_offset = $("RROW-" + id).offsetTop; - $("headlines-frame").scrollTop += (new_offset-old_offset); - - if ($("RROW-" + id).offsetTop != old_offset) - $("headlines-frame").scrollTop = new_offset; */ + if (old_offset > new_offset) + $("headlines-frame").scrollTop -= (old_offset-new_offset); toggleUnread(id, 0, true); toggleSelected(id); @@ -1609,16 +1682,21 @@ function isCdmMode() { return getInitParam("combined_display_mode"); } -function markHeadline(id) { +function markHeadline(id, marked) { + if (marked == undefined) marked = true; + var row = $("RROW-" + id); if (row) { var check = dijit.byId("RCHK-" + id); if (check) { - check.attr("checked", true); + check.attr("checked", marked); } - row.addClassName("Selected"); + if (marked) + row.addClassName("Selected"); + else + row.removeClassName("Selected"); } } |