summaryrefslogtreecommitdiff
path: root/js/FeedTree.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/FeedTree.js')
-rwxr-xr-xjs/FeedTree.js158
1 files changed, 97 insertions, 61 deletions
diff --git a/js/FeedTree.js b/js/FeedTree.js
index 17cd3deea..b81638c39 100755
--- a/js/FeedTree.js
+++ b/js/FeedTree.js
@@ -82,6 +82,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
}
if (id.match("FEED:")) {
+ tnode.rowNode.setAttribute('data-feed-id', bare_id);
+ tnode.rowNode.setAttribute('data-is-cat', "false");
+
const menu = new dijit.Menu();
menu.row_id = bare_id;
@@ -132,10 +135,18 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
}
if (id.match("CAT:")) {
- tnode.loadingNode = dojo.create('img', { className: 'loadingNode', src: 'images/blank_icon.gif'});
+ tnode.rowNode.setAttribute('data-feed-id', bare_id);
+ tnode.rowNode.setAttribute('data-is-cat', "true");
+
+ tnode.loadingNode = dojo.create('img', { className: 'loadingNode', src: App.getInitParam('icon_blank')});
domConstruct.place(tnode.loadingNode, tnode.labelNode, 'after');
}
+ if (id.match("FEED:")) {
+ tnode.loadingNode = dojo.create('img', { className: 'loadingNode', src: App.getInitParam('icon_blank')});
+ domConstruct.place(tnode.loadingNode, tnode.expandoNode, 'only');
+ }
+
if (id.match("CAT:") && bare_id == -1) {
const menu = new dijit.Menu();
menu.row_id = bare_id;
@@ -191,10 +202,15 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
},
getRowClass: function (item/*, opened */) {
- let rc = "dijitTreeRow";
+ let rc = "dijitTreeRow dijitTreeRowFlex";
const is_cat = String(item.id).indexOf('CAT:') != -1;
+ if (is_cat)
+ rc += " Is_Cat";
+ else
+ rc += " Is_Feed";
+
if (!is_cat && item.error != '') rc += " Error";
if (item.unread > 0) rc += " Unread";
if (item.auxcounter > 0) rc += " Has_Aux";
@@ -303,7 +319,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
}, 0);
}
},
- setFeedIcon: function(feed, is_cat, src) {
+ setIcon: function(feed, is_cat, src) {
let treeNode;
if (is_cat)
@@ -313,13 +329,19 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
if (treeNode) {
treeNode = treeNode[0];
- const icon = dojo.create('img', { src: src, className: 'icon' });
- domConstruct.place(icon, treeNode.iconNode, 'only');
- return true;
+
+ // could be <i material>
+ const icon = treeNode.iconNode.querySelector('img.icon');
+
+ if (icon) {
+ icon.src = src;
+
+ return true;
+ }
}
return false;
},
- setFeedExpandoIcon: function(feed, is_cat, src) {
+ showLoading: function(feed, is_cat, show) {
let treeNode;
if (is_cat)
@@ -329,14 +351,17 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
if (treeNode) {
treeNode = treeNode[0];
- if (treeNode.loadingNode) {
- treeNode.loadingNode.src = src;
- return true;
+
+ if (show) {
+ treeNode.loadingNode.addClassName("visible");
+ treeNode.loadingNode.setAttribute("src",
+ is_cat ? App.getInitParam("icon_three_dots") : App.getInitParam("icon_oval"));
} else {
- const icon = dojo.create('img', { src: src, className: 'loadingExpando' });
- domConstruct.place(icon, treeNode.expandoNode, 'only');
- return true;
+ treeNode.loadingNode.removeClassName("visible");
+ treeNode.loadingNode.setAttribute("src", App.getInitParam("icon_blank"))
}
+
+ return true
}
return false;
@@ -360,7 +385,28 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
}
},
- getNextFeed: function (feed, is_cat) {
+ getNextUnread: function(feed, is_cat) {
+ return this.getNextFeed(feed, is_cat, true);
+ },
+ _nextTreeItemFromIndex: function (start, unread_only) {
+ const items = this.model.store._arrayOfAllItems;
+
+ for (let i = start+1; i < items.length; i++) {
+ const id = String(items[i].id);
+ const box = this._itemNodesMap[id];
+ const unread = parseInt(items[i].unread);
+
+ if (box && (!unread_only || unread > 0)) {
+ const row = box[0].rowNode;
+ const cat = box[0].rowNode.parentNode.parentNode;
+
+ if (Element.visible(cat) && Element.visible(row)) {
+ return items[i];
+ }
+ }
+ }
+ },
+ getNextFeed: function (feed, is_cat, unread_only = false) {
let treeItem;
if (is_cat) {
@@ -370,35 +416,40 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
}
const items = this.model.store._arrayOfAllItems;
- let item = items[0];
+ const start = items.indexOf(treeItem);
- for (let i = 0; i < items.length; i++) {
- if (items[i] == treeItem) {
+ if (start != -1) {
+ let item = this._nextTreeItemFromIndex(start, unread_only);
- for (let j = i+1; j < items.length; j++) {
- const id = String(items[j].id);
- const box = this._itemNodesMap[id];
+ // let's try again from the top
+ // 0 (instead of -1) to skip Special category
+ if (!item) {
+ item = this._nextTreeItemFromIndex(0, unread_only);
+ }
- if (box) {
- const row = box[0].rowNode;
- const cat = box[0].rowNode.parentNode.parentNode;
+ if (item)
+ return [this.model.store.getValue(item, 'bare_id'),
+ !this.model.store.getValue(item, 'id').match('FEED:')];
+ }
- if (Element.visible(cat) && Element.visible(row)) {
- item = items[j];
- break;
- }
- }
+ return [false, false];
+ },
+ _prevTreeItemFromIndex: function (start) {
+ const items = this.model.store._arrayOfAllItems;
+
+ for (let i = start-1; i > 0; i--) {
+ const id = String(items[i].id);
+ const box = this._itemNodesMap[id];
+
+ if (box) {
+ const row = box[0].rowNode;
+ const cat = box[0].rowNode.parentNode.parentNode;
+
+ if (Element.visible(cat) && Element.visible(row)) {
+ return items[i];
}
- break;
}
}
-
- 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) {
let treeItem;
@@ -410,37 +461,22 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
}
const items = this.model.store._arrayOfAllItems;
- let item = items[0] == treeItem ? items[items.length-1] : items[0];
-
- for (let i = 0; i < items.length; i++) {
- if (items[i] == treeItem) {
-
- for (let j = i-1; j > 0; j--) {
- const id = String(items[j].id);
- const box = this._itemNodesMap[id];
-
- if (box) {
- const row = box[0].rowNode;
- const cat = box[0].rowNode.parentNode.parentNode;
+ const start = items.indexOf(treeItem);
- if (Element.visible(cat) && Element.visible(row)) {
- item = items[j];
- break;
- }
- }
+ if (start != -1) {
+ let item = this._prevTreeItemFromIndex(start);
- }
- break;
+ // wrap from the bottom
+ if (!item) {
+ item = this._prevTreeItemFromIndex(items.length);
}
- }
- if (item) {
- return [this.model.store.getValue(item, 'bare_id'),
- !this.model.store.getValue(item, 'id').match('FEED:')];
- } else {
- return false;
+ if (item)
+ return [this.model.store.getValue(item, 'bare_id'),
+ !this.model.store.getValue(item, 'id').match('FEED:')];
}
+ return [false, false];
},
getFeedCategory: function(feed) {
try {