]> git.wh0rd.org - tt-rss.git/blobdiff - viewfeed.js
add collapsed CDM mode
[tt-rss.git] / viewfeed.js
index 9aad5e2921b38ff4f026a46e6afd0536487fddf4..24584e49fc376317d6c39621de9f863b31a008bf 100644 (file)
@@ -109,8 +109,17 @@ function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) {
                                                if (!c) {
                                                        c = document.getElementById("headlinesInnerContainer");
                                                }
+
+                                               var ids = getSelectedArticleIds2();
        
                                                c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
+
+                                               debug("restore selected ids: " + ids);
+
+                                               for (var i = 0; i < ids.length; i++) {
+                                                       markHeadline(ids[i]);
+                                               }
+
                                        } else {
                                                debug("no new headlines received");
                                        }
@@ -175,7 +184,8 @@ function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) {
                }
        
                _feed_cur_page = feed_cur_page;
-       
+               _infscroll_request_sent = 0;
+
                notify("");
        } catch (e) {
                exception_error("headlines_callback2", e);
@@ -203,6 +213,9 @@ function showArticleInHeadlines(id) {
                cleanSelected("headlinesList");
        
                var crow = document.getElementById("RROW-" + id);
+
+               if (!crow) return;
+
                var article_is_unread = crow.className.match("Unread");
                        
                crow.className = crow.className.replace("Unread", "");
@@ -300,17 +313,6 @@ function view(id, feed_id, skip_history) {
 
                var date = new Date();
 
-/*             if (!xmlhttp_ready(xmlhttp) && last_article_view < date.getTime() / 1000 - 15) {
-                       debug("<b>xmlhttp seems to be stuck at view, aborting</b>");
-                       xmlhttp.abort();
-                       if (is_safari()) {
-                               debug("trying alternative reset method for Safari");
-                               xmlhttp = Ajax.getTransport();
-                       }
-               }
-
-               if (xmlhttp_ready(xmlhttp)) { */
-
                var neighbor_ids = getRelativePostIds(active_post_id);
 
                /* only request uncached articles */
@@ -679,11 +681,6 @@ function toggleUnread(id, cmode) {
 
 function selectionToggleUnread(cdm_mode, set_state, callback_func, no_error) {
        try {
-/*             if (!xmlhttp_ready(xmlhttp_rpc)) {
-                       printLockingError();
-                       return;
-               } */
-       
                var rows;
 
                if (cdm_mode) {
@@ -737,16 +734,8 @@ function selectionToggleUnread(cdm_mode, set_state, callback_func, no_error) {
                        var query = "backend.php?op=rpc&subop=catchupSelected&ids=" +
                                param_escape(rows.toString()) + "&cmode=" + cmode;
 
-//                     _catchup_callback_func = callback_func;
-
-                       debug(callback_func);
-
                        notify_progress("Loading, please wait...");
 
-/*                     xmlhttp_rpc.open("GET", query, true);
-                       xmlhttp_rpc.onreadystatechange=catchup_callback;
-                       xmlhttp_rpc.send(null); */
-
                        new Ajax.Request(query, {
                                onComplete: function(transport) { 
                                        catchup_callback2(transport, callback_func); 
@@ -975,8 +964,9 @@ function catchupSelection() {
        
                var fn = getFeedName(getActiveFeedId(), active_feed_is_cat);
                
-               var str = __("Mark all selected articles in %s as read?");
+               var str = __("Mark %d selected articles in %s as read?");
        
+               str = str.replace("%d", rows.length);
                str = str.replace("%s", fn);
        
                if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
@@ -1013,12 +1003,12 @@ function labelFromSearch(search, search_mode, match_on, feed_id, is_cat) {
                        "&title=" + param_escape(title);
 
                debug("LFS: " + query);
-       
-               xmlhttp_rpc.open("GET", query, true);
-               xmlhttp_rpc.onreadystatechange=dlg_frefresh_callback;
-               xmlhttp_rpc.send(null);
-       }
 
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       dlg_frefresh_callback(transport);
+                               } });
+       }
 }
 
 function editArticleTags(id, feed_id, cdm_enabled) {
@@ -1035,40 +1025,34 @@ function editArticleTags(id, feed_id, cdm_enabled) {
 }
 
 
-function tag_saved_callback() {
-       if (xmlhttp_rpc.readyState == 4) {
-               try {
-                       debug("in tag_saved_callback");
+function tag_saved_callback(transport) {
+       try {
+               debug("in tag_saved_callback");
 
-                       closeInfoBox();
-                       notify("");
+               closeInfoBox();
+               notify("");
 
-                       if (tagsAreDisplayed()) {
-                               _reload_feedlist_after_view = true;
-                       }
+               if (tagsAreDisplayed()) {
+                       _reload_feedlist_after_view = true;
+               }
 
-                       if (!_tag_active_cdm) {
-                               if (active_post_id == _tag_active_post_id) {
-                                       debug("reloading current article");
-                                       view(_tag_active_post_id, _tag_active_feed_id);                 
-                               }
-                       } else {
-                               debug("reloading current feed");
-                               viewCurrentFeed();
+               if (!_tag_active_cdm) {
+                       if (active_post_id == _tag_active_post_id) {
+                               debug("reloading current article");
+                               view(_tag_active_post_id, _tag_active_feed_id);                 
                        }
-
-               } catch (e) {
-                       exception_error("catchup_callback", e);
+               } else {
+                       debug("reloading current feed");
+                       viewCurrentFeed();
                }
+
+       } catch (e) {
+               exception_error("catchup_callback", e);
        }
 }
 
 function editTagsSave() {
 
-       if (!xmlhttp_ready(xmlhttp_rpc)) {
-               printLockingError();
-       }
-
        notify_progress("Saving article tags...");
 
        var form = document.forms["tag_edit_form"];
@@ -1079,9 +1063,10 @@ function editTagsSave() {
 
        debug(query);
 
-       xmlhttp_rpc.open("GET", query, true);                   
-       xmlhttp_rpc.onreadystatechange=tag_saved_callback;
-       xmlhttp_rpc.send(null);
+       new Ajax.Request(query, {
+               onComplete: function(transport) {
+                               tag_saved_callback(transport);
+                       } });
 
 }
 
@@ -1275,10 +1260,17 @@ function headlines_scroll_handler() {
 
                var e = document.getElementById("headlinesInnerContainer");
 
-               if (e.scrollTop + e.offsetHeight > e.scrollHeight - 300) {
-                       if (!_infscroll_disable) {
-                               debug("more cowbell!");
-                               viewNextFeedPage();
+               // don't do infinite scrolling when Limit == All
+
+               var toolbar_form = document.forms["main_toolbar_form"];
+
+               var limit = toolbar_form.limit[toolbar_form.limit.selectedIndex];
+               if (limit.value != 0) {
+                       if (e.scrollTop + e.offsetHeight > e.scrollHeight - 50) {
+                               if (!_infscroll_disable) {
+                                       debug("more cowbell!");
+                                       viewNextFeedPage();
+                               }
                        }
                }
 
@@ -1351,10 +1343,11 @@ function catchupRelativeToArticle(below) {
                                var query = "backend.php?op=rpc&subop=catchupSelected&ids=" +
                                        param_escape(ids_to_mark.toString()) + "&cmode=0";
 
-                               xmlhttp_rpc.open("GET", query, true);
-                               xmlhttp_rpc.onreadystatechange=catchup_callback;
-                               xmlhttp_rpc.send(null);
-       
+                               new Ajax.Request(query, {
+                                       onComplete: function(transport) { 
+                                               catchup_callback2(transport); 
+                                       } });
+
                        }
                }
 
@@ -1362,3 +1355,25 @@ function catchupRelativeToArticle(below) {
                exception_error("catchupRelativeToArticle", e);
        }
 }
+
+function cdmExpandArticle(a_id) {
+       try {
+               var id = 'CICD-' + a_id;
+
+               Effect.Appear(id, {duration : 0.5, 
+                       beforeStart: function(effect) { 
+                               var h_id = 'CICH-' + a_id;
+                               var h_elem = document.getElementById(h_id);
+                               if (h_elem) { h_elem.style.display = "none"; }
+
+                               toggleUnread(a_id, 0);
+                       }});
+
+
+       } catch (e) {
+               exception_error("appearBlockElementF", e);
+       }
+
+}
+
+