Starter.min.js 7.2 KB

1
  1. MWF.require("MWF.widget.Mask",null,false);MWF.xApplication.cms=MWF.xApplication.cms||{};MWF.xApplication.cms.Explorer=MWF.xApplication.cms.Explorer||{};MWF.xApplication.cms.Explorer.Starter=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{style:"default"},initialize:function(t,e,i,s){this.setOptions(s);this.path="/x_component_cms_Explorer/$Starter/";this.cssPath="/x_component_cms_Explorer/$Starter/"+this.options.style+"/css.wcss";this._loadCss();MWF.xDesktop.requireApp("cms.Explorer","$Starter."+MWF.language,null,false);this.lp=MWF.xApplication.cms.Explorer.Starter.lp;this.columnData=t;this.categoryData=e;this.app=i},load:function(){this.createMarkNode();this.createAreaNode();this.createStartNode();this.areaNode.inject(this.markNode,"after");this.areaNode.fade("in");$("form_startSubject").focus();this.setStartNodeSize();this.setStartNodeSizeFun=this.setStartNodeSize.bind(this);this.app.addEvent("resize",this.setStartNodeSizeFun)},createMarkNode:function(){this.markNode=new Element("div#mark",{styles:this.css.markNode,events:{mouseover:function(t){t.stopPropagation()},mouseout:function(t){t.stopPropagation()}}}).inject(this.app.content)},createAreaNode:function(){this.areaNode=new Element("div#area",{styles:this.css.areaNode})},createStartNode:function(){this.createNode=new Element("div",{styles:this.css.createNode}).inject(this.areaNode);this.createNewNode=new Element("div",{styles:this.css.createNewNode}).inject(this.createNode);this.formNode=new Element("div",{styles:this.css.formNode}).inject(this.createNode);var t='<table width="100%" height="90%" border="0" cellPadding="0" cellSpacing="0">'+'<tr><td colSpan="2" style="height: 60px; line-height: 60px; text-align: center; font-size: 24px; font-weight: bold">'+this.lp.start+" - "+this.categoryData.name+"</td></tr>"+'<tr><td style="height: 30px; line-height: 30px; text-align: left">'+this.lp.department+":</td>"+'<td style="; text-align: left;" id="form_startDepartment"></td></tr>'+'<tr><td style="height: 30px; line-height: 30px; text-align: left">'+this.lp.identity+":</td>"+'<td style="; text-align: left;"><div id="form_startIdentity"></div></td></tr>'+'<tr><td style="height: 30px; line-height: 30px; text-align: left">'+this.lp.date+":</td>"+'<td style="; text-align: left;"><div id="form_startDate"></div></td></tr>'+'<tr><td style="height: 30px; line-height: 30px; text-align: left">'+this.lp.subject+":</td>"+'<td style="; text-align: left;"><input type="text" id="form_startSubject" '+'style="width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; '+'height: 26px;"/></td></tr>'+"</table>";this.formNode.set("html",t);this.setStartFormContent();this.cancelActionNode=new Element("div",{styles:this.css.cancelActionNode,text:this.lp.cancel}).inject(this.formNode);this.startOkActionNode=new Element("div",{styles:this.css.startOkActionNode,text:this.lp.ok}).inject(this.formNode);this.cancelActionNode.addEvent("click",function(t){this.cancelStart(t)}.bind(this));this.startOkActionNode.addEvent("click",function(t){this.okStart(t)}.bind(this))},setStartFormContent:function(){this.dateArea=this.formNode.getElementById("form_startDate");var t=new Date;this.dateArea.set("text",t.format("%Y-%m-%d %H:%M"));this.departmentSelArea=this.formNode.getElementById("form_startDepartment");this.identityArea=this.formNode.getElementById("form_startIdentity");this.getOrgAction(function(){this.loadDepartments()}.bind(this))},loadDepartments:function(){if(this.app.desktop.session.user.name){this.orgAction.listIdentityByPerson(function(t){var e=t.data.length==1?true:false;t.data.each(function(t){var i=new MWF.xApplication.cms.Explorer.Starter.DepartmentSel(t,this,this.departmentSelArea,this.identityArea);if(e)i.selected()}.bind(this))}.bind(this),null,this.app.desktop.session.user.name)}},getOrgAction:function(t){if(!this.orgAction){MWF.require("MWF.xAction.org.express.RestActions",function(){this.orgAction=new MWF.xAction.org.express.RestActions;if(t)t()}.bind(this))}else{if(t)t()}},setStartNodeSize:function(){var t=this.app.content.getSize();var e=this.app.content.getSize();this.markNode.setStyles({width:""+e.x+"px",height:""+e.y+"px"});this.areaNode.setStyles({width:""+t.x+"px",height:""+t.y+"px"});var i=t.y*.8;var s=t.y*.2/2;this.createNode.setStyles({height:""+i+"px","margin-top":""+s+"px"});var a=this.createNewNode.getSize();var r=i*.7;if(r>250)r=250;var n=i*.3/2-a.y;this.formNode.setStyles({height:""+r+"px","margin-top":""+n+"px"})},cancelStart:function(t){var e=this;if($("form_startSubject").get("value")){this.app.confirm("warn",t,this.lp.start_cancel_title,this.lp.start_cancel,"320px","100px",function(){e.markNode.destroy();e.areaNode.destroy();this.close()},function(){this.close()},null,this.app.content)}else{this.markNode.destroy();this.areaNode.destroy()}},okStart:function(t){var e=$("form_startSubject").get("value");this.getDocumentAction();var i={id:this.documentAction.getUUID(),isNewDocument:true,title:e,creatorIdentity:this.identityArea.get("value"),appId:this.categoryData.appId,catagoryId:this.categoryData.id,form:this.categoryData.formId,formName:this.categoryData.formName,docStatus:"draft",catagoryName:this.categoryData.name,categoryAlias:this.categoryData.alias,attachmentList:[]};if(!i.title){$("form_startSubject").setStyle("border-color","red");$("form_startSubject").focus();this.app.notice(this.lp.inputSubject,"error")}else if(!i.creatorIdentity){this.departmentSelArea.setStyle("border-color","red");this.app.notice(this.lp.selectStartId,"error")}else{this.mask=new MWF.widget.Mask({style:"desktop"});this.mask.loadNode(this.areaNode);this.getDocumentAction(function(){this.documentAction.addDocument(i,function(t){this.mask.hide();this.markNode.destroy();this.areaNode.destroy();this.fireEvent("started",[t.data,e,this.categoryData.name]);this.app.notice(this.lp.Started,"success")}.bind(this),null)}.bind(this))}},getDocumentAction:function(t){if(!this.documentAction){MWF.xDesktop.requireApp("cms.Explorer","Actions.RestActions",function(){this.documentAction=new MWF.xApplication.cms.Explorer.Actions.RestActions;if(t)t()}.bind(this))}else{if(t)t()}}});MWF.xApplication.cms.Explorer.Starter.DepartmentSel=new Class({initialize:function(t,e,i,s){this.data=t;this.starter=e;this.container=i;this.idArea=s;this.css=this.starter.css;this.isSelected=false;this.load()},load:function(){this.node=new Element("div",{styles:this.css.departSelNode}).inject(this.container);this.starter.orgAction.getDepartmentByIdentity(function(t){this.node.set("text",t.data.name)}.bind(this),null,this.data.name);this.node.addEvents({mouseover:function(){if(!this.isSelected)this.node.setStyles(this.css.departSelNode_over)}.bind(this),mouseout:function(){if(!this.isSelected)this.node.setStyles(this.css.departSelNode_out)}.bind(this),click:function(){this.selected()}.bind(this)})},selected:function(){if(!this.isSelected){if(this.starter.currentDepartment)this.starter.currentDepartment.unSelected();this.node.setStyles(this.css.departSelNode_selected);this.isSelected=true;this.starter.currentDepartment=this;this.idArea.set({text:this.data.display,value:this.data.name})}},unSelected:function(){if(this.isSelected){if(this.starter.currentDepartment)this.starter.currentDepartment=null;this.node.setStyles(this.css.departSelNode);this.isSelected=false}}});