Tidied up some of the angular code, split the UI into it's own directives for easier maintainability

Also changed the spinner to white for #715
This commit is contained in:
Jamie.Rees 2016-12-02 08:57:42 +00:00
parent a2639375fb
commit 0185e8238d
13 changed files with 264 additions and 203 deletions

View file

@ -1,25 +1,27 @@
(function(){
(function() {
angular.module('ngLoadingSpinner', ['angularSpinner'])
.directive('usSpinner', ['$http', '$rootScope' ,function ($http, $rootScope){
return {
link: function (scope, elm, attrs)
{
$rootScope.spinnerActive = false;
scope.isLoading = function () {
return $http.pendingRequests.length > 0;
.directive('usSpinner',
[
'$http', '$rootScope', function($http, $rootScope) {
return {
link: function(scope, elm, attrs) {
$rootScope.spinnerActive = false;
scope.isLoading = function() {
return $http.pendingRequests.length > 0;
};
scope.$watch(scope.isLoading,
function(loading) {
$rootScope.spinnerActive = loading;
if (loading) {
elm.removeClass('ng-hide');
} else {
elm.addClass('ng-hide');
}
});
}
};
scope.$watch(scope.isLoading, function (loading)
{
$rootScope.spinnerActive = loading;
if(loading){
elm.removeClass('ng-hide');
}else{
elm.addClass('ng-hide');
}
});
}
};
}]);
]);
}).call(this);