From c409d34a3009005be41efbc6c8cdf994bddaae35 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 29 Mar 2013 19:31:10 +0400 Subject: [PATCH] fix cdmExpandArticle not always removing active class; make moving between posts take expanded cdm margins into account --- js/viewfeed.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/viewfeed.js b/js/viewfeed.js index 2434a8211..c030bf0c9 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -1150,7 +1150,9 @@ function cdmScrollToArticleId(id, force) { if (force || e.offsetTop+e.offsetHeight > (ctr.scrollTop+ctr.offsetHeight) || e.offsetTop < ctr.scrollTop) { - ctr.scrollTop = e.offsetTop; + + // expanded cdm has a 4px margin now + ctr.scrollTop = parseInt(e.offsetTop) - 4; } } catch (e) { @@ -1432,6 +1434,8 @@ function cdmExpandArticle(id) { if (!$("RROW-" + id)) return false; + var oldrow = $("RROW-" + getActiveArticleId()); + var elem = $("CICD-" + getActiveArticleId()); if (id == getActiveArticleId() && Element.visible(elem)) @@ -1448,9 +1452,10 @@ function cdmExpandArticle(id) { Element.hide(elem); Element.show("CEXC-" + getActiveArticleId()); Element.hide(collapse); - $("RROW-" + getActiveArticleId()).removeClassName("active"); } + if (oldrow) oldrow.removeClassName("active"); + setActiveArticleId(id); elem = $("CICD-" + id); @@ -1470,7 +1475,6 @@ function cdmExpandArticle(id) { Element.show(elem); Element.hide("CEXC-" + id); Element.show(collapse); - $("RROW-" + id).addClassName("active"); } var new_offset = $("RROW-" + id).offsetTop; @@ -1480,6 +1484,7 @@ function cdmExpandArticle(id) { toggleUnread(id, 0, true); toggleSelected(id); + $("RROW-" + id).addClassName("active"); } catch (e) { exception_error("cdmExpandArticle", e);