@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kigi/components",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -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
- private unWatchPercentage: any
9
- private unWatchShow: any
10
- private progressCircle: any
11
- private onFinish: Function
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
- createProgress() {
22
- this.duration = this.duration || 1400
23
- this.uidComponent = UtilUID.generete()
24
- this.unWatchShow = this.$scope.$watch('$ctrl.show', (value) => {
25
- this.$timeout(() => {
26
- value !== undefined && value ? this.addInBody() : this.removeInBody()
27
- })
28
- })
29
- this.$timeout(() => {
30
- this.progressCircle = new progressBar.Circle('#progress', {
31
- color: '#666',
32
- strokeWidth: 4,
33
- trailWidth: 1,
34
- easing: 'easeInOut',
35
- duration: this.duration,
36
- text: {
37
- autoStyleContainer: true,
38
- },
39
- from: { color: '#666', width: 1 },
40
- to: { color: '#000', width: 4 },
41
- step: (state, circle) => {
42
- const value = Math.round(circle.value() * 100)
43
- if (value === 0) {
44
- circle.setText('')
45
- } else {
46
- if (this.duration && value === 100) {
47
- this.$timeout(() => this.show = false, 2000)
48
- }
49
- circle.setText(value + '%')
50
- }
51
- }
52
- })
53
- this.progressCircle.text.style.fontFamily = '"Raleway", Helvetica, sans-serif'
54
- this.progressCircle.text.style.fontSize = '2rem'
55
- this.progressCircle.animate(0.0)
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
- this.unWatchPercentage = this.$scope.$watch('$ctrl.percentage', (value) => {
58
- if (this.progressCircle && value !== undefined) {
59
- this.progressCircle.animate(value / 100)
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
- addInBody() {
66
- const body = angular.element(document).find('body')
67
- const list = this.$element.find('div.mbg-progress-circle-wrapper')
68
- list.attr('uid', this.uidComponent)
69
- body.append(list)
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
- removeInBody() {
73
- const list = angular.element(`[uid="${this.uidComponent}"]`)
74
- this.$element.find('.mbg-progress-circle-wrapper').append(list)
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
- $onDestroy() {
78
- if (this.unWatchPercentage) {
79
- this.unWatchPercentage()
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
- bindings: {
94
- percentage: '=?',
95
- titleProgress: '@?',
96
- show: '=?',
97
- duration: '=?'
98
- },
99
- template,
100
- controller: MbgProgressCircleController,
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 }