2018-11-29 18:21:06 +00:00
|
|
|
/* global dijit */
|
2018-08-23 06:56:34 +00:00
|
|
|
define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) {
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
return declare("fox.FeedTree", dijit.Tree, {
|
|
|
|
_onKeyPress: function(/* Event */ e) {
|
|
|
|
return; // Stop dijit.Tree from interpreting keystrokes
|
|
|
|
},
|
|
|
|
_createTreeNode: function(args) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const tnode = new dijit._TreeNode(args);
|
2010-11-17 19:51:44 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const icon = dojo.doc.createElement('img');
|
2017-01-20 17:29:59 +00:00
|
|
|
if (args.item.icon && args.item.icon[0]) {
|
|
|
|
icon.src = args.item.icon[0];
|
|
|
|
} else {
|
|
|
|
icon.src = 'images/blank_icon.gif';
|
|
|
|
}
|
|
|
|
icon.className = 'tinyFeedIcon';
|
|
|
|
domConstruct.place(icon, tnode.iconNode, 'only');
|
2010-11-19 17:18:20 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const id = args.item.id[0];
|
|
|
|
const bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
2010-11-21 13:11:14 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (bare_id < _label_base_index) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const span = dojo.doc.createElement('span');
|
|
|
|
const fg_color = args.item.fg_color[0];
|
|
|
|
const bg_color = args.item.bg_color[0];
|
2010-11-21 13:11:14 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
span.innerHTML = "α";
|
|
|
|
span.className = 'labelColorIndicator';
|
|
|
|
span.setStyle({
|
|
|
|
color: fg_color,
|
|
|
|
backgroundColor: bg_color});
|
2010-11-21 13:11:14 +00:00
|
|
|
|
2017-01-20 17:29:59 +00:00
|
|
|
domConstruct.place(span, tnode.iconNode, 'only');
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
2010-11-19 17:18:20 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (id.match("FEED:")) {
|
2018-11-29 18:21:06 +00:00
|
|
|
let menu = new dijit.Menu();
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.row_id = bare_id;
|
2011-11-11 11:28:11 +00:00
|
|
|
|
2012-09-10 18:51:53 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
2016-08-10 10:40:24 +00:00
|
|
|
label: __("Mark as read"),
|
2012-09-10 18:51:53 +00:00
|
|
|
onClick: function() {
|
2018-12-01 14:21:26 +00:00
|
|
|
Feeds.catchupFeed(this.getParent().row_id);
|
2012-09-10 18:51:53 +00:00
|
|
|
}}));
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (bare_id > 0) {
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Edit feed"),
|
|
|
|
onClick: function() {
|
2018-12-01 19:39:29 +00:00
|
|
|
CommonDialogs.editFeed(this.getParent().row_id, false);
|
2016-08-10 10:40:24 +00:00
|
|
|
}}));
|
|
|
|
|
|
|
|
/* menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Update feed"),
|
|
|
|
onClick: function() {
|
|
|
|
heduleFeedUpdate(this.getParent().row_id, false);
|
|
|
|
}})); */
|
|
|
|
}
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id.match("CAT:") && bare_id >= 0) {
|
2018-11-29 18:21:06 +00:00
|
|
|
let menu = new dijit.Menu();
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.row_id = bare_id;
|
|
|
|
|
2016-11-11 11:14:31 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
2016-11-22 06:11:13 +00:00
|
|
|
label: __("Mark as read"),
|
2016-11-11 11:14:31 +00:00
|
|
|
onClick: function() {
|
2018-12-01 14:21:26 +00:00
|
|
|
Feeds.catchupFeed(this.getParent().row_id, true);
|
2016-11-11 11:14:31 +00:00
|
|
|
}}));
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
2016-11-22 06:11:13 +00:00
|
|
|
label: __("(Un)collapse"),
|
2012-09-10 18:51:53 +00:00
|
|
|
onClick: function() {
|
2016-11-22 06:11:13 +00:00
|
|
|
dijit.byId("feedTree").collapseCat(this.getParent().row_id);
|
2016-08-10 10:40:24 +00:00
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
2012-09-10 18:51:53 +00:00
|
|
|
}
|
2010-11-19 17:18:20 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (id.match("CAT:")) {
|
|
|
|
loading = dojo.doc.createElement('img');
|
|
|
|
loading.className = 'loadingNode';
|
|
|
|
loading.src = 'images/blank_icon.gif';
|
2017-01-21 17:54:36 +00:00
|
|
|
domConstruct.place(loading, tnode.labelNode, 'after');
|
2016-08-10 10:40:24 +00:00
|
|
|
tnode.loadingNode = loading;
|
|
|
|
}
|
2013-05-15 21:08:04 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (id.match("CAT:") && bare_id == -1) {
|
2018-11-29 18:21:06 +00:00
|
|
|
let menu = new dijit.Menu();
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.row_id = bare_id;
|
2013-05-15 21:08:04 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Mark all feeds as read"),
|
|
|
|
onClick: function() {
|
2018-12-01 14:05:28 +00:00
|
|
|
Feeds.catchupAllFeeds();
|
2016-08-10 10:40:24 +00:00
|
|
|
}}));
|
|
|
|
|
|
|
|
menu.bindDomNode(tnode.domNode);
|
|
|
|
tnode._menu = menu;
|
2013-05-07 12:28:49 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
ctr = dojo.doc.createElement('span');
|
|
|
|
ctr.className = 'counterNode';
|
|
|
|
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");
|
|
|
|
|
2017-01-21 17:54:36 +00:00
|
|
|
domConstruct.place(ctr, tnode.rowNode, 'first');
|
2016-08-10 10:40:24 +00:00
|
|
|
tnode.counterNode = ctr;
|
|
|
|
|
|
|
|
//tnode.labelNode.innerHTML = args.label;
|
|
|
|
return tnode;
|
|
|
|
},
|
|
|
|
postCreate: function() {
|
|
|
|
this.connect(this.model, "onChange", "updateCounter");
|
|
|
|
this.connect(this, "_expandNode", function() {
|
2018-12-02 18:52:50 +00:00
|
|
|
this.hideRead(App.getInitParam("hide_read_feeds"), App.getInitParam("hide_read_shows_special"));
|
2016-08-10 10:40:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.inherited(arguments);
|
|
|
|
},
|
|
|
|
updateCounter: function (item) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const tree = this;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
//console.log("updateCounter: " + item.id[0] + " " + item.unread + " " + tree);
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
let node = tree._itemNodesMap[item.id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
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 ?
|
2017-01-22 17:20:35 +00:00
|
|
|
item.unread > 0 ?
|
|
|
|
Effect.Appear(ctr, {duration : 0.3,
|
|
|
|
queue: { position: 'end', scope: 'CAPPEAR-' + item.id, limit: 1 }}) :
|
|
|
|
Element.show(ctr) :
|
2016-08-10 10:40:24 +00:00
|
|
|
Element.hide(ctr);
|
|
|
|
|
|
|
|
item.unread == 0 && item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux");
|
|
|
|
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
getTooltip: function (item) {
|
|
|
|
if (item.updated)
|
|
|
|
return item.updated;
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
},
|
|
|
|
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) {
|
2018-11-29 18:21:06 +00:00
|
|
|
let rc = (!item.error || item.error == '') ? "dijitTreeRow" :
|
2016-08-10 10:40:24 +00:00
|
|
|
"dijitTreeRow Error";
|
|
|
|
|
|
|
|
if (item.unread > 0) rc += " Unread";
|
2018-02-08 10:54:06 +00:00
|
|
|
if (item.updates_disabled > 0) rc += " UpdatesDisabled";
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
},
|
|
|
|
getLabel: function(item) {
|
2018-11-29 18:21:06 +00:00
|
|
|
let name = String(item.name);
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
/* Horrible */
|
|
|
|
name = name.replace(/"/g, "\"");
|
|
|
|
name = name.replace(/&/g, "&");
|
|
|
|
name = name.replace(/—/g, "-");
|
|
|
|
name = name.replace(/</g, "<");
|
|
|
|
name = name.replace(/>/g, ">");
|
|
|
|
|
|
|
|
/* var label;
|
|
|
|
|
|
|
|
if (item.unread > 0) {
|
|
|
|
label = name + " (" + item.unread + ")";
|
|
|
|
} else {
|
|
|
|
label = name;
|
|
|
|
} */
|
|
|
|
|
|
|
|
return name;
|
|
|
|
},
|
|
|
|
expandParentNodes: function(feed, is_cat, list) {
|
|
|
|
try {
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
const id = String(list[i].id);
|
|
|
|
let item = this._itemNodesMap[id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (item) {
|
|
|
|
item = item[0];
|
|
|
|
this._expandNode(item);
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
} catch (e) {
|
2017-03-04 11:34:44 +00:00
|
|
|
exception_error(e);
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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 {
|
2018-11-29 18:21:06 +00:00
|
|
|
const test_id = is_cat ? 'CAT:' + feed : 'FEED:' + feed;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (!root) {
|
|
|
|
if (!this.model || !this.model.store) return false;
|
2013-03-26 12:31:36 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const items = this.model.store._arrayOfTopLevelItems;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < items.length; i++) {
|
2016-08-10 10:40:24 +00:00
|
|
|
if (String(items[i].id) == test_id) {
|
2013-03-26 12:31:36 +00:00
|
|
|
this.expandParentNodes(feed, is_cat, parents);
|
|
|
|
} else {
|
2016-08-10 10:40:24 +00:00
|
|
|
this.findNodeParentsAndExpandThem(feed, is_cat, items[i], []);
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-29 18:21:06 +00:00
|
|
|
} else if (root.items) {
|
2016-08-10 10:40:24 +00:00
|
|
|
parents.push(root);
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < root.items.length; i++) {
|
2016-08-10 10:40:24 +00:00
|
|
|
if (String(root.items[i].id) == test_id) {
|
|
|
|
this.expandParentNodes(feed, is_cat, parents);
|
|
|
|
} else {
|
|
|
|
this.findNodeParentsAndExpandThem(feed, is_cat, root.items[i], parents.slice(0));
|
|
|
|
}
|
|
|
|
}
|
2018-11-29 18:21:06 +00:00
|
|
|
} else if (String(root.id) == test_id) {
|
2016-08-10 10:40:24 +00:00
|
|
|
this.expandParentNodes(feed, is_cat, parents.slice(0));
|
|
|
|
}
|
|
|
|
} catch (e) {
|
2017-03-04 11:34:44 +00:00
|
|
|
exception_error(e);
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
selectFeed: function(feed, is_cat) {
|
|
|
|
this.findNodeParentsAndExpandThem(feed, is_cat, false, false);
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (is_cat)
|
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
|
|
|
|
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
|
|
|
if (!is_cat) this._expandNode(treeNode);
|
|
|
|
this.set("selectedNodes", [treeNode]);
|
2017-05-05 07:35:10 +00:00
|
|
|
this.focusNode(treeNode);
|
2017-05-12 05:05:35 +00:00
|
|
|
|
|
|
|
// focus headlines to route key events there
|
|
|
|
setTimeout(function() {
|
|
|
|
$("headlines-frame").focus();
|
|
|
|
}, 0);
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
setFeedIcon: function(feed, is_cat, src) {
|
|
|
|
if (is_cat)
|
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
2018-11-29 18:21:06 +00:00
|
|
|
const icon = dojo.doc.createElement('img');
|
2017-01-20 17:29:59 +00:00
|
|
|
icon.src = src;
|
|
|
|
icon.className = 'tinyFeedIcon';
|
|
|
|
domConstruct.place(icon, treeNode.iconNode, 'only');
|
2016-08-10 10:40:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
setFeedExpandoIcon: function(feed, is_cat, src) {
|
|
|
|
if (is_cat)
|
|
|
|
treeNode = this._itemNodesMap['CAT:' + feed];
|
|
|
|
else
|
|
|
|
treeNode = this._itemNodesMap['FEED:' + feed];
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
|
|
|
if (treeNode.loadingNode) {
|
|
|
|
treeNode.loadingNode.src = src;
|
|
|
|
return true;
|
|
|
|
} else {
|
2018-11-29 18:21:06 +00:00
|
|
|
const icon = dojo.doc.createElement('img');
|
2017-01-20 17:29:59 +00:00
|
|
|
icon.src = src;
|
2017-01-21 19:30:20 +00:00
|
|
|
icon.className = 'loadingExpando';
|
2017-01-20 17:29:59 +00:00
|
|
|
domConstruct.place(icon, treeNode.expandoNode, 'only');
|
2016-08-10 10:40:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
return false;
|
|
|
|
},
|
|
|
|
hasCats: function() {
|
|
|
|
return this.model.hasCats();
|
|
|
|
},
|
|
|
|
hideReadCat: function (cat, hide, show_special) {
|
|
|
|
if (this.hasCats()) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const tree = this;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (cat && cat.items) {
|
2018-11-29 18:21:06 +00:00
|
|
|
let cat_unread = tree.hideReadFeeds(cat.items, hide, show_special);
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const id = String(cat.id);
|
|
|
|
const node = tree._itemNodesMap[id];
|
|
|
|
const bare_id = parseInt(id.substr(id.indexOf(":")+1));
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (node) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const check_unread = tree.model.getFeedUnread(bare_id, true);
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (hide && cat_unread == 0 && check_unread == 0 && (id != "CAT:-1" || !show_special)) {
|
|
|
|
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
|
|
|
}
|
2012-09-13 22:40:01 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
hideRead: function (hide, show_special) {
|
|
|
|
if (this.hasCats()) {
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const tree = this;
|
|
|
|
const cats = this.model.store._arrayOfTopLevelItems;
|
2012-09-13 22:40:01 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
cats.each(function(cat) {
|
|
|
|
tree.hideReadCat(cat, hide, show_special);
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
this.hideReadFeeds(this.model.store._arrayOfTopLevelItems, hide,
|
|
|
|
show_special);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
hideReadFeeds: function (items, hide, show_special) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const tree = this;
|
|
|
|
let cat_unread = 0;
|
2012-09-13 22:40:01 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
items.each(function(feed) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const id = String(feed.id);
|
2010-11-17 19:51:44 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
// it's a subcategory
|
|
|
|
if (feed.items) {
|
|
|
|
tree.hideReadCat(feed, hide, show_special);
|
|
|
|
} else { // it's a feed
|
2018-11-29 18:21:06 +00:00
|
|
|
const bare_id = parseInt(feed.bare_id);
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const unread = feed.unread[0];
|
|
|
|
const has_error = feed.error[0] != '';
|
|
|
|
const node = tree._itemNodesMap[id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (node) {
|
|
|
|
if (hide && unread == 0 && !has_error && (bare_id > 0 || bare_id < _label_base_index || !show_special)) {
|
|
|
|
Effect.Fade(node[0].rowNode, {duration : 0.3,
|
|
|
|
queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }});
|
|
|
|
} else {
|
|
|
|
Element.show(node[0].rowNode);
|
|
|
|
++cat_unread;
|
|
|
|
}
|
2012-09-15 16:39:44 +00:00
|
|
|
}
|
2010-11-17 19:51:44 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
});
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
return cat_unread;
|
|
|
|
},
|
|
|
|
collapseCat: function(id) {
|
|
|
|
if (!this.model.hasCats()) return;
|
2010-12-27 12:39:40 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const tree = this;
|
2010-12-27 12:39:40 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const node = tree._itemNodesMap['CAT:' + id][0];
|
|
|
|
const item = tree.model.store._itemsByIdentity['CAT:' + id];
|
2010-12-27 12:39:40 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (node && item) {
|
|
|
|
if (!node.isExpanded)
|
|
|
|
tree._expandNode(node);
|
|
|
|
else
|
|
|
|
tree._collapseNode(node);
|
2010-12-27 12:39:40 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getVisibleUnreadFeeds: function() {
|
2018-11-29 18:21:06 +00:00
|
|
|
const items = this.model.store._arrayOfAllItems;
|
|
|
|
const rv = [];
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
const id = String(items[i].id);
|
|
|
|
const box = this._itemNodesMap[id];
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (box) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const row = box[0].rowNode;
|
|
|
|
let cat = false;
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
try {
|
|
|
|
cat = box[0].rowNode.parentNode.parentNode;
|
|
|
|
} catch (e) { }
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (row) {
|
|
|
|
if (Element.visible(row) && (!cat || Element.visible(cat))) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const feed_id = String(items[i].bare_id);
|
|
|
|
const is_cat = !id.match('FEED:');
|
|
|
|
const unread = this.model.getFeedUnread(feed_id, is_cat);
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (unread > 0)
|
|
|
|
rv.push([feed_id, is_cat]);
|
2011-08-31 15:22:47 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
2011-08-31 15:22:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
},
|
|
|
|
getNextFeed: function (feed, is_cat) {
|
|
|
|
if (is_cat) {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
|
|
|
|
} else {
|
|
|
|
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
}
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const items = this.model.store._arrayOfAllItems;
|
|
|
|
let item = items[0];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < items.length; i++) {
|
2016-08-10 10:40:24 +00:00
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let j = i+1; j < items.length; j++) {
|
|
|
|
const id = String(items[j].id);
|
|
|
|
const box = this._itemNodesMap[id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (box) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const row = box[0].rowNode;
|
|
|
|
const cat = box[0].rowNode.parentNode.parentNode;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (Element.visible(cat) && Element.visible(row)) {
|
|
|
|
item = items[j];
|
|
|
|
break;
|
|
|
|
}
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
break;
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (item) {
|
|
|
|
return [this.model.store.getValue(item, 'bare_id'),
|
|
|
|
!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];
|
|
|
|
}
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
const items = this.model.store._arrayOfAllItems;
|
|
|
|
let item = items[0] == treeItem ? items[items.length-1] : items[0];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let i = 0; i < items.length; i++) {
|
2016-08-10 10:40:24 +00:00
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
2018-11-29 18:21:06 +00:00
|
|
|
for (let j = i-1; j > 0; j--) {
|
|
|
|
const id = String(items[j].id);
|
|
|
|
const box = this._itemNodesMap[id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (box) {
|
2018-11-29 18:21:06 +00:00
|
|
|
const row = box[0].rowNode;
|
|
|
|
const cat = box[0].rowNode.parentNode.parentNode;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
if (Element.visible(cat) && Element.visible(row)) {
|
|
|
|
item = items[j];
|
|
|
|
break;
|
|
|
|
}
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
2011-01-18 13:27:31 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2011-01-18 09:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
if (item) {
|
|
|
|
return [this.model.store.getValue(item, 'bare_id'),
|
|
|
|
!this.model.store.getValue(item, 'id').match('FEED:')];
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-18 09:40:19 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
getFeedCategory: function(feed) {
|
|
|
|
try {
|
|
|
|
return this.getNodesByItem(this.model.store.
|
2012-04-04 11:34:06 +00:00
|
|
|
_itemsByIdentity["FEED:" + feed])[0].
|
2016-08-10 10:40:24 +00:00
|
|
|
getParent().item.bare_id[0];
|
2011-01-18 09:40:19 +00:00
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
2010-11-17 19:51:44 +00:00
|
|
|
});
|
2016-08-10 10:40:24 +00:00
|
|
|
|