From 1a709d21d57bd8bc905c02caa62379f547214e64 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 20 Nov 2010 11:52:11 +0300 Subject: [PATCH] enable server-side storage of collapsed status of categories --- FeedTree.js | 18 ++++++++++++++++++ tt-rss.js | 7 +++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/FeedTree.js b/FeedTree.js index 76b46601b..18112f6b7 100644 --- a/FeedTree.js +++ b/FeedTree.js @@ -237,4 +237,22 @@ dojo.declare("fox.FeedTree", dijit.Tree, { return cat_unread; }, + collapseHiddenCats: function() { + if (!this.model.hasCats()) return; + + var cats = this.model.store._arrayOfTopLevelItems; + var tree = this; + + dojo.forEach(cats, function(cat) { + var hidden = tree.model.store.getValue(cat, 'hidden'); + var id = tree.model.store.getValue(cat, 'id'); + var node = tree._itemNodesMap[id][0]; + + if (hidden) + tree._collapseNode(node); + else + tree._expandNode(node); + + }); + }, }); diff --git a/tt-rss.js b/tt-rss.js index a4082bd8b..aa23ea075 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -92,7 +92,7 @@ function updateFeedList() { new Ajax.Request("backend.php", { parameters: "backend.php?op=feeds&subop=collapse&cid=" + - param_escape(cat_id) + "&mode=1" } ); + param_escape(cat_id) + "&mode=0" } ); }, onClose: function (item, node) { var id = String(item.id); @@ -100,7 +100,7 @@ function updateFeedList() { new Ajax.Request("backend.php", { parameters: "backend.php?op=feeds&subop=collapse&cid=" + - param_escape(cat_id) + "&mode=0" } ); + param_escape(cat_id) + "&mode=1" } ); }, onClick: function (item, node) { @@ -133,6 +133,9 @@ function updateFeedList() { var tmph = dojo.connect(tree, 'onLoad', function() { dojo.disconnect(tmph); Element.hide("feedlistLoading"); + + tree.collapseHiddenCats(); + feedlist_init(); // var node = dijit.byId("feedTree")._itemNodesMap['FEED:-2'][0].domNode