]> git.wh0rd.org Git - tt-rss.git/commitdiff
properly skip over collapsed categories when using j/k hotkeys (refs #292)
authorAndrew Dolgov <fox@fakecake.org>
Tue, 18 Jan 2011 09:40:19 +0000 (12:40 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Tue, 18 Jan 2011 09:40:19 +0000 (12:40 +0300)
FeedTree.js
tt-rss.js

index a0d4fc7eaf06f5083bf9b02cb592f29ce781501c..4e090eedd9cb7767d357128ac2ea38c1aec64954 100644 (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;
+               }
+
+       },
+
 });
index 4cb3ec56378fcba56ee46b2936a52183135ce0f9..3bc0ea4aba21113c5e87732884de098e8689a031 100644 (file)
--- 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]);