]> git.wh0rd.org Git - tt-rss.git/commitdiff
assorted fixes, support for n/p shortcuts in CDM (refs #191)
authorAndrew Dolgov <fox@bah.spb.su>
Tue, 19 Feb 2008 14:49:36 +0000 (15:49 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Tue, 19 Feb 2008 14:49:36 +0000 (15:49 +0100)
feedlist.js
tt-rss.css
viewfeed.js

index 180d6204d515cd4038765c8430a923c4eb91d107..878a538c149383935ab4b549036a214a9e3086da 100644 (file)
@@ -36,6 +36,10 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
 
 //             if (!offset) page_offset = 0;
 
+               if (feed == getActiveFeedId()) {
+                       cache_invalidate("F:" + feed);
+               }
+
                var force_nocache = false;
 
                var page_offset = 0;
index 3c75196bb29d2f477ad7e679b5f05fc65ae2a839..06db9da0cbba6c7a852ad0867e7f8da39ef42a71 100644 (file)
@@ -944,6 +944,10 @@ div.cdmArticleSelected div.cdmFooter {
        background-color : transparent;
 }
 
+div.cdmArticleUnreadSelected div.cdmFooter {
+       background-color : transparent;
+}
+
 div.cdmFooter span.s0 {
        border-width : 0px 1px 0px 0px;
        border-color : #c0c0c0;
index 0609bb5ff23c4b78e51de4924466ecd217c23101..7b3dff325b86c546da9533aadd1889de85c09683 100644 (file)
@@ -667,47 +667,121 @@ function correctHeadlinesOffset(id) {
 
 function moveToPost(mode) {
 
+       try {
+
        // check for combined mode
-       if (!document.getElementById("headlinesList"))
-               return;
+               if (document.getElementById("headlinesList")) {
+       
+                       var rows = getVisibleHeadlineIds();
+               
+                       var prev_id = false;
+                       var next_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 (mode == "next") {
+                               if (next_id) {
+                                       correctHeadlinesOffset(next_id);
+                                       view(next_id, getActiveFeedId());
+                               }
+                       }
+               
+                       if (mode == "prev") {
+                               if (prev_id) {
+                                       correctHeadlinesOffset(prev_id);
+                                       view(prev_id, getActiveFeedId());
+                               }
+                       } 
+               } else {
+                       var rows = cdmGetUnreadArticles();
 
-       var rows = getVisibleHeadlineIds();
+                       if (mode == "next") {
 
-       var prev_id = false;
-       var next_id = false;
+                               for (var i = 0; i < rows.length; i++) {
 
-       if (!document.getElementById('RROW-' + active_post_id)) {
-               active_post_id = false;
-       }
+                                       if (cdmArticleIsActuallyVisible(rows[i]) ||
+                                                       cdmArticleIsBelowViewport(rows[i])) {
+
+                                               cdmScrollToArticleId(rows[i]);
+                                               setTimeout("toggleUnread(" + rows[i] + ", undefined, true)", 500);
+                                               //toggleUnread(rows[i], undefined, true);
+
+                                               break;
+                                       }
+                               }
+
+                       } else if (mode == "prev") {
+
+                               for (var i = 0; i < rows.length; i++) {
+
+                                       if (cdmArticleIsActuallyVisible(rows[i]) ||
+                                                       (cdmArticleIsAboveViewport(rows[i]) &&
+                                                               !cdmArticleIsAboveViewport(rows[i+1]))) {
+
+                                               cdmScrollToArticleId(rows[i]);
+                                               setTimeout("toggleUnread(" + rows[i] + ", undefined, true)", 500);
+                                               //toggleUnread(rows[i], undefined, true);
+
+                                               break;
+                                       } 
+                               }
 
-       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) {
-                       correctHeadlinesOffset(next_id);
-                       view(next_id, getActiveFeedId());
-               }
+       } catch (e) {
+               exception_error(e, "moveToPost");
        }
+}
+
+function toggleSelected(id) {
+       try {
+       
+               var row = document.getElementById("RROW-" + id);
+               if (row) {
+                       var nc = row.className;
+                       
+                       if (!nc.match("Selected")) {
+                               nc = nc + "Selected";
+                       } else {
+                               nc = nc.replace("Selected", "");
+                       }
 
-       if (mode == "prev") {
-               if (prev_id) {
-                       correctHeadlinesOffset(prev_id);
-                       view(prev_id, getActiveFeedId());
+                       row.className = nc;
                }
-       } 
+       } catch (e) {
+               exception_error(e, "toggleSelected");
+       }
 }
 
-function toggleUnread(id, cmode) {
+/*function toggleUnread_afh(effect) {
+       try {
+
+               var elem = effect.element;
+               //elem.style.backgroundColor = "transparent";
+
+               alert(elem.className);
+       } catch (e) {
+               exception_error(e, "toggleUnread_afh");
+       }
+} */
+
+function toggleUnread(id, cmode, effect) {
        try {
        
                var row = document.getElementById("RROW-" + id);
@@ -716,14 +790,36 @@ function toggleUnread(id, cmode) {
                        nc = nc.replace("Unread", "");
                        nc = nc.replace("Selected", "");
 
+                       // since we are removing selection from the object, uncheck
+                       // corresponding checkbox
+
+                       var cb = document.getElementById("RCHK-" + id);
+                       if (cb) {
+                               cb.checked = false;
+                       }
+
+                       // NOTE: I'm not sure that resetting selection here is a feature -fox
+
                        if (cmode == undefined || cmode == 2) {
                                if (row.className.match("Unread")) {
                                        row.className = nc;
+
+/*                                     if (effect) {
+                                               new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5",
+                                                       afterFinish: toggleUnread_afh,
+                                                       queue: { position:'end', scope: 'TMRQ-' + id, limit: 1 } } );
+                                       } */
+
                                } else {
                                        row.className = nc + "Unread";
                                }
                        } else if (cmode == 0) {
                                row.className = nc;
+
+/*                             if (effect) {
+                                       new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5",
+                                               queue: { position:'end', scope: 'TMRQ-' + id, limit: 1 } } );
+                               } */
                        } else if (cmode == 1) {
                                row.className = nc + "Unread";
                        }
@@ -1164,6 +1260,90 @@ function editTagsInsert() {
        }
 }
 
+function cdmArticleIsBelowViewport(id) {
+       try {
+               var ctr = document.getElementById("headlinesInnerContainer");
+               var e = document.getElementById("RROW-" + id);
+
+               if (!e || !ctr) return;
+
+               // article starts below viewport
+
+               if (ctr.scrollTop < e.offsetTop) {
+                       return true;
+               } else {        
+                       return false;
+               }
+
+       } catch (e) {
+               exception_error(e, "cdmArticleIsVisible");
+       }
+}
+
+function cdmArticleIsAboveViewport(id) {
+       try {
+               var ctr = document.getElementById("headlinesInnerContainer");
+               var e = document.getElementById("RROW-" + id);
+
+               if (!e || !ctr) return;
+
+               // article starts above viewport
+
+               if (ctr.scrollTop > e.offsetTop + e.offsetHeight) {
+                       return true;
+               } else {        
+                       return false;
+               }
+
+       } catch (e) {
+               exception_error(e, "cdmArticleIsVisible");
+       }
+}
+
+function cdmScrollToArticleId(id) {
+       try {
+               var ctr = document.getElementById("headlinesInnerContainer");
+               var e = document.getElementById("RROW-" + id);
+
+               if (!e || !ctr) return;
+
+               ctr.scrollTop = e.offsetTop;
+
+       } catch (e) {
+               exception_error(e, "cdmScrollToArticleId");
+       }
+}
+
+function cdmArticleIsActuallyVisible(id) {
+       try {
+               var ctr = document.getElementById("headlinesInnerContainer");
+               var e = document.getElementById("RROW-" + id);
+
+               if (!e || !ctr) return;
+
+               // article fits in viewport OR article is longer than viewport and
+               // its bottom is visible
+
+               if (ctr.scrollTop <= e.offsetTop && e.offsetTop + e.offsetHeight <=
+                               ctr.scrollTop + ctr.offsetHeight) {
+
+                       return true;
+               
+               } else if (e.offsetHeight > ctr.offsetHeight &&
+                               e.offsetTop + e.offsetHeight >= ctr.scrollTop &&
+                               e.offsetTop + e.offsetHeight <= ctr.scrollTop + ctr.offsetHeight) {
+
+                       return true;
+
+               }
+
+               return false;
+
+       } catch (e) {
+               exception_error(e, "cdmArticleIsVisible");
+       }
+}
+
 function cdmWatchdog() {
 
        try {
@@ -1350,6 +1530,8 @@ function cdmMouseOut(elem) {
 function headlines_scroll_handler() {
        try {
 
+               debug("headlines_scroll_handler");
+
                var e = document.getElementById("headlinesInnerContainer");
 
                // don't do infinite scrolling when Limit == All