dzxstatic
Version:
The static files of Discuz! X
1 lines • 4.52 kB
JavaScript
function FileProgress(e,s){if(this.fileProgressID=e.id,this.opacity=100,this.height=0,this.fileProgressWrapper=document.getElementById(this.fileProgressID),this.fileProgressWrapper)this.fileProgressElement=this.fileProgressWrapper.firstChild,this.reset();else{this.fileProgressWrapper=document.createElement("div"),this.fileProgressWrapper.className="progressWrapper",this.fileProgressWrapper.id=this.fileProgressID,this.fileProgressElement=document.createElement("div"),this.fileProgressElement.className="progressContainer";var r=document.createElement("a");r.className="progressCancel",r.href="#",r.style.visibility="hidden",r.appendChild(document.createTextNode(" "));var i=document.createElement("div");i.className="progressName",i.appendChild(document.createTextNode(e.name));var t=document.createElement("div");t.className="progressBarInProgress";var o=document.createElement("div");o.className="progressBarStatus",o.innerHTML=" ",this.fileProgressElement.appendChild(r),this.fileProgressElement.appendChild(i),this.fileProgressElement.appendChild(o),this.fileProgressElement.appendChild(t),this.fileProgressWrapper.appendChild(this.fileProgressElement),document.getElementById(s).appendChild(this.fileProgressWrapper)}this.height=this.fileProgressWrapper.offsetHeight,this.setTimer(null)}FileProgress.prototype.setTimer=function(e){this.fileProgressElement.FP_TIMER=e},FileProgress.prototype.getTimer=function(e){return this.fileProgressElement.FP_TIMER||null},FileProgress.prototype.reset=function(){this.fileProgressElement.className="progressContainer",this.fileProgressElement.childNodes[2].innerHTML=" ",this.fileProgressElement.childNodes[2].className="progressBarStatus",this.fileProgressElement.childNodes[3].className="progressBarInProgress",this.fileProgressElement.childNodes[3].style.width="0%",this.appear()},FileProgress.prototype.setProgress=function(e){this.fileProgressElement.className="progressContainer green",this.fileProgressElement.childNodes[3].className="progressBarInProgress",this.fileProgressElement.childNodes[3].style.width=e+"%",this.appear()},FileProgress.prototype.setComplete=function(){this.fileProgressElement.className="progressContainer blue",this.fileProgressElement.childNodes[3].className="progressBarComplete",this.fileProgressElement.childNodes[3].style.width=""},FileProgress.prototype.setError=function(){this.fileProgressElement.className="progressContainer red",this.fileProgressElement.childNodes[3].className="progressBarError",this.fileProgressElement.childNodes[3].style.width="";var e=this;this.setTimer(setTimeout((function(){e.disappear()}),5e3))},FileProgress.prototype.setCancelled=function(){this.fileProgressElement.className="progressContainer",this.fileProgressElement.childNodes[3].className="progressBarError",this.fileProgressElement.childNodes[3].style.width="";var e=this;this.setTimer(setTimeout((function(){e.disappear()}),2e3))},FileProgress.prototype.setStatus=function(e){this.fileProgressElement.childNodes[2].innerHTML=e},FileProgress.prototype.toggleCancel=function(e,s){if(this.fileProgressElement.childNodes[0].style.visibility=e?"visible":"hidden",s){var r=this.fileProgressID;this.fileProgressElement.childNodes[0].onclick=function(){return s.cancelUpload(r),!1}}},FileProgress.prototype.appear=function(){if(null!==this.getTimer()&&(clearTimeout(this.getTimer()),this.setTimer(null)),this.fileProgressWrapper.filters)try{this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity=100}catch(e){this.fileProgressWrapper.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=100)"}else this.fileProgressWrapper.style.opacity=1;this.fileProgressWrapper.style.height="",this.height=this.fileProgressWrapper.offsetHeight,this.opacity=100,this.fileProgressWrapper.style.display=""},FileProgress.prototype.disappear=function(){if(this.opacity>0)if(this.opacity-=15,this.opacity<0&&(this.opacity=0),this.fileProgressWrapper.filters)try{this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity=this.opacity}catch(e){this.fileProgressWrapper.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+this.opacity+")"}else this.fileProgressWrapper.style.opacity=this.opacity/100;if(this.height>0&&(this.height-=4,this.height<0&&(this.height=0),this.fileProgressWrapper.style.height=this.height+"px"),this.height>0||this.opacity>0){var e=this;this.setTimer(setTimeout((function(){e.disappear()}),30))}else this.fileProgressWrapper.style.display="none",this.setTimer(null)};