r89915 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89914‎ | r89915 | r89916 >
Date:05:17, 12 June 2011
Author:neilk
Status:ok (Comments)
Tags:todo 
Comment:
this is taken from mediawiki.special.upload.js -- should be its own lib
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.fileApi.js (added) (history)

Diff [purge]

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
133 + native

Comments

#Comment by Brion VIBBER (talk | contribs)   17:47, 13 June 2011

todo: merge into a module in core, use commonly

Status & tagging log