diff --git a/src/main/webapp/directives/toolbar.html b/src/main/webapp/directives/toolbar.html index 39f02f51..0b017585 100644 --- a/src/main/webapp/directives/toolbar.html +++ b/src/main/webapp/directives/toolbar.html @@ -2,8 +2,8 @@
- - + +
diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 35a5aa99..9c0768bc 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -88,52 +88,53 @@ module.controller('CategoryTreeCtrl', function($scope, $routeParams, $location, }); }); -module.controller('FeedListCtrl', function($scope, $routeParams, $http, - EntryService, SettingsService) { +module.controller('FeedListCtrl', function($scope, $routeParams, $http, $route, + $window, EntryService, SettingsService) { $scope.selectedType = $routeParams._type; $scope.selectedId = $routeParams._id; - $scope.settings = SettingsService.settings; - $scope.$watch('settings.readingMode', function() { - $scope.refreshList(); + $scope.name = null; + $scope.entries = []; + + $scope.settingsService = SettingsService; + $scope.$watch('settingsService.settings.readingMode', function(newValue, + oldValue) { + if (newValue && oldValue && newValue != oldValue) { + $route.reload(); + } }); - $scope.limit = 20; + $scope.limit = 10; $scope.busy = false; $scope.hasMore = true; - $scope.refreshList = function() { - $scope.entryList = EntryService.get({ - type : $scope.selectedType, - id : $scope.selectedId, - readType : $scope.settings.readingMode, - offset : 0, - limit : 30 - }); - }; - $scope.loadMoreEntries = function() { if (!$scope.hasMore) return; - if (!$scope.entryList || !$scope.entryList.entries) - return; if ($scope.busy) return; $scope.busy = true; + + var limit = $scope.limit; + if ($scope.entries.length == 0) { + $window = angular.element($window); + limit = $window.height() / 33; + limit = parseInt(limit) + 5; + } EntryService.get({ type : $scope.selectedType, id : $scope.selectedId, - readType : $scope.settings.readingMode, - offset : $scope.entryList.entries.length, - limit : $scope.limit + readType : $scope.settingsService.settings.readingMode, + offset : $scope.entries.length, + limit : limit }, function(data) { - var entries = data.entries - for ( var i = 0; i < entries.length; i++) { - $scope.entryList.entries.push(entries[i]); + for ( var i = 0; i < data.entries.length; i++) { + $scope.entries.push(data.entries[i]); } + $scope.name = data.name; $scope.busy = false; - $scope.hasMore = entries.length == $scope.limit + $scope.hasMore = data.entries.length == limit }); } @@ -153,7 +154,6 @@ module.controller('FeedListCtrl', function($scope, $routeParams, $http, $scope.isOpen = false; $scope.entryClicked = function(entry, event) { - console.log('click !') $scope.mark(entry, true); if (!event.ctrlKey && event.which != 2) { event.preventDefault(); diff --git a/src/main/webapp/js/directives.js b/src/main/webapp/js/directives.js index e2ce332f..b0a4a851 100644 --- a/src/main/webapp/js/directives.js +++ b/src/main/webapp/js/directives.js @@ -93,7 +93,6 @@ module.directive('category', function($compile) { }; $scope.toggleCategory = function(category) { - console.log(category.expanded) SubscriptionService.collapse({ id : category.id, collapse : !category.expanded @@ -111,17 +110,17 @@ module.directive('toolbar', function($routeParams, $route, SettingsService, replace : true, templateUrl : 'directives/toolbar.html', controller : function($scope, $route, $http, SettingsService) { - + function totalActiveAjaxRequests() { return ($http.pendingRequests.length + $.active); } - + $scope.loading = true; - $scope.$watch(totalActiveAjaxRequests, function () { + $scope.$watch(totalActiveAjaxRequests, function() { $scope.loading = !(totalActiveAjaxRequests() === 0); - }); - - $scope.settings = SettingsService.settings; + }); + + $scope.settingsService = SettingsService; $scope.refresh = function() { $route.reload(); }; diff --git a/src/main/webapp/js/services.js b/src/main/webapp/js/services.js index 8fef9e1a..3f6faefe 100644 --- a/src/main/webapp/js/services.js +++ b/src/main/webapp/js/services.js @@ -59,9 +59,10 @@ module.factory('SubscriptionService', [ }); }; s.subscribe = function(sub, callback) { - res.subscribe(sub, function(data){ + res.subscribe(sub, function(data) { s.init(); - if(callback) callback(data); + if (callback) + callback(data); }); }; @@ -118,9 +119,8 @@ module.factory('EntryService', [ '$resource', '$http', module.service('SettingsService', function($resource) { var s = {} s.settings = {}; - s.settings.readingMode = 'unread'; $resource('rest/settings/get').get(function(data) { - s.settings.readingMode = data.readingMode; + s.settings = data; }); s.save = function() { $resource('rest/settings/save').save(s.settings); diff --git a/src/main/webapp/templates/feeds.html b/src/main/webapp/templates/feeds.html index f3cc3439..e4a13c85 100644 --- a/src/main/webapp/templates/feeds.html +++ b/src/main/webapp/templates/feeds.html @@ -1,11 +1,11 @@
-

{{entryList.name}}  »

+

{{name}}  »

-
-
+
+
{{entry.feedName}} @@ -15,13 +15,12 @@
-
"{{entryList.name}}" has no unread items.
-
Loading data...
+
"{{name}}" has no unread items.
\ No newline at end of file