Skip to content

Commit 9725c0e

Browse files
committed
fix comments
1 parent 26385f5 commit 9725c0e

6 files changed

+49
-32
lines changed

.babelrc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2+
"retainLines": true,
23
"presets": [
34
["@babel/preset-env", {
45
"exclude": ["transform-typeof-symbol"],
5-
"modules": false,
6-
"targets": {
7-
"browsers": [
8-
"last 3 versions",
9-
"edge >= 12",
10-
"ie 11"
11-
]
12-
}
6+
"modules": false
7+
}]
8+
],
9+
"plugins": [
10+
["@babel/plugin-proposal-object-rest-spread", {
11+
"loose": true,
12+
"useBuiltIns": true
1313
}]
1414
]
1515
}

dist/filepond-plugin-file-validate-size.esm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePondPluginFileValidateSize 2.1.2
2+
* FilePondPluginFileValidateSize 2.1.3
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/

dist/filepond-plugin-file-validate-size.esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/filepond-plugin-file-validate-size.js

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* FilePondPluginFileValidateSize 2.1.2
2+
* FilePondPluginFileValidateSize 2.1.3
33
* Licensed under MIT, https://opensource.org/licenses/MIT/
44
* Please visit https://pqina.nl/filepond/ for details.
55
*/
@@ -22,43 +22,42 @@
2222
// get quick reference to Type utils
2323
var Type = utils.Type,
2424
replaceInString = utils.replaceInString,
25-
toNaturalFileSize = utils.toNaturalFileSize; // filtering if an item is allowed in hopper
25+
toNaturalFileSize = utils.toNaturalFileSize;
2626

27+
// filtering if an item is allowed in hopper
2728
addFilter('ALLOW_HOPPER_ITEM', function(file, _ref2) {
2829
var query = _ref2.query;
29-
3030
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
3131
return true;
3232
}
3333

3434
var sizeMax = query('GET_MAX_FILE_SIZE');
35-
3635
if (sizeMax !== null && file.size >= sizeMax) {
3736
return false;
3837
}
3938

4039
var sizeMin = query('GET_MIN_FILE_SIZE');
41-
4240
if (sizeMin !== null && file.size <= sizeMin) {
4341
return false;
4442
}
4543

4644
return true;
47-
}); // called for each file that is loaded
45+
});
46+
47+
// called for each file that is loaded
4848
// right before it is set to the item state
4949
// should return a promise
50-
5150
addFilter('LOAD_FILE', function(file, _ref3) {
5251
var query = _ref3.query;
5352
return new Promise(function(resolve, reject) {
5453
// if not allowed, all fine, exit
5554
if (!query('GET_ALLOW_FILE_SIZE_VALIDATION')) {
5655
resolve(file);
5756
return;
58-
} // reject or resolve based on file size
57+
}
5958

59+
// reject or resolve based on file size
6060
var sizeMax = query('GET_MAX_FILE_SIZE');
61-
6261
if (sizeMax !== null && file.size >= sizeMax) {
6362
reject({
6463
status: {
@@ -68,11 +67,12 @@
6867
})
6968
}
7069
});
70+
7171
return;
72-
} // reject or resolve based on file size
72+
}
7373

74+
// reject or resolve based on file size
7475
var sizeMin = query('GET_MIN_FILE_SIZE');
75-
7676
if (sizeMin !== null && file.size <= sizeMin) {
7777
reject({
7878
status: {
@@ -82,11 +82,12 @@
8282
})
8383
}
8484
});
85+
8586
return;
86-
} // returns the current option value
87+
}
8788

89+
// returns the current option value
8890
var totalSizeMax = query('GET_MAX_TOTAL_FILE_SIZE');
89-
9091
if (totalSizeMax !== null) {
9192
// get the current total file size
9293
var currentTotalSize = query('GET_ACTIVE_ITEMS').reduce(function(
@@ -95,59 +96,69 @@
9596
) {
9697
return total + item.fileSize;
9798
},
98-
0); // get the size of the new file
99+
0);
99100

101+
// get the size of the new file
100102
if (currentTotalSize > totalSizeMax) {
101103
reject({
102104
status: {
103105
main: query('GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED'),
106+
104107
sub: replaceInString(query('GET_LABEL_MAX_TOTAL_FILE_SIZE'), {
105108
filesize: toNaturalFileSize(totalSizeMax)
106109
})
107110
}
108111
});
112+
109113
return;
110114
}
111-
} // file is fine, let's pass it back
115+
}
112116

117+
// file is fine, let's pass it back
113118
resolve(file);
114119
});
115120
});
121+
116122
return {
117123
options: {
118124
// Enable or disable file type validation
119125
allowFileSizeValidation: [true, Type.BOOLEAN],
126+
120127
// Max individual file size in bytes
121128
maxFileSize: [null, Type.INT],
129+
122130
// Min individual file size in bytes
123131
minFileSize: [null, Type.INT],
132+
124133
// Max total file size in bytes
125134
maxTotalFileSize: [null, Type.INT],
135+
126136
// error labels
127137
labelMinFileSizeExceeded: ['File is too small', Type.STRING],
128138
labelMinFileSize: ['Minimum file size is {filesize}', Type.STRING],
139+
129140
labelMaxFileSizeExceeded: ['File is too large', Type.STRING],
130141
labelMaxFileSize: ['Maximum file size is {filesize}', Type.STRING],
142+
131143
labelMaxTotalFileSizeExceeded: [
132144
'Maximum total size exceeded',
133145
Type.STRING
134146
],
147+
135148
labelMaxTotalFileSize: [
136149
'Maximum total file size is {filesize}',
137150
Type.STRING
138151
]
139152
}
140153
};
141-
}; // fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags
154+
};
142155

156+
// fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags
143157
var isBrowser =
144158
typeof window !== 'undefined' && typeof window.document !== 'undefined';
145-
146159
if (isBrowser) {
147160
document.dispatchEvent(
148-
new CustomEvent('FilePond:pluginloaded', {
149-
detail: plugin
150-
})
161+
new CustomEvent('FilePond:pluginloaded', { detail: plugin })
151162
);
152163
}
153164

dist/filepond-plugin-file-validate-size.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "filepond-plugin-file-validate-size",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "File Size Validation Plugin for FilePond",
55
"license": "MIT",
66
"author": {
@@ -12,6 +12,12 @@
1212
"main": "dist/filepond-plugin-file-validate-size.js",
1313
"browser": "dist/filepond-plugin-file-validate-size.js",
1414
"module": "dist/filepond-plugin-file-validate-size.esm.js",
15+
"browserslist": [
16+
"last 1 version and not Explorer 10",
17+
"Explorer 11",
18+
"iOS >= 9",
19+
"Android >= 4.4"
20+
],
1521
"files": [
1622
"dist"
1723
],

0 commit comments

Comments
 (0)