From: Andrew Dolgov Date: Fri, 16 May 2008 02:06:57 +0000 (+0100) Subject: CDM mode: add article selection, rework moveToPost() X-Git-Tag: 1.2.23-final~131 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=5ad9d132117af6a65a1b496850e7db441b36b5ad;p=tt-rss.git CDM mode: add article selection, rework moveToPost() --- diff --git a/functions.js b/functions.js index 010889ca..eb036e3c 100644 --- a/functions.js +++ b/functions.js @@ -274,13 +274,23 @@ function getVisibleHeadlineIds() { } function getFirstVisibleHeadlineId() { - var rows = getVisibleHeadlineIds(); - return rows[0]; + if (isCdmMode()) { + var rows = cdmGetVisibleArticles(); + return rows[0]; + } else { + var rows = getVisibleHeadlineIds(); + return rows[0]; + } } function getLastVisibleHeadlineId() { - var rows = getVisibleHeadlineIds(); - return rows[rows.length-1]; + if (isCdmMode()) { + var rows = cdmGetVisibleArticles(); + return rows[rows.length-1]; + } else { + var rows = getVisibleHeadlineIds(); + return rows[rows.length-1]; + } } function markHeadline(id) { diff --git a/functions.php b/functions.php index 1b92f944..3dc4f4b6 100644 --- a/functions.php +++ b/functions.php @@ -5016,6 +5016,7 @@ print "
"; print "
"; diff --git a/viewfeed.js b/viewfeed.js index e5e862d5..2deb9a65 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -675,45 +675,68 @@ function moveToPost(mode) { try { - // check for combined mode - if (document.getElementById("headlinesList")) { - - var rows = getVisibleHeadlineIds(); + var rows; + + if (isCdmMode()) { + rows = cdmGetVisibleArticles(); + } else { + rows = getVisibleHeadlineIds(); + } - var prev_id = false; - var next_id = false; + var prev_id = false; + var next_id = false; - if (!document.getElementById('RROW-' + active_post_id)) { - active_post_id = false; - } + if (!document.getElementById('RROW-' + active_post_id)) { + active_post_id = false; + } - if (active_post_id == false) { - next_id = getFirstVisibleHeadlineId(); - prev_id = getLastVisibleHeadlineId(); - } else { - for (var i = 0; i < rows.length; i++) { - if (rows[i] == active_post_id) { - prev_id = rows[i-1]; - next_id = rows[i+1]; - } + if (active_post_id == false) { + next_id = getFirstVisibleHeadlineId(); + prev_id = getLastVisibleHeadlineId(); + } else { + for (var i = 0; i < rows.length; i++) { + if (rows[i] == active_post_id) { + prev_id = rows[i-1]; + next_id = rows[i+1]; } } + } - if (mode == "next") { - if (next_id) { + if (mode == "next") { + if (next_id) { + if (isCdmMode()) { + + if (!cdmArticleIsActuallyVisible(next_id)) { + cdmScrollToArticleId(next_id); + } + cdmSelectArticles("none"); + toggleUnread(next_id, 0, true); + toggleSelected(next_id); + + } else { correctHeadlinesOffset(next_id); view(next_id, getActiveFeedId()); } } + } - if (mode == "prev") { - if (prev_id) { + if (mode == "prev") { + if (prev_id) { + if (isCdmMode()) { + cdmScrollToArticleId(prev_id); + cdmSelectArticles("none"); + toggleUnread(prev_id, 0, true); + toggleSelected(prev_id); + } else { correctHeadlinesOffset(prev_id); view(prev_id, getActiveFeedId()); } - } - } else { - var rows = cdmGetUnreadArticles(); + } + } + + +/* } else { + var rows = cdmGetVisibleArticles(); if (mode == "next") { @@ -726,7 +749,9 @@ function moveToPost(mode) { cdmScrollToArticleId(rows[i]); } //setTimeout("toggleUnread(" + rows[i] + ", undefined, true)", 500); + cdmSelectArticles("none"); toggleUnread(rows[i], undefined, true); + toggleSelected(rows[i]); return; } @@ -743,15 +768,17 @@ function moveToPost(mode) { cdmScrollToArticleId(rows[i]); //setTimeout("toggleUnread(" + rows[i] + ", undefined, true)", 500); + cdmSelectArticles("none"); toggleUnread(rows[i], undefined, true); + cdmSelectArticleById(rows[i]); break; } } - } + } - } + } */ } catch (e) { exception_error(e, "moveToPost"); @@ -761,14 +788,26 @@ function moveToPost(mode) { function toggleSelected(id) { try { + var cb = document.getElementById("RCHK-" + id); + var row = document.getElementById("RROW-" + id); if (row) { var nc = row.className; if (!nc.match("Selected")) { nc = nc + "Selected"; + if (cb) { + cb.checked = true; + } + + // In CDM basically last selected article == active article + if (isCdmMode()) active_post_id = id; } else { nc = nc.replace("Selected", ""); + if (cb) { + cb.checked = false; + } + } row.className = nc; @@ -1542,20 +1581,34 @@ function getActiveArticleId() { return active_post_id; } -function cdmMouseIn(elem) { +function cdmClicked(elem) { try { if (elem.id && elem.id.match("RROW-")) { var id = elem.id.replace("RROW-", ""); active_post_id = id; + + cdmSelectArticles("none"); + toggleSelected(id); + } } catch (e) { exception_error("cdmMouseIn", e); - } + } +} +function cdmMouseIn(elem) { +/* try { + if (elem.id && elem.id.match("RROW-")) { + var id = elem.id.replace("RROW-", ""); + active_post_id = id; + } + } catch (e) { + exception_error("cdmMouseIn", e); + } */ } function cdmMouseOut(elem) { - active_post_id = false; + //active_post_id = false; } function headlines_scroll_handler() {