Conditions | 1 |
Paths | 1 |
Total Lines | 62 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | // Third Party Libraries |
||
76 | function multiFileDrop(form) |
||
77 | { |
||
78 | // Initialize Drag and Drop |
||
79 | var drop = $('#dropzone-box').dropzone( |
||
80 | { |
||
81 | url: form.attr('action'), |
||
82 | autoProcessQueue: false, |
||
83 | uploadMultiple: true, |
||
84 | parallelUploads: 10, |
||
85 | maxFiles: 10, |
||
86 | maxFilesize: maxUpload, |
||
87 | addRemoveLinks: true, |
||
88 | init: function() |
||
89 | { |
||
90 | var myDrop = this; |
||
91 | form.on('submit', function(e, formData) |
||
92 | { |
||
93 | e.preventDefault(); |
||
94 | if(myDrop.getQueuedFiles().length > 0) |
||
95 | { |
||
96 | myDrop.processQueue(); |
||
97 | $('#forProgressBar').show(); |
||
98 | $('.submit-button').attr('disabled', true); |
||
99 | } |
||
100 | else |
||
101 | { |
||
102 | $.post(form.attr('action'), form.serialize(), function(data) |
||
103 | { |
||
104 | uploadComplete(data); |
||
105 | }); |
||
106 | } |
||
107 | }); |
||
108 | this.on('sendingmultiple', function(file, xhr, formData) |
||
109 | { |
||
110 | var formArray = form.serializeArray(); |
||
111 | $.each(formArray, function() |
||
112 | { |
||
113 | formData.append(this.name, this.value); |
||
114 | }); |
||
115 | }); |
||
116 | this.on('totaluploadprogress', function(progress) |
||
117 | { |
||
118 | $("#progressBar").css("width", Math.round(progress)+"%"); |
||
119 | $("#progressStatus").text(Math.round(progress)+"%"); |
||
120 | console.log(progress); |
||
121 | }); |
||
122 | this.on('reset', function() |
||
123 | { |
||
124 | $('#form-errors').addClass('d-none'); |
||
125 | }); |
||
126 | this.on('successmultiple', function(files, response) |
||
127 | { |
||
128 | this.removeAllFiles(true); |
||
129 | uploadComplete(response); |
||
130 | }); |
||
131 | this.on('errormultiple', function(file, response) |
||
132 | { |
||
133 | uploadFailed(response); |
||
134 | }); |
||
135 | } |
||
136 | }); |
||
137 | } |
||
138 | |||
163 |