|
@@ -4,7 +4,7 @@ import Plugin from './Plugin'
|
|
* Progress bar
|
|
* Progress bar
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
-export default class Progress extends Plugin {
|
|
|
|
|
|
+export default class ProgressBar extends Plugin {
|
|
constructor (core, opts) {
|
|
constructor (core, opts) {
|
|
super(core, opts)
|
|
super(core, opts)
|
|
this.type = 'progress'
|
|
this.type = 'progress'
|
|
@@ -14,15 +14,21 @@ export default class Progress extends Plugin {
|
|
|
|
|
|
// merge default options with the ones set by user
|
|
// merge default options with the ones set by user
|
|
this.opts = Object.assign({}, defaultOptions, opts)
|
|
this.opts = Object.assign({}, defaultOptions, opts)
|
|
|
|
+ }
|
|
|
|
|
|
- this.progressBarElement = document.querySelector('.UppyDragDrop-progressInner')
|
|
|
|
|
|
+ setProgress (percentage) {
|
|
|
|
+ this.progressBarPercentageEl.innerHTML = percentage
|
|
|
|
+ this.progressBarInnerEl.setAttribute('style', `width: ${percentage}%`)
|
|
}
|
|
}
|
|
|
|
|
|
- progressBar (percentage) {
|
|
|
|
- const progressContainer = document.querySelector(this.opts.target)
|
|
|
|
- progressContainer.innerHTML = '<div class="UppyProgressBar"></div>'
|
|
|
|
- const progressBarElement = document.querySelector(`${this.opts.target} .UppyProgressBar`)
|
|
|
|
- progressBarElement.setAttribute('style', `width: ${percentage}%`)
|
|
|
|
|
|
+ initProgressBar () {
|
|
|
|
+ const progressBarContainerEl = document.querySelector(this.opts.target)
|
|
|
|
+ progressBarContainerEl.innerHTML = `<div class="UppyProgressBar">
|
|
|
|
+ <div class="UppyProgressBar-inner"></div>
|
|
|
|
+ <div class="UppyProgressBar-percentage"></div>
|
|
|
|
+ </div>`
|
|
|
|
+ this.progressBarPercentageEl = document.querySelector(`${this.opts.target} .UppyProgressBar-percentage`)
|
|
|
|
+ this.progressBarInnerEl = document.querySelector(`${this.opts.target} .UppyProgressBar-inner`)
|
|
}
|
|
}
|
|
|
|
|
|
initEvents () {
|
|
initEvents () {
|
|
@@ -30,13 +36,15 @@ export default class Progress extends Plugin {
|
|
const percentage = data.percentage
|
|
const percentage = data.percentage
|
|
const plugin = data.plugin
|
|
const plugin = data.plugin
|
|
this.core.log(
|
|
this.core.log(
|
|
- `this is what the progress is: ${percentage}, and its set by ${plugin.constructor.name}`
|
|
|
|
|
|
+ `progress is: ${percentage}, set by ${plugin.constructor.name}`
|
|
)
|
|
)
|
|
- this.progressBar(percentage)
|
|
|
|
|
|
+ this.setProgress(percentage)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
install () {
|
|
install () {
|
|
- return this.initEvents()
|
|
|
|
|
|
+ this.initProgressBar()
|
|
|
|
+ this.initEvents()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
}
|
|
}
|