]> git.wh0rd.org Git - tt-rss.git/commitdiff
manually find and expand all parent nodes of a selected feed in feedTree
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 26 Mar 2013 12:31:36 +0000 (16:31 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 26 Mar 2013 12:32:06 +0000 (16:32 +0400)
because dojo is incapable of doing it itself in a situation where tree
persistence cookie is at initial state, bloody fucking hell

js/FeedTree.js
js/feedlist.js

index 2e686c156728334b54b42176b9be6bd4460c5a0e..e0b068f177fb2b2f402604573fc4bb75cbc929d5 100644 (file)
@@ -218,7 +218,63 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
 
                return label;
        },
+       expandParentNodes: function(feed, is_cat, list) {
+               try {
+                       for (var i = 0; i < list.length; i++) {
+                               var id = String(list[i].id);
+                               var item = this._itemNodesMap[id];
+
+                               if (item) {
+                                       item = item[0];
+                                       this._expandNode(item);
+                               }
+                       }
+               } catch (e) {
+                       exception_error("expandParentNodes", e);
+               }
+       },
+       findNodeParentsAndExpandThem: function(feed, is_cat, root, parents) {
+               // expands all parents of specified feed to properly mark it as active
+               // my fav thing about frameworks is doing everything myself
+               try {
+                       var test_id = is_cat ? 'CAT:' + feed : 'FEED:' + feed;
+
+                       if (!root) {
+                               if (!this.model || !this.model.store) return false;
+
+                               var items = this.model.store._arrayOfTopLevelItems;
+
+                               for (var i = 0; i < items.length; i++) {
+                                       if (String(items[i].id) == test_id) {
+                                               this.expandParentNodes(feed, is_cat, parents);
+                                       } else {
+                                               this.findNodeParentsAndExpandThem(feed, is_cat, items[i], []);
+                                       }
+                               }
+                       } else {
+                               if (root.items) {
+                                       parents.push(root);
+
+                                       for (var i = 0; i < root.items.length; i++) {
+                                               if (String(root.items[i].id) == test_id) {
+                                                       this.expandParentNodes(feed, is_cat, parents);
+                                               } else {
+                                                       this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents);
+                                               }
+                                       }
+                               } else {
+                                       if (String(root.id) == test_id) {
+                                               this.expandParentNodes(feed, is_cat, parents);
+                                       }
+                               }
+                       }
+               } catch (e) {
+                       exception_error("findNodeParentsAndExpandThem", e);
+               }
+       },
        selectFeed: function(feed, is_cat) {
+               this.findNodeParentsAndExpandThem(feed, is_cat, false, false);
+
                if (is_cat)
                        treeNode = this._itemNodesMap['CAT:' + feed];
                else
index aaf6c2aa6f767a4e62a60ecfb929538144a9e487..7385177d1f48c48da1f97d7284d560950a004245 100644 (file)
@@ -513,3 +513,5 @@ function decrementFeedCounter(feed, is_cat) {
                exception_error("decrement_feed_counter", e);
        }
 }
+
+