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, {
|
2019-04-07 10:21:52 +00:00
|
|
|
_onContainerKeydown: function(/* Event */ e) {
|
|
|
|
return; // Stop dijit.Tree from interpreting keystrokes
|
|
|
|
},
|
|
|
|
_onContainerKeypress: function(/* Event */ e) {
|
2016-08-10 10:40:24 +00:00
|
|
|
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-12-05 17:26:27 +00:00
|
|
|
const iconName = args.item.icon ? String(args.item.icon[0]) : null;
|
|
|
|
let iconNode;
|
|
|
|
|
|
|
|
if (iconName) {
|
|
|
|
if (iconName.indexOf("/") == -1) {
|
2020-02-20 11:14:45 +00:00
|
|
|
iconNode = dojo.create("i", { className: "material-icons icon icon-" + iconName, innerHTML: iconName });
|
2018-12-05 17:26:27 +00:00
|
|
|
} else {
|
2020-02-20 11:14:45 +00:00
|
|
|
iconNode = dojo.create('img', { className: 'icon' });
|
2018-12-05 17:26:27 +00:00
|
|
|
if (args.item.icon && args.item.icon[0]) {
|
|
|
|
iconNode.src = args.item.icon[0];
|
|
|
|
} else {
|
|
|
|
iconNode.src = 'images/blank_icon.gif';
|
|
|
|
}
|
|
|
|
}
|
2017-01-20 17:29:59 +00:00
|
|
|
}
|
2018-12-05 17:26:27 +00:00
|
|
|
|
|
|
|
if (iconNode)
|
|
|
|
domConstruct.place(iconNode, 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) {
|
2020-02-20 11:14:45 +00:00
|
|
|
const label = dojo.create('i', { className: "material-icons icon icon-label", innerHTML: "label" });
|
|
|
|
|
2018-12-06 05:26:52 +00:00
|
|
|
//const fg_color = args.item.fg_color[0];
|
2018-11-29 18:21:06 +00:00
|
|
|
const bg_color = args.item.bg_color[0];
|
2010-11-21 13:11:14 +00:00
|
|
|
|
2018-12-06 05:26:52 +00:00
|
|
|
label.setStyle({
|
|
|
|
color: bg_color,
|
|
|
|
});
|
2010-11-21 13:11:14 +00:00
|
|
|
|
2018-12-06 05:26:52 +00:00
|
|
|
domConstruct.place(label, 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
|
|
|
}}));
|
|
|
|
|
2019-04-08 12:51:05 +00:00
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
label: __("Debug feed"),
|
|
|
|
onClick: function() {
|
|
|
|
window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + this.getParent().row_id +
|
|
|
|
"&csrf_token=" + App.getInitParam("csrf_token"));
|
|
|
|
}}));
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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:")) {
|
2020-02-20 11:14:45 +00:00
|
|
|
tnode.loadingNode = dojo.create('img', { className: 'loadingNode', src: 'images/blank_icon.gif'});
|
|
|
|
domConstruct.place(tnode.loadingNode, tnode.labelNode, 'after');
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
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() {
|
2019-01-31 09:16:56 +00:00
|
|
|
Feeds.catchupAll();
|
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
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
tnode.markedCounterNode = dojo.create('span', { className: 'counterNode marked', innerHTML: args.item.markedcounter });
|
|
|
|
domConstruct.place(tnode.markedCounterNode, tnode.rowNode, 'first');
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
tnode.auxCounterNode = dojo.create('span', { className: 'counterNode aux', innerHTML: args.item.auxcounter });
|
|
|
|
domConstruct.place(tnode.auxCounterNode, tnode.rowNode, 'first');
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
tnode.unreadCounterNode = dojo.create('span', { className: 'counterNode unread', innerHTML: args.item.unread });
|
|
|
|
domConstruct.place(tnode.unreadCounterNode, tnode.rowNode, 'first');
|
2016-08-10 10:40:24 +00:00
|
|
|
|
|
|
|
return tnode;
|
|
|
|
},
|
|
|
|
postCreate: function() {
|
|
|
|
this.connect(this.model, "onChange", "updateCounter");
|
|
|
|
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);
|
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeNode = tree._itemNodesMap[item.id];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
if (treeNode) {
|
|
|
|
treeNode = treeNode[0];
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
treeNode.unreadCounterNode.innerHTML = item.unread;
|
|
|
|
treeNode.auxCounterNode.innerHTML = item.auxcounter;
|
|
|
|
treeNode.markedCounterNode.innerHTML = item.markedcounter;
|
2013-03-26 12:31:36 +00:00
|
|
|
}
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
getTooltip: function (item) {
|
2018-12-10 10:38:59 +00:00
|
|
|
return [item.updated, item.error].filter(x => x && x != "").join(" - ");
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
getIconClass: function (item, opened) {
|
2018-12-05 17:26:27 +00:00
|
|
|
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon";
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
getLabelClass: function (item, opened) {
|
2019-05-06 06:32:08 +00:00
|
|
|
return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
|
2016-08-10 10:40:24 +00:00
|
|
|
},
|
|
|
|
getRowClass: function (item, opened) {
|
2020-02-21 11:06:21 +00:00
|
|
|
let rc = "dijitTreeRow";
|
|
|
|
|
|
|
|
const is_cat = String(item.id).indexOf('CAT:') != -1;
|
2016-08-10 10:40:24 +00:00
|
|
|
|
2020-02-21 11:06:21 +00:00
|
|
|
if (!is_cat && item.error != '') rc += " Error";
|
2016-08-10 10:40:24 +00:00
|
|
|
if (item.unread > 0) rc += " Unread";
|
2020-02-20 11:14:45 +00:00
|
|
|
if (item.auxcounter > 0) rc += " Has_Aux";
|
2020-01-24 11:35:10 +00:00
|
|
|
if (item.markedcounter > 0) rc += " Has_Marked";
|
2018-02-08 10:54:06 +00:00
|
|
|
if (item.updates_disabled > 0) rc += " UpdatesDisabled";
|
2020-02-21 11:06:21 +00:00
|
|
|
if (item.bare_id < 0 || item.bare_id == 0 && !is_cat) rc += " Special";
|
|
|
|
if (item.bare_id == -1 && is_cat) rc += " AlwaysVisible";
|
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, ">");
|
|
|
|
|
|
|
|
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) {
|
2018-12-03 10:38:13 +00:00
|
|
|
App.Error.report(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) {
|
2018-12-03 10:38:13 +00:00
|
|
|
App.Error.report(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
|
|
|
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeNode;
|
|
|
|
|
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
|
2019-01-27 20:31:00 +00:00
|
|
|
setTimeout(() => {
|
2017-05-12 05:05:35 +00:00
|
|
|
$("headlines-frame").focus();
|
2019-01-27 20:31:00 +00:00
|
|
|
|
2019-01-28 15:49:58 +00:00
|
|
|
if (treeNode) {
|
|
|
|
const node = treeNode.rowNode;
|
|
|
|
const tree = this.domNode;
|
|
|
|
|
|
|
|
if (node && tree) {
|
|
|
|
// scroll tree to selection if needed
|
|
|
|
if (node.offsetTop < tree.scrollTop || node.offsetTop > tree.scrollTop + tree.clientHeight) {
|
|
|
|
$("feedTree").scrollTop = node.offsetTop;
|
|
|
|
}
|
2019-01-28 15:48:56 +00:00
|
|
|
}
|
2019-01-27 20:31:00 +00:00
|
|
|
}
|
|
|
|
|
2017-05-12 05:05:35 +00:00
|
|
|
}, 0);
|
2016-08-10 10:40:24 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
setFeedIcon: function(feed, is_cat, src) {
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeNode;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
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];
|
2020-02-20 11:14:45 +00:00
|
|
|
const icon = dojo.create('img', { src: src, className: 'icon' });
|
2017-01-20 17:29:59 +00:00
|
|
|
domConstruct.place(icon, treeNode.iconNode, 'only');
|
2016-08-10 10:40:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
setFeedExpandoIcon: function(feed, is_cat, src) {
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeNode;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
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 {
|
2020-02-20 11:14:45 +00:00
|
|
|
const icon = dojo.create('img', { src: src, 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();
|
|
|
|
},
|
|
|
|
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
|
|
|
}
|
|
|
|
},
|
|
|
|
getNextFeed: function (feed, is_cat) {
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeItem;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
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) {
|
2020-02-20 11:14:45 +00:00
|
|
|
let treeItem;
|
|
|
|
|
2016-08-10 10:40:24 +00:00
|
|
|
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
|
|
|
|