Prechádzať zdrojové kódy

Possible replaceTargetContent, minor refactoring

Artur Paikin 9 rokov pred
rodič
commit
e0bbc16cc6

+ 3 - 1
src/plugins/DragDrop.js

@@ -79,7 +79,9 @@ export default class DragDrop extends Plugin {
   handleInputChange () {
   handleInputChange () {
     this.core.log('All right, something selected through input...')
     this.core.log('All right, something selected through input...')
 
 
-    const newFiles = Object.keys(this.input.files).map((key) => this.input.files[key])
+    const newFiles = Object.keys(this.input.files).map((key) => {
+      this.input.files[key]
+    })
 
 
     this.core.emitter.emit('file-add', {
     this.core.emitter.emit('file-add', {
       plugin: this,
       plugin: this,

+ 11 - 6
src/plugins/Plugin.js

@@ -29,22 +29,27 @@ export default class Plugin {
 
 
   /**
   /**
    * Check if supplied `target` is a `string` or an `object`.
    * Check if supplied `target` is a `string` or an `object`.
-   * If object (that means its a plugin), search `plugins` for
-   * a plugin with same name and return its target.
+   * If it’s an object — target is a plugin, and we search `plugins`
+   * for a plugin with same name and return its target.
    *
    *
    * @param {String|Object} target
    * @param {String|Object} target
    *
    *
    */
    */
-  getTarget (target, callerPlugin, el, render) {
+  getTarget (target, caller, el, render) {
     if (typeof target === 'string') {
     if (typeof target === 'string') {
-      this.core.log(`Installing ${callerPlugin.name} to ${target}`)
+      this.core.log(`Installing ${caller.name} to ${target}`)
+
+      // clear everything inside the target selector
+      // if (replaceTargetContent) {
+      //   document.querySelector(target).innerHTML = ''
+      // }
       document.querySelector(target).appendChild(el)
       document.querySelector(target).appendChild(el)
 
 
       return target
       return target
     } else {
     } else {
-      this.core.log(`Installing ${callerPlugin.name} to ${target.name}`)
+      this.core.log(`Installing ${caller.name} to ${target.name}`)
       let targetPlugin = this.core.getPlugin(target.name)
       let targetPlugin = this.core.getPlugin(target.name)
-      let selectorTarget = targetPlugin.addTarget(callerPlugin, render)
+      let selectorTarget = targetPlugin.addTarget(caller, render)
 
 
       return selectorTarget
       return selectorTarget
     }
     }

+ 3 - 1
src/plugins/ProgressBar.js

@@ -11,7 +11,9 @@ export default class ProgressBar extends Plugin {
     this.type = 'progressindicator'
     this.type = 'progressindicator'
 
 
     // set default options
     // set default options
-    const defaultOptions = {}
+    const defaultOptions = {
+      replaceTargetContent: false
+    }
 
 
     // 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)

+ 1 - 0
src/plugins/Tus10.js

@@ -9,6 +9,7 @@ export default class Tus10 extends Plugin {
   constructor (core, opts) {
   constructor (core, opts) {
     super(core, opts)
     super(core, opts)
     this.type = 'uploader'
     this.type = 'uploader'
+    this.type = 'Tus'
 
 
     // set default options
     // set default options
     const defaultOptions = {}
     const defaultOptions = {}