@kigi/components 1.8.4 → 1.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -4,100 +4,98 @@ import * as angular from 'angular'
|
|
|
4
4
|
import { UtilUID } from '../../helpers/util-uid'
|
|
5
5
|
const progressBar = require('progressbar.js')
|
|
6
6
|
class MbgProgressCircleController {
|
|
7
|
+
private unWatchPercentage: any
|
|
8
|
+
private unWatchShow: any
|
|
9
|
+
private progressCircle: any
|
|
10
|
+
private onFinish: Function
|
|
11
|
+
private uidComponent
|
|
12
|
+
private show = false
|
|
13
|
+
private closeOnFinish
|
|
14
|
+
private duration: number
|
|
15
|
+
private percentage
|
|
7
16
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
private uidComponent
|
|
13
|
-
private show = false
|
|
14
|
-
private duration: number
|
|
15
|
-
private percentage
|
|
16
|
-
|
|
17
|
-
constructor(public $scope, public $element, public $attrs, public $timeout) {
|
|
18
|
-
this.percentage = this.percentage || 100
|
|
17
|
+
constructor(public $scope, public $element, public $attrs, public $timeout) {
|
|
18
|
+
this.percentage = this.percentage || 100
|
|
19
|
+
if (this.closeOnFinish == undefined) {
|
|
20
|
+
this.closeOnFinish = true
|
|
19
21
|
}
|
|
22
|
+
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
24
|
+
createProgress() {
|
|
25
|
+
this.duration = this.duration || 1400
|
|
26
|
+
this.uidComponent = UtilUID.generete()
|
|
27
|
+
this.unWatchShow = this.$scope.$watch('$ctrl.show', (value) => {
|
|
28
|
+
this.$timeout(() => {
|
|
29
|
+
value !== undefined && value ? this.addInBody() : this.removeInBody()
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
this.$timeout(() => {
|
|
33
|
+
this.progressCircle = new progressBar.Circle('#progress', {
|
|
34
|
+
color: '#666',
|
|
35
|
+
strokeWidth: 4,
|
|
36
|
+
trailWidth: 1,
|
|
37
|
+
easing: 'easeInOut',
|
|
38
|
+
duration: this.duration,
|
|
39
|
+
text: {
|
|
40
|
+
autoStyleContainer: true,
|
|
41
|
+
},
|
|
42
|
+
from: { color: '#666', width: 1 },
|
|
43
|
+
to: { color: '#000', width: 4 },
|
|
44
|
+
step: (state, circle) => {
|
|
45
|
+
const value = Math.round(circle.value() * 100)
|
|
46
|
+
if (value === 0) {
|
|
47
|
+
circle.setText('')
|
|
48
|
+
} else {
|
|
49
|
+
if (this.duration && value === 100 && this.closeOnFinish) {
|
|
50
|
+
this.$timeout(() => (this.show = false), 2000)
|
|
51
|
+
}
|
|
52
|
+
circle.setText(value + '%')
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
this.progressCircle.text.style.fontFamily = '"Raleway", Helvetica, sans-serif'
|
|
57
|
+
this.progressCircle.text.style.fontSize = '2rem'
|
|
58
|
+
this.progressCircle.animate(0.0)
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
this.unWatchPercentage = this.$scope.$watch('$ctrl.percentage', (value) => {
|
|
61
|
+
if (this.progressCircle && value !== undefined) {
|
|
62
|
+
this.progressCircle.animate(value / 100)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
addInBody() {
|
|
69
|
+
const body = angular.element(document).find('body')
|
|
70
|
+
const list = this.$element.find('div.mbg-progress-circle-wrapper')
|
|
71
|
+
list.attr('uid', this.uidComponent)
|
|
72
|
+
body.append(list)
|
|
73
|
+
}
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
removeInBody() {
|
|
76
|
+
const list = angular.element(`[uid="${this.uidComponent}"]`)
|
|
77
|
+
this.$element.find('.mbg-progress-circle-wrapper').append(list)
|
|
78
|
+
}
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
80
|
+
$onDestroy() {
|
|
81
|
+
if (this.unWatchPercentage) {
|
|
82
|
+
this.unWatchPercentage()
|
|
81
83
|
}
|
|
82
|
-
|
|
84
|
+
}
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
MbgProgressCircleController.$inject = [
|
|
86
|
-
'$scope',
|
|
87
|
-
'$element',
|
|
88
|
-
'$attrs',
|
|
89
|
-
'$timeout'
|
|
90
|
-
]
|
|
87
|
+
MbgProgressCircleController.$inject = ['$scope', '$element', '$attrs', '$timeout']
|
|
91
88
|
|
|
92
89
|
const mbgProgressCircle = {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
bindings: {
|
|
91
|
+
percentage: '=?',
|
|
92
|
+
titleProgress: '@?',
|
|
93
|
+
show: '=?',
|
|
94
|
+
duration: '=?',
|
|
95
|
+
closeOnFinish: '=?',
|
|
96
|
+
},
|
|
97
|
+
template,
|
|
98
|
+
controller: MbgProgressCircleController,
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
export { mbgProgressCircle }
|