-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular-progress.js
More file actions
41 lines (33 loc) · 1.02 KB
/
angular-progress.js
File metadata and controls
41 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(function (angular) {
'use strict';
var module;
try {
module = angular.module('coUtils');
} catch (e) {
module = angular.module('coUtils', []);
}
module
.directive('progress', function () {
return {
restrict: 'A',
scope: {
value: '=',
total: '=',
start: '=?'
},
template: '<div ng-style="percentage"></div>',
link: function(scope, element) {
element.addClass('co-progress');
scope.start = scope.start || 0;
scope.$watch('value', function (value) {
var range = scope.total - scope.start,
adjusted = parseFloat(value - scope.start),
point = 100.0 / parseFloat(range);
scope.percentage = {
width: point * adjusted + '%'
};
});
}
};
});
}(this.angular));