diff options
author | Andrew Dolgov <[email protected]> | 2012-08-14 10:47:24 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-08-14 10:47:24 +0400 |
commit | 675b51e8ff6bf0e9a34dd4c774e2d619e27df505 (patch) | |
tree | 4f9f8b877de00e7d47a389d895746bf04a78c25c /js | |
parent | f5fdc4f4f1de5f078f0eb0c2f678f533c3734452 (diff) | |
parent | 854a2ace869b29f805d203bb74968ef1500eb54b (diff) |
Merge branch 'nested-cats'
Diffstat (limited to 'js')
-rw-r--r-- | js/FeedTree.js | 27 | ||||
-rw-r--r-- | js/PrefFeedTree.js | 8 | ||||
-rw-r--r-- | js/feedlist.js | 17 | ||||
-rw-r--r-- | js/tt-rss.js | 16 |
4 files changed, 60 insertions, 8 deletions
diff --git a/js/FeedTree.js b/js/FeedTree.js index 30e625015..b39e72862 100644 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -120,6 +120,14 @@ dojo.declare("fox.FeedTree", dijit.Tree, { dojo.place(span, tnode.iconNode, 'replace'); } + if (id.match("CAT:") && bare_id > 0) { + param = dojo.doc.createElement('span'); + param.className = 'feedParam'; + param.innerHTML = ""; + dojo.place(param, tnode.labelNode, 'after'); + tnode._paramNode = param; + } + if (id.match("FEED:") && bare_id > 0) { var menu = new dijit.Menu(); menu.row_id = bare_id; @@ -183,11 +191,15 @@ dojo.declare("fox.FeedTree", dijit.Tree, { name = name.replace(/</g, "<"); name = name.replace(/>/g, ">"); + var label; + if (item.unread > 0) { - return name + " (" + item.unread + ")"; + label = name + " (" + item.unread + ")"; } else { - return name; + label = name; } + + return label; }, selectFeed: function(feed, is_cat) { if (is_cat) @@ -443,4 +455,15 @@ dojo.declare("fox.FeedTree", dijit.Tree, { return false; } }, + setCatParam: function(cat, value) { + var treeNode = this._itemNodesMap['CAT:' + cat]; + + if (treeNode && treeNode[0] && treeNode[0]._paramNode) { + if (value > 0) + treeNode[0]._paramNode.innerHTML = '+' + value; + else + treeNode[0]._paramNode.innerHTML = ""; + } + this.model.setFeedValue(cat, true, 'child_unread', value); + }, }); diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 9e2ee0662..12c02c447 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -5,7 +5,7 @@ dojo.require("lib.CheckBoxTree"); dojo.require("dojo.data.ItemFileWriteStore"); dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, { - + _saveEverything: function(saveCompleteCallback, saveFailedCallback, newFileContentString) { @@ -17,7 +17,7 @@ dojo.declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, { load: saveCompleteCallback}); }, -}); +}); dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, { _createTreeNode: function(args) { @@ -42,7 +42,7 @@ dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, { this.tree.model.store.save(); }, getRowClass: function (item, opened) { - return (!item.error || item.error == '') ? "dijitTreeRow" : + return (!item.error || item.error == '') ? "dijitTreeRow" : "dijitTreeRow Error"; }, getIconClass: function (item, opened) { @@ -71,7 +71,7 @@ dojo.declare("fox.PrefFeedTree", lib.CheckBoxTree, { return ((id.match("CAT:") && position == "over") || (id.match("FEED:") && position != "over")); } else if (source_id.match("CAT:")) { - return ((id.match("CAT:") && position != "over") || + return ((id.match("CAT:") && !id.match("CAT:0")) || (id.match("root") && position == "over")); } }, diff --git a/js/feedlist.js b/js/feedlist.js index 13cdc2694..aef4bbe16 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -170,6 +170,7 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) { } query += "&cat=" + is_cat; + query += "&include_children=" + dijit.byId("include_children").attr("checked"); console.log(query); @@ -286,6 +287,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 child_unread = parseInt(elems[l].child_counter); if (id == "global-unread") { global_unread = ctr; @@ -322,6 +324,8 @@ function parse_counters(elems, scheduled_call) { setFeedIcon(id, false, 'images/blank_icon.gif'); } } + } else { + setCatParam(id, child_unread); } } @@ -411,6 +415,19 @@ function setFeedValue(feed, is_cat, key, value) { } } +function setCatParam(cat, value) { + try { + var tree = dijit.byId("feedTree"); + + if (tree && tree.model) + return tree.setCatParam(cat, value); + + } catch (e) { + // + } +} + + function selectFeed(feed, is_cat) { try { var tree = dijit.byId("feedTree"); diff --git a/js/tt-rss.js b/js/tt-rss.js index ef5d72e5b..8a82e4c7d 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -42,6 +42,9 @@ function setActiveFeedId(id, is_cat) { selectFeed(id, is_cat); + dijit.byId("include_children").attr("disabled", !(is_cat && id > 0)); + + } catch (e) { exception_error("setActiveFeedId", e); } @@ -61,12 +64,12 @@ function updateFeedList() { } var store = new dojo.data.ItemFileWriteStore({ - url: "backend.php?op=feeds"}); + url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2"}); var treeModel = new fox.FeedStoreModel({ store: store, query: { - "type": "feed" + "type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed" }, rootId: "root", rootLabel: "Feeds", @@ -105,6 +108,8 @@ function updateFeedList() { id: "feedTree", }, "feedTree"); + _force_scheduled_update = true; + /* var menu = new dijit.Menu({id: 'feedMenu'}); menu.addChild(new dijit.MenuItem({ @@ -324,6 +329,13 @@ function init_second_stage() { dijit.getEnclosingWidget(toolbar.order_by).attr('value', getInitParam("default_view_order_by")); + + if (getInitParam("enable_feed_cats") == 0) + Element.hide(dijit.byId("include_children").domNode); + + dijit.byId("include_children").attr("checked", + getInitParam("default_include_children")); + feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1; loading_set_progress(30); |