Procházet zdrojové kódy

more import refactors

Artur Paikin před 8 roky
rodič
revize
7408155b6b

+ 1 - 1
src/index.js

@@ -10,7 +10,7 @@ import Dashboard from './plugins/Dashboard/index.js'
 
 
 // Acquirers
 // Acquirers
 import Dummy from './plugins/Dummy'
 import Dummy from './plugins/Dummy'
-import DragDrop from './plugins/DragDrop/DragDrop.js'
+import DragDrop from './plugins/DragDrop/index.js'
 import Formtag from './plugins/Formtag'
 import Formtag from './plugins/Formtag'
 import GoogleDrive from './plugins/GoogleDrive/index.js'
 import GoogleDrive from './plugins/GoogleDrive/index.js'
 import Webcam from './plugins/Webcam/index.js'
 import Webcam from './plugins/Webcam/index.js'

+ 13 - 11
src/plugins/DragDrop.js → src/plugins/DragDrop/index.js

@@ -1,18 +1,19 @@
-import Plugin from './Plugin'
-import { toArray } from '../core/Utils'
+import Plugin from './../Plugin'
+import { toArray } from '../../core/Utils'
 import dragDrop from 'drag-drop'
 import dragDrop from 'drag-drop'
-import html from '../core/html'
+import html from '../../core/html'
 
 
 /**
 /**
  * Drag & Drop plugin
  * Drag & Drop plugin
  *
  *
  */
  */
 export default class DragDrop extends Plugin {
 export default class DragDrop extends Plugin {
-  constructor (core, opts) {
+  constructor (core, opts, props) {
     super(core, opts)
     super(core, opts)
     this.type = 'acquirer'
     this.type = 'acquirer'
     this.id = 'DragDrop'
     this.id = 'DragDrop'
     this.title = 'Drag & Drop'
     this.title = 'Drag & Drop'
+    this.props = props
     this.icon = html`
     this.icon = html`
       <svg class="UppyIcon" width="28" height="28" viewBox="0 0 16 16">
       <svg class="UppyIcon" width="28" height="28" viewBox="0 0 16 16">
         <path d="M15.982 2.97c0-.02 0-.02-.018-.037 0-.017-.017-.035-.035-.053 0 0 0-.018-.02-.018-.017-.018-.034-.053-.052-.07L13.19.123c-.017-.017-.034-.035-.07-.053h-.018c-.018-.017-.035-.017-.053-.034h-.02c-.017 0-.034-.018-.052-.018h-6.31a.415.415 0 0 0-.446.426V11.11c0 .25.196.446.445.446h8.89A.44.44 0 0 0 16 11.11V3.023c-.018-.018-.018-.035-.018-.053zm-2.65-1.46l1.157 1.157h-1.157V1.51zm1.78 9.157h-8V.89h5.332v2.22c0 .25.196.446.445.446h2.22v7.11z"/>
         <path d="M15.982 2.97c0-.02 0-.02-.018-.037 0-.017-.017-.035-.035-.053 0 0 0-.018-.02-.018-.017-.018-.034-.053-.052-.07L13.19.123c-.017-.017-.034-.035-.07-.053h-.018c-.018-.017-.035-.017-.053-.034h-.02c-.017 0-.034-.018-.052-.018h-6.31a.415.415 0 0 0-.446.426V11.11c0 .25.196.446.445.446h8.89A.44.44 0 0 0 16 11.11V3.023c-.018-.018-.018-.035-.018-.053zm-2.65-1.46l1.157 1.157h-1.157V1.51zm1.78 9.157h-8V.89h5.332v2.22c0 .25.196.446.445.446h2.22v7.11z"/>
@@ -64,18 +65,19 @@ export default class DragDrop extends Plugin {
   handleDrop (files) {
   handleDrop (files) {
     this.core.log('All right, someone dropped something...')
     this.core.log('All right, someone dropped something...')
 
 
-    // this.core.emitter.emit('file-add', {
-    //   plugin: this,
-    //   acquiredFiles: files
-    // })
-
     files.forEach((file) => {
     files.forEach((file) => {
-      this.core.emitter.emit('file-add', {
+      this.props.addFile({
         source: this.id,
         source: this.id,
         name: file.name,
         name: file.name,
         type: file.type,
         type: file.type,
         data: file
         data: file
       })
       })
+      // this.core.emitter.emit('file-add', {
+      //   source: this.id,
+      //   name: file.name,
+      //   type: file.type,
+      //   data: file
+      // })
     })
     })
   }
   }
 
 
@@ -138,7 +140,7 @@ export default class DragDrop extends Plugin {
             <strong>${this.core.i18n('chooseFile')}</strong>
             <strong>${this.core.i18n('chooseFile')}</strong>
             <span class="UppyDragDrop-dragText">${this.core.i18n('orDragDrop')}</span>
             <span class="UppyDragDrop-dragText">${this.core.i18n('orDragDrop')}</span>
           </label>
           </label>
-          ${!this.core.opts.autoProceed && target !== 'Modal'
+          ${!this.core.opts.autoProceed && target !== 'Dashboard'
             ? html`<button class="UppyDragDrop-uploadBtn UppyNextBtn"
             ? html`<button class="UppyDragDrop-uploadBtn UppyNextBtn"
                          type="submit"
                          type="submit"
                          onclick=${next}>
                          onclick=${next}>

+ 1 - 1
src/plugins/index.js

@@ -6,7 +6,7 @@ import Dashboard from './Dashboard/index.js'
 
 
 // Acquirers
 // Acquirers
 import Dummy from './Dummy'
 import Dummy from './Dummy'
-import DragDrop from './DragDrop'
+import DragDrop from './DragDrop/index.js'
 import Formtag from './Formtag'
 import Formtag from './Formtag'
 import GoogleDrive from './GoogleDrive/index.js'
 import GoogleDrive from './GoogleDrive/index.js'
 import Webcam from './Webcam/index.js'
 import Webcam from './Webcam/index.js'

+ 1 - 1
website/src/examples/dragdrop/app.es6

@@ -1,5 +1,5 @@
 import Uppy from '../../../../src/core/Core.js'
 import Uppy from '../../../../src/core/Core.js'
-import DragDrop from '../../../../src/plugins/DragDrop.js'
+import DragDrop from '../../../../src/plugins/DragDrop/index.js'
 import ProgressBar from '../../../../src/plugins/ProgressBar.js'
 import ProgressBar from '../../../../src/plugins/ProgressBar.js'
 import Tus10 from '../../../../src/plugins/Tus10.js'
 import Tus10 from '../../../../src/plugins/Tus10.js'
 
 

+ 2 - 2
website/src/examples/i18n/app.html

@@ -8,8 +8,8 @@
 <script src="/uppy/locales/ru_RU.js"></script>
 <script src="/uppy/locales/ru_RU.js"></script>
 <script>
 <script>
   var uppy = new Uppy.Core({locales: Uppy.locales.ru_RU, debug: true});
   var uppy = new Uppy.Core({locales: Uppy.locales.ru_RU, debug: true});
-  uppy.use(Uppy.plugins.DragDrop, {target: '.UppyDragDrop'});
-  uppy.use(Uppy.plugins.Tus10, {endpoint: 'http://master.tus.io:3020/files/'});
+  uppy.use(Uppy.DragDrop, {target: '.UppyDragDrop'});
+  uppy.use(Uppy.Tus10, {endpoint: 'http://master.tus.io:3020/files/'});
   uppy.run();
   uppy.run();
 
 
   console.log('--> Uppy pre-built version with Tus10, DragDrop & Russian language pack has loaded');
   console.log('--> Uppy pre-built version with Tus10, DragDrop & Russian language pack has loaded');