]> git.wh0rd.org Git - tt-rss.git/commitdiff
CDM mode: add article selection, rework moveToPost()
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 16 May 2008 02:06:57 +0000 (03:06 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 16 May 2008 02:06:57 +0000 (03:06 +0100)
functions.js
functions.php
viewfeed.js

index 010889cab4a9580fb32af51eb7345862b7d325e5..eb036e3c4e17b8e2885ecbba239a9063fba95ccb 100644 (file)
@@ -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) {
index 1b92f94409ef62065c8d5e2c361f35a4b6437457..3dc4f4b603a781ddb7df66b35e9ea0365119f0ee 100644 (file)
 
                                        print "<div class=\"cdmArticle$add_class\" 
                                                id=\"RROW-$id\" onmouseover='cdmMouseIn(this)' 
+                                               onclick='cdmClicked(this)'
                                                onmouseout='cdmMouseOut(this)'>";
 
                                        print "<div class=\"cdmHeader\">";
index e5e862d59481fa3fc87dbf17de97b7ae74443297..2deb9a656907c8e28b1c25b899b79a58467abf64 100644 (file)
@@ -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() {