|
21 | 21 | './jquery.fileupload-image',
|
22 | 22 | './jquery.fileupload-audio',
|
23 | 23 | './jquery.fileupload-video',
|
24 |
| - './jquery.fileupload-validate' |
| 24 | + './jquery.fileupload-validate', |
| 25 | + './vendor/heic2any.min' |
25 | 26 | ], factory);
|
26 | 27 | } else if (typeof exports === 'object') {
|
27 | 28 | // Node/CommonJS:
|
|
31 | 32 | require('./jquery.fileupload-image'),
|
32 | 33 | require('./jquery.fileupload-audio'),
|
33 | 34 | require('./jquery.fileupload-video'),
|
34 |
| - require('./jquery.fileupload-validate') |
| 35 | + require('./jquery.fileupload-validate'), |
| 36 | + require('./vendor/heic2any.min') |
35 | 37 | );
|
36 | 38 | } else {
|
37 | 39 | // Browser globals:
|
|
100 | 102 | var blobx = data.files[0];
|
101 | 103 | var fileReader = new FileReader();
|
102 | 104 | fileReader.onloadend = function (e) {
|
| 105 | + /* eslint-disable-next-line no-undef */ |
103 | 106 | var arr = new Uint8Array(e.target.result).subarray(0, 4);
|
104 | 107 | var header = '';
|
105 | 108 | var type = '';
|
|
130 | 133 | break;
|
131 | 134 | }
|
132 | 135 |
|
| 136 | + /* eslint-disable jsdoc/require-jsdoc */ |
| 137 | + function addContinues() { |
| 138 | + if (e.isDefaultPrevented()) { |
| 139 | + return false; |
| 140 | + } |
| 141 | + |
| 142 | + data.context = that |
| 143 | + ._renderUpload(data.files) |
| 144 | + .data('data', data) |
| 145 | + .addClass('processing'); |
| 146 | + options.filesContainer[options.prependFiles ? 'prepend' : 'append']( |
| 147 | + data.context |
| 148 | + ); |
| 149 | + that._forceReflow(data.context); |
| 150 | + that._transition(data.context); |
| 151 | + data |
| 152 | + .process(function () { |
| 153 | + return $this.fileupload('process', data); |
| 154 | + }) |
| 155 | + .always(function () { |
| 156 | + data.context |
| 157 | + .each(function (index) { |
| 158 | + $(this) |
| 159 | + .find('.size') |
| 160 | + .text(that._formatFileSize(data.files[index].size)); |
| 161 | + }) |
| 162 | + .removeClass('processing'); |
| 163 | + that._renderPreviews(data); |
| 164 | + }) |
| 165 | + .done(function () { |
| 166 | + data.context.find('.edit,.start').prop('disabled', false); |
| 167 | + if ( |
| 168 | + that._trigger('added', e, data) !== false && |
| 169 | + (options.autoUpload || data.autoUpload) && |
| 170 | + data.autoUpload !== false |
| 171 | + ) { |
| 172 | + data.submit(); |
| 173 | + } |
| 174 | + }) |
| 175 | + .fail(function () { |
| 176 | + if (data.files.error) { |
| 177 | + data.context.each(function (index) { |
| 178 | + var error = data.files[index].error; |
| 179 | + if (error) { |
| 180 | + $(this).find('.error').text(error); |
| 181 | + } |
| 182 | + }); |
| 183 | + } |
| 184 | + }); |
| 185 | + } |
| 186 | + |
133 | 187 | if (type !== 'unknown') {
|
134 | 188 | if (type === 'image/heic' || type === 'image/heif') {
|
135 | 189 | var originalName = data.files[0].name;
|
136 |
| - |
| 190 | + /* eslint-disable-next-line no-undef */ |
137 | 191 | heic2any({
|
138 | 192 | blob: data.files[0],
|
139 | 193 | toType: 'image/jpeg',
|
140 |
| - quality: 0.5, // cuts the quality and size by half |
| 194 | + quality: 0.5 // cuts the quality and size by half |
141 | 195 | }).then(function (conversionResultBlob) {
|
142 | 196 | // conversionResult is a BLOB
|
143 | 197 | // of the JPEG formatted image
|
|
148 | 202 | .replace('.heic', '.jpg')
|
149 | 203 | .replace('.heif', '.jpg'),
|
150 | 204 | {
|
151 |
| - type: conversionResultBlob.type, |
| 205 | + type: conversionResultBlob.type |
152 | 206 | }
|
153 | 207 | );
|
154 | 208 | // console.log('Converted to jpeg:', data.files[0]);
|
|
163 | 217 | ) {
|
164 | 218 | addContinues(data);
|
165 | 219 | } else {
|
166 |
| - console.log('Aborted'); |
| 220 | + // console.log('Aborted'); |
167 | 221 | data.abort();
|
168 | 222 | }
|
169 | 223 | }
|
170 | 224 | };
|
171 | 225 |
|
172 | 226 | fileReader.readAsArrayBuffer(blobx);
|
173 |
| - |
174 |
| - function addContinues() { |
175 |
| - if (e.isDefaultPrevented()) { |
176 |
| - return false; |
177 |
| - } |
178 |
| - |
179 |
| - data.context = that |
180 |
| - ._renderUpload(data.files) |
181 |
| - .data('data', data) |
182 |
| - .addClass('processing'); |
183 |
| - options.filesContainer[options.prependFiles ? 'prepend' : 'append']( |
184 |
| - data.context |
185 |
| - ); |
186 |
| - that._forceReflow(data.context); |
187 |
| - that._transition(data.context); |
188 |
| - data |
189 |
| - .process(function () { |
190 |
| - return $this.fileupload('process', data); |
191 |
| - }) |
192 |
| - .always(function () { |
193 |
| - data.context |
194 |
| - .each(function (index) { |
195 |
| - $(this) |
196 |
| - .find('.size') |
197 |
| - .text(that._formatFileSize(data.files[index].size)); |
198 |
| - }) |
199 |
| - .removeClass('processing'); |
200 |
| - that._renderPreviews(data); |
201 |
| - }) |
202 |
| - .done(function () { |
203 |
| - data.context.find('.edit,.start').prop('disabled', false); |
204 |
| - if ( |
205 |
| - that._trigger('added', e, data) !== false && |
206 |
| - (options.autoUpload || data.autoUpload) && |
207 |
| - data.autoUpload !== false |
208 |
| - ) { |
209 |
| - data.submit(); |
210 |
| - } |
211 |
| - }) |
212 |
| - .fail(function () { |
213 |
| - if (data.files.error) { |
214 |
| - data.context.each(function (index) { |
215 |
| - var error = data.files[index].error; |
216 |
| - if (error) { |
217 |
| - $(this).find('.error').text(error); |
218 |
| - } |
219 |
| - }); |
220 |
| - } |
221 |
| - }); |
222 |
| - } |
223 | 227 | },
|
224 | 228 | // Callback for the start of each file upload request:
|
225 | 229 | send: function (e, data) {
|
|
0 commit comments