Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 008a07b

Browse files
committed
Fix slint errors and warnings, update readme requirements
1 parent 88481c6 commit 008a07b

File tree

3 files changed

+63
-56
lines changed

3 files changed

+63
-56
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ For further information, please refer to the following guides:
129129
- [jQuery Iframe Transport plugin](https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.iframe-transport.js)
130130
(included): Required for
131131
[browsers without XHR file upload support](https://github.com/blueimp/jQuery-File-Upload/wiki/Browser-support).
132+
- [heic2any plugin](https://github.com/alexcorvi/heic2any) Requiered for HEIC/HEIF Convertion proccess.
133+
- [Uint8Array polyfill](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) Requiered for HEIC/HEIF conversion proccess in browsers cannot support ES6.
132134

133135
### Optional requirements
134136

js/jquery.fileupload-ui.js

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
'./jquery.fileupload-image',
2222
'./jquery.fileupload-audio',
2323
'./jquery.fileupload-video',
24-
'./jquery.fileupload-validate'
24+
'./jquery.fileupload-validate',
25+
'./vendor/heic2any.min'
2526
], factory);
2627
} else if (typeof exports === 'object') {
2728
// Node/CommonJS:
@@ -31,7 +32,8 @@
3132
require('./jquery.fileupload-image'),
3233
require('./jquery.fileupload-audio'),
3334
require('./jquery.fileupload-video'),
34-
require('./jquery.fileupload-validate')
35+
require('./jquery.fileupload-validate'),
36+
require('./vendor/heic2any.min')
3537
);
3638
} else {
3739
// Browser globals:
@@ -100,6 +102,7 @@
100102
var blobx = data.files[0];
101103
var fileReader = new FileReader();
102104
fileReader.onloadend = function (e) {
105+
/* eslint-disable-next-line no-undef */
103106
var arr = new Uint8Array(e.target.result).subarray(0, 4);
104107
var header = '';
105108
var type = '';
@@ -130,14 +133,65 @@
130133
break;
131134
}
132135

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+
133187
if (type !== 'unknown') {
134188
if (type === 'image/heic' || type === 'image/heif') {
135189
var originalName = data.files[0].name;
136-
190+
/* eslint-disable-next-line no-undef */
137191
heic2any({
138192
blob: data.files[0],
139193
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
141195
}).then(function (conversionResultBlob) {
142196
// conversionResult is a BLOB
143197
// of the JPEG formatted image
@@ -148,7 +202,7 @@
148202
.replace('.heic', '.jpg')
149203
.replace('.heif', '.jpg'),
150204
{
151-
type: conversionResultBlob.type,
205+
type: conversionResultBlob.type
152206
}
153207
);
154208
// console.log('Converted to jpeg:', data.files[0]);
@@ -163,63 +217,13 @@
163217
) {
164218
addContinues(data);
165219
} else {
166-
console.log('Aborted');
220+
// console.log('Aborted');
167221
data.abort();
168222
}
169223
}
170224
};
171225

172226
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-
}
223227
},
224228
// Callback for the start of each file upload request:
225229
send: function (e, data) {

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
crossorigin="anonymous"
3434
></script>
3535
<script src="../js/vendor/jquery.ui.widget.js"></script>
36+
<script src="../js/vendor/heic2any.min.js"></script>
3637
<script src="../js/jquery.iframe-transport.js"></script>
3738
<script src="../js/jquery.fileupload.js"></script>
3839
<script src="../js/jquery.fileupload-process.js"></script>

0 commit comments

Comments
 (0)