]> source.dussan.org Git - gitea.git/commitdiff
fix Dropzone.js integration (#7445)
authorsilverwind <me@silverwind.io>
Fri, 12 Jul 2019 20:49:04 +0000 (22:49 +0200)
committerzeripath <art27@cantab.net>
Fri, 12 Jul 2019 20:49:04 +0000 (21:49 +0100)
public/js/index.js

index d890784abb3c795d6a89b250d29f0a3f78148a83..b5ead5e6061952badad9999afaccd2ca52c77583 100644 (file)
@@ -10,6 +10,9 @@ function htmlEncode(text) {
 var csrf;
 var suburl;
 
+// Disable Dropzone auto-discover because it's manually initialized
+Dropzone.autoDiscover = false;
+
 // Polyfill for IE9+ support (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
 if (!Array.from) {
     Array.from = (function () {
@@ -2005,13 +2008,11 @@ $(document).ready(function () {
     }
 
     // Dropzone
-    var $dropzone = $('#dropzone');
+    const $dropzone = $('#dropzone');
     if ($dropzone.length > 0) {
-        // Disable auto discover for all elements:
-        Dropzone.autoDiscover = false;
+        const filenameDict = {};
 
-        var filenameDict = {};
-        $dropzone.dropzone({
+        new Dropzone("#dropzone", {
             url: $dropzone.data('upload-url'),
             headers: {"X-Csrf-Token": csrf},
             maxFiles: $dropzone.data('max-file'),
@@ -2039,7 +2040,7 @@ $(document).ready(function () {
                         });
                     }
                 })
-            }
+            },
         });
     }