1
0
mirror of https://github.com/danbee/myimages synced 2025-03-04 08:39:09 +00:00
myimages/lib/js/plupload/plupload.html4.min.js
2010-03-10 11:08:15 +00:00

1 line
3.3 KiB
JavaScript

(function(a){a.runtimes.Html4=a.addRuntime("html4",{init:function(f,g){var d={},c,b;function e(l){var k,j,m=[],n,h;h=l.value.replace(/\\/g,"/");h=h.substring(h.length,h.lastIndexOf("/")+1);n=a.guid();k=new a.File(n,h,1025);d[n]=k;k.input=l;m.push(k);f.trigger("FilesAdded",m)}f.bind("Init",function(o){var h,w,u,s=[],n,t,m=o.settings.filters,l,r,q=/MSIE/.test(navigator.userAgent),k="javascript",v,j=document.body;if(f.settings.container){j=document.getElementById(f.settings.container);j.style.position="relative"}if(!o.settings.form){h=document.getElementsByTagName("form");if(!h.length){c=document.createElement("form");c.setAttribute("action",o.settings.url);c.setAttribute("target","_self");document.body.appendChild(c)}else{c=h[0]}c.setAttribute("id",c.id||o.id);c.setAttribute("method","post");c.setAttribute("enctype","multipart/form-data")}else{c=(typeof o.settings.form=="string")?document.getElementById(o.settings.form):o.settings.form}a.each(o.settings.multipart_params,function(y,x){var i=document.createElement("input");a.extend(i,{type:"hidden",name:x,value:y});c.appendChild(i)});b=document.createElement("iframe");b.setAttribute("src",k+':""');b.setAttribute("name",o.id+"_iframe");b.setAttribute("id",o.id+"_iframe");b.style.display="none";a.addEvent(b,"load",function(z){var A=z.target,x=f.currentfile;var y=A.contentWindow.document||A.contentDocument||window.frames[A.id].document;if(y.location.href=="about:blank"||!x){return}var i=y.documentElement.innerText||y.documentElement.textContent;if(i!=""){x.status=a.DONE;x.loaded=1025;x.percent=100;if(x.input){x.input.removeAttribute("name")}o.trigger("UploadProgress",x);o.trigger("FileUploaded",x,{response:i});if(c.tmpAction){c.action=c.tmpAction}if(c.tmpTarget){c.target=c.tmpTarget}}});c.appendChild(b);if(q){window.frames[b.id].name=b.name}w=document.createElement("div");w.id=o.id+"_iframe_container";for(n=0;n<m.length;n++){l=m[n].extensions.split(/,/);for(t=0;t<l.length;t++){r=a.mimeTypes[l[t]];if(r){s.push(r)}}}a.extend(w.style,{position:"absolute",background:"transparent",width:"100px",height:"100px",overflow:"hidden",zIndex:99999,opacity:0});v=f.settings.shim_bgcolor;if(v){a.extend(w.style,{background:v,opacity:1})}w.className="plupload_iframe";j.appendChild(w);function p(){u=document.createElement("input");u.setAttribute("type","file");u.setAttribute("accept",s.join(","));u.setAttribute("size",1);a.extend(u.style,{width:"100%",height:"100%",opacity:0});if(q){a.extend(u.style,{filter:"alpha(opacity=0)"})}a.addEvent(u,"change",function(i){var x=i.target;if(x.value){p();x.style.display="none";e(x)}});w.appendChild(u);return true}p()});f.bind("Refresh",function(h){var i,j,k;i=document.getElementById(f.settings.browse_button);j=a.getPos(i,document.getElementById(h.settings.container));k=a.getSize(i);a.extend(document.getElementById(f.id+"_iframe_container").style,{top:j.y+"px",left:j.x+"px",width:k.w+"px",height:k.h+"px"})});f.bind("UploadFile",function(h,i){if(i.status==a.DONE||i.status==a.FAILED||h.state==a.STOPPED){return}if(!i.input){i.status=a.ERROR;return}i.input.setAttribute("name","file");c.tmpAction=c.action;c.action=a.buildUrl(h.settings.url,{name:i.target_name||i.name});c.tmpTarget=c.target;c.target=b.name;this.currentfile=i;c.submit()});f.bind("FilesRemoved",function(h,k){var j,l;for(j=0;j<k.length;j++){l=k[j].input;if(l){l.parentNode.removeChild(l)}}});f.features={};g({success:true})}})})(plupload);