Skip to content

Commit 98093c0

Browse files
committed
v2.0.9: + hotfixes
1 parent f551c8c commit 98093c0

File tree

9 files changed

+97
-56
lines changed

9 files changed

+97
-56
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,11 +1396,19 @@ Button like link.
13961396
## Changelog
13971397
13981398
1399+
### 2.0.9
1400+
<ul>
1401+
<li>#253: fixed `proxyXHR.loaded`</li>
1402+
<li>#250: + check `disabled`-attr</li>
1403+
</ul>
1404+
1405+
13991406
### 2.0.8
14001407
<ul>
14011408
<li>Two new resize strategies `width` and `height`</li>
14021409
</ul>
14031410
1411+
14041412
### 2.0.7
14051413
<ul>
14061414
<li>#214: iframe transport under IE8</li>

dist/FileAPI.html5.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! FileAPI 2.0.8 - BSD | git://github.com/mailru/FileAPI.git
1+
/*! FileAPI 2.0.9 - BSD | git://github.com/mailru/FileAPI.git
22
* FileAPI — a set of javascript tools for working with files. Multiupload, drag'n'drop and chunked file upload. Images: crop, resize and auto orientation by EXIF.
33
*/
44

@@ -135,6 +135,8 @@
135135
_rinput = /input/i,
136136
_rdata = /^data:[^,]+,/,
137137

138+
_toString = {}.toString,
139+
138140

139141
Math = window.Math,
140142

@@ -278,7 +280,7 @@
278280
* FileAPI (core object)
279281
*/
280282
api = {
281-
version: '2.0.8',
283+
version: '2.0.9',
282284

283285
cors: false,
284286
html5: true,
@@ -556,19 +558,25 @@
556558

557559

558560
/**
559-
* Is file instance
560-
*
561+
* Is file?
561562
* @param {File} file
562563
* @return {Boolean}
563564
*/
564565
isFile: function (file){
565-
return html5 && file && (file instanceof File);
566+
return _toString.call(file) === '[object File]';
566567
},
567568

569+
570+
/**
571+
* Is blob?
572+
* @param {Blob} blob
573+
* @returns {Boolean}
574+
*/
568575
isBlob: function (blob) {
569-
return html5 && blob && (blob instanceof Blob);
576+
return this.isFile(blob) || (_toString.call(blob) === '[object Blob]');
570577
},
571578

579+
572580
/**
573581
* Is canvas element
574582
*
@@ -1128,7 +1136,7 @@
11281136
options.progress({
11291137
type: 'progress'
11301138
, total: _total
1131-
, loaded: proxyXHR.loaded = (_loaded + data.size * (evt.loaded/evt.total))|0
1139+
, loaded: proxyXHR.loaded = (_loaded + data.size * (evt.loaded/evt.total)) || 0
11321140
}, _file, xhr, _fileOptions);
11331141
}
11341142
} : noop,
@@ -2139,9 +2147,9 @@
21392147
if( !err ){
21402148
api.each(transform, function (params, name){
21412149
if( !queue.isFail() ){
2142-
var ImgTrans = new Image(img.nodeType ? img : file);
2150+
var ImgTrans = new Image(img.nodeType ? img : file), isFn = typeof params == 'function';
21432151

2144-
if( typeof params == 'function' ){
2152+
if( isFn ){
21452153
params(img, ImgTrans);
21462154
}
21472155
else if( params.width ){
@@ -2162,13 +2170,16 @@
21622170
params.rotate = 'auto';
21632171
}
21642172

2165-
ImgTrans.set({
2166-
deg: params.rotate
2167-
, type: params.type || file.type || 'image/png'
2168-
, quality: params.quality || 1
2169-
, overlay: params.overlay
2170-
, filter: params.filter
2171-
});
2173+
ImgTrans.set({ type: ImgTrans.matrix.type || params.type || file.type || 'image/png' });
2174+
2175+
if( !isFn ){
2176+
ImgTrans.set({
2177+
deg: params.rotate
2178+
, overlay: params.overlay
2179+
, filter: params.filter
2180+
, quality: params.quality || 1
2181+
});
2182+
}
21722183

21732184
queue.inc();
21742185
ImgTrans.toData(function (err, image){

dist/FileAPI.html5.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/FileAPI.js

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! FileAPI 2.0.8 - BSD | git://github.com/mailru/FileAPI.git
1+
/*! FileAPI 2.0.9 - BSD | git://github.com/mailru/FileAPI.git
22
* FileAPI — a set of javascript tools for working with files. Multiupload, drag'n'drop and chunked file upload. Images: crop, resize and auto orientation by EXIF.
33
*/
44

@@ -135,6 +135,8 @@
135135
_rinput = /input/i,
136136
_rdata = /^data:[^,]+,/,
137137

138+
_toString = {}.toString,
139+
138140

139141
Math = window.Math,
140142

@@ -278,7 +280,7 @@
278280
* FileAPI (core object)
279281
*/
280282
api = {
281-
version: '2.0.8',
283+
version: '2.0.9',
282284

283285
cors: false,
284286
html5: true,
@@ -556,19 +558,25 @@
556558

557559

558560
/**
559-
* Is file instance
560-
*
561+
* Is file?
561562
* @param {File} file
562563
* @return {Boolean}
563564
*/
564565
isFile: function (file){
565-
return html5 && file && (file instanceof File);
566+
return _toString.call(file) === '[object File]';
566567
},
567568

569+
570+
/**
571+
* Is blob?
572+
* @param {Blob} blob
573+
* @returns {Boolean}
574+
*/
568575
isBlob: function (blob) {
569-
return html5 && blob && (blob instanceof Blob);
576+
return this.isFile(blob) || (_toString.call(blob) === '[object Blob]');
570577
},
571578

579+
572580
/**
573581
* Is canvas element
574582
*
@@ -1128,7 +1136,7 @@
11281136
options.progress({
11291137
type: 'progress'
11301138
, total: _total
1131-
, loaded: proxyXHR.loaded = (_loaded + data.size * (evt.loaded/evt.total))|0
1139+
, loaded: proxyXHR.loaded = (_loaded + data.size * (evt.loaded/evt.total)) || 0
11321140
}, _file, xhr, _fileOptions);
11331141
}
11341142
} : noop,
@@ -2139,9 +2147,9 @@
21392147
if( !err ){
21402148
api.each(transform, function (params, name){
21412149
if( !queue.isFail() ){
2142-
var ImgTrans = new Image(img.nodeType ? img : file);
2150+
var ImgTrans = new Image(img.nodeType ? img : file), isFn = typeof params == 'function';
21432151

2144-
if( typeof params == 'function' ){
2152+
if( isFn ){
21452153
params(img, ImgTrans);
21462154
}
21472155
else if( params.width ){
@@ -2162,13 +2170,16 @@
21622170
params.rotate = 'auto';
21632171
}
21642172

2165-
ImgTrans.set({
2166-
deg: params.rotate
2167-
, type: params.type || file.type || 'image/png'
2168-
, quality: params.quality || 1
2169-
, overlay: params.overlay
2170-
, filter: params.filter
2171-
});
2173+
ImgTrans.set({ type: ImgTrans.matrix.type || params.type || file.type || 'image/png' });
2174+
2175+
if( !isFn ){
2176+
ImgTrans.set({
2177+
deg: params.rotate
2178+
, overlay: params.overlay
2179+
, filter: params.filter
2180+
, quality: params.quality || 1
2181+
});
2182+
}
21722183

21732184
queue.inc();
21742185
ImgTrans.toData(function (err, image){
@@ -3468,7 +3479,7 @@
34683479
mouseover: function (evt){
34693480
var target = api.event.fix(evt).target;
34703481

3471-
if( /input/i.test(target.nodeName) && target.type == 'file' ){
3482+
if( /input/i.test(target.nodeName) && target.type == 'file' && !target.disabled ){
34723483
var
34733484
state = target.getAttribute(_attr)
34743485
, wrapper = flash.getWrapper(target)

dist/FileAPI.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/FileAPI.Flash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
mouseover: function (evt){
158158
var target = api.event.fix(evt).target;
159159

160-
if( /input/i.test(target.nodeName) && target.type == 'file' ){
160+
if( /input/i.test(target.nodeName) && target.type == 'file' && !target.disabled ){
161161
var
162162
state = target.getAttribute(_attr)
163163
, wrapper = flash.getWrapper(target)

lib/FileAPI.Image.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@
348348
if( !err ){
349349
api.each(transform, function (params, name){
350350
if( !queue.isFail() ){
351-
var ImgTrans = new Image(img.nodeType ? img : file);
351+
var ImgTrans = new Image(img.nodeType ? img : file), isFn = typeof params == 'function';
352352

353-
if( typeof params == 'function' ){
353+
if( isFn ){
354354
params(img, ImgTrans);
355355
}
356356
else if( params.width ){
@@ -371,13 +371,16 @@
371371
params.rotate = 'auto';
372372
}
373373

374-
ImgTrans.set({
375-
deg: params.rotate
376-
, type: params.type || file.type || 'image/png'
377-
, quality: params.quality || 1
378-
, overlay: params.overlay
379-
, filter: params.filter
380-
});
374+
ImgTrans.set({ type: ImgTrans.matrix.type || params.type || file.type || 'image/png' });
375+
376+
if( !isFn ){
377+
ImgTrans.set({
378+
deg: params.rotate
379+
, overlay: params.overlay
380+
, filter: params.filter
381+
, quality: params.quality || 1
382+
});
383+
}
381384

382385
queue.inc();
383386
ImgTrans.toData(function (err, image){

lib/FileAPI.core.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
_rinput = /input/i,
4242
_rdata = /^data:[^,]+,/,
4343

44+
_toString = {}.toString,
45+
4446

4547
Math = window.Math,
4648

@@ -184,7 +186,7 @@
184186
* FileAPI (core object)
185187
*/
186188
api = {
187-
version: '2.0.8',
189+
version: '2.0.9',
188190

189191
cors: false,
190192
html5: true,
@@ -462,19 +464,25 @@
462464

463465

464466
/**
465-
* Is file instance
466-
*
467+
* Is file?
467468
* @param {File} file
468469
* @return {Boolean}
469470
*/
470471
isFile: function (file){
471-
return html5 && file && (file instanceof File);
472+
return _toString.call(file) === '[object File]';
472473
},
473474

475+
476+
/**
477+
* Is blob?
478+
* @param {Blob} blob
479+
* @returns {Boolean}
480+
*/
474481
isBlob: function (blob) {
475-
return html5 && blob && (blob instanceof Blob);
482+
return this.isFile(blob) || (_toString.call(blob) === '[object Blob]');
476483
},
477484

485+
478486
/**
479487
* Is canvas element
480488
*
@@ -1034,7 +1042,7 @@
10341042
options.progress({
10351043
type: 'progress'
10361044
, total: _total
1037-
, loaded: proxyXHR.loaded = (_loaded + data.size * (evt.loaded/evt.total))|0
1045+
, loaded: proxyXHR.loaded = (_loaded + data.size * (evt.loaded/evt.total)) || 0
10381046
}, _file, xhr, _fileOptions);
10391047
}
10401048
} : noop,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "fileapi",
33
"exportName": "FileAPI",
4-
"version": "2.0.8",
4+
"version": "2.0.9",
55
"devDependencies": {
66
"grunt": "~0.4.5",
77
"grunt-version": "~0.3.0",

0 commit comments

Comments
 (0)