|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
/* global dijit */
|
|
|
|
|
define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) {
|
|
|
|
|
|
|
|
|
|
return declare("fox.FeedTree", dijit.Tree, {
|
|
|
|
@ -5,9 +6,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
return; // Stop dijit.Tree from interpreting keystrokes
|
|
|
|
|
},
|
|
|
|
|
_createTreeNode: function(args) {
|
|
|
|
|
var tnode = new dijit._TreeNode(args);
|
|
|
|
|
const tnode = new dijit._TreeNode(args);
|
|
|
|
|
|
|
|
|
|
var icon = dojo.doc.createElement('img');
|
|
|
|
|
const icon = dojo.doc.createElement('img');
|
|
|
|
|
if (args.item.icon && args.item.icon[0]) {
|
|
|
|
|
icon.src = args.item.icon[0];
|
|
|
|
|
} else {
|
|
|
|
@ -16,13 +17,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
icon.className = 'tinyFeedIcon';
|
|
|
|
|
domConstruct.place(icon, tnode.iconNode, 'only');
|
|
|
|
|
|
|
|
|
|
var id = args.item.id[0];
|
|
|
|
|
var bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
|
|
|
|
const id = args.item.id[0];
|
|
|
|
|
const bare_id = parseInt(id.substr(id.indexOf(':')+1));
|
|
|
|
|
|
|
|
|
|
if (bare_id < _label_base_index) {
|
|
|
|
|
var span = dojo.doc.createElement('span');
|
|
|
|
|
var fg_color = args.item.fg_color[0];
|
|
|
|
|
var bg_color = args.item.bg_color[0];
|
|
|
|
|
const span = dojo.doc.createElement('span');
|
|
|
|
|
const fg_color = args.item.fg_color[0];
|
|
|
|
|
const bg_color = args.item.bg_color[0];
|
|
|
|
|
|
|
|
|
|
span.innerHTML = "α";
|
|
|
|
|
span.className = 'labelColorIndicator';
|
|
|
|
@ -34,7 +35,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id.match("FEED:")) {
|
|
|
|
|
var menu = new dijit.Menu();
|
|
|
|
|
let menu = new dijit.Menu();
|
|
|
|
|
menu.row_id = bare_id;
|
|
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
@ -62,7 +63,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id.match("CAT:") && bare_id >= 0) {
|
|
|
|
|
var menu = new dijit.Menu();
|
|
|
|
|
let menu = new dijit.Menu();
|
|
|
|
|
menu.row_id = bare_id;
|
|
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
@ -90,7 +91,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id.match("CAT:") && bare_id == -1) {
|
|
|
|
|
var menu = new dijit.Menu();
|
|
|
|
|
let menu = new dijit.Menu();
|
|
|
|
|
menu.row_id = bare_id;
|
|
|
|
|
|
|
|
|
|
menu.addChild(new dijit.MenuItem({
|
|
|
|
@ -128,11 +129,11 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
this.inherited(arguments);
|
|
|
|
|
},
|
|
|
|
|
updateCounter: function (item) {
|
|
|
|
|
var tree = this;
|
|
|
|
|
const tree = this;
|
|
|
|
|
|
|
|
|
|
//console.log("updateCounter: " + item.id[0] + " " + item.unread + " " + tree);
|
|
|
|
|
|
|
|
|
|
var node = tree._itemNodesMap[item.id];
|
|
|
|
|
let node = tree._itemNodesMap[item.id];
|
|
|
|
|
|
|
|
|
|
if (node) {
|
|
|
|
|
node = node[0];
|
|
|
|
@ -166,7 +167,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
return (item.unread == 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
|
|
|
|
|
},
|
|
|
|
|
getRowClass: function (item, opened) {
|
|
|
|
|
var rc = (!item.error || item.error == '') ? "dijitTreeRow" :
|
|
|
|
|
let rc = (!item.error || item.error == '') ? "dijitTreeRow" :
|
|
|
|
|
"dijitTreeRow Error";
|
|
|
|
|
|
|
|
|
|
if (item.unread > 0) rc += " Unread";
|
|
|
|
@ -175,7 +176,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
return rc;
|
|
|
|
|
},
|
|
|
|
|
getLabel: function(item) {
|
|
|
|
|
var name = String(item.name);
|
|
|
|
|
let name = String(item.name);
|
|
|
|
|
|
|
|
|
|
/* Horrible */
|
|
|
|
|
name = name.replace(/"/g, "\"");
|
|
|
|
@ -196,9 +197,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
},
|
|
|
|
|
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];
|
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
|
const id = String(list[i].id);
|
|
|
|
|
let item = this._itemNodesMap[id];
|
|
|
|
|
|
|
|
|
|
if (item) {
|
|
|
|
|
item = item[0];
|
|
|
|
@ -213,37 +214,33 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
// 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;
|
|
|
|
|
const test_id = is_cat ? 'CAT:' + feed : 'FEED:' + feed;
|
|
|
|
|
|
|
|
|
|
if (!root) {
|
|
|
|
|
if (!this.model || !this.model.store) return false;
|
|
|
|
|
|
|
|
|
|
var items = this.model.store._arrayOfTopLevelItems;
|
|
|
|
|
const items = this.model.store._arrayOfTopLevelItems;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
|
for (let 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) {
|
|
|
|
|
} else if (root.items) {
|
|
|
|
|
parents.push(root);
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < root.items.length; i++) {
|
|
|
|
|
for (let i = 0; i < root.items.length; i++) {
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (String(root.id) == test_id) {
|
|
|
|
|
} else if (String(root.id) == test_id) {
|
|
|
|
|
this.expandParentNodes(feed, is_cat, parents.slice(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
exception_error(e);
|
|
|
|
|
}
|
|
|
|
@ -276,7 +273,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
|
|
|
|
|
if (treeNode) {
|
|
|
|
|
treeNode = treeNode[0];
|
|
|
|
|
var icon = dojo.doc.createElement('img');
|
|
|
|
|
const icon = dojo.doc.createElement('img');
|
|
|
|
|
icon.src = src;
|
|
|
|
|
icon.className = 'tinyFeedIcon';
|
|
|
|
|
domConstruct.place(icon, treeNode.iconNode, 'only');
|
|
|
|
@ -296,7 +293,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
treeNode.loadingNode.src = src;
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
var icon = dojo.doc.createElement('img');
|
|
|
|
|
const icon = dojo.doc.createElement('img');
|
|
|
|
|
icon.src = src;
|
|
|
|
|
icon.className = 'loadingExpando';
|
|
|
|
|
domConstruct.place(icon, treeNode.expandoNode, 'only');
|
|
|
|
@ -311,17 +308,17 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
},
|
|
|
|
|
hideReadCat: function (cat, hide, show_special) {
|
|
|
|
|
if (this.hasCats()) {
|
|
|
|
|
var tree = this;
|
|
|
|
|
const tree = this;
|
|
|
|
|
|
|
|
|
|
if (cat && cat.items) {
|
|
|
|
|
var cat_unread = tree.hideReadFeeds(cat.items, hide, show_special);
|
|
|
|
|
let cat_unread = tree.hideReadFeeds(cat.items, hide, show_special);
|
|
|
|
|
|
|
|
|
|
var id = String(cat.id);
|
|
|
|
|
var node = tree._itemNodesMap[id];
|
|
|
|
|
var bare_id = parseInt(id.substr(id.indexOf(":")+1));
|
|
|
|
|
const id = String(cat.id);
|
|
|
|
|
const node = tree._itemNodesMap[id];
|
|
|
|
|
const bare_id = parseInt(id.substr(id.indexOf(":")+1));
|
|
|
|
|
|
|
|
|
|
if (node) {
|
|
|
|
|
var check_unread = tree.model.getFeedUnread(bare_id, true);
|
|
|
|
|
const check_unread = tree.model.getFeedUnread(bare_id, true);
|
|
|
|
|
|
|
|
|
|
if (hide && cat_unread == 0 && check_unread == 0 && (id != "CAT:-1" || !show_special)) {
|
|
|
|
|
Effect.Fade(node[0].rowNode, {duration : 0.3,
|
|
|
|
@ -337,8 +334,8 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
hideRead: function (hide, show_special) {
|
|
|
|
|
if (this.hasCats()) {
|
|
|
|
|
|
|
|
|
|
var tree = this;
|
|
|
|
|
var cats = this.model.store._arrayOfTopLevelItems;
|
|
|
|
|
const tree = this;
|
|
|
|
|
const cats = this.model.store._arrayOfTopLevelItems;
|
|
|
|
|
|
|
|
|
|
cats.each(function(cat) {
|
|
|
|
|
tree.hideReadCat(cat, hide, show_special);
|
|
|
|
@ -350,21 +347,21 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
hideReadFeeds: function (items, hide, show_special) {
|
|
|
|
|
var tree = this;
|
|
|
|
|
var cat_unread = 0;
|
|
|
|
|
const tree = this;
|
|
|
|
|
let cat_unread = 0;
|
|
|
|
|
|
|
|
|
|
items.each(function(feed) {
|
|
|
|
|
var id = String(feed.id);
|
|
|
|
|
const id = String(feed.id);
|
|
|
|
|
|
|
|
|
|
// it's a subcategory
|
|
|
|
|
if (feed.items) {
|
|
|
|
|
tree.hideReadCat(feed, hide, show_special);
|
|
|
|
|
} else { // it's a feed
|
|
|
|
|
var bare_id = parseInt(feed.bare_id);;
|
|
|
|
|
const bare_id = parseInt(feed.bare_id);
|
|
|
|
|
|
|
|
|
|
var unread = feed.unread[0];
|
|
|
|
|
var has_error = feed.error[0] != '';
|
|
|
|
|
var node = tree._itemNodesMap[id];
|
|
|
|
|
const unread = feed.unread[0];
|
|
|
|
|
const has_error = feed.error[0] != '';
|
|
|
|
|
const node = tree._itemNodesMap[id];
|
|
|
|
|
|
|
|
|
|
if (node) {
|
|
|
|
|
if (hide && unread == 0 && !has_error && (bare_id > 0 || bare_id < _label_base_index || !show_special)) {
|
|
|
|
@ -383,10 +380,10 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
collapseCat: function(id) {
|
|
|
|
|
if (!this.model.hasCats()) return;
|
|
|
|
|
|
|
|
|
|
var tree = this;
|
|
|
|
|
const tree = this;
|
|
|
|
|
|
|
|
|
|
var node = tree._itemNodesMap['CAT:' + id][0];
|
|
|
|
|
var item = tree.model.store._itemsByIdentity['CAT:' + id];
|
|
|
|
|
const node = tree._itemNodesMap['CAT:' + id][0];
|
|
|
|
|
const item = tree.model.store._itemsByIdentity['CAT:' + id];
|
|
|
|
|
|
|
|
|
|
if (node && item) {
|
|
|
|
|
if (!node.isExpanded)
|
|
|
|
@ -397,16 +394,16 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getVisibleUnreadFeeds: function() {
|
|
|
|
|
var items = this.model.store._arrayOfAllItems;
|
|
|
|
|
var rv = [];
|
|
|
|
|
const items = this.model.store._arrayOfAllItems;
|
|
|
|
|
const rv = [];
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
|
var id = String(items[i].id);
|
|
|
|
|
var box = this._itemNodesMap[id];
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
|
const id = String(items[i].id);
|
|
|
|
|
const box = this._itemNodesMap[id];
|
|
|
|
|
|
|
|
|
|
if (box) {
|
|
|
|
|
var row = box[0].rowNode;
|
|
|
|
|
var cat = false;
|
|
|
|
|
const row = box[0].rowNode;
|
|
|
|
|
let cat = false;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
cat = box[0].rowNode.parentNode.parentNode;
|
|
|
|
@ -414,9 +411,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
const feed_id = String(items[i].bare_id);
|
|
|
|
|
const is_cat = !id.match('FEED:');
|
|
|
|
|
const unread = this.model.getFeedUnread(feed_id, is_cat);
|
|
|
|
|
|
|
|
|
|
if (unread > 0)
|
|
|
|
|
rv.push([feed_id, is_cat]);
|
|
|
|
@ -435,19 +432,19 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
items = this.model.store._arrayOfAllItems;
|
|
|
|
|
var item = items[0];
|
|
|
|
|
const items = this.model.store._arrayOfAllItems;
|
|
|
|
|
let item = items[0];
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
|
|
|
|
|
for (var j = i+1; j < items.length; j++) {
|
|
|
|
|
var id = String(items[j].id);
|
|
|
|
|
var box = this._itemNodesMap[id];
|
|
|
|
|
for (let j = i+1; j < items.length; j++) {
|
|
|
|
|
const id = String(items[j].id);
|
|
|
|
|
const box = this._itemNodesMap[id];
|
|
|
|
|
|
|
|
|
|
if (box) {
|
|
|
|
|
var row = box[0].rowNode;
|
|
|
|
|
var cat = box[0].rowNode.parentNode.parentNode;
|
|
|
|
|
const row = box[0].rowNode;
|
|
|
|
|
const cat = box[0].rowNode.parentNode.parentNode;
|
|
|
|
|
|
|
|
|
|
if (Element.visible(cat) && Element.visible(row)) {
|
|
|
|
|
item = items[j];
|
|
|
|
@ -473,19 +470,19 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
|
|
|
|
|
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
items = this.model.store._arrayOfAllItems;
|
|
|
|
|
var item = items[0] == treeItem ? items[items.length-1] : items[0];
|
|
|
|
|
const items = this.model.store._arrayOfAllItems;
|
|
|
|
|
let item = items[0] == treeItem ? items[items.length-1] : items[0];
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
|
for (let i = 0; i < items.length; i++) {
|
|
|
|
|
if (items[i] == treeItem) {
|
|
|
|
|
|
|
|
|
|
for (var j = i-1; j > 0; j--) {
|
|
|
|
|
var id = String(items[j].id);
|
|
|
|
|
var box = this._itemNodesMap[id];
|
|
|
|
|
for (let j = i-1; j > 0; j--) {
|
|
|
|
|
const id = String(items[j].id);
|
|
|
|
|
const box = this._itemNodesMap[id];
|
|
|
|
|
|
|
|
|
|
if (box) {
|
|
|
|
|
var row = box[0].rowNode;
|
|
|
|
|
var cat = box[0].rowNode.parentNode.parentNode;
|
|
|
|
|
const row = box[0].rowNode;
|
|
|
|
|
const cat = box[0].rowNode.parentNode.parentNode;
|
|
|
|
|
|
|
|
|
|
if (Element.visible(cat) && Element.visible(row)) {
|
|
|
|
|
item = items[j];
|
|
|
|
|