]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement additional counter mode for virtual feeds when there's 0 unread articles
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 15 May 2013 21:08:04 +0000 (01:08 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 15 May 2013 21:08:04 +0000 (01:08 +0400)
classes/pref/feeds.php
include/functions.php
js/FeedTree.js
js/feedlist.js
tt-rss.css

index ffe7410fe901295c1d35e4db639ebd09ee6f63e1..d43740310700cde1ec7ba46ebbf2b19d0af9729b 100644 (file)
@@ -54,6 +54,7 @@ class Pref_Feeds extends Handler_Protected {
                        $cat['type'] = 'category';
                        $cat['unread'] = 0;
                        $cat['child_unread'] = 0;
+                       $cat['auxcounter'] = 0;
 
                        $cat['items'] = $this->get_category_items($line['id']);
 
@@ -74,6 +75,7 @@ class Pref_Feeds extends Handler_Protected {
                        $feed = array();
                        $feed['id'] = 'FEED:' . $feed_line['id'];
                        $feed['bare_id'] = (int)$feed_line['id'];
+                       $feed['auxcounter'] = 0;
                        $feed['name'] = $feed_line['title'];
                        $feed['checkbox'] = false;
                        $feed['unread'] = 0;
@@ -132,6 +134,7 @@ class Pref_Feeds extends Handler_Protected {
                                        $item = array();
                                        $item['id'] = 'FEED:' . $feed_id;
                                        $item['bare_id'] = (int)$feed_id;
+                                       $item['auxcounter'] = 0;
                                        $item['name'] = $feed['title'];
                                        $item['checkbox'] = false;
                                        $item['error'] = '';
@@ -193,6 +196,7 @@ class Pref_Feeds extends Handler_Protected {
                                $cat = array();
                                $cat['id'] = 'CAT:' . $line['id'];
                                $cat['bare_id'] = (int)$line['id'];
+                               $cat['auxcounter'] = 0;
                                $cat['name'] = $line['title'];
                                $cat['items'] = array();
                                $cat['checkbox'] = false;
@@ -215,6 +219,7 @@ class Pref_Feeds extends Handler_Protected {
                        $cat = array();
                        $cat['id'] = 'CAT:0';
                        $cat['bare_id'] = 0;
+                       $cat['auxcounter'] = 0;
                        $cat['name'] = __("Uncategorized");
                        $cat['items'] = array();
                        $cat['type'] = 'category';
@@ -232,6 +237,7 @@ class Pref_Feeds extends Handler_Protected {
                                $feed = array();
                                $feed['id'] = 'FEED:' . $feed_line['id'];
                                $feed['bare_id'] = (int)$feed_line['id'];
+                               $feed['auxcounter'] = 0;
                                $feed['name'] = $feed_line['title'];
                                $feed['checkbox'] = false;
                                $feed['error'] = $feed_line['last_error'];
@@ -263,6 +269,7 @@ class Pref_Feeds extends Handler_Protected {
                                $feed = array();
                                $feed['id'] = 'FEED:' . $feed_line['id'];
                                $feed['bare_id'] = (int)$feed_line['id'];
+                               $feed['auxcounter'] = 0;
                                $feed['name'] = $feed_line['title'];
                                $feed['checkbox'] = false;
                                $feed['error'] = $feed_line['last_error'];
@@ -1541,6 +1548,7 @@ class Pref_Feeds extends Handler_Protected {
                $obj['updated'] = $updated;
                $obj['icon'] = getFeedIcon($feed_id);
                $obj['bare_id'] = $feed_id;
+               $obj['auxcounter'] = 0;
 
                return $obj;
        }
index 149809a35dad81d79f12fcac71fcf68a72c5acab..5296f9e61ea662db69291a0feb2fc6b71dba1ca8 100644 (file)
 
                        $count = getFeedUnread($i);
 
+                       if ($i == 0 || $i == -1 || $i == -2)
+                               $auxctr = getFeedArticles($i, false);
+                       else
+                               $auxctr = 0;
+
                        $cv = array("id" => $i,
-                               "counter" => (int) $count);
+                               "counter" => (int) $count,
+                               "auxcounter" => $auxctr);
 
 //                     if (get_pref('EXTENDED_FEEDLIST'))
 //                             $cv["xmsg"] = getFeedArticles($i)." ".__("total");
index f3ac8ba19587362c93e6b5c596f18daaaafba6db..e35417dafd1e844b04c696667048a5d77dacf805 100644 (file)
@@ -186,11 +186,13 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
 
                ctr = dojo.doc.createElement('span');
                ctr.className = 'counterNode';
-               ctr.innerHTML = args.item.unread;
+               ctr.innerHTML = args.item.unread > 0 ? args.item.unread : args.item.auxcounter;
 
                //args.item.unread > 0 ? ctr.addClassName("unread") : ctr.removeClassName("unread");
 
-               args.item.unread > 0 ? Element.show(ctr) : Element.hide(ctr);
+               args.item.unread > 0 || args.item.auxcounter > 0 ? Element.show(ctr) : Element.hide(ctr);
+
+               args.item.unread == 0 && args.item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux");
 
                dojo.place(ctr, tnode.rowNode, 'first');
                tnode.counterNode = ctr;
@@ -218,10 +220,14 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
 
                        if (node.counterNode) {
                                ctr = node.counterNode;
-                               ctr.innerHTML = item.unread;
-                               item.unread > 0 ? Effect.Appear(ctr, {duration : 0.3,
+                               ctr.innerHTML = item.unread > 0 ? item.unread : item.auxcounter;
+                               item.unread > 0 || item.auxcounter > 0 ?
+                                       Effect.Appear(ctr, {duration : 0.3,
                                        queue: { position: 'end', scope: 'CAPPEAR-' + item.id, limit: 1 }}) :
                                                Element.hide(ctr);
+
+                               item.unread == 0 && item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux");
+
                        }
                }
 
index 51082f8272f0b854995dbdbf4cdb14225d14f1d5..84b561227578c82b6b62dafb782c61a6520331e7 100644 (file)
@@ -219,6 +219,7 @@ function parse_counters(elems, scheduled_call) {
                        var error = elems[l].error;
                        var has_img = elems[l].has_img;
                        var updated = elems[l].updated;
+                       var auxctr = parseInt(elems[l].auxcounter);
 
                        if (id == "global-unread") {
                                global_unread = ctr;
@@ -236,6 +237,7 @@ function parse_counters(elems, scheduled_call) {
                        }
 
                        setFeedUnread(id, (kind == "cat"), ctr);
+                       setFeedValue(id, (kind == "cat"), 'auxcounter', auxctr);
 
                        if (kind != "cat") {
                                setFeedValue(id, false, 'error', error);
index a437c9d413695c335e699a3cb44a20d3cfbd6b2b..f1459e3c07fad1c6bf7b47f7db0ce5f447545f7a 100644 (file)
@@ -1067,6 +1067,12 @@ div.hl.active {
        font-family : "Segoe UI", Tahoma, sans-serif;
 }
 
+#feedTree .counterNode.aux {
+       background : #f0f0f0;
+       color : #999;
+       border-color : #f0f0f0;
+}
+
 #feedTree .counterNode {
        font-weight : bold;
        display : inline-block;