243ecb7b13
git-svn-id: https://develop.svn.wordpress.org/trunk@20760 602fd350-edb4-49c9-b593-d223f7449a82
1 line
2.3 KiB
JavaScript
1 line
2.3 KiB
JavaScript
if(typeof wp==="undefined"){var wp={}}(function(b,c){var d,a;a=c(document.body);d=function(f){var e=this,h={container:"container",browser:"browse_button",dropzone:"drop_element"},g;this.plupload=c.extend(true,{multipart_params:{}},wpPluploadDefaults);this.container=document.body;c.extend(true,this,f);for(g in this){if(c.isFunction(this[g])){this[g]=c.proxy(this[g],this)}}for(g in h){if(!this[g]){continue}this[g]=c(this[g]).first();if(!this[g].length){delete this[g];continue}if(!this[g].prop("id")){this[g].prop("id","__wp-uploader-id-"+d.uuid++)}this.plupload[h[g]]=this[g].prop("id")}this.uploader=new plupload.Uploader(this.plupload);delete this.plupload;this.param(this.params||{});delete this.params;this.uploader.bind("Init",this.init);this.uploader.init();this.browser.on("mouseenter",this.refresh);a.toggleClass("uploader-drag-drop",this.uploader.features.dragdrop);this.uploader.bind("UploadProgress",this.progress);this.uploader.bind("FileUploaded",function(i,k,j){try{j=JSON.parse(j.response)}catch(l){return e.error(pluploadL10n.default_error,l)}if(!j||!j.type||!j.data){return e.error(pluploadL10n.default_error)}if("error"===j.type){return e.error(j.data.message,j.data)}if("success"===j.type){return e.success(j.data)}});this.uploader.bind("Error",function(i,j){var l=pluploadL10n.default_error,k;for(k in d.errorMap){if(j.code===plupload[k]){l=d.errorMap[k];break}}e.error(l,j);i.refresh()});this.uploader.bind("FilesAdded",function(i,j){c.each(j,function(){e.added(this)});i.refresh();i.start()})};d.uuid=0;d.errorMap={FAILED:pluploadL10n.upload_failed,FILE_EXTENSION_ERROR:pluploadL10n.invalid_filetype,IMAGE_FORMAT_ERROR:pluploadL10n.not_an_image,IMAGE_MEMORY_ERROR:pluploadL10n.image_memory_exceeded,IMAGE_DIMENSIONS_ERROR:pluploadL10n.image_dimensions_exceeded,GENERIC_ERROR:pluploadL10n.upload_failed,IO_ERROR:pluploadL10n.io_error,HTTP_ERROR:pluploadL10n.http_error,SECURITY_ERROR:pluploadL10n.security_error};c.extend(d.prototype,{param:function(e,f){if(arguments.length===1&&typeof e==="string"){return this.uploader.settings.multipart_params[e]}if(arguments.length>1){this.uploader.settings.multipart_params[e]=f}else{c.extend(this.uploader.settings.multipart_params,e)}},init:function(){},error:function(){},success:function(){},added:function(){},progress:function(){},complete:function(){},refresh:function(){this.uploader.refresh()}});b.Uploader=d})(wp,jQuery); |