properly skip over collapsed categories when using j/k hotkeys (refs )

This commit is contained in:
Andrew Dolgov 2011-01-18 12:40:19 +03:00
parent 0569a7122c
commit d026d372b5
2 changed files with 78 additions and 51 deletions

View File

@ -52,55 +52,6 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
if (treeItem)
return this.store.setValue(treeItem, key, value);
},
getNextFeed: function (feed, is_cat) {
if (is_cat) {
treeItem = this.store._itemsByIdentity['CAT:' + feed];
} else {
treeItem = this.store._itemsByIdentity['FEED:' + feed];
}
items = this.store._arrayOfAllItems;
var item = items[0];
for (var i = 0; i < items.length; i++) {
if (items[i] == treeItem) {
item = items[i+1];
break;
}
}
if (item) {
return [this.store.getValue(item, 'bare_id'),
!this.store.getValue(item, 'id').match('FEED:')];
} else {
return false;
}
},
getPreviousFeed: function (feed, is_cat) {
if (is_cat) {
treeItem = this.store._itemsByIdentity['CAT:' + feed];
} else {
treeItem = this.store._itemsByIdentity['FEED:' + feed];
}
items = this.store._arrayOfAllItems;
var item = items[items.length-1];
for (var i = 0; i < items.length; i++) {
if (items[i] == treeItem) {
item = items[i-1];
break;
}
}
if (item) {
return [this.store.getValue(item, 'bare_id'),
!this.store.getValue(item, 'id').match('FEED:')];
} else {
return false;
}
},
getNextUnreadFeed: function (feed, is_cat) {
if (is_cat) {
treeItem = this.store._itemsByIdentity['CAT:' + feed];
@ -346,4 +297,80 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
});
},
getNextFeed: function (feed, is_cat) {
if (is_cat) {
treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
} else {
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
}
items = this.model.store._arrayOfAllItems;
var item = items[0];
for (var i = 0; i < items.length; i++) {
if (items[i] == treeItem) {
for (j = i+1; j < items.length; j++) {
var id = String(items[j].id);
var box = this._itemNodesMap[id];
if (box) {
box = box[0].containerNode.parentNode.parentNode;
if (Element.visible(box)) {
item = items[j];
break;
}
}
}
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) {
if (is_cat) {
treeItem = this.model.store._itemsByIdentity['CAT:' + feed];
} else {
treeItem = this.model.store._itemsByIdentity['FEED:' + feed];
}
items = this.model.store._arrayOfAllItems;
var item = items[0];
for (var i = 0; i < items.length; i++) {
if (items[i] == treeItem) {
for (j = i-1; j > 0; j--) {
var id = String(items[j].id);
var box = this._itemNodesMap[id];
if (box) {
box = box[0].containerNode.parentNode.parentNode;
if (Element.visible(box)) {
item = items[j];
break;
}
}
}
break;
}
}
if (item) {
return [this.model.store.getValue(item, 'bare_id'),
!this.model.store.getValue(item, 'id').match('FEED:')];
} else {
return false;
}
},
});

View File

@ -704,7 +704,7 @@ function hotkey_handler(e) {
}
if (keycode == 74) { // j
var rv = dijit.byId("feedTree").model.getPreviousFeed(
var rv = dijit.byId("feedTree").getPreviousFeed(
getActiveFeedId(), activeFeedIsCat());
if (rv) viewfeed(rv[0], '', rv[1]);
@ -713,7 +713,7 @@ function hotkey_handler(e) {
}
if (keycode == 75) { // k
var rv = dijit.byId("feedTree").model.getNextFeed(
var rv = dijit.byId("feedTree").getNextFeed(
getActiveFeedId(), activeFeedIsCat());
if (rv) viewfeed(rv[0], '', rv[1]);