| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
mw.libs.ve = mw.libs.ve || {}; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
mw.libs.ve.ProgressBarWidget = function VeUiMwProgressBarWidget() { |
| 23 |
this.progressStep = 0; |
| 24 |
this.progressSteps = [ |
| 25 |
|
| 26 |
[ 30, 3000 ], |
| 27 |
[ 70, 2000 ], |
| 28 |
[ 100, 1000 ] |
| 29 |
]; |
| 30 |
|
| 31 |
this.$bar = $( '<div>' ).addClass( 've-init-mw-progressBarWidget-bar' ).css( 'width', 0 ); |
| 32 |
this.$element = $( '<div>' ).addClass( 've-init-mw-progressBarWidget' ).append( this.$bar ); |
| 33 |
}; |
| 34 |
|
| 35 |
mw.libs.ve.ProgressBarWidget.prototype.setLoadingProgress = function ( target, duration ) { |
| 36 |
const $bar = this.$bar.stop(); |
| 37 |
$bar.css( 'transition', 'width ' + duration + 'ms ease-in' ); |
| 38 |
setTimeout( () => { |
| 39 |
$bar.css( 'width', target + '%' ); |
| 40 |
} ); |
| 41 |
}; |
| 42 |
|
| 43 |
mw.libs.ve.ProgressBarWidget.prototype.incrementLoadingProgress = function () { |
| 44 |
const step = this.progressSteps[ this.progressStep ]; |
| 45 |
if ( step ) { |
| 46 |
this.setLoadingProgress( step[ 0 ], step[ 1 ] ); |
| 47 |
this.progressStep++; |
| 48 |
} |
| 49 |
}; |
| 50 |
|
| 51 |
mw.libs.ve.ProgressBarWidget.prototype.clearLoading = function () { |
| 52 |
this.progressStep = 0; |
| 53 |
this.setLoadingProgress( 0, 0 ); |
| 54 |
}; |