mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
fix keyboard navigation for the tree (fix #404)
This commit is contained in:
@@ -194,24 +194,6 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var flat = function() {
|
|
||||||
var a = [];
|
|
||||||
a.push([ 'all', 'category' ]);
|
|
||||||
a.push([ 'starred', 'category' ]);
|
|
||||||
for ( var i = 1; i < CategoryService.flatCategories.length; i++) {
|
|
||||||
var cat = CategoryService.flatCategories[i];
|
|
||||||
a.push([ cat.id, 'category' ]);
|
|
||||||
|
|
||||||
var feeds = cat.orig.feeds;
|
|
||||||
if (feeds) {
|
|
||||||
for ( var j = 0; j < feeds.length; j++) {
|
|
||||||
a.push([ feeds[j].id, 'feed' ]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
};
|
|
||||||
|
|
||||||
var getCurrentIndex = function (id, type, flat) {
|
var getCurrentIndex = function (id, type, flat) {
|
||||||
var index = -1;
|
var index = -1;
|
||||||
for ( var i = 0; i < flat.length; i++) {
|
for ( var i = 0; i < flat.length; i++) {
|
||||||
@@ -225,7 +207,7 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
|
|||||||
};
|
};
|
||||||
|
|
||||||
var openNextNode = function() {
|
var openNextNode = function() {
|
||||||
var f = flat();
|
var f = CategoryService.flatAll;
|
||||||
var current = getCurrentIndex($scope.selectedId, $scope.selectedType, f);
|
var current = getCurrentIndex($scope.selectedId, $scope.selectedType, f);
|
||||||
current++;
|
current++;
|
||||||
if(current < f.length) {
|
if(current < f.length) {
|
||||||
@@ -237,7 +219,7 @@ function($scope, $timeout, $stateParams, $window, $location, $state, $route, Cat
|
|||||||
};
|
};
|
||||||
|
|
||||||
var openPreviousNode = function() {
|
var openPreviousNode = function() {
|
||||||
var f = flat();
|
var f = CategoryService.flatAll;
|
||||||
var current = getCurrentIndex($scope.selectedId, $scope.selectedType, f);
|
var current = getCurrentIndex($scope.selectedId, $scope.selectedType, f);
|
||||||
current--;
|
current--;
|
||||||
if(current >= 0) {
|
if(current >= 0) {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ function($resource, $http) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// flatten feeds
|
// flatten feeds
|
||||||
var flatfeeds = function(category) {
|
var flatFeeds = function(category) {
|
||||||
var subs = [];
|
var subs = [];
|
||||||
var callback = function(category) {
|
var callback = function(category) {
|
||||||
subs.push.apply(subs, category.feeds);
|
subs.push.apply(subs, category.feeds);
|
||||||
@@ -156,6 +156,18 @@ function($resource, $http) {
|
|||||||
traverse(callback, category);
|
traverse(callback, category);
|
||||||
return subs;
|
return subs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// flatten everything
|
||||||
|
var flatAll = function(category, a) {
|
||||||
|
a.push([ category.id, 'category' ]);
|
||||||
|
_.each(category.children, function(child) {
|
||||||
|
flatAll(child, a);
|
||||||
|
});
|
||||||
|
_.each(category.feeds, function(feed) {
|
||||||
|
a.push([ feed.id, 'feed' ]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var actions = {
|
var actions = {
|
||||||
get : {
|
get : {
|
||||||
method : 'GET',
|
method : 'GET',
|
||||||
@@ -209,7 +221,12 @@ function($resource, $http) {
|
|||||||
res.get(function(data) {
|
res.get(function(data) {
|
||||||
res.subscriptions = data;
|
res.subscriptions = data;
|
||||||
res.flatCategories = flatten(data);
|
res.flatCategories = flatten(data);
|
||||||
res.feeds = flatfeeds(data);
|
res.feeds = flatFeeds(data);
|
||||||
|
|
||||||
|
res.flatAll = [];
|
||||||
|
flatAll(data, res.flatAll);
|
||||||
|
res.flatAll.splice(1, 0, ['starred', 'category']);
|
||||||
|
|
||||||
if (callback)
|
if (callback)
|
||||||
callback(data);
|
callback(data);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user