|
1 | | -/*! FileAPI 2.0.8 - BSD | git://github.com/mailru/FileAPI.git |
| 1 | +/*! FileAPI 2.0.9 - BSD | git://github.com/mailru/FileAPI.git |
2 | 2 | * 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. |
3 | 3 | */ |
4 | 4 |
|
|
135 | 135 | _rinput = /input/i, |
136 | 136 | _rdata = /^data:[^,]+,/, |
137 | 137 |
|
| 138 | +_toString = {}.toString, |
| 139 | + |
138 | 140 |
|
139 | 141 | Math = window.Math, |
140 | 142 |
|
|
278 | 280 | * FileAPI (core object) |
279 | 281 | */ |
280 | 282 | api = { |
281 | | -version: '2.0.8', |
| 283 | +version: '2.0.9', |
282 | 284 |
|
283 | 285 | cors: false, |
284 | 286 | html5: true, |
|
556 | 558 |
|
557 | 559 |
|
558 | 560 | /** |
559 | | - * Is file instance |
560 | | - * |
| 561 | + * Is file? |
561 | 562 | * @param {File} file |
562 | 563 | * @return {Boolean} |
563 | 564 | */ |
564 | 565 | isFile: function (file){ |
565 | | -returnhtml5 && file && (file instanceof File); |
| 566 | +return _toString.call(file) === '[object File]'; |
566 | 567 | }, |
567 | 568 |
|
| 569 | + |
| 570 | +/** |
| 571 | + * Is blob? |
| 572 | + * @param {Blob} blob |
| 573 | + * @returns {Boolean} |
| 574 | + */ |
568 | 575 | isBlob: function (blob) { |
569 | | -return html5 && blob && (blob instanceof Blob); |
| 576 | +return this.isFile(blob) || (_toString.call(blob) === '[object Blob]'); |
570 | 577 | }, |
571 | 578 |
|
| 579 | + |
572 | 580 | /** |
573 | 581 | * Is canvas element |
574 | 582 | * |
|
1128 | 1136 | options.progress({ |
1129 | 1137 | type: 'progress' |
1130 | 1138 | , 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 |
1132 | 1140 | }, _file, xhr, _fileOptions); |
1133 | 1141 | } |
1134 | 1142 | } : noop, |
|
2139 | 2147 | if( !err ){ |
2140 | 2148 | api.each(transform, function (params, name){ |
2141 | 2149 | 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'; |
2143 | 2151 |
|
2144 | | -if( typeof params == 'function' ){ |
| 2152 | +if( isFn ){ |
2145 | 2153 | params(img, ImgTrans); |
2146 | 2154 | } |
2147 | 2155 | else if( params.width ){ |
|
2162 | 2170 | params.rotate = 'auto'; |
2163 | 2171 | } |
2164 | 2172 |
|
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 | +} |
2172 | 2183 |
|
2173 | 2184 | queue.inc(); |
2174 | 2185 | ImgTrans.toData(function (err, image){ |
|
3468 | 3479 | mouseover: function (evt){ |
3469 | 3480 | var target = api.event.fix(evt).target; |
3470 | 3481 |
|
3471 | | -if( /input/i.test(target.nodeName) && target.type == 'file' ){ |
| 3482 | +if( /input/i.test(target.nodeName) && target.type == 'file' && !target.disabled ){ |
3472 | 3483 | var |
3473 | 3484 | state = target.getAttribute(_attr) |
3474 | 3485 | , wrapper = flash.getWrapper(target) |
|
0 commit comments