cdmcollapse/expand: use less convoluted selector queries

This commit is contained in:
Andrew Dolgov 2017-02-13 22:45:30 +03:00
parent 61570c474b
commit 20deb5fc32
1 changed files with 9 additions and 10 deletions

View File

@ -1492,8 +1492,7 @@ function cdmCollapseArticle(event, id, unmark) {
var elem = $("CICD-" + id); var elem = $("CICD-" + id);
if (elem && row) { if (elem && row) {
var collapse = $$("div#RROW-" + id + var collapse = row.select("span[class='collapseBtn']")[0];
" span[class='collapseBtn']")[0];
Element.hide(elem); Element.hide(elem);
Element.show("CEXC-" + id); Element.show("CEXC-" + id);
@ -1531,7 +1530,9 @@ function cdmExpandArticle(id, noexpand) {
try { try {
console.log("cdmExpandArticle " + id); console.log("cdmExpandArticle " + id);
if (!$("RROW-" + id)) return false; var row = $("RROW-" + id);
if (!row) return false;
var oldrow = $("RROW-" + getActiveArticleId()); var oldrow = $("RROW-" + getActiveArticleId());
@ -1542,11 +1543,10 @@ function cdmExpandArticle(id, noexpand) {
selectArticles("none"); selectArticles("none");
var old_offset = $("RROW-" + id).offsetTop; var old_offset = row.offsetTop;
if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) { if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) {
var collapse = $$("div#RROW-" + getActiveArticleId() + var collapse = oldrow.select("span[class='collapseBtn']")[0];
" span[class='collapseBtn']")[0];
Element.hide(elem); Element.hide(elem);
Element.show("CEXC-" + getActiveArticleId()); Element.show("CEXC-" + getActiveArticleId());
@ -1559,8 +1559,7 @@ function cdmExpandArticle(id, noexpand) {
elem = $("CICD-" + id); elem = $("CICD-" + id);
var collapse = $$("div#RROW-" + id + var collapse = row.select("span[class='collapseBtn']")[0];
" span[class='collapseBtn']")[0];
var cencw = $("CENCW-" + id); var cencw = $("CENCW-" + id);
@ -1576,7 +1575,7 @@ function cdmExpandArticle(id, noexpand) {
Element.show(collapse); Element.show(collapse);
} }
var new_offset = $("RROW-" + id).offsetTop; var new_offset = row.offsetTop;
if (old_offset > new_offset) if (old_offset > new_offset)
$("headlines-frame").scrollTop -= (old_offset-new_offset); $("headlines-frame").scrollTop -= (old_offset-new_offset);
@ -1589,7 +1588,7 @@ function cdmExpandArticle(id, noexpand) {
} }
toggleSelected(id); toggleSelected(id);
$("RROW-" + id).addClassName("active"); row.addClassName("active");
PluginHost.run(PluginHost.HOOK_ARTICLE_EXPANDED, id); PluginHost.run(PluginHost.HOOK_ARTICLE_EXPANDED, id);