text: MWF.xDesktop.requireApp("File","Actions.RestActions",null,!1),MWF.require("MWF.widget.AttachmentController",null,!1),MWF.xApplication.File.AttachmentController=new Class({Extends:MWF.widget.AttachmentController,createTopNode:function(){this.topNode=new Element("div",{styles:this.css.topNode}).inject(this.node),this.createFolderGroupActions(),this.createEditGroupActions(),this.createReadGroupActions(),this.createListGroupActions(),this.createShareGroupActions(),this.createViewGroupActions()},checkActions:function(){this.checkFolderAction(),this.checkUploadAction(),this.checkDeleteAction(),this.checkReplaceAction(),this.checkDownloadAction(),this.checkSizeAction(),this.checkShareAction(),this.checkListStyleAction()},createFolderGroupActions:function(){this.folderActionBoxNode=new Element("div",{styles:this.css.actionsBoxNode}).inject(this.topNode),this.folderActionsGroupNode=new Element("div",{styles:this.css.actionsGroupNode}).inject(this.folderActionBoxNode),this.createFolderAction=this.createAction(this.folderActionsGroupNode,"createFolder",MWF.LP.widget.createFolder,function(){this.createFolder()}.bind(this)),this.renameAction=this.createAction(this.folderActionsGroupNode,"rename",MWF.LP.widget.rename,function(){this.renameFolder()}.bind(this))},createShareGroupActions:function(){this.shareActionBoxNode=new Element("div",{styles:this.css.actionsBoxNode}).inject(this.topNode),this.shareActionsGroupNode=new Element("div",{styles:this.css.actionsGroupNode}).inject(this.shareActionBoxNode),this.shareAction=this.createAction(this.shareActionsGroupNode,"share",MWF.LP.widget.share,function(){this.shareAttachment()}.bind(this)),this.sendAction=this.createAction(this.shareActionsGroupNode,"send",MWF.LP.widget.send,function(){this.sendAttachment()}.bind(this))},checkReplaceAction:function(){if(this.options.readonly)return this.setActionDisabled(this.replaceAction),this.setActionDisabled(this.min_replaceAction),!1;this.options.isReplace&&this.selectedAttachments.length&&1==this.selectedAttachments.length?"folder"==this.selectedAttachments[0].type?(this.setActionDisabled(this.replaceAction),this.setActionDisabled(this.min_replaceAction)):(this.setActionEnabled(this.replaceAction),this.setActionEnabled(this.min_replaceAction)):(this.setActionDisabled(this.replaceAction),this.setActionDisabled(this.min_replaceAction))},checkFolderAction:function(){1==this.selectedAttachments.length?this.setActionEnabled(this.renameAction):this.setActionDisabled(this.renameAction)},checkShareAction:function(){this.selectedAttachments.length?1==this.selectedAttachments.length&&"folder"==this.selectedAttachments[0].type?(this.setActionDisabled(this.shareAction),this.setActionDisabled(this.sendAction)):(this.setActionEnabled(this.shareAction),this.setActionEnabled(this.sendAction)):(this.setActionDisabled(this.shareAction),this.setActionDisabled(this.sendAction))},addAttachment:function(t){"min"==this.options.size?this.attachments.push(new MWF.widget.AttachmentController.AttachmentMin(t,this)):this.attachments.push(new MWF.xApplication.File.AttachmentController.Attachment(t,this))},addAttachmentFolder:function(t){var e=new MWF.xApplication.File.AttachmentController.Folder(t,this);return this.attachments.push(e),e},createFolder:function(t,e){this.module&&this.module.createFolder(t,e)},renameFolder:function(t,e){this.module&&this.module.renameFileFolder(t,e)},shareAttachment:function(){this.module&&this.module.shareAttachment()},sendAttachment:function(){this.module&&this.module.sendAttachment()}}),MWF.xApplication.File.AttachmentController.Attachment=new Class({Extends:MWF.widget.AttachmentController.Attachment,loadList:function(){this.node.setStyles(this.css.attachmentNode_list),this.isSelected&&this.node.setStyles(this.css.attachmentNode_list_selected),this.iconNode=new Element("div",{styles:this.css.attachmentIconNode_list}).inject(this.node),this.iconImgAreaNode=new Element("div",{styles:this.css.attachmentIconImgAreaNode_list}).inject(this.iconNode),this.iconImgNode=new Element("img",{styles:this.css.attachmentIconImgNode_list}).inject(this.iconImgAreaNode),this.iconImgNode.set({src:this.getIcon(),border:0}),this.textNode=new Element("div",{styles:this.css.attachmentTextNode_list}).inject(this.node),this.textTitleNode=new Element("div",{styles:this.css.attachmentTextTitleNode_list}).inject(this.textNode),this.textTitleNode.set("text",this.data.name);var t="",e=this.data.length/1024;if(e>1024){var i=e/1024;t=(i=Math.round(100*i)/100)+"M"}else t=(e=Math.round(100*e)/100)+"K";this.textSizeNode=new Element("div",{styles:this.css.attachmentTextSizeNode_list}).inject(this.textNode),this.textSizeNode.set("text",t),this.textUploaderNode=new Element("div",{styles:this.css.attachmentTextUploaderNode_list}).inject(this.textNode),this.textUploaderNode.set("text",o2.name.cn(this.data.person||this.data.creatorUid)),this.textTimeNode=new Element("div",{styles:this.css.attachmentTextTimeNode_list}).inject(this.textNode),this.textTimeNode.set("text",this.data.lastUpdateTime),this.extensionNode=new Element("div",{styles:this.css.attachmentTextActivityNode_list}).inject(this.textNode),this.extensionNode.set("text",this.data.extension||o2.LP.widget.unknow),this.custom_List()},loadSequence:function(){this.node.setStyles(this.css.attachmentNode_sequence),this.isSelected&&this.node.setStyles(this.css.attachmentNode_sequence_selected),this.sequenceNode=new Element("div",{styles:this.css.attachmentSeqNode_sequence,text:this.seq||1}).inject(this.node),this.iconNode=new Element("div",{styles:this.css.attachmentIconNode_list}).inject(this.node),this.iconImgAreaNode=new Element("div",{styles:this.css.attachmentIconImgAreaNode_list}).inject(this.iconNode),this.iconImgNode=new Element("img",{styles:this.css.attachmentIconImgNode_list}).inject(this.iconImgAreaNode),this.iconImgNode.set({src:this.getIcon(),border:0}),this.textNode=new Element("div",{styles:this.css.attachmentTextNode_sequence}).inject(this.node),this.textTitleNode=new Element("div",{styles:this.css.attachmentTextTitleNode_list}).inject(this.textNode),this.textTitleNode.set("text",this.data.name);var t="",e=this.data.length/1024;if(e>1024){var i=e/1024;t=(i=Math.round(100*i)/100)+"M"}else t=(e=Math.round(100*e)/100)+"K";this.textSizeNode=new Element("div",{styles:this.css.attachmentTextSizeNode_list}).inject(this.textNode),this.textSizeNode.set("text",t),this.textUploaderNode=new Element("div",{styles:this.css.attachmentTextUploaderNode_list}).inject(this.textNode),this.textUploaderNode.set("text",o2.name.cn(this.data.person||this.data.creatorUid)),this.textTimeNode=new Element("div",{styles:this.css.attachmentTextTimeNode_list}).inject(this.textNode),this.textTimeNode.set("text",this.data.lastUpdateTime),this.extensionNode=new Element("div",{styles:this.css.attachmentTextActivityNode_list}).inject(this.textNode),this.extensionNode.set("text",this.data.extension||o2.LP.widget.unknow),this.custom_Sequence()},createInforNode:function(t){var e="",i=this.data.length/1024;if(i>1024){var s=i/1024;e=(s=Math.round(100*s)/100)+"M"}else e=(i=Math.round(100*i)/100)+"K";var n=this.data.shareList?this.data.shareList.map((function(t){return t.substring(0,t.indexOf("@"))})).join(","):"",o=this.data.editorList?this.data.editorList.map((function(t){return t.substring(0,t.indexOf("@"))})).join(","):"";this.inforNode=new Element("div",{styles:this.css.attachmentInforNode});var d="<div style='overflow:hidden; font-weight: bold'>"+this.data.name+"</div>";d+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.uploader+": </div><div style='width:120px; float:left; margin-left:10px'>"+MWF.name.cn(this.data.person)+"</div></div>",d+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.uploadTime+": </div><div style='width:120px; float:left; margin-left:10px'>"+this.data.createTime+"</div></div>",d+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.modifyTime+": </div><div style='width:120px; float:left; margin-left:10px'>"+this.data.lastUpdateTime+"</div></div>",d+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.size+": </div><div style='width:120px; float:left; margin-left:10px'>"+e+"</div></div>",d+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.share+": </div><div style='width:120px; float:left; margin-left:10px'>"+n+"</div></div>",d+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.send+": </div><div style='width:120px; float:left; margin-left:10px'>"+o+"</div></div>",this.inforNode.set("html",d),t&&t()},custom_Preview:function(){var t=this.data.shareList?this.data.shareList.join(","):"",e=this.data.editorList?this.data.editorList.join(","):"";if(t||e)new Element("div",{styles:{width:"24px",height:"24px",background:"url(../x_component_File/$Main/default/icon/share_flag_preview.png) center center no-repeat",position:"relative",top:"-28px"}}).inject(this.iconImgAreaNode)},custom_Icon:function(){var t=this.data.shareList?this.data.shareList.join(","):"",e=this.data.editorList?this.data.editorList.join(","):"";if(t||e)new Element("div",{styles:{width:"16px",height:"16px",background:"url(../x_component_File/$Main/default/icon/share_flag_icon.png) center center no-repeat",position:"relative",top:"-18px"}}).inject(this.iconImgAreaNode)},custom_List:function(){var t=this.data.shareList?this.data.shareList.join(","):"",e=this.data.editorList?this.data.editorList.join(","):"";if(t||e)new Element("div",{styles:{width:"10px",height:"10px",background:"url(../x_component_File/$Main/default/icon/share_flag_list.png) center center no-repeat",position:"relative",top:"-14px"}}).inject(this.iconImgAreaNode)}}),MWF.xApplication.File.AttachmentController.Folder=new Class({Extends:MWF.widget.AttachmentController.Attachment,initialize:function(t,e){this.data=t,this.controller=e,this.css=this.controller.css,this.listStyle=this.controller.options.listStyle,this.content=this.controller.content,this.isSelected=!1,this.type="folder",this.load()},getIcon:function(){return"../x_component_File/$Main/default/file/folder.png"},createInforNode:function(t){var e="",i=this.data.size/1024;if(i>1024){var s=i/1024;e=(s=Math.round(100*s)/100)+"M"}else e=(i=Math.round(100*i)/100)+"K";this.inforNode=new Element("div",{styles:this.css.attachmentInforNode});var n="<div style='overflow:hidden; font-weight: bold'>"+this.data.name+"</div>";n+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.attCount+": </div><div style='width:120px; float:left; margin-left:10px'>"+this.data.attachmentCount+"</div></div>",n+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.folderCount+": </div><div style='width:120px; float:left; margin-left:10px'>"+this.data.folderCount+"</div></div>",n+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.uploadTime+": </div><div style='width:120px; float:left; margin-left:10px'>"+this.data.createTime+"</div></div>",n+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.modifyTime+": </div><div style='width:120px; float:left; margin-left:10px'>"+this.data.updateTime+"</div></div>",n+="<div style='clear: both; overflow:hidden'><div style='width:40px; float:left; font-weight: bold'>"+MWF.LP.widget.size+": </div><div style='width:120px; float:left; margin-left:10px'>"+e+"</div></div>",this.inforNode.set("html",n),t&&t()},loadPreview:function(){this.node.setStyles(this.css.attachmentNode_preview),this.isSelected&&this.node.setStyles(this.css.attachmentNode_preview_selected),this.iconNode=new Element("div",{styles:this.css.attachmentPreviewIconNode}).inject(this.node),this.iconImgAreaNode=new Element("div",{styles:this.css.attachmentPreviewIconImgAreaNode}).inject(this.iconNode),this.iconImgNode=new Element("img",{styles:this.css.attachmentPreviewIconImgNode}).inject(this.iconImgAreaNode);var t=this.getIcon();this.iconImgNode.set({src:t,border:0}),this.textNode=new Element("div",{styles:this.css.attachmentPreviewTextNode}).inject(this.node),this.textNode.set("text",this.data.name)},setEvent:function(){this.node.addEvents({mouseover:function(){this.isSelected||this.node.setStyles(this.css["attachmentNode_"+this.controller.options.listStyle+"_over"])}.bind(this),mouseout:function(){this.isSelected||this.node.setStyles(this.css["attachmentNode_"+this.controller.options.listStyle])}.bind(this),mousedown:function(t){this.selected(t)}.bind(this),dblclick:function(t){this.openFolder(t)}.bind(this)})},openFolder:function(){this.treeNode.clickNode()}});