-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathvueku.js
94 lines (76 loc) · 1.45 KB
/
vueku.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
global.Vue = require('vue');
Vue.config.debug = true;
new Vue({
el: 'body',
data(){
return {
progress: 0,
status: "doesn't start yet",
error: false,
direction: false
};
},
components: {
'loading-bar': require('./vue-loading-bar.vue')
},
methods: {
progressTo(val){
this.progress = val;
},
setToError(bol){
this.error = bol;
this.status = "Error";
},
changeDirection(direction){
if(this.progress > 0){
this.progress = 100;
}
this.direction = !this.direction;
}
},
events: {
/**
* Global Loading Callback Event
*
* @event-name loading-bar:{event-name}
*/
// Loading Bar on started
'loading-bar:started': function (){
console.log('started');
this.status = "started";
},
// Loading Bar on loading
'loading-bar:loading': function (){
console.log('loading');
this.status = "loading";
},
// Loading Bar on loaded
'loading-bar:loaded': function (){
console.log('loaded');
this.status = "loaded";
},
// Loading Bar on error
'loading-bar:error': function (){
console.log('error');
this.status = "error";
},
},
ready(){
var self = this;
self.progress = 10;
for (var i = 0; i < 30; i++) {
if(i > 20 && i < 29){
setTimeout(function () {
self.progress += 5;
},50*i);
}else{
setTimeout(function () {
self.progress ++;
},10*i);
}
}
setTimeout(function () {
self.progress = 100;
},1500);
}
});