|
@@ -13,6 +13,7 @@ const Url = require('@uppy/url')
|
|
|
const Webcam = require('@uppy/webcam')
|
|
|
const ScreenCapture = require('@uppy/screen-capture')
|
|
|
const Tus = require('@uppy/tus')
|
|
|
+const DropTarget = require('@uppy/drop-target')
|
|
|
const localeList = require('../locale_list.json')
|
|
|
|
|
|
const COMPANION = require('../env')
|
|
@@ -21,7 +22,7 @@ const RTL_LOCALES = ['ar_SA', 'fa_IR', 'he_IL']
|
|
|
|
|
|
if (typeof window !== 'undefined' && typeof window.Uppy === 'undefined') {
|
|
|
window.Uppy = {
|
|
|
- locales: {}
|
|
|
+ locales: {},
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -33,7 +34,7 @@ function uppyInit () {
|
|
|
const opts = window.uppyOptions
|
|
|
|
|
|
const uppy = new Uppy({
|
|
|
- logger: Uppy.debugLogger
|
|
|
+ logger: Uppy.debugLogger,
|
|
|
})
|
|
|
|
|
|
uppy.use(Tus, { endpoint: 'https://tusd.tusdemo.net/files/', resume: true })
|
|
@@ -54,8 +55,8 @@ function uppyInit () {
|
|
|
showProgressDetails: true,
|
|
|
metaFields: [
|
|
|
{ id: 'name', name: 'Name', placeholder: 'file name' },
|
|
|
- { id: 'caption', name: 'Caption', placeholder: 'add description' }
|
|
|
- ]
|
|
|
+ { id: 'caption', name: 'Caption', placeholder: 'add description' },
|
|
|
+ ],
|
|
|
})
|
|
|
|
|
|
window.uppy = uppy
|
|
@@ -69,25 +70,25 @@ function uppySetOptions () {
|
|
|
minFileSize: null,
|
|
|
maxNumberOfFiles: null,
|
|
|
minNumberOfFiles: null,
|
|
|
- allowedFileTypes: null
|
|
|
+ allowedFileTypes: null,
|
|
|
}
|
|
|
|
|
|
const restrictions = {
|
|
|
maxFileSize: 1000000,
|
|
|
maxNumberOfFiles: 3,
|
|
|
minNumberOfFiles: 2,
|
|
|
- allowedFileTypes: ['image/*', 'video/*']
|
|
|
+ allowedFileTypes: ['image/*', 'video/*'],
|
|
|
}
|
|
|
|
|
|
window.uppy.setOptions({
|
|
|
autoProceed: opts.autoProceed,
|
|
|
- restrictions: opts.restrictions ? restrictions : defaultNullRestrictions
|
|
|
+ restrictions: opts.restrictions ? restrictions : defaultNullRestrictions,
|
|
|
})
|
|
|
|
|
|
window.uppy.getPlugin('Dashboard').setOptions({
|
|
|
note: opts.restrictions ? 'Images and video only, 2–3 files, up to 1 MB' : '',
|
|
|
theme: opts.darkMode ? 'dark' : 'light',
|
|
|
- disabled: opts.disabled
|
|
|
+ disabled: opts.disabled,
|
|
|
})
|
|
|
|
|
|
const googleDriveInstance = window.uppy.getPlugin('GoogleDrive')
|
|
@@ -150,7 +151,7 @@ function uppySetOptions () {
|
|
|
if (opts.Webcam && !webcamInstance) {
|
|
|
window.uppy.use(Webcam, {
|
|
|
target: Dashboard,
|
|
|
- showVideoSourceDropdown: true
|
|
|
+ showVideoSourceDropdown: true,
|
|
|
})
|
|
|
}
|
|
|
if (!opts.Webcam && webcamInstance) {
|
|
@@ -172,11 +173,19 @@ function uppySetOptions () {
|
|
|
if (!opts.imageEditor && imageEditorInstance) {
|
|
|
window.uppy.removePlugin(imageEditorInstance)
|
|
|
}
|
|
|
+
|
|
|
+ const dropTargetInstance = window.uppy.getPlugin('DropTarget')
|
|
|
+ if (opts.DropTarget && !dropTargetInstance) {
|
|
|
+ window.uppy.use(DropTarget, { target: document.body })
|
|
|
+ }
|
|
|
+ if (!opts.DropTarget && dropTargetInstance) {
|
|
|
+ window.uppy.removePlugin(dropTargetInstance)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function whenLocaleAvailable (localeName, callback) {
|
|
|
- var interval = 100 // ms
|
|
|
- var loop = setInterval(function () {
|
|
|
+ const interval = 100 // ms
|
|
|
+ const loop = setInterval(() => {
|
|
|
if (window.Uppy && window.Uppy.locales && window.Uppy.locales[localeName]) {
|
|
|
clearInterval(loop)
|
|
|
callback(window.Uppy.locales[localeName])
|
|
@@ -185,8 +194,8 @@ function whenLocaleAvailable (localeName, callback) {
|
|
|
}
|
|
|
|
|
|
function loadLocaleFromCDN (localeName) {
|
|
|
- var head = document.getElementsByTagName('head')[0]
|
|
|
- var js = document.createElement('script')
|
|
|
+ const head = document.getElementsByTagName('head')[0]
|
|
|
+ const js = document.createElement('script')
|
|
|
js.type = 'text/javascript'
|
|
|
js.src = `https://releases.transloadit.com/uppy/locales/v1.17.2/${localeName}.min.js`
|
|
|
|
|
@@ -203,11 +212,11 @@ function setLocale (localeName) {
|
|
|
: 'ltr'
|
|
|
|
|
|
window.uppy.setOptions({
|
|
|
- locale: localeObj
|
|
|
+ locale: localeObj,
|
|
|
})
|
|
|
|
|
|
window.uppy.getPlugin('Dashboard').setOptions({
|
|
|
- direction
|
|
|
+ direction,
|
|
|
})
|
|
|
})
|
|
|
}
|