mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-24 10:47:44 +00:00
Ditch the idea of a glue class in favor of just preset plugins
This commit is contained in:
parent
6c610f552f
commit
6be4fc97f1
1 changed files with 19 additions and 17 deletions
36
classes.es6
36
classes.es6
|
|
@ -2,26 +2,13 @@
|
|||
|
||||
// file: core/Transloadit.js
|
||||
class Transloadit {
|
||||
constructor(opts) {
|
||||
this.opts = opts
|
||||
}
|
||||
run() {
|
||||
this.core = new TransloaditCore(this.opts)
|
||||
.use(DragDrop, {modal: true, wait: this.opts.wait})
|
||||
.use(Tus10, {endpoint: 'http://master.tus.io:8080'})
|
||||
|
||||
return this.core.run();
|
||||
}
|
||||
}
|
||||
|
||||
// file: core/TransloaditCore.js
|
||||
class TransloaditCore {
|
||||
constructor(opts) {
|
||||
// Dictates in what order different plugin types are ran:
|
||||
this.types = ['selecter', 'uploader'];
|
||||
this.types = ['presetter', 'selecter', 'uploader'];
|
||||
|
||||
// Container for different types of plugins
|
||||
this.plugins = {
|
||||
presetter: [],
|
||||
selecter: [],
|
||||
uploader: [],
|
||||
};
|
||||
|
|
@ -79,6 +66,17 @@ class TransloaditPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
// file: presets/TransloaditBasic.js
|
||||
class TransloaditBasic extends TransloaditPlugin {
|
||||
constructor(core, opts) {
|
||||
super(core, opts);
|
||||
this.type = 'presetter';
|
||||
this.core
|
||||
.use(DragDrop, {modal: true, wait: true})
|
||||
.use(Tus10, {endpoint: 'http://master.tus.io:8080'})
|
||||
}
|
||||
}
|
||||
|
||||
// file: plugins/DragDrop.js
|
||||
class DragDrop extends TransloaditPlugin {
|
||||
constructor(core, opts) {
|
||||
|
|
@ -115,7 +113,7 @@ class Tus10 extends TransloaditPlugin {
|
|||
}
|
||||
|
||||
// file: ./examples/advanced.js
|
||||
var transloadit = new TransloaditCore({wait: false});
|
||||
var transloadit = new Transloadit({wait: false});
|
||||
var files = transloadit
|
||||
.use(DragDrop, {modal: true})
|
||||
.use(Tus10, {endpoint: 'http://master.tus.io:8080'})
|
||||
|
|
@ -127,7 +125,11 @@ console.dir(files);
|
|||
|
||||
|
||||
// file: ./examples/novice.js
|
||||
var transloadit = new Transloadit({wait: false});
|
||||
var transloadit = new Transloadit();
|
||||
var files = transloadit
|
||||
.use(TransloaditBasic)
|
||||
.run();
|
||||
|
||||
var files = transloadit.run();
|
||||
|
||||
console.log('--> Finished transloadit. Final result: ');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue