forked from Archives/Athou_commafeed
activity spinner
This commit is contained in:
@@ -132,7 +132,6 @@ module.controller('FeedListCtrl', function($scope, $routeParams, $http,
|
||||
offset : $scope.entryList.entries.length,
|
||||
limit : $scope.limit
|
||||
}, function(data) {
|
||||
console.log(data)
|
||||
var entries = data.entries
|
||||
for ( var i = 0; i < entries.length; i++) {
|
||||
$scope.entryList.entries.push(entries[i]);
|
||||
|
||||
@@ -102,7 +102,17 @@ module.directive('toolbar', function($routeParams, $route, SettingsService,
|
||||
restrict : 'E',
|
||||
replace : true,
|
||||
templateUrl : 'directives/toolbar.html',
|
||||
controller : function($scope, $route, SettingsService) {
|
||||
controller : function($scope, $route, $http, SettingsService) {
|
||||
|
||||
function totalActiveAjaxRequests() {
|
||||
return ($http.pendingRequests.length + $.active);
|
||||
}
|
||||
|
||||
$scope.loading = true;
|
||||
$scope.$watch(totalActiveAjaxRequests, function () {
|
||||
$scope.loading = !(totalActiveAjaxRequests() === 0);
|
||||
});
|
||||
|
||||
$scope.settings = SettingsService.settings;
|
||||
$scope.refresh = function() {
|
||||
$route.reload();
|
||||
@@ -125,4 +135,41 @@ module.directive('toolbar', function($routeParams, $route, SettingsService,
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
module.directive('spinner', function() {
|
||||
return {
|
||||
scope : {
|
||||
shown : '=',
|
||||
},
|
||||
restrict : 'A',
|
||||
link : function($scope, element) {
|
||||
element.addClass('spinner');
|
||||
var opts = {
|
||||
lines : 11, // The number of lines to draw
|
||||
length : 5, // The length of each line
|
||||
width : 3, // The line thickness
|
||||
radius : 8, // The radius of the inner circle
|
||||
corners : 1, // Corner roundness (0..1)
|
||||
rotate : 0, // The rotation offset
|
||||
color : '#000', // #rgb or #rrggbb
|
||||
speed : 1.3, // Rounds per second
|
||||
trail : 60, // Afterglow percentage
|
||||
shadow : false, // Whether to render a shadow
|
||||
hwaccel : true, // Whether to use hardware acceleration
|
||||
zIndex : 2e9, // The z-index (defaults to 2000000000)
|
||||
top : 50, // Top position relative to parent in px
|
||||
left : 'auto' // Left position relative to parent in px
|
||||
};
|
||||
var spinner = new Spinner(opts);
|
||||
$scope.$watch('shown', function(shown) {
|
||||
if (shown) {
|
||||
spinner.spin();
|
||||
element.append(spinner.el);
|
||||
} else {
|
||||
spinner.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user