From d026d372b552f9fd4bac4614a8491fa59b947c41 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 18 Jan 2011 12:40:19 +0300 Subject: [PATCH] properly skip over collapsed categories when using j/k hotkeys (refs #292) --- FeedTree.js | 125 ++++++++++++++++++++++++++++++++-------------------- tt-rss.js | 4 +- 2 files changed, 78 insertions(+), 51 deletions(-) diff --git a/FeedTree.js b/FeedTree.js index a0d4fc7e..4e090eed 100644 --- a/FeedTree.js +++ b/FeedTree.js @@ -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; + } + + }, + }); diff --git a/tt-rss.js b/tt-rss.js index 4cb3ec56..3bc0ea4a 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -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]); -- 2.39.5