Index: trunk/extensions/UploadWizard/resources/mw.fileApi.js |
— | — | @@ -0,0 +1,31 @@ |
| 2 | +/* miscellaneous fileApi routines -- partially copied from mediawiki.special.upload.js, must refactor... */ |
| 3 | + |
| 4 | +( function( $, mw ) { |
| 5 | + |
| 6 | + /** |
| 7 | + * Is the FileAPI available with sufficient functionality? |
| 8 | + */ |
| 9 | + mw.fileApi = { |
| 10 | + |
| 11 | + isAvailable: function() { |
| 12 | + return typeof window.FileReader !== 'undefined'; |
| 13 | + }, |
| 14 | + |
| 15 | + /** |
| 16 | + * Check if this is a recognizable image type... |
| 17 | + * Also excludes files over 10M to avoid going insane on memory usage. |
| 18 | + * |
| 19 | + * @todo is there a way we can ask the browser what's supported in <img>s? |
| 20 | + * |
| 21 | + * @param {File} file |
| 22 | + * @return boolean |
| 23 | + */ |
| 24 | + isPreviewableFile: function( file ) { |
| 25 | + var known = [ 'image/png', 'image/gif', 'image/jpeg', 'image/svg+xml'], |
| 26 | + tooHuge = 10 * 1024 * 1024; |
| 27 | + return ( $.inArray( file.type, known ) !== -1 ) && file.size > 0 && file.size < tooHuge; |
| 28 | + } |
| 29 | + |
| 30 | + }; |
| 31 | + |
| 32 | +} )( jQuery, mediaWiki ); |
Property changes on: trunk/extensions/UploadWizard/resources/mw.fileApi.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 33 | + native |