Bläddra i källkod

website: fix `Uppy is not defined` error (#3461)

Antoine du Hamel 3 år sedan
förälder
incheckning
c7770657b0
2 ändrade filer med 34 tillägg och 26 borttagningar
  1. 4 0
      website/src/examples/i18n/app.html
  2. 30 26
      website/themes/uppy/layout/index.ejs

+ 4 - 0
website/src/examples/i18n/app.html

@@ -16,6 +16,8 @@
 <script src="https://releases.transloadit.com/uppy/v2.4.1/uppy.legacy.min.js" nomodule></script>
 <script src="https://releases.transloadit.com/uppy/locales/v2.0.5/ru_RU.min.js"></script>
 <script>
+window.addEventListener('DOMContentLoaded', function () {
+  'use strict';
   var uppy = new Uppy.Core({
     debug: true,
     autoProceed: true,
@@ -45,4 +47,6 @@
   });
 
   console.log('--> Uppy pre-built version with Tus, DragDrop & Russian language pack has loaded');
+  window.uppy = uppy;
+});
 </script>

+ 30 - 26
website/themes/uppy/layout/index.ejs

@@ -192,32 +192,36 @@
 <script src="https://releases.transloadit.com/uppy/v2.4.1/uppy.legacy.min.js" nomodule></script>
 
 <script>
-  var TUS_ENDPOINT = 'https://tusd.tusdemo.net/files/'
-  var COMPANION_ENDPOINT = 'http://localhost:3020'
-  if (location.hostname === 'uppy.io') {
-    COMPANION_ENDPOINT = '//companion.uppy.io'
-  }
-
-  var uppy = new Uppy.Core({ debug: true })
-    .use(Uppy.Dashboard, {
-      target: '#demo',
-      inline: true,
-      metaFields: [
-        { id: 'license', name: 'License', placeholder: 'specify license' },
-        { id: 'caption', name: 'Caption', placeholder: 'describe what the image is about' }
-      ]
+  window.addEventListener('DOMContentLoaded', function() {
+    'use strict'
+    var TUS_ENDPOINT = 'https://tusd.tusdemo.net/files/'
+    var COMPANION_ENDPOINT = 'http://localhost:3020'
+    if (location.hostname === 'uppy.io') {
+      COMPANION_ENDPOINT = '//companion.uppy.io'
+    }
+    
+    var uppy = new Uppy.Core({ debug: true })
+      .use(Uppy.Dashboard, {
+        target: '#demo',
+        inline: true,
+        metaFields: [
+          { id: 'license', name: 'License', placeholder: 'specify license' },
+          { id: 'caption', name: 'Caption', placeholder: 'describe what the image is about' }
+        ]
+      })
+      .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
+      .use(Uppy.Instagram, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
+      .use(Uppy.Dropbox, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
+      // .use(Uppy.Box, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
+      .use(Uppy.Facebook, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
+      .use(Uppy.OneDrive, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
+      .use(Uppy.Webcam, { target: Uppy.Dashboard })
+      .use(Uppy.Url, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
+      .use(Uppy.Tus, { endpoint: TUS_ENDPOINT})
+    
+    uppy.on('success', function (files) {
+      console.log('Upload complete! We’ve uploaded these files:', files)
     })
-    .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
-    .use(Uppy.Instagram, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
-    .use(Uppy.Dropbox, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
-    // .use(Uppy.Box, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
-    .use(Uppy.Facebook, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
-    .use(Uppy.OneDrive, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
-    .use(Uppy.Webcam, { target: Uppy.Dashboard })
-    .use(Uppy.Url, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
-    .use(Uppy.Tus, { endpoint: TUS_ENDPOINT})
-
-  uppy.on('success', function (files) {
-    console.log('Upload complete! We’ve uploaded these files:', files)
+    window.uppy = uppy
   })
 </script>