]> git.wh0rd.org - tt-rss.git/blobdiff - js/FeedTree.js
temporarily enable entity loader when importing opml because idk
[tt-rss.git] / js / FeedTree.js
index a3761ad2e349e8125464f523749c929186523d0b..6c06f00d5ea09fc775906a09579540be2b32e957 100644 (file)
@@ -58,12 +58,12 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
 
                if (is_cat) {
                        treeItem = this.store._itemsByIdentity['CAT:' + feed];
-                       items = this.store._arrayOfTopLevelItems;
                } else {
                        treeItem = this.store._itemsByIdentity['FEED:' + feed];
-                       items = this.store._arrayOfAllItems;
                }
 
+               items = this.store._arrayOfAllItems;
+
                for (var i = 0; i < items.length; i++) {
                        if (items[i] == treeItem) {
 
@@ -71,14 +71,18 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
                                        var unread = this.store.getValue(items[j], 'unread');
                                        var id = this.store.getValue(items[j], 'id');
 
-                                       if (unread > 0 && (is_cat || id.match("FEED:"))) return items[j];
+                                       if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) {
+                                               if( !is_cat || ! (this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed) ) return items[j];
+                                       }
                                }
 
                                for (var j = 0; j < i; j++) {
                                        var unread = this.store.getValue(items[j], 'unread');
                                        var id = this.store.getValue(items[j], 'id');
 
-                                       if (unread > 0 && (is_cat || id.match("FEED:"))) return items[j];
+                                       if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) {
+                                               if( !is_cat || ! (this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed) ) return items[j];
+                                       }
                                }
                        }
                }
@@ -186,13 +190,52 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
 
                ctr = dojo.doc.createElement('span');
                ctr.className = 'counterNode';
-               ctr.innerHTML = '0';
-               dojo.place(ctr, tnode.labelNode, 'after');
+               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 || 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;
 
                //tnode.labelNode.innerHTML = args.label;
                return tnode;
        },
+       postCreate: function() {
+               this.connect(this.model, "onChange", "updateCounter");
+               this.connect(this, "_expandNode", function() {
+                       this.hideRead(getInitParam("hide_read_feeds"), getInitParam("hide_read_shows_special"));
+               });
+
+               this.inherited(arguments);
+       },
+       updateCounter: function (item) {
+               var tree = this;
+
+               //console.log("updateCounter: " + item.id[0] + " " + item.unread + " " + tree);
+
+               var node = tree._itemNodesMap[item.id];
+
+               if (node) {
+                       node = node[0];
+
+                       if (node.counterNode) {
+                               ctr = node.counterNode;
+                               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");
+
+                       }
+               }
+
+       },
        getTooltip: function (item) {
                if (item.updated)
                        return item.updated;
@@ -322,11 +365,9 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
 
                if (treeNode) {
                        treeNode = treeNode[0];
-                       if (is_cat) {
-                               if (treeNode.loadingNode) {
-                                       treeNode.loadingNode.src = src;
-                                       return true;
-                               }
+                       if (treeNode.loadingNode) {
+                               treeNode.loadingNode.src = src;
+                               return true;
                        } else {
                                treeNode.expandoNode.src = src;
                                return true;
@@ -502,7 +543,7 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
                }
 
                items = this.model.store._arrayOfAllItems;
-               var item = items[0];
+               var item = items[0] == treeItem ? items[items.length-1] : items[0];
 
                for (var i = 0; i < items.length; i++) {
                        if (items[i] == treeItem) {