http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89915

Revision: 89915
Author:   neilk
Date:     2011-06-12 05:17:38 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
this is taken from mediawiki.special.upload.js -- should be its own lib

Added Paths:
-----------
    trunk/extensions/UploadWizard/resources/mw.fileApi.js

Added: trunk/extensions/UploadWizard/resources/mw.fileApi.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.fileApi.js                       
        (rev 0)
+++ trunk/extensions/UploadWizard/resources/mw.fileApi.js       2011-06-12 
05:17:38 UTC (rev 89915)
@@ -0,0 +1,31 @@
+/* miscellaneous fileApi routines -- partially copied from 
mediawiki.special.upload.js, must refactor... */
+
+( function( $, mw ) { 
+
+       /**
+        * Is the FileAPI available with sufficient functionality?
+        */
+       mw.fileApi = { 
+
+               isAvailable: function() {
+                       return typeof window.FileReader !== 'undefined';
+               },
+
+               /**
+                * Check if this is a recognizable image type...
+                * Also excludes files over 10M to avoid going insane on memory 
usage.
+                *
+                * @todo is there a way we can ask the browser what's supported 
in <img>s?
+                *
+                * @param {File} file
+                * @return boolean
+                */
+               isPreviewableFile: function( file ) {
+                       var     known = [ 'image/png', 'image/gif', 
'image/jpeg', 'image/svg+xml'],
+                               tooHuge = 10 * 1024 * 1024;
+                       return ( $.inArray( file.type, known ) !== -1 ) && 
file.size > 0 && file.size < tooHuge;
+               }
+
+       };
+
+} )( jQuery, mediaWiki );


Property changes on: trunk/extensions/UploadWizard/resources/mw.fileApi.js
___________________________________________________________________
Added: svn:eol-style
   + native


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to