| @@ 98-168 (lines=71) @@ | ||
| 95 | } |
|
| 96 | ||
| 97 | // Initialize drag and drop for multiple file uploads |
|
| 98 | function multiFileDrop(form) |
|
| 99 | { |
|
| 100 | // Initialize Drag and Drop |
|
| 101 | var drop = $('#dropzone-box').dropzone( |
|
| 102 | { |
|
| 103 | url: form.attr('action'), |
|
| 104 | autoProcessQueue: false, |
|
| 105 | parallelUploads: 1, |
|
| 106 | maxFiles: 1, |
|
| 107 | maxFilesize: maxUpload, |
|
| 108 | addRemoveLinks: true, |
|
| 109 | chunking: true, |
|
| 110 | chunkSize: 1000000, |
|
| 111 | parallelChunkUploads: false, |
|
| 112 | method: "POST", |
|
| 113 | init: function() |
|
| 114 | { |
|
| 115 | var myDrop = this; |
|
| 116 | form.on('submit', function(e, formData) |
|
| 117 | { |
|
| 118 | e.preventDefault(); |
|
| 119 | if(myDrop.getQueuedFiles().length > 0) |
|
| 120 | { |
|
| 121 | myDrop.processQueue(); |
|
| 122 | $('#forProgressBar').show(); |
|
| 123 | $('.submit-button').attr('disabled', true); |
|
| 124 | } |
|
| 125 | else |
|
| 126 | { |
|
| 127 | $.post(form.attr('action'), form.serialize(), function(data) |
|
| 128 | { |
|
| 129 | uploadComplete(data); |
|
| 130 | }); |
|
| 131 | } |
|
| 132 | }); |
|
| 133 | this.on('sending', function(file, xhr, formData) |
|
| 134 | { |
|
| 135 | var formArray = form.serializeArray(); |
|
| 136 | $.each(formArray, function() |
|
| 137 | { |
|
| 138 | formData.append(this.name, this.value); |
|
| 139 | }); |
|
| 140 | }); |
|
| 141 | this.on('uploadprogress', function(progress) |
|
| 142 | { |
|
| 143 | var prog = Math.round(progress.upload.progress); |
|
| 144 | ||
| 145 | if(prog != 100) |
|
| 146 | { |
|
| 147 | $("#progressBar").css("width", prog+"%"); |
|
| 148 | $("#progressStatus").text(prog+"%"); |
|
| 149 | } |
|
| 150 | // $("#progressBar").css("width", Math.round(progress.upload.progress)+"%"); |
|
| 151 | // $("#progressStatus").text(Math.round(progress.upload.progress)+"%"); |
|
| 152 | }); |
|
| 153 | this.on('reset', function() |
|
| 154 | { |
|
| 155 | $('#form-errors').addClass('d-none'); |
|
| 156 | }); |
|
| 157 | this.on('success', function(files, response) |
|
| 158 | { |
|
| 159 | console.log(response); |
|
| 160 | uploadComplete(response); |
|
| 161 | }); |
|
| 162 | this.on('errormultiple', function(file, response) |
|
| 163 | { |
|
| 164 | uploadFailed(response); |
|
| 165 | }); |
|
| 166 | } |
|
| 167 | }); |
|
| 168 | } |
|
| 169 | ||
| 170 | // Reset the progress bar and drag and drop box |
|
| 171 | function resetProgressBar() |
|
| @@ 25-95 (lines=71) @@ | ||
| 22 | ||
| 23 | /////////////////////////// Drag and Drop/File Upload Functions //////////////////////////////////// |
|
| 24 | // Initialize drag and drop for only one file |
|
| 25 | function fileDrop(form) |
|
| 26 | { |
|
| 27 | // Initialize Drag and Drop |
|
| 28 | var drop = $('#dropzone-box').dropzone( |
|
| 29 | { |
|
| 30 | url: form.attr('action'), |
|
| 31 | autoProcessQueue: false, |
|
| 32 | parallelUploads: 1, |
|
| 33 | maxFiles: 1, |
|
| 34 | maxFilesize: maxUpload, |
|
| 35 | addRemoveLinks: true, |
|
| 36 | chunking: true, |
|
| 37 | chunkSize: 1000000, |
|
| 38 | parallelChunkUploads: false, |
|
| 39 | method: "POST", |
|
| 40 | init: function() |
|
| 41 | { |
|
| 42 | var myDrop = this; |
|
| 43 | form.on('submit', function(e, formData) |
|
| 44 | { |
|
| 45 | e.preventDefault(); |
|
| 46 | if(myDrop.getQueuedFiles().length > 0) |
|
| 47 | { |
|
| 48 | myDrop.processQueue(); |
|
| 49 | $('#forProgressBar').show(); |
|
| 50 | $('.submit-button').attr('disabled', true); |
|
| 51 | } |
|
| 52 | else |
|
| 53 | { |
|
| 54 | $.post(form.attr('action'), form.serialize(), function(data) |
|
| 55 | { |
|
| 56 | uploadComplete(data); |
|
| 57 | }); |
|
| 58 | } |
|
| 59 | }); |
|
| 60 | this.on('sending', function(file, xhr, formData) |
|
| 61 | { |
|
| 62 | var formArray = form.serializeArray(); |
|
| 63 | $.each(formArray, function() |
|
| 64 | { |
|
| 65 | formData.append(this.name, this.value); |
|
| 66 | }); |
|
| 67 | }); |
|
| 68 | this.on('uploadprogress', function(progress) |
|
| 69 | { |
|
| 70 | var prog = Math.round(progress.upload.progress); |
|
| 71 | ||
| 72 | if(prog != 100) |
|
| 73 | { |
|
| 74 | $("#progressBar").css("width", prog+"%"); |
|
| 75 | $("#progressStatus").text(prog+"%"); |
|
| 76 | } |
|
| 77 | // $("#progressBar").css("width", Math.round(progress.upload.progress)+"%"); |
|
| 78 | // $("#progressStatus").text(Math.round(progress.upload.progress)+"%"); |
|
| 79 | }); |
|
| 80 | this.on('reset', function() |
|
| 81 | { |
|
| 82 | $('#form-errors').addClass('d-none'); |
|
| 83 | }); |
|
| 84 | this.on('success', function(files, response) |
|
| 85 | { |
|
| 86 | console.log(response); |
|
| 87 | uploadComplete(response); |
|
| 88 | }); |
|
| 89 | this.on('errormultiple', function(file, response) |
|
| 90 | { |
|
| 91 | uploadFailed(response); |
|
| 92 | }); |
|
| 93 | } |
|
| 94 | }); |
|
| 95 | } |
|
| 96 | ||
| 97 | // Initialize drag and drop for multiple file uploads |
|
| 98 | function multiFileDrop(form) |
|