(function() {
if (window.FileUpload) {
返回;
}
window.FileUpload = function (id, url) {
this.id = id;
this.autoUpload = true
this.url = url;
this.maxSize = null;
this.extensions = null;
this.dropId = null;
window.FileUpload.prototype.init = function() {
var obj = this;
$('#' this.id).change(function () {
if (obj.autoUpload) {
obj.upload();
}
});
if (this.supportsFormData()) {
if (this.dropId != null) {
var drop = $('#' this.dropId)[0];
drop.addEventListener("dragover", function(e) {
e.stopPropagation();
e.preventDefault();
$('#' obj.dropId).addClass(" Dragover");
}, false);
drop.addEventListener("dragout", function(e) {
$('#' obj.dropId).removeClass("dragover");
}, false);
drop.addEventListener("drop", function(e) {
e.stopPropagation();
e.preventDefault();
$('#' obj. dropId).removeClass("dragover");
obj._uploadUsingFormData(e.dataTransfer.files[0]);
},假);
}
} else {
if (this.dropId != null) {
$('#' this.dropId).hide();
}
}
};
FileUpload.prototype.supportsFormData = function() {
return window.FormData != undefined;
};
FileUpload.prototype.upload = function() {
if (this.supportsFormData()) {
this._uploadUsingFormData($("#" this.id)[0].files[ 0]);
} else {
this._uploadUsingFrame();
}
};
FileUpload.prototype._uploadUsingFrame = function() {
var obj = this;
var $frame = $('#uploadFrame');
if ($frame.length == 0) {
$frame = $('