forked from Archives/Athou_commafeed
fix infinitescroll when list is not long enough to fill the screen
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user