diff --git a/js/controllers.js b/js/controllers.js index de912c8..a7ef1d2 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -49,61 +49,56 @@ function FeedCtrl($scope, $routeParams, $location, feeds, pageSwitcher, feedItem } }; - $scope.showItemOptions = function(id) { - angular.forEach($scope.feed.items, function(value, key) { - if (value.id == id) { - $scope.feed.items[key].showOptions = !$scope.feed.items[key].showOptions; - } else { - $scope.feed.items[key].showOptions = false; + pageSwitcher.setBack('feeds'); } + +function ListItemCtrl($scope, $rootScope, feedItems, downloader, pageChanger) +{ + $scope.playItem = function(id) { + feedItems.get(id, function(feedItem) { + $rootScope.$broadcast('playItem', feedItem); }); }; + $scope.showItemOptions = function(id) { + //TODO: close all other options bars + this.item.showOptions = !this.item.showOptions; + }; + $scope.addToQueue = function(id) { feedItems.addToQueue(id); }; - $scope.playItem = function(id) { - feedItems.get(id, function(feedItem) { - $rootScope.$broadcast('playItem', feedItem); - }); - }; - - pageSwitcher.setBack('feeds'); -} - -function QueueListCtrl($scope, $rootScope, pageSwitcher, feedItems, feeds, downloader, queueList, pageChanger) { - $scope.queue = queueList.getQueueList(); - - $scope.$on('queueListRefresh', function(event) { - $rootScope.$apply(queueList.rebuildList()); - }); - - $scope.playItem = function(id) { - feedItems.get(id, function(feedItem) { - $rootScope.$broadcast('playItem', feedItem); - }); - }; - - $scope.showItemOptions = function(id) { - angular.forEach($scope.queue, function(value, key) { - if (value.id == id) { - $scope.queue[key].showOptions = !$scope.queue[key].showOptions; - } else { - $scope.queue[key].showOptions = false; - } - }); - }; - $scope.downloadFile = function(id) { feedItems.get(id, function(feedItem) { downloader.downloadFiles([feedItem]); }); }; + + $scope.reDownloadFile = function(id) { + feedItems.get(id, function(feedItem) { + feedItem.audio = null; + downloader.downloadFiles([feedItem]); + }); + }; + + $scope.goToFeed = function(feedId) { + pageChanger.goToFeed(feedId); + }; + $scope.removeFromQueue = function(feedItemId) { feedItems.unQueue(feedItemId); }; +} + +function QueueListCtrl($scope, $rootScope, pageSwitcher, feedItems, feeds, downloader, queueList, pageChanger) { + $scope.queue = queueList.getQueueList(); + + $scope.$on('queueListRefresh', function(event) { + console.log('rebuilding'); + $rootScope.$apply(queueList.rebuildList()); + }); $scope.downloadItems = function(updateStatus) { feeds.downloadAllItems(feedItems, function(feedItem, feed) { @@ -116,18 +111,6 @@ function QueueListCtrl($scope, $rootScope, pageSwitcher, feedItems, feeds, downl }); }; - $scope.reDownloadFile = function(id) { - feedItems.get(id, function(feedItem) { - feedItem.audio = null; - downloader.downloadFiles([feedItem]); - }); - }; - - //TODO: extract this to somewhere - $scope.goToFeed = function(feedId) { - pageChanger.goToFeed(feedId); - }; - pageSwitcher.change('queue'); } diff --git a/partials/feed.html b/partials/feed.html index 9a0bec1..5f67f7a 100644 --- a/partials/feed.html +++ b/partials/feed.html @@ -14,18 +14,22 @@ {{ feed.summary }}