(function($, undefined) {

	// TODO test de non compatibilité IE9, etc...
	var onProgress;

	function uploadOne(url, file, data, cb) {

		var formData = new FormData();
		if (data) {
			formData.append('data', data);
		}
		formData.append('file', file);

		$.ajax({
			url: url,
			type: "POST",
			data: formData,
			processData: false,
			contentType: false,
			cache: false,
			xhr: function() { // workaround because jqXHR does not expose upload property
	            var xhr = $.ajaxSettings.xhr();
	            if (xhr.upload && onProgress) {
	                xhr.upload.addEventListener('progress', function(e) {
	                	onProgress(e);
	                }, false);
	            }
	            return xhr;
	        },
			success: function(message) {
				cb(null, null, message);
			},
			error: function(jqXHR, textStatus, message) {
				cb(jqXHR, textStatus, message);
			}
		});
	}

	function upload(url, files, data, i) {
		uploadOne(url, files[i], data, function(jqXHR, textStatus, message) {
			if (jqXHR) {
				onError && onError(jqXHR, textStatus, message);
			} else {
				if ((i+1) === files.length) {
					onSuccess && onSuccess(message);
				} else {
					upload(url, files, data, i+1);
				}
			}
		});
	}

	function getFilesInput($files) {
		return $.makeArray($files.prop('files'));
	}

	$.fn.upload = function(options) {

		if (!options) {
			return;
		}

		var url = options.url,
			data = options.data;

		if (!url) {
			return;
		}

		onProgress = options.onProgress,
		onSuccess = options.onSuccess,
		onError = options.onError;

		$(this).on("change", function(e) {
			upload(url, getFilesInput($(this)), data ? JSON.stringify(data) : null, 0);
        });
	};

}(jQuery));
@@ -474,28 +474,19 @@
 perty%0D%0A%09
-            
+%09%09%09
 var xhr 
@@ -511,28 +511,19 @@
 hr();%0D%0A%09
-            
+%09%09%09
 if (xhr.
@@ -548,32 +548,20 @@
 ss) %7B%0D%0A%09
-                
+%09%09%09%09
 xhr.uplo
@@ -608,32 +608,20 @@
 (e) %7B%0D%0A%09
-                
+%09%09%09%09
 %09onProgr
@@ -634,65 +634,35 @@
 ;%0D%0A%09
-                %7D, false);%0D%0A%09            %7D%0D%0A%09            
+%09%09%09%09%7D, false);%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%09
 retu
@@ -671,24 +671,18 @@
  xhr;%0D%0A%09
-        
+%09%09
 %7D,%0D%0A%09%09%09s
@@ -1483,17 +1483,17 @@
 Progress
-,
+;
 %0D%0A%09%09onSu
@@ -1517,17 +1517,17 @@
 nSuccess
-,
+;
 %0D%0A%09%09onEr

fix syntax warning