getPreviousFeed/getNextFeed: implement wrap around
This commit is contained in:
parent
eadaaebd58
commit
3e22368962
106
js/FeedTree.js
106
js/FeedTree.js
|
@ -388,6 +388,24 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
|
||||||
getNextUnread: function(feed, is_cat) {
|
getNextUnread: function(feed, is_cat) {
|
||||||
return this.getNextFeed(feed, is_cat, true);
|
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) {
|
getNextFeed: function (feed, is_cat, unread_only = false) {
|
||||||
let treeItem;
|
let treeItem;
|
||||||
|
|
||||||
|
@ -398,35 +416,39 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = this.model.store._arrayOfAllItems;
|
const items = this.model.store._arrayOfAllItems;
|
||||||
let item = false;
|
const start = items.indexOf(treeItem);
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
if (start != -1) {
|
||||||
if (items[i] == treeItem) {
|
let item = this._nextTreeItemFromIndex(start, unread_only);
|
||||||
|
|
||||||
for (let j = i+1; j < items.length; j++) {
|
// let's try again from the top
|
||||||
const id = String(items[j].id);
|
// 0 (instead of -1) to skip Special category
|
||||||
const box = this._itemNodesMap[id];
|
if (!item) {
|
||||||
const unread = parseInt(items[j].unread);
|
item = this._nextTreeItemFromIndex(0, unread_only);
|
||||||
|
|
||||||
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)) {
|
|
||||||
item = items[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
return [this.model.store.getValue(item, 'bare_id'),
|
||||||
|
!this.model.store.getValue(item, 'id').match('FEED:')];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item) {
|
return [false, false];
|
||||||
return [this.model.store.getValue(item, 'bare_id'),
|
},
|
||||||
!this.model.store.getValue(item, 'id').match('FEED:')];
|
_prevTreeItemFromIndex: function (start) {
|
||||||
} else {
|
const items = this.model.store._arrayOfAllItems;
|
||||||
return [false, false];
|
|
||||||
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getPreviousFeed: function (feed, is_cat) {
|
getPreviousFeed: function (feed, is_cat) {
|
||||||
|
@ -439,36 +461,22 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/co
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = this.model.store._arrayOfAllItems;
|
const items = this.model.store._arrayOfAllItems;
|
||||||
let item = false;
|
const start = items.indexOf(treeItem);
|
||||||
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
if (start != -1) {
|
||||||
if (items[i] == treeItem) {
|
let item = this._prevTreeItemFromIndex(start);
|
||||||
|
|
||||||
for (let j = i-1; j > 0; j--) {
|
// wrap from the bottom
|
||||||
const id = String(items[j].id);
|
if (!item) {
|
||||||
const box = this._itemNodesMap[id];
|
item = this._prevTreeItemFromIndex(items.length);
|
||||||
|
|
||||||
if (box) {
|
|
||||||
const row = box[0].rowNode;
|
|
||||||
const cat = box[0].rowNode.parentNode.parentNode;
|
|
||||||
|
|
||||||
if (Element.visible(cat) && Element.visible(row)) {
|
|
||||||
item = items[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item)
|
||||||
|
return [this.model.store.getValue(item, 'bare_id'),
|
||||||
|
!this.model.store.getValue(item, 'id').match('FEED:')];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item) {
|
return [false, false];
|
||||||
return [this.model.store.getValue(item, 'bare_id'),
|
|
||||||
!this.model.store.getValue(item, 'id').match('FEED:')];
|
|
||||||
} else {
|
|
||||||
return [false, false];
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
getFeedCategory: function(feed) {
|
getFeedCategory: function(feed) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue