
SFT.Upload=function(){var objArgs={};switch(arguments.length){case 1:objArgs=arguments[0];break;}var self=this;SFT.Upload.SUPERconstructor.call(self,objArgs);};SFT.Upload.id="SFT.Upload";SFT.inherit(SFT.Upload,SFT.Widget);SFT.Upload.prototype.init=function(objArgs){var self=this;this.config=objArgs;this.component=document.getElementById(self.config.id);this.attachmentImg=document.getElementById(self.config.attachmentImgId);this.attachmentImg.src=SFT.contextPath+SFT.getTheme().imagePath+"_attachment.gif";this.componentImg=document.getElementById(self.config.imgId);this.componentImgDiv=document.getElementById(self.config.imgDivId);self.synchronize();self.showImg();};SFT.Upload.prototype.synchronize=function(){var self=this;try{self.componentImg.src=self.component.fileZoomImageUrl;}catch(e){}};SFT.Upload.prototype.showImg=function(){var self=this;var url=self.component.value;if(typeof url=="undefined"){url="";}self.componentImg.src=url;self.componentImg.onload=function(){if(self.componentImg.offsetWidth>300){self.componentImg.style.width="300px";}};var lowerUrl=url.toLowerCase();self.componentImgDiv.style.display="none";self.attachmentImg.style.display="none";var mode=self.config.mode;if((mode=="S"||mode=="P")){if(lowerUrl.endWith(".gif")||lowerUrl.endWith(".jpg")||lowerUrl.endWith(".jpeg")||lowerUrl.endWith(".png")||lowerUrl.endWith(".bmp")){self.componentImgDiv.style.display="block";if(self.componentImg.offsetWidth>300){self.componentImg.style.width="300px";}self.attachmentImg.style.display="none";}else{if(url.length==0){self.componentImgDiv.style.display="none";self.attachmentImg.style.display="none";}else{self.componentImgDiv.style.display="none";self.attachmentImg.style.display="block";}}return;}if(mode=="I"||mode=="D"||mode=="R"){if(url.length==0){self.componentImgDiv.style.display="none";self.attachmentImg.style.display="none";}else{self.componentImgDiv.style.display="none";self.attachmentImg.style.display="block";}return;}if(mode=="E"||mode=="M"){self.componentImgDiv.style.display="none";self.attachmentImg.style.display="none";}};SFT.Upload.prototype.responseJson=function(jsonObj){var self=this;this.component.value=jsonObj.fileUrl;this.component.fileZoomImageUrl=jsonObj.fileZoomImageUrl;if(typeof self.config.onupload=="function"){try{self.config.onupload(jsonObj);}catch(e){}}self.synchronize();};SFT.Upload.prototype.cancel=function(){var self=this;var component=document.getElementById(self.config.id);component.value="";component.fileZoomImageUrl="";document.getElementById(self.config.uploadFrameId).src=self.config.uploadAction+"?componentId="+self.config.id+"&model.id=";self.synchronize();return false;};SFT.Upload.prototype.upload=function(){var self=this;var frm=document.getElementById(self.config.uploadFrameId);frm.forms[0].submit();};SFT.Upload.prototype.download=function(){var self=this;var component=document.getElementById(self.config.id);var id=component.value;if(id==null||id.length==0){alert("\u65e0\u76f8\u5e94\u5f97\u9644\u4ef6\u53ef\u4f9b\u4e0b\u8f7d!");return;}var win=window.open(component.value,"_blank","toolbar=no,resizable");win.focus();return false;};


