2010-11-17 19:51:44 +00:00
|
|
|
dojo.provide("fox.FeedTree");
|
|
|
|
dojo.provide("fox.FeedStoreModel");
|
|
|
|
|
|
|
|
dojo.require("dijit.Tree");
|
2010-11-19 17:18:20 +00:00
|
|
|
dojo.require("dijit.Menu");
|
2010-11-17 19:51:44 +00:00
|
|
|
|
|
|
|
dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
|
2010-11-19 19:18:26 +00:00
|
|
|
getItemsInCategory: function (id) {
|
|
|
|
if (!this.store._itemsByIdentity) return undefined;
|
|
|
|
|
|
|
|
cat = this.store._itemsByIdentity['CAT:' + id];
|
|
|
|
|
|
|
|
if (cat && cat.items)
|
|
|
|
return cat.items;
|
|
|
|
else
|
|
|
|
return undefined;
|
|
|
|
|
|
|
|
},
|
2010-11-17 19:51:44 +00:00
|
|
|
getItemById: function(id) {
|
|
|
|
return this.store._itemsByIdentity[id];
|
|
|
|
},
|
2011-08-31 15:22:47 +00:00
|
|
|
getFeedValue: function(feed, is_cat, key) {
|
2010-11-19 12:38:24 +00:00
|
|
|
if (!this.store._itemsByIdentity) return undefined;
|
|
|
|
|
2011-08-31 15:22:47 +00:00
|
|
|
if (is_cat)
|
2010-11-17 19:51:44 +00:00
|
|
|
treeItem = this.store._itemsByIdentity['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeItem = this.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
|
|
|
|
if (treeItem)
|
|
|
|
return this.store.getValue(treeItem, key);
|
|
|
|
},
|
2011-08-31 15:22:47 +00:00
|
|
|
getFeedName: function(feed, is_cat) {
|
2010-11-17 19:51:44 +00:00
|
|
|
return this.getFeedValue(feed, is_cat, 'name');
|
|
|
|
},
|
|
|
|
getFeedUnread: function(feed, is_cat) {
|
|
|
|
var unread = parseInt(this.getFeedValue(feed, is_cat, 'unread'));
|
|
|
|
return (isNaN(unread)) ? 0 : unread;
|
|
|
|
},
|
|
|
|
setFeedUnread: function(feed, is_cat, unread) {
|
|
|
|
return this.setFeedValue(feed, is_cat, 'unread', parseInt(unread));
|
|
|
|
},
|
|
|
|
setFeedValue: function(feed, is_cat, key, value) {
|
|
|
|
if (!value) value = '';
|
2010-11-19 12:38:24 +00:00
|
|
|
if (!this.store._itemsByIdentity) return undefined;
|
2010-11-17 19:51:44 +00:00
|
|
|
|
2011-08-31 15:22:47 +00:00
|
|
|
if (is_cat)
|
2010-11-17 19:51:44 +00:00
|
|
|
treeItem = this.store._itemsByIdentity['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeItem = this.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
|
|
|
|
if (treeItem)
|
|
|
|
return this.store.setValue(treeItem, key, value);
|
|
|
|
},
|
2010-11-20 08:25:08 +00:00
|
|
|
getNextUnreadFeed: function (feed, is_cat) {
|
2011-09-01 12:13:08 +00:00
|
|
|
if (!this.store._itemsByIdentity)
|
|
|
|
return null;
|
|
|
|
|
2010-11-20 08:25:08 +00:00
|
|
|
if (is_cat) {
|
|
|
|
treeItem = this.store._itemsByIdentity['CAT:' + feed];
|
|
|
|
items = this.store._arrayOfTopLevelItems;
|
|
|
|
} else {
|
|
|
|
treeItem = this.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
items = this.store._arrayOfAllItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
2011-12-10 17:26:59 +00:00
|
|
|
for (var j = i+1; j < items.length; j++) {
|
2010-11-20 08:25:08 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2011-12-10 17:26:59 +00:00
|
|
|
for (var j = 0; j < i; j++) {
|
2010-11-20 08:25:08 +00:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2010-11-20 08:25:08 +00:00
|
|
|
return null;
|
|
|
|
},
|
|
|
|
hasCats: function() {
|
|
|
|
if (this.store && this.store._itemsByIdentity)
|
|
|
|
return this.store._itemsByIdentity['CAT:-1'] != undefined;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
},
|
2010-11-17 19:51:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
dojo.declare("fox.FeedTree", dijit.Tree, {
|
2012-02-02 08:40:10 +00:00
|
|
|
_onKeyPress: function(/* Event */ e) {
|
|
|
|
return; // Stop dijit.Tree from interpreting keystrokes
|
|
|
|
},
|
2010-11-17 19:51:44 +00:00
|
|
|
_createTreeNode: function(args) {
|
|
|
|
var tnode = new dijit._TreeNode(args);
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2013-04-17 05:09:51 +00:00
|
|
|
if (args.item.icon && args.item.icon[0])
|
2010-11-17 19:51:44 +00:00
|
|
|
tnode.iconNode.src = args.item.icon[0];
|
|
|
|
|
2010-11-19 17:18:20 +00:00
|
|
|
var id = args.item.id[0];
|
|
|
|
var bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
|
|
|
|
2013-03-27 05:40:07 +00:00
|
|
|
if (bare_id < _label_base_index) {
|
2010-11-21 13:11:14 +00:00
|
|
|
var span = dojo.doc.createElement('span');
|
|
|
|
var fg_color = args.item.fg_color[0];
|
|
|
|
var bg_color = args.item.bg_color[0];
|
|
|
|
|
|
|
|
span.innerHTML = "α";
|
|
|
|
span.className = 'labelColorIndicator';
|
|
|
|
span.setStyle({
|
|
|
|
color: fg_color,
|
|
|
|
backgroundColor: bg_color});
|
|
|
|
|
|
|
|
dojo.place(span, tnode.iconNode, 'replace');
|
|
|
|
}
|
|
|
|
|
2012-09-10 18:51:53 +00:00
|
|
|
if (id.match("FEED:")) {
|
2010-11-19 17:18:20 +00:00
|
|
|
var menu = new dijit.Menu();
|
|
|
|
menu.row_id = bare_id;
|
|
|
|
|
2011-11-11 11:28:11 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Mark as read"),
|
|
|
|
onClick: function() {
|
|
|
|
catchupFeed(this.getParent().row_id);
|
|
|
|
}}));
|
|
|
|
|
2012-09-10 18:51:53 +00:00
|
|
|
if (bare_id > 0) {
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Edit feed"),
|
|
|
|
onClick: function() {
|
|
|
|
editFeed(this.getParent().row_id, false);
|
|
|
|
}}));
|
|
|
|
|
2012-10-25 09:15:14 +00:00
|
|
|
/* menu.addChild(new dijit.MenuItem({
|
2012-09-10 18:51:53 +00:00
|
|
|
label: __("Update feed"),
|
|
|
|
onClick: function() {
|
2012-10-25 09:15:14 +00:00
|
|
|
heduleFeedUpdate(this.getParent().row_id, false);
|
|
|
|
}})); */
|
2012-09-10 18:51:53 +00:00
|
|
|
}
|
2010-11-19 17:18:20 +00:00
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
|
|
|
}
|
|
|
|
|
2013-01-18 14:09:44 +00:00
|
|
|
if (id.match("CAT:") && bare_id >= 0) {
|
2011-11-11 11:28:11 +00:00
|
|
|
var menu = new dijit.Menu();
|
|
|
|
menu.row_id = bare_id;
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Mark as read"),
|
|
|
|
onClick: function() {
|
|
|
|
catchupFeed(this.getParent().row_id, true);
|
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
|
|
|
}
|
|
|
|
|
2013-03-19 16:29:20 +00:00
|
|
|
if (id.match("CAT:")) {
|
|
|
|
loading = dojo.doc.createElement('img');
|
|
|
|
loading.className = 'loadingNode';
|
2013-03-21 10:13:13 +00:00
|
|
|
loading.src = 'images/blank_icon.gif';
|
2013-03-19 16:29:20 +00:00
|
|
|
dojo.place(loading, tnode.labelNode, 'after');
|
|
|
|
tnode.loadingNode = loading;
|
|
|
|
}
|
|
|
|
|
2013-01-18 14:12:39 +00:00
|
|
|
if (id.match("CAT:") && bare_id == -1) {
|
|
|
|
var menu = new dijit.Menu();
|
|
|
|
menu.row_id = bare_id;
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Mark all feeds as read"),
|
|
|
|
onClick: function() {
|
|
|
|
catchupAllFeeds();
|
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
|
|
|
}
|
|
|
|
|
2013-04-10 11:22:05 +00:00
|
|
|
ctr = dojo.doc.createElement('span');
|
|
|
|
ctr.className = 'counterNode';
|
2013-05-07 12:28:49 +00:00
|
|
|
ctr.innerHTML = args.item.unread;
|
|
|
|
|
2013-05-07 16:03:09 +00:00
|
|
|
//args.item.unread > 0 ? ctr.addClassName("unread") : ctr.removeClassName("unread");
|
|
|
|
|
|
|
|
args.item.unread > 0 ? Element.show(ctr) : Element.hide(ctr);
|
2013-05-07 12:28:49 +00:00
|
|
|
|
2013-05-07 21:40:10 +00:00
|
|
|
dojo.place(ctr, tnode.rowNode, 'first');
|
2013-04-10 11:22:05 +00:00
|
|
|
tnode.counterNode = ctr;
|
2013-01-18 14:12:39 +00:00
|
|
|
|
2010-12-28 06:05:06 +00:00
|
|
|
//tnode.labelNode.innerHTML = args.label;
|
2010-11-17 19:51:44 +00:00
|
|
|
return tnode;
|
|
|
|
},
|
2013-05-07 12:28:49 +00:00
|
|
|
postCreate: function() {
|
|
|
|
this.connect(this.model, "onChange", "updateCounter");
|
|
|
|
|
|
|
|
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) {
|
2013-05-07 16:03:09 +00:00
|
|
|
ctr = node.counterNode;
|
|
|
|
ctr.innerHTML = item.unread;
|
|
|
|
item.unread > 0 ? Effect.Appear(ctr, {duration : 0.3,
|
|
|
|
queue: { position: 'end', scope: 'CAPPEAR-' + item.id, limit: 1 }}) :
|
|
|
|
Element.hide(ctr);
|
2013-05-07 12:28:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
2013-05-07 11:50:53 +00:00
|
|
|
getTooltip: function (item) {
|
|
|
|
if (item.updated)
|
|
|
|
return item.updated;
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
},
|
2010-11-17 19:51:44 +00:00
|
|
|
getIconClass: function (item, opened) {
|
|
|
|
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feedIcon";
|
|
|
|
},
|
|
|
|
getLabelClass: function (item, opened) {
|
|
|
|
return (item.unread == 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
|
|
|
|
},
|
|
|
|
getRowClass: function (item, opened) {
|
2013-04-10 11:22:05 +00:00
|
|
|
var rc = (!item.error || item.error == '') ? "dijitTreeRow" :
|
2010-11-17 19:51:44 +00:00
|
|
|
"dijitTreeRow Error";
|
2013-04-10 11:22:05 +00:00
|
|
|
|
|
|
|
if (item.unread > 0) rc += " Unread";
|
|
|
|
|
|
|
|
return rc;
|
2010-11-17 19:51:44 +00:00
|
|
|
},
|
|
|
|
getLabel: function(item) {
|
2010-12-28 13:10:10 +00:00
|
|
|
var name = String(item.name);
|
|
|
|
|
|
|
|
/* Horrible */
|
2011-01-24 07:05:15 +00:00
|
|
|
name = name.replace(/"/g, "\"");
|
|
|
|
name = name.replace(/&/g, "&");
|
|
|
|
name = name.replace(/—/g, "-");
|
|
|
|
name = name.replace(/</g, "<");
|
|
|
|
name = name.replace(/>/g, ">");
|
2010-12-28 13:10:10 +00:00
|
|
|
|
2013-04-10 11:22:05 +00:00
|
|
|
/* var label;
|
2012-08-13 15:52:34 +00:00
|
|
|
|
2010-11-17 19:51:44 +00:00
|
|
|
if (item.unread > 0) {
|
2012-08-13 15:52:34 +00:00
|
|
|
label = name + " (" + item.unread + ")";
|
2010-11-17 19:51:44 +00:00
|
|
|
} else {
|
2012-08-13 15:52:34 +00:00
|
|
|
label = name;
|
2013-04-10 11:22:05 +00:00
|
|
|
} */
|
2012-08-13 15:52:34 +00:00
|
|
|
|
2013-04-10 11:22:05 +00:00
|
|
|
return name;
|
2010-11-17 19:51:44 +00:00
|
|
|
},
|
2013-03-26 12:31:36 +00:00
|
|
|
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 {
|
2013-04-04 16:58:43 +00:00
|
|
|
this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents.slice(0));
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (String(root.id) == test_id) {
|
2013-04-04 16:58:43 +00:00
|
|
|
this.expandParentNodes(feed, is_cat, parents.slice(0));
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
exception_error("findNodeParentsAndExpandThem", e);
|
|
|
|
}
|
|
|
|
},
|
2010-11-17 19:51:44 +00:00
|
|
|
selectFeed: function(feed, is_cat) {
|
2013-03-26 12:31:36 +00:00
|
|
|
this.findNodeParentsAndExpandThem(feed, is_cat, false, false);
|
|
|
|
|
2011-08-31 15:22:47 +00:00
|
|
|
if (is_cat)
|
2010-11-17 19:51:44 +00:00
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
|
|
|
|
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
|
|
|
if (!is_cat) this._expandNode(treeNode);
|
2011-11-08 16:40:44 +00:00
|
|
|
this.set("selectedNodes", [treeNode]);
|
2010-11-17 19:51:44 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
setFeedIcon: function(feed, is_cat, src) {
|
2011-08-31 15:22:47 +00:00
|
|
|
if (is_cat)
|
2010-11-17 19:51:44 +00:00
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
|
|
|
|
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
|
|
|
treeNode.iconNode.src = src;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
setFeedExpandoIcon: function(feed, is_cat, src) {
|
2011-08-31 15:22:47 +00:00
|
|
|
if (is_cat)
|
2010-11-17 19:51:44 +00:00
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
|
|
|
|
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
2013-05-07 12:44:59 +00:00
|
|
|
if (treeNode.loadingNode) {
|
|
|
|
treeNode.loadingNode.src = src;
|
|
|
|
return true;
|
2013-03-19 16:29:20 +00:00
|
|
|
} else {
|
|
|
|
treeNode.expandoNode.src = src;
|
|
|
|
return true;
|
|
|
|
}
|
2010-11-17 19:51:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
hasCats: function() {
|
2010-11-20 08:25:08 +00:00
|
|
|
return this.model.hasCats();
|
2010-11-17 19:51:44 +00:00
|
|
|
},
|
2012-09-13 22:40:01 +00:00
|
|
|
hideReadCat: function (cat, hide, show_special) {
|
2010-11-17 19:51:44 +00:00
|
|
|
if (this.hasCats()) {
|
|
|
|
var tree = this;
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2012-09-13 22:40:01 +00:00
|
|
|
if (cat && cat.items) {
|
2010-11-17 19:51:44 +00:00
|
|
|
var cat_unread = tree.hideReadFeeds(cat.items, hide, show_special);
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2010-11-17 19:51:44 +00:00
|
|
|
var id = String(cat.id);
|
|
|
|
var node = tree._itemNodesMap[id];
|
|
|
|
var bare_id = parseInt(id.substr(id.indexOf(":")+1));
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2010-11-17 19:51:44 +00:00
|
|
|
if (node) {
|
|
|
|
var check_unread = tree.model.getFeedUnread(bare_id, true);
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2012-10-11 08:46:33 +00:00
|
|
|
if (hide && cat_unread == 0 && check_unread == 0) {
|
2011-08-31 15:22:47 +00:00
|
|
|
Effect.Fade(node[0].rowNode, {duration : 0.3,
|
2010-11-17 19:51:44 +00:00
|
|
|
queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }});
|
|
|
|
} else {
|
|
|
|
Element.show(node[0].rowNode);
|
|
|
|
++cat_unread;
|
|
|
|
}
|
2011-08-31 15:22:47 +00:00
|
|
|
}
|
2012-09-13 22:40:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
hideRead: function (hide, show_special) {
|
|
|
|
if (this.hasCats()) {
|
|
|
|
|
|
|
|
var tree = this;
|
|
|
|
var cats = this.model.store._arrayOfTopLevelItems;
|
|
|
|
|
|
|
|
cats.each(function(cat) {
|
|
|
|
tree.hideReadCat(cat, hide, show_special);
|
2010-11-17 19:51:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
2011-08-31 15:22:47 +00:00
|
|
|
this.hideReadFeeds(this.model.store._arrayOfTopLevelItems, hide,
|
2010-11-17 19:51:44 +00:00
|
|
|
show_special);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
hideReadFeeds: function (items, hide, show_special) {
|
|
|
|
var tree = this;
|
|
|
|
var cat_unread = 0;
|
|
|
|
|
|
|
|
items.each(function(feed) {
|
|
|
|
var id = String(feed.id);
|
2012-09-15 16:39:44 +00:00
|
|
|
|
2012-09-15 16:44:50 +00:00
|
|
|
// it's a subcategory
|
|
|
|
if (feed.items) {
|
2012-09-15 16:46:02 +00:00
|
|
|
tree.hideReadCat(feed, hide, show_special);
|
2012-09-15 16:44:50 +00:00
|
|
|
} else { // it's a feed
|
2012-09-15 16:39:44 +00:00
|
|
|
var bare_id = parseInt(feed.bare_id);;
|
|
|
|
|
|
|
|
var unread = feed.unread[0];
|
|
|
|
var node = tree._itemNodesMap[id];
|
|
|
|
|
|
|
|
if (node) {
|
2013-03-27 05:40:07 +00:00
|
|
|
if (hide && unread == 0 && (bare_id > 0 || bare_id < _label_base_index || !show_special)) {
|
2012-09-15 16:39:44 +00:00
|
|
|
Effect.Fade(node[0].rowNode, {duration : 0.3,
|
|
|
|
queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }});
|
|
|
|
} else {
|
|
|
|
Element.show(node[0].rowNode);
|
|
|
|
++cat_unread;
|
|
|
|
}
|
2010-11-17 19:51:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2010-11-17 19:51:44 +00:00
|
|
|
return cat_unread;
|
|
|
|
},
|
2010-12-27 12:39:40 +00:00
|
|
|
collapseCat: function(id) {
|
|
|
|
if (!this.model.hasCats()) return;
|
|
|
|
|
|
|
|
var tree = this;
|
|
|
|
|
|
|
|
var node = tree._itemNodesMap['CAT:' + id][0];
|
|
|
|
var item = tree.model.store._itemsByIdentity['CAT:' + id];
|
|
|
|
|
|
|
|
if (node && item) {
|
2013-02-27 11:34:13 +00:00
|
|
|
if (!node.isExpanded)
|
2010-12-27 12:39:40 +00:00
|
|
|
tree._expandNode(node);
|
|
|
|
else
|
|
|
|
tree._collapseNode(node);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
2011-08-31 15:22:47 +00:00
|
|
|
getVisibleUnreadFeeds: function() {
|
|
|
|
var items = this.model.store._arrayOfAllItems;
|
|
|
|
var rv = [];
|
|
|
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
var id = String(items[i].id);
|
|
|
|
var box = this._itemNodesMap[id];
|
|
|
|
|
|
|
|
if (box) {
|
|
|
|
var row = box[0].rowNode;
|
|
|
|
var cat = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
cat = box[0].rowNode.parentNode.parentNode;
|
|
|
|
} catch (e) { }
|
|
|
|
|
|
|
|
if (row) {
|
|
|
|
if (Element.visible(row) && (!cat || Element.visible(cat))) {
|
|
|
|
var feed_id = String(items[i].bare_id);
|
|
|
|
var is_cat = !id.match('FEED:');
|
|
|
|
var unread = this.model.getFeedUnread(feed_id, is_cat);
|
|
|
|
|
|
|
|
if (unread > 0)
|
|
|
|
rv.push([feed_id, is_cat]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
},
|
2011-01-18 09:40:19 +00:00
|
|
|
getNextFeed: function (feed, is_cat) {
|
|
|
|
if (is_cat) {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
|
|
|
|
} else {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
}
|
|
|
|
|
|
|
|
items = this.model.store._arrayOfAllItems;
|
|
|
|
var item = items[0];
|
|
|
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
2011-12-10 17:26:59 +00:00
|
|
|
for (var j = i+1; j < items.length; j++) {
|
2011-08-31 15:22:47 +00:00
|
|
|
var id = String(items[j].id);
|
2011-01-18 09:40:19 +00:00
|
|
|
var box = this._itemNodesMap[id];
|
|
|
|
|
|
|
|
if (box) {
|
2011-01-18 13:27:31 +00:00
|
|
|
var row = box[0].rowNode;
|
|
|
|
var cat = box[0].rowNode.parentNode.parentNode;
|
2011-01-18 09:40:19 +00:00
|
|
|
|
2011-01-18 13:27:31 +00:00
|
|
|
if (Element.visible(cat) && Element.visible(row)) {
|
2011-01-18 09:40:19 +00:00
|
|
|
item = items[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item) {
|
2011-08-31 15:22:47 +00:00
|
|
|
return [this.model.store.getValue(item, 'bare_id'),
|
2011-01-18 09:40:19 +00:00
|
|
|
!this.model.store.getValue(item, 'id').match('FEED:')];
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getPreviousFeed: function (feed, is_cat) {
|
|
|
|
if (is_cat) {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
|
|
|
|
} else {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
}
|
|
|
|
|
|
|
|
items = this.model.store._arrayOfAllItems;
|
|
|
|
var item = items[0];
|
|
|
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
2011-12-10 17:26:59 +00:00
|
|
|
for (var j = i-1; j > 0; j--) {
|
2011-08-31 15:22:47 +00:00
|
|
|
var id = String(items[j].id);
|
2011-01-18 09:40:19 +00:00
|
|
|
var box = this._itemNodesMap[id];
|
|
|
|
|
|
|
|
if (box) {
|
2011-01-18 13:27:31 +00:00
|
|
|
var row = box[0].rowNode;
|
|
|
|
var cat = box[0].rowNode.parentNode.parentNode;
|
2011-01-18 09:40:19 +00:00
|
|
|
|
2011-01-18 13:27:31 +00:00
|
|
|
if (Element.visible(cat) && Element.visible(row)) {
|
2011-01-18 09:40:19 +00:00
|
|
|
item = items[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-18 13:27:31 +00:00
|
|
|
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item) {
|
2011-08-31 15:22:47 +00:00
|
|
|
return [this.model.store.getValue(item, 'bare_id'),
|
2011-01-18 09:40:19 +00:00
|
|
|
!this.model.store.getValue(item, 'id').match('FEED:')];
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
2012-04-04 11:34:06 +00:00
|
|
|
getFeedCategory: function(feed) {
|
|
|
|
try {
|
|
|
|
return this.getNodesByItem(this.model.store.
|
|
|
|
_itemsByIdentity["FEED:" + feed])[0].
|
|
|
|
getParent().item.bare_id[0];
|
2011-01-18 09:40:19 +00:00
|
|
|
|
2012-04-04 11:34:06 +00:00
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2010-11-17 19:51:44 +00:00
|
|
|
});
|