| 1 |
- MWF.xDesktop.requireApp("Template","MPopupForm",null,false);MWF.xDesktop.requireApp("Template","MTooltips",null,false);MWF.require("MWF.widget.O2Identity",null,false);MWF.xDesktop.requireApp("Selector","package",null,false);MWF.require("MWF.widget.AttachmentController",null,false);var MWFCalendar=MWF.xApplication.Calendar=MWF.xApplication.Calendar||{};MWFCalendar.ColorOptions={deep:["#428ffc","#5bcc61","#f9bf24","#f75f59","#f180f7","#9072f1","#909090","#1462be"],light:["#cae2ff","#d0f1b0","#fef4bb","#fdd9d9","#f4c5f7","#d6ccf9","#e7e7e7","#cae2ff"],getLightColor:function(t){var e=this.deep.indexOf(t);return e>-1?this.light[e]:this.light[0]},getDeepColor:function(t){var e=this.light.indexOf(t);return e>-1?this.deep[e]:this.deep[0]}};MWFCalendar.EventForm=new Class({Extends:MPopupForm,Implements:[Options,Events],options:{style:"meeting",width:"800",height:"475",hasTop:true,hasIcon:false,hasTopIcon:false,hasTopContent:false,draggable:true,maxAction:true,closeAction:true,isFull:false,startTime:null,endTime:null,isWholeday:false,defaultCalendarId:""},open:function(t){if(this.options.isFull){this.options.width="800";this.options.height="630"}this.fireEvent("queryOpen");this.isNew=false;this.isEdited=false;this._open();this.fireEvent("postOpen")},create:function(){if(this.options.isFull){this.options.width="1100";this.options.height="630"}this.fireEvent("queryCreate");this.isNew=true;this._open();this.fireEvent("postCreate")},edit:function(){if(this.options.isFull){this.options.width="1100";this.options.height="630"}this.fireEvent("queryEdit");this.isEdited=true;this._open();this.fireEvent("postEdit")},_createTableContent:function(){var t="/x_desktop/res/framework/rrule/";COMMON.AjaxModule.load(t+"rrule.js",function(){this.app.actions.listMyCalendar(function(t){this.calendarIds=[];this.calendarNames=[];this.calendarList=[];(t.data.myCalendars||[]).each(function(t){if(t.publishable||t.manageable)this.calendarList.push(t)}.bind(this));(t.data.unitCalendars||[]).each(function(t){if(t.publishable||t.manageable)this.calendarList.push(t)}.bind(this));this.calendarList.each(function(t){this.calendarIds.push(t.id);this.calendarNames.push(t.name)}.bind(this));if(this.isEdited||this.isNew){this._createTableContent_Edit()}else{this._createTableContent_Read()}}.bind(this))}.bind(this))},_createTableContent_Read:function(){this.formTopTextNode.set("text",this.lp.readEvent);this.formTableContainer.setStyle("width","86%");var t=this.data;var e=Date.parse(t.startTime);var i=Date.parse(t.endTime);var s=e.format(this.lp.dateFormatAll)+"("+this.lp.weeks.arr[e.get("day")]+")";var a=i.format(this.lp.dateFormatAll)+"("+this.lp.weeks.arr[i.get("day")]+")";if(t.recurrenceRule){this.oldRecurrenceRule=t.recurrenceRule;this.rRule=RRule.fromString(t.recurrenceRule).origOptions}else{this.rRule={}}var l=["不","每天","每周","每月(当日)","每年(当日)"];var n=["NONE",RRule["DAILY"],RRule["WEEKLY"],RRule["MONTHLY"],RRule["YEARLY"]];var o;if(this.rRule.freq){o=l[n.indexOf(this.rRule.freq)];if(this.rRule.byweekday){var r=this.rRule.byweekday.toString().split(",");var d=[];var h=this.lp.weeks.arr;var c=this.lp.weeks.rruleArr;r.each(function(t){d.push(h[c.indexOf(t)])});o="每"+d.join("、")+"重复"}else{o=o+"重复"}if(this.rRule.until&&o!="不重复"){o+=" 结束日期:"+this.rRule.until.format("%Y-%m-%d")}}else{o="不重复"}var p;if(t.valarmTime_config){var m=t.valarmTime_config.split(",");m.each(function(t,e){var i;if(e==0){i="天"}else if(e==1){i="小时"}else if(e==2){i="分钟"}else{i="秒"}if(t&&t!="0"){p="提前"+Math.abs(t)+i+"提醒"}}.bind(this))}var f=this.calendarNames[this.calendarIds.indexOf(t.calendarId)];var u="<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='table-layout:fixed;'>"+"<tr><td styles='formTableTitle' width='40'>日历:</td>"+" <td styles='formTableValue' width='400'>"+f+"</td>"+"</tr>"+"<tr><td styles='formTableTitle'>标题:</td>"+" <td styles='formTableValue'><div styles='colorItem'></div>"+t.title+"</td></tr>"+"<tr><td styles='formTableTitle'>开始:</td>"+" <td styles='formTableValue'>"+s+"</td>"+"</tr>"+"<tr><td styles='formTableTitle'>结束:</td>"+" <td styles='formTableValue'>"+a+"</td>"+"</tr>"+"<tr><td styles='formTableTitle'>地点:</td>"+" <td styles='formTableValue'>"+(t.locationName||"")+"</td>"+"</tr>";if(p){u+="<tr><td styles='formTableTitle'>提醒:</td>"+" <td styles='formTableValue'>"+p+"</td>"+"</tr>"}if(o&&o!="不"&&o!="不重复"){"<tr><td styles='formTableTitle'>重复:</td>"+" <td styles='formTableValue'>"+o+"</td>"+"</tr>"}if(t.comment){u+="<tr><td styles='formTableTitle'>内容:</td>"+" <td styles='formTableValue'>"+t.comment+"</td>"+"</tr>"}this.formTableArea.set("html",u);this.formTableArea.getElements("[styles='formTableTitle']").setStyles({color:"#333","font-size":"16px",padding:"0px 20px 0px 0px",height:"35px","line-height":"35px","text-align":"left"});this.formTableArea.getElements("[styles='formTableValue']").setStyles({"text-align":"left","font-size":"16px"});var b=this.formTableArea.getElement("[styles='colorItem']");var y=new Element("div",{styles:this.css.colorNode}).inject(b);y.setStyle("background-color",this.data.color)},_createTableContent_Edit:function(){this.oldCoordinate=null;var t=this.editEnable=this.isEdited||this.isNew;this.userName=layout.desktop.session.user.distinguishedName;this.userId=layout.desktop.session.user.id;if(this.options.isFull){this.formTableContainer.setStyles({width:"auto","padding-left":"40px"})}else{this.formTableContainer.setStyle("width","80%")}if(this.isNew){this.formTopTextNode.set("text",this.lp.addEvent)}else if(this.isEdited){this.formTopTextNode.set("text",this.lp.editEvent);this.options.height="590"}var e,i,s,a,l,n;if(this.options.startTime&&this.options.endTime){e=this.date=typeOf(this.options.startTime)=="string"?Date.parse(this.options.startTime):this.options.startTime;i=typeOf(this.options.endTime)=="string"?Date.parse(this.options.endTime):this.options.endTime;s=e.format("%Y-%m-%d");a=e.format("%H:%M");l=i.format("%Y-%m-%d");n=i.format("%H:%M")}else{e=this.date=(new Date).increment("hour",1);i=e.clone().increment("hour",1);s=e.format("%Y-%m-%d");a=e.format("%H")+":00";l=i.format("%Y-%m-%d");n=i.format("%H")+":00"}var o=this.data;if(this.options.isWholeday&&this.isNew){o.isAllDayEvent=true}if(o.startTime){var r=Date.parse(o.startTime);o.startDateInput=r.format("%Y-%m-%d");o.startTimeInput=this.getString(r.getHours())+":"+this.getString(r.getMinutes())}if(o.endTime){var d=Date.parse(o.endTime);o.endDateInput=d.format("%Y-%m-%d");o.endTimeInput=this.getString(d.getHours())+":"+this.getString(d.getMinutes())}if(o.recurrenceRule){this.oldRecurrenceRule=o.recurrenceRule;this.rRule=RRule.fromString(o.recurrenceRule).origOptions}else{this.rRule={}}o.repeat=this.rRule.freq||"";if(this.rRule.until){o.repeatUntilAvailable="AVAILABLE";o.repeatUntilDate=this.rRule.until.format("%Y-%m-%d")}if(this.rRule.byweekday){o.repeatWeeks=this.rRule.byweekday.toString().split(",")}if(o.valarmTime_config){var h=o.valarmTime_config.split(",");h.each(function(t,e){var i;if(e==0){i="d"}else if(e==1){i="h"}else if(e==2){i="m"}else{i="s"}if(t&&t!="0"){o.remind=t+"_"+i}}.bind(this))}this.formTableArea.set("html",this.getHtml());this.colorItem=this.formTableArea.getElement("[item='color']");if(!this.data.color){if(this.options.defaultCalendarId){this.data.color=this.getColorByCalendarId(this.options.defaultCalendarId)}else{this.data.color=this.calendarList[0].color}}MWF.xDesktop.requireApp("Template","MForm",function(){this.form=new MForm(this.formTableArea,o,{isEdited:this.isEdited||this.isNew,style:"meeting",hasColon:true,itemTemplate:{calendarId:{text:this.lp.calendar,defaultValue:this.options.defaultCalendarId,type:"select",selectValue:this.calendarIds,selectText:this.calendarNames,event:{change:function(t){this.setColorByCalendarId(t.getValue())}.bind(this)}},startDateInput:{text:this.lp.beginTime,tType:"date",defaultValue:s,notEmpty:true},startTimeInput:{tType:"time",defaultValue:a,className:this.isNew||this.isEdited?"inputTimeUnformatWidth":"",disable:o.isAllDayEvent},endDateInput:{text:this.lp.endTime,tType:"date",defaultValue:l,notEmpty:true},endTimeInput:{tType:"time",defaultValue:n,className:this.isNew||this.isEdited?"inputTimeUnformatWidth":"",disable:o.isAllDayEvent},remind:{text:this.lp.remind,type:"select",selectText:["不提醒","开始时","提前5分钟","提前10分钟","提前15分钟","提前30分钟","提前1小时","提前2小时"],selectValue:["","-5_s","-5_m","-10_m","-15_m","-30_m","-1_h","-2_h"]},isAllDayEvent:{type:"checkbox",selectValue:["true"],selectText:["全天"],event:{change:function(t){var e=t.form.getItem("startTimeInput");var i=t.form.getItem("endTimeInput");if(t.getValue()=="true"&&!e.options.disable&&!i.options.disable){e.getElements().setStyle("display","none");i.getElements().setStyle("display","none")}else{if(e.options.disable)e.enable();if(i.options.disable)i.enable();e.getElements().setStyle("display","");i.getElements().setStyle("display","")}}.bind(this)}},title:{text:this.lp.eventSubject,notEmpty:true},description:{type:"textarea"},locationName:{text:"地点"},repeat:{text:this.lp.repeat,type:"select",defaultValue:"NONE",selectText:["不重复","每天","每周","每月(当日)","每年(当日)"],selectValue:["NONE",RRule["DAILY"],RRule["WEEKLY"],RRule["MONTHLY"],RRule["YEARLY"]],event:{change:function(t){var e=t.getValue();var i=this.formTableArea.getElement("[item='repeatUntilArea']");i.setStyle("display",e=="NONE"?"none":"");if(e==RRule["WEEKLY"]){this.showWeek()}else{i=this.formTableArea.getElement("[item='repeatWeekArea']");i.setStyle("display","none")}}.bind(this)}},repeatUntilAvailable:{text:this.lp.repeatUntilAvailable,type:"radio",selectText:["永不","结束日期"],selectValue:["NONE","AVAILABLE"],defaultValue:"NONE"},repeatUntilDate:{tType:"date",event:{click:function(){this.form.getItem("repeatUntilAvailable").setValue("AVAILABLE")}.bind(this)}},comment:{text:this.lp.content,type:"rtf",RTFConfig:{skin:"bootstrapck",resize_enabled:false,toolbar:[{name:"document",items:["Preview"]},{name:"basicstyles",items:["Bold","Italic","Underline","Strike","-","RemoveFormat"]},{name:"list",items:["NumberedList","BulletedList"]},{name:"links",items:["Link","Unlink"]}]}}}},this.app);this.form.load();if(this.data.repeat==RRule["WEEKLY"]){this.showWeek()}this.loadColor()}.bind(this),true)},getRRuleString:function(t){if(!t)t=this.form.getResult(false,null,false,false,false);if(!t.repeat||t.repeat=="NONE")return"";var e={freq:t.repeat};if(t.repeatUntilAvailable!="NONE"&&t.repeatUntilDate!=""){e.until=Date.parse(t.repeatUntilDate)}if(t.repeat==RRule["WEEKLY"]){e.byweekday=[];this.getSelectWeek().each(function(t){e.byweekday.push(RRule[t])})}var i=new RRule(e);return i.toString()},getHtml:function(){var t=this.isEdited||this.isNew?"border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;":"";if(this.options.isFull){var e="<div style='overflow: hidden;'>"+"<div item='baseInforContainer' style='float: left; width : 500px;'>"+"<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='table-layout:fixed;'>"+"<tr><td styles='formTableTitle' width='80' lable='calendarId'></td>"+" <td styles='formTableValue' item='calendarId' colspan='2' width='400'></td>"+"</tr>"+"<tr><td styles='formTableTitle' lable='title'></td>"+" <td styles='formTableValue' item='title' colspan='2'></td></tr>"+"<tr><td styles='formTableTitle' lable='startDateInput'></td>"+" <td styles='formTableValue' item='startDateInput' width='"+(this.editEnable?"260":"100")+"'></td>"+" <td styles='formTableValue' item='startTimeInput'></td>"+"</tr>"+"<tr><td styles='formTableTitle' lable='endDateInput'></td>"+" <td styles='formTableValue' item='endDateInput'></td>"+" <td styles='formTableValue' item='endTimeInput'></td>"+"</tr>"+"<tr><td styles='formTableTitle'></td>"+" <td styles='formTableValue' item='isAllDayEvent' colspan='2'></td>"+"</tr>"+"<tr><td styles='formTableTitle' lable='locationName'></td>"+" <td styles='formTableValue' item='locationName' colspan='2'></td>"+"</tr>"+"<tr><td styles='formTableTitle' lable='remind'></td>"+" <td styles='formTableValue' item='remind' colspan='2'></td>"+"</tr>"+"<tr><td styles='formTableTitle' lable='repeat'></td>"+" <td styles='formTableValue' item='repeat' colspan='2'></td>"+"</tr>"+"<tr item='repeatWeekArea' style='display:"+(this.data.repeat==RRule["WEEKLY"]?"":"none")+";'><td styles='formTableTitle'></td>"+" <td styles='formTableValue' item='repeatWeek' colspan='2' style='overflow:hidden;'></td>"+"</tr>"+"<tr item='repeatUntilArea' style='display:"+(!this.data.repeat||this.data.repeat==""?"none":"")+";'><td styles='formTableTitle'></td>"+" <td styles='formTableValue' colspan='2' style='overflow: hidden;line-height:34px;'>"+" <div lable='repeatUntilAvailable' style='float: left;'></div>"+" <div item='repeatUntilAvailable' style='float: left;'></div>"+" <div item='repeatUntilDate' style='float: left;width:170px;'></div>"+" </td>"+"</tr>"+"<tr><td styles='formTableTitle'>"+this.lp.color+":</td>"+" <td styles='formTableValue' item='color' colspan='2' style='overflow: hidden;'></td>"+"</tr>"+"</table>"+"</div>"+"<div style='float: left; width : 500px;' item='commentContainer'>"+"<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>"+"<tr><td styles='formTableTitle' ></td>"+" <td styles='formTableValue' lable='comment' colspan='2'></td>"+"</tr>"+"<tr><td styles='formTableTitle' ></td>"+" <td styles='formTableValue' item='comment' colspan='2'></td>"+"</tr>"+"<tr item='attachmentTr'><td styles='formTableTitle'></td>"+" <td styles='formTableValue' item='attachment'></td></tr>"+"</table>"+"</div>"+"</div>";return e}else{return"<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>"+"<tr><td styles='formTableTitle' lable='calendarId'></td>"+" <td styles='formTableValue' item='calendarId' colspan='2'></td></tr>"+"<tr><td styles='formTableTitle' lable='title'></td>"+" <td styles='formTableValue' item='title' colspan='2'></td></tr>"+"<tr><td styles='formTableTitle' width='100' lable='startDateInput'></td>"+" <td styles='formTableValue' item='startDateInput' width='300'></td>"+" <td styles='formTableValue' item='startTimeInput'></td>"+"</tr>"+"<tr><td styles='formTableTitle' lable='endDateInput'></td>"+" <td styles='formTableValue' item='endDateInput'></td>"+" <td styles='formTableValue' item='endTimeInput'></td>"+"</tr>"+"<tr><td styles='formTableTitle'></td>"+" <td styles='formTableValue' item='isAllDayEvent' colspan='2'></td>"+"</tr>"+"<tr><td styles='formTableTitle' lable='remind'></td>"+" <td styles='formTableValue' item='remind' colspan='2'></td>"+"</tr>"+"</table>"}},_setNodesSize:function(t,e,i,s){if(this.options.isFull){var a=this.formAreaNode.getElement("[item='baseInforContainer']");var l=this.formAreaNode.getElement("[item='commentContainer']");if(a)a.setStyle("width",(t-100)/2);if(l)l.setStyle("width",(t-100)/2)}},getColorByCalendarId:function(e){var i;this.calendarList.each(function(t){if(t.id==e){i=t.color}}.bind(this));return i},setColorByCalendarId:function(t){var e=this.getColorByCalendarId(t);if(e){this.data.color=e;this.setColor(e)}},setColor:function(e){(this.colorOptions||[]).each(function(t){if(t.retrieve("color")==e){t.click()}})},loadColor:function(){if(this.isEdited||this.isNew){this.loadColor_Edited()}else{this.loadColor_Read()}},loadColor_Read:function(){if(!this.colorItem)return;var t=new Element("div",{styles:this.css.colorNode}).inject(this.colorItem);t.setStyle("background-color",this.data.color);t.setStyles(this.css.colorNode_current)},loadColor_Edited:function(){if(!this.colorItem)return;this.colorOptions=[];if(!this.data.color){if(this.options.defaultCalendarId){this.getColorByCalendarId(this.options.defaultCalendarId)}else{this.data.color=this.calendarList[0].color}}MWFCalendar.ColorOptions.deep.each(function(t,e){var i=new Element("div",{styles:this.css.colorNode,events:{click:function(t){if(this.currentColorNode)this.currentColorNode.setStyles(this.css.colorNode);t.target.setStyles(this.css.colorNode_current);this.currentColorNode=t.target}.bind(this)}}).inject(this.colorItem);i.setStyle("background-color",t);i.store("color",t);if(this.data.color){if(this.data.color==t){i.setStyles(this.css.colorNode_current);this.currentColorNode=i}}else if(e==0){i.setStyles(this.css.colorNode_current);this.currentColorNode=i}this.colorOptions.push(i)}.bind(this))},showWeek:function(){var t=this.formTableArea.getElement("[item='repeatWeekArea']");if(!t)return;t.setStyle("display","");if(this.isWeekSelectCreated)return;this.weekItems=[];var e=this.formTableArea.getElement("[item='repeatWeek']");var i=this.css.weekDayStyle={border:"1px solid #ccc","border-radius":"3px",height:"20px","line-heigh":"20px",background:"#f7f7f7",color:"#666",padding:"0px 9px","margin-right":"9px",float:"left","font-size":"12px",cursor:"pointer"};var s=this.css.weekDayOnStyle=Object.merge(Object.clone(i),{border:"1px solid #3c75b7",background:"#3c75b7",color:"#fff"});var a=this.data.repeatWeeks||[this.lp.weeks.rruleArr[this.date.getDay()]];for(var l=0;l<7;l++){var n=this.lp.weeks.rruleArr[l];var o=a.contains(n);var r=new Element("div",{styles:o?s:i,text:this.lp.weeks.arr[l],events:{click:function(t){this.triggerWeek(t.target)}.bind(this)}}).inject(e);if(o){if(this.date.getDay()==l){this.currrentWeekDayItem=r}r.store("isOn",true)}r.store("weekDay",n);this.weekItems.push(r)}this.isWeekSelectCreated=true},triggerWeek:function(t){if(t.retrieve("isOn")){t.store("isOn",false);t.setStyles(this.css.weekDayStyle)}else{t.store("isOn",true);t.setStyles(this.css.weekDayOnStyle)}if(this.getSelectWeek().length==0){this.triggerWeek(this.currrentWeekDayItem)}},getSelectWeek:function(){if(!this.weekItems)return[];var e=[];this.weekItems.each(function(t){if(t.retrieve("isOn")){e.push(t.retrieve("weekDay"))}});return e},_createBottomContent:function(){var t="<div style='width:700px;margin:0px auto;'><table width='700' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>"+"<tr><td styles='formTableValue' width='100'></td>"+" <td styles='formTableValue' style='padding-top: 15px;'>"+" <div item='saveAction' style='float:left;display:"+(this.isEdited||this.isNew?"":"none")+";'></div>"+" <div item='editAction' style='float:left;display:"+(this.isEdited||this.isNew?"none":"")+";'></div>"+" <div item='removeAction' style='float:left;display:"+(this.isEdited?"":"none")+";'></div>"+" <div item='cancelAction' style='"+(this.isEdited||this.isNew?"float:left;":"float:left")+"'></div>"+" <div item='moreInfor' style='float: right;margin-top:5px;'></div>"+" </td></tr>"+"</table></div>";this.formBottomNode.set("html",t);MWF.xDesktop.requireApp("Template","MForm",function(){var t=new MForm(this.formBottomNode,{},{isEdited:this.isEdited||this.isNew,style:"meeting",hasColon:true,itemTemplate:{moreInfor:{type:"a",value:"更多编辑",event:{click:function(){this.openMoreInfor()}.bind(this)},disable:this.options.isFull},saveAction:{type:"button",className:"inputOkButton",value:this.lp.save,event:{click:function(){this.save()}.bind(this)}},removeAction:{type:"button",className:"inputCancelButton",value:this.lp.cancelEvent,event:{click:function(t,e){this.cancelEvent(e)}.bind(this)}},editAction:{type:"button",className:"inputOkButton",value:this.lp.editEvent,event:{click:function(){this.editEvent()}.bind(this)}},cancelAction:{type:"button",className:"inputCancelButton",value:this.lp.close,event:{click:function(){this.close()}.bind(this)}}}},this.app);t.load()}.bind(this),true)},openMoreInfor:function(){this.options.isFull=true;this.options.width="1100";this.options.height="620";this.isWeekSelectCreated=false;this.reload(true)},getString:function(t){var e="00"+t;return e.substr(e.length-2,2)},getEventData:function(e){if(this.data&&this.data.id){this.app.actions.getEvent(this.data.id,function(t){this.data=t.data;if(e)e()}.bind(this))}else{if(e)e()}},editEvent:function(){this.isWeekSelectCreated=false;this.formTopNode=null;if(this.setFormNodeSizeFun&&this.app){this.app.removeEvent("resize",this.setFormNodeSizeFun)}if(this.formMaskNode)this.formMaskNode.destroy();this.formAreaNode.destroy();this.edit()},reset:function(){this.formTableArea.empty();this._createTableContent()},loadAttachment:function(){if(!this.attachmentTr)return;this.attachmentTr.setStyle("display","");this.attachmentNode=new Element("div",{styles:this.css.createEventAttachmentNode}).inject(this.attachmentArea);var t=new Element("div",{styles:this.css.createEventAttachmentContentNode}).inject(this.attachmentNode);MWF.require("MWF.widget.AttachmentController",function(){this.attachmentController=new MWF.widget.AttachmentController(t,this,{size:"min",isSizeChange:false,isReplace:false,isUpload:this.isNew||this.isEdited,isDelete:this.isNew||this.isEdited,isDownload:true,readonly:!this.isNew&&!this.isEdited});this.attachmentController.load();if(this.data.attachmentList){this.data.attachmentList.each(function(t){t.person=t.lastUpdatePerson.split("@")[0];var e=this.attachmentController.addAttachment(t)}.bind(this))}}.bind(this))},uploadAttachment:function(t,e){if(!this.uploadFileAreaNode){this.createUploadFileNode()}this.fileUploadNode.click()},createUploadFileNode:function(){this.uploadFileAreaNode=new Element("div");var t='<input name="file" type="file" multiple/>';this.uploadFileAreaNode.set("html",t);this.fileUploadNode=this.uploadFileAreaNode.getFirst();this.fileUploadNode.addEvent("change",function(){var t=this.fileUploadNode.files;if(t.length){for(var e=0;e<t.length;e++){var i=t.item(e);var s=new FormData;s.append("file",i);this.app.actions.addAttachment(function(t,e){if(t.id){this.app.actions.getAttachment(t.id,function(t){if(t.data)this.attachmentController.addAttachment(t.data);this.attachmentController.checkActions()}.bind(this))}this.attachmentController.checkActions()}.bind(this),null,s,this.data.id,i)}}}.bind(this))},deleteAttachments:function(t,e,i){var s=[];i.each(function(t){s.push(t.data.name)}.bind(this));var a=this;this.app.confirm("warn",t,this.lp.deleteAttachmentTitle,this.lp.deleteAttachment+"( "+s.join(", ")+" )",300,120,function(){while(i.length){attachment=i.shift();a.deleteAttachment(attachment)}this.close()},function(){this.close()},null)},deleteAttachment:function(e){this.app.actions.deleteFile(e.data.id,function(t){this.attachmentController.removeAttachment(e);this.attachmentController.checkActions()}.bind(this))},downloadAttachment:function(t,e,i){i.each(function(t){this.app.actions.getFileDownload(t.data.id)}.bind(this))},openAttachment:function(t,e,i){i.each(function(t){this.app.actions.getFile(t.data.id)}.bind(this))},getAttachmentUrl:function(t,e){this.app.actions.getFileUrl(t.data.id,e)},cancelEvent:function(t){var e=this;var i=this.data;var s=function(){this.view.reload();this.close()}.bind(this);if(this.oldRecurrenceRule){this.openDeleteOptionForm(function(t){if(t=="single"){this.app.actions.deleteSingleEvent(i.id,function(t){s(t)}.bind(this))}else if(t=="after"){this.app.actions.deleteAfterEvent(i.id,function(t){s(t)}.bind(this))}else if(t=="all"){this.app.actions.deleteAllEventsWithRepeatMaster(i.id,function(t){s(t)}.bind(this))}}.bind(this))}else if(i.id){var a=this.app.lp.cancel_confirm.replace(/{name}/g,this.data.title);this.app.confirm("infor",t,this.app.lp.cancel_confirm_title,a,380,200,function(){e._cancelEvent();this.close()},function(){this.close()})}},_cancelEvent:function(){var t=this.view;this.app.actions.deleteSingleEvent(this.data.id,function(){t.reload();this.close()}.bind(this))},openDeleteOptionForm:function(e){this.deleteOptionsForm=new MWFCalendar.DeleteOptionDialog(this,{},{onPostOk:function(t){if(e){e(t)}}.bind(this)},{});this.deleteOptionsForm.edit()},save:function(){this._save(function(){this.app.notice(this.lp.event_saveSuccess,"success");this.close()}.bind(this))},_save:function(e){var i=this.getSaveData();if(!i)return;var t="";if(!i.title)t+=this.lp.event_input_subject_error;if(i.startTime){if(Date.parse(i.startTime)-Date.parse(i.endTime)>0)t+=this.lp.event_input_time_error}if(t){this.app.notice(this.lp.event_input_error+t,"error");return false}var s=function(t){this.data.id=t.data.id;this.oldRecurrenceRule=i.recurrenceRule;this.waitReload=true;if(e)e()}.bind(this);this.data=i;if(this.oldRecurrenceRule){this.openSaveOptionForm(function(t){if(t=="single"){this.app.actions.updateSingleEvent(i.id,this.data,function(t){s(t)}.bind(this))}else if(t=="after"){this.app.actions.updateAfterEvent(i.id,this.data,function(t){s(t)}.bind(this))}else if(t=="all"){this.app.actions.updateAllEventsWithRepeatMaster(i.id,this.data,function(t){s(t)}.bind(this))}}.bind(this))}else if(i.id){this.app.actions.updateSingleEvent(i.id,this.data,function(t){s(t)}.bind(this))}else{this.app.actions.addEvent(this.data,function(t){s(t)}.bind(this))}},openSaveOptionForm:function(e){this.saveOptionsForm=new MWFCalendar.SaveOptionDialog(this,{},{onPostOk:function(t){if(e){e(t)}}.bind(this)},{});this.saveOptionsForm.edit()},getSaveData:function(){var t=this.form.getResult(true,"",true,false,true);if(!t)return null;if(t){t.isAllDayEvent=typeOf(t.isAllDayEvent)=="array"?t.isAllDayEvent.join(""):t.isAllDayEvent;if(t.isAllDayEvent=="true"){t.startTime=this.data.startDateInput+" "+"00:00:00";t.endTime=this.data.endDateInput+" "+"23:59:59"}else{t.startTime=this.data.startDateInput+" "+this.data.startTimeInput+":00";t.endTime=this.data.endDateInput+" "+this.data.endTimeInput+":00"}t.recurrenceRule=this.getRRuleString(t);if(t.remind){var e=[0,0,0,0];var i=t.remind.split("_");var s=parseInt(i[0]);if(i[1]=="d"){e[0]=s}else if(i[1]=="h"){e[1]=s}else if(i[1]=="m"){e[2]=s}else if(i[1]=="s"){e[3]=s}t.valarmTime_config=e.join(",")}if(!t.calendarId){t.calendarId=this.app.currentCalendarData.id}if(this.currentColorNode){t.color=this.currentColorNode.retrieve("color")}else if(t.calendarId){t.color=this.getColorByCalendarId(t.calendarId)}else{t.color=MWFCalendar.ColorOptions.deep[0]}delete t.range}return t},close:function(t){this.fireEvent("queryClose");this._close();if(this.setFormNodeSizeFun&&this.app){this.app.removeEvent("resize",this.setFormNodeSizeFun)}if(this.formMaskNode)this.formMaskNode.destroy();this.formAreaNode.destroy();this.fireEvent("postClose");if(this.waitReload)this.view.reload();delete this}});MWFCalendar.CalendarForm=new Class({Extends:MPopupForm,Implements:[Options,Events],options:{style:"meeting",width:"800",height:"500",hasTop:true,hasIcon:false,hasTopIcon:false,hasTopContent:false,draggable:true,maxAction:true,resizeable:true,closeAction:true,resultSeparator:null},_createTableContent:function(){var t=this.data;var e=this.editEnable=!this.isEdited&&!this.isNew&&this.data.manageable;this.userName=(layout.desktop.session.user||layout.user).distinguishedName;this.userId=(layout.desktop.session.user||layout.user).id;if(t.type=="UNIT"){this.options.height="650"}if(this.isNew){this.formTopTextNode.set("text","新建日历")}else if(this.isEdited){this.formTopTextNode.set("text","编辑日历")}else{this.formTopTextNode.set("text","日历")}this.formTableArea.set("html",this.getHtml());this.formTableContainer.setStyle("width","80%");this.colorItem=this.formTableArea.getElement("[item='color']");MWF.xDesktop.requireApp("Template","MForm",function(){this.form=new MForm(this.formTableArea,t,{isEdited:this.isEdited||this.isNew,style:"meeting",hasColon:true,itemTemplate:{name:{text:"日历名称",notEmpty:true},description:{text:"备注",type:"textarea"},type:{text:"类型",type:"select",isEdited:this.isNew,selectValue:["PERSON","UNIT"],selectText:["个人日历","组织日历"],defaultValue:"PERSON",event:{change:function(t){this.changeType(t.getValue())}.bind(this)}},target:{text:"所属组织",type:"org",orgType:"unit",validRule:{empty:function(t,e){if(e.form.getItem("type").getValue()=="UNIT"&&t==""){return false}else{return true}}},validMessage:{empty:"所属组织不能为空"}},isPublic:{text:"是否公开",type:"select",selectValue:["true","false"],selectText:["是","否"],defaultValue:"false"},status:{text:"是否启用",type:"radio",selectValue:["OPEN","CLOSE"],selectText:["是","否"],defaultValue:"OPEN"},manageablePersonList:{text:"管理者",type:"org",orgType:"person",count:0},viewerList:{text:"可见范围",type:"org",orgType:["person","unit","group"],count:0,value:function(){return(t.viewablePersonList||[]).combine(t.viewableUnitList||[]).combine(t.viewableGroupList||[])}.bind(this)},publisherList:{text:"可新建范围",type:"org",orgType:["person","unit","group"],count:0,value:function(){return(t.publishablePersonList||[]).combine(t.publishableUnitList||[]).combine(t.publishableGroupList||[])}.bind(this)}}},this.app);this.form.load();this.loadColor()}.bind(this),true)},getHtml:function(){var t=this.isEdited||this.isNew?"border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;":"";var e=this.data.type!="UNIT"?"style='display:none'":"";var i=this.data.type!="UNIT"?"style='display:none'":"";return"<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='table-layout:fixed;'>"+"<tr><td styles='formTableTitle' width='80' lable='name'></td>"+" <td styles='formTableValue' item='name' width='400' colspan='3'></td></tr>"+"<tr><td styles='formTableTitle'>"+this.lp.color+":</td>"+" <td styles='formTableValue' item='color' style='overflow: hidden;' colspan='3'></td></tr>"+"<tr><td styles='formTableTitle' lable='type' width='80'></td>"+" <td styles='formTableValue' item='type'></td>"+" <td styles='formTableTitleRight' lable='isPublic' width='50'></td>"+" <td styles='formTableValue' item='isPublic'></td></tr>"+"<tr><td styles='formTableTitle' lable='description'></td>"+" <td styles='formTableValue' item='description' colspan='3'></td></tr>"+"<tr "+e+"><td styles='formTableTitle' lable='target'></td>"+" <td styles='formTableValue' item='target' colspan='3'></td></tr>"+"<tr "+i+"><td styles='formTableTitle' lable='manageablePersonList'></td>"+" <td styles='formTableValue' item='manageablePersonList' colspan='3'></td></tr>"+"<tr "+i+"><td styles='formTableTitle' lable='viewerList'></td>"+" <td styles='formTableValue' item='viewerList' colspan='3'></td></tr>"+"<tr "+i+"><td styles='formTableTitle' lable='publisherList'></td>"+" <td styles='formTableValue' item='publisherList' colspan='3'></td></tr>"+"</tr>"+"<tr><td styles='formTableTitle' lable='status'></td>"+" <td styles='formTableValue' item='status' colspan='3'></td></tr>"+"</table>"},changeType:function(e){var t=["target","manageablePersonList","viewerList","publisherList"];t.each(function(t){this.formTableArea.getElement("[item='"+t+"']").getParent().setStyle("display",e=="UNIT"?"":"none")}.bind(this));this.options.height=e=="UNIT"?"650":"500";this.setFormNodeSize()},loadColor:function(){if(this.isEdited||this.isNew){this.loadColor_Edited()}else{this.loadColor_Read()}},loadColor_Read:function(){if(!this.colorItem)return;var t=new Element("div",{styles:this.css.colorNode}).inject(this.colorItem);t.setStyle("background-color",this.data.color);t.setStyles(this.css.colorNode_current)},loadColor_Edited:function(){if(!this.colorItem)return;this.colorOptions=[];MWFCalendar.ColorOptions.deep.each(function(t,e){var i=new Element("div",{styles:this.css.colorNode,events:{click:function(t){if(this.currentColorNode)this.currentColorNode.setStyles(this.css.colorNode);t.target.setStyles(this.css.colorNode_current);this.currentColorNode=t.target}.bind(this)}}).inject(this.colorItem);i.setStyle("background-color",t);i.store("color",t);if(this.data.color){if(this.data.color==t){i.setStyles(this.css.colorNode_current);this.currentColorNode=i}}else if(e==0){i.setStyles(this.css.colorNode_current);this.currentColorNode=i}this.colorOptions.push(i)}.bind(this))},_createBottomContent:function(){var t="<div style='width:700px;margin:0px auto;'><table width='700' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>"+"<tr><td styles='formTableValue' width='100'></td>"+" <td styles='formTableValue' style='padding-top: 15px;'>"+" <div item='saveAction' style='float:left;display:"+(this.isEdited||this.isNew?"":"none")+";'></div>"+" <div item='editAction' style='float:left;display:"+(this.editEnable?"":"none")+";'></div>"+" <div item='removeAction' style='float:left;display:"+(this.isEdited?"":"none")+";'></div>"+" <div item='cancelAction' style='"+(this.isEdited||this.isNew||this.editEnable?"float:left;":"float:right;margin-right:15px;")+"'></div>"+" </td></tr>"+"</table></div>";this.formBottomNode.set("html",t);MWF.xDesktop.requireApp("Template","MForm",function(){var t=new MForm(this.formBottomNode,{},{isEdited:this.isEdited||this.isNew,style:"meeting",hasColon:true,itemTemplate:{saveAction:{type:"button",className:"inputOkButton",value:this.lp.save,event:{click:function(){this.ok()}.bind(this)}},removeAction:{type:"button",className:"inputCancelButton",value:this.lp.deleteCalendar,event:{click:function(t,e){this.deleteCalendar(e)}.bind(this)}},editAction:{type:"button",className:"inputOkButton",value:this.lp.editCalendar,event:{click:function(){this.editCalendar()}.bind(this)}},cancelAction:{type:"button",className:"inputCancelButton",value:this.lp.close,event:{click:function(){this.close()}.bind(this)}}}},this.app);t.load()}.bind(this),true)},deleteCalendar:function(){},editCalendar:function(){this.formTopNode=null;if(this.setFormNodeSizeFun&&this.app){this.app.removeEvent("resize",this.setFormNodeSizeFun)}if(this.formMaskNode)this.formMaskNode.destroy();this.formAreaNode.destroy();this.edit()},reset:function(){this.formTableArea.empty();this._createTableContent()},_ok:function(e,i){if(e.type=="UNIT"){var t=this.form.getItem("viewerList").dom;e.viewablePersonList=t.getValueByType("person");e.viewableUnitList=t.getValueByType("unit");e.viewableGroupList=t.getValueByType("group");var s=this.form.getItem("publisherList").dom;e.publishablePersonList=s.getValueByType("person");e.publishableUnitList=s.getValueByType("unit");e.publishableGroupList=s.getValueByType("group");e.target=e.target.join("")}else{e.target=this.userName;["manageablePersonList","viewablePersonList","publishablePersonList"].each(function(t){e[t]=[this.userName]}.bind(this));["viewableUnitList","viewableGroupList","publishableUnitList","publishableGroupList"].each(function(t){e[t]=[]})}if(this.currentColorNode){e.color=this.currentColorNode.retrieve("color")}else{e.color=MWFCalendar.ColorOptions.deep[0]}delete e.viewerList;delete e.publisherList;this.app.actions.saveCalendar(e,function(t){if(this.view)this.view.reload();i(t)}.bind(this))},close:function(t){this.fireEvent("queryClose");this._close();if(this.setFormNodeSizeFun&&this.app){this.app.removeEvent("resize",this.setFormNodeSizeFun)}if(this.formMaskNode)this.formMaskNode.destroy();this.formAreaNode.destroy();this.fireEvent("postClose");if(this.waitReload)this.view.reload();delete this}});MWFCalendar.SaveOptionDialog=new Class({Extends:MPopupForm,Implements:[Options,Events],options:{style:"meeting",width:"470",height:"325",hasTop:true,hasIcon:false,hasTopIcon:false,hasTopContent:false,draggable:true,closeAction:true,title:"修改重复日程"},_createTableContent:function(){this.formTableContainer.setStyles({width:"auto","padding-top":"20px","padding-left":"40px"});this.lp={ok:"确定修改",cancel:"取消"};var t="<table width='80%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+"<tr><td styles='formTableTitle' lable='saveOption'></td>"+"<tr><td styles='formTableValue' item='saveOption'></td></tr>"+"</table>";this.formTableArea.set("html",t);MWF.xDesktop.requireApp("Template","MForm",function(){this.form=new MForm(this.formTableArea,{empName:"xadmin"},{style:"meeting",isEdited:this.isEdited||this.isNew,itemTemplate:{saveOption:{defaultValue:"single",text:"请选择您要修改日程的类型",type:"radio",selectText:["只修改当前日程","修改当前日程和之后的此重复日程","修改所有此重复日程"],selectValue:["single","after","all"]}}},this.app);this.form.load()}.bind(this),true)},ok:function(t){this.fireEvent("queryOk");var e=this.form.getResult(true,this.options.resultSeparator,true,false,true);if(e){if(this.formMaskNode)this.formMaskNode.destroy();this.formAreaNode.destroy();this.fireEvent("postOk",e.saveOption)}}});MWFCalendar.DeleteOptionDialog=new Class({Extends:MPopupForm,Implements:[Options,Events],options:{style:"meeting",width:"470",height:"325",hasTop:true,hasIcon:false,hasTopIcon:false,hasTopContent:false,draggable:true,closeAction:true,title:"删除重复日程"},_createTableContent:function(){this.formTableContainer.setStyles({width:"auto","padding-top":"20px","padding-left":"40px"});this.lp={ok:"确定删除",cancel:"取消"};var t="<table width='80%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+"<tr><td styles='formTableTitle' lable='saveOption'></td>"+"<tr><td styles='formTableValue' item='saveOption'></td></tr>"+"</table>";this.formTableArea.set("html",t);MWF.xDesktop.requireApp("Template","MForm",function(){this.form=new MForm(this.formTableArea,{empName:"xadmin"},{isEdited:this.isEdited||this.isNew,style:"meeting",itemTemplate:{saveOption:{defaultValue:"single",text:"请选择您要删除日程的类型",type:"radio",selectText:["只删除当前日程","删除当前日程和之后的此重复日程","删除所有此重复日程"],selectValue:["single","after","all"]}}},this.app);this.form.load()}.bind(this),true)},ok:function(t){this.fireEvent("queryOk");var e=this.form.getResult(true,this.options.resultSeparator,true,false,true);if(e){if(this.formMaskNode)this.formMaskNode.destroy();this.formAreaNode.destroy();this.fireEvent("postOk",e.saveOption)}}});MWFCalendar.EventTooltip=new Class({Extends:MTooltips,options:{displayDelay:300},_loadCustom:function(t){this.loadAttachment();this.loadButton();if(t)t()},_getHtml:function(){var t=this.data;var e="font-size:14px;color:#333";var i="font-size:14px;color:#666;padding-right:10px";var s=Date.parse(this.data.startTime);var a=Date.parse(this.data.endTime);var l=s.format(this.lp.dateFormatAll)+"("+this.lp.weeks.arr[s.get("day")]+")";var n=a.format(this.lp.dateFormatAll)+"("+this.lp.weeks.arr[a.get("day")]+")";var o="<div style='font-size: 16px;color:#333;padding:10px 10px 10px 20px;'>"+t.title+"</div>"+"<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+"<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>"+"<tr><td style='"+e+";' width='40'>开始:</td>"+" <td style='"+i+"'>"+l+"</td></tr>"+"<tr><td style='"+e+"'>结束:</td>"+" <td style='"+i+"'>"+n+"</td></tr>"+"<tr><td style='"+e+"'>"+this.lp.locationName+":</td>"+" <td style='"+i+"'>"+(this.data.locationName||"")+"</td></tr>"+"<tr><td style='"+e+"'></td>"+" <td style='"+i+"' item='seeMore'></td></tr>"+"</table>";return o},destroy:function(){if(this.node){this.node.destroy();this.node=null}},loadButton:function(){var t=this.node.getElement("[item='seeMore']");new Element("div",{styles:{"background-color":"#3c75b7",height:"28px","line-height":"28px","border-radius":"5px",width:"80px","text-align":"center","font-size":"12px",cursor:"pointer",color:"#fff"},events:{click:function(){var t=new MWFCalendar.EventForm(this,this.data,{isFull:true},{app:this.app});t.view=this.view;t.edit();this.hide()}.bind(this)},text:"查看更多"}).inject(t)},loadAttachment:function(){if(this.options.isHideAttachment)return;if(typeOf(this.data.attachmentList)=="array"&&this.data.attachmentList[0]){var t=this.node.getElement("[item='attachment']");this.attachmentNode=new Element("div").inject(t);var e=new Element("div",{}).inject(this.attachmentNode);this.attachmentController=new MWFCalendar.EventTooltip.AttachmentController(e,this,{size:"min",isSizeChange:false,isReplace:false,isUpload:false,isDelete:false,isDownload:true,readonly:true});this.attachmentController.load();this.data.attachmentList.each(function(t){t.person=t.lastUpdatePerson.split("@")[0];var e=this.attachmentController.addAttachment(t)}.bind(this))}},downloadAttachment:function(t,e,i){i.each(function(t){this.app.actions.getFileDownload(t.data.id)}.bind(this))},openAttachment:function(t,e,i){i.each(function(t){this.app.actions.getFile(t.data.id)}.bind(this))},getAttachmentUrl:function(t,e){this.app.actions.getFileUrl(t.data.id,e)}});MWFCalendar.EventTooltip.AttachmentController=new Class({Extends:MWF.widget.AttachmentController,loadMin:function(){if(!this.node)this.node=new Element("div",{styles:this.css.container_min});if(!this.minActionAreaNode){this.minContent=new Element("div",{styles:this.css.minContentNode}).inject(this.node);this.minContent.setStyles({"margin-right":"0px"});this.node.inject(this.container);this.checkActions();this.setEvent()}else{this.minContent.setStyle("display","block");this.minContent.empty()}var t=[];while(this.attachments.length){var e=this.attachments.shift();t.push(new MWFCalendar.EventTooltip.AttachmentMin(e.data,this))}this.attachments=t},addAttachment:function(t){if(this.options.size=="min"){this.attachments.push(new MWFCalendar.EventTooltip.AttachmentMin(t,this))}else{this.attachments.push(new MWF.widget.AttachmentController.Attachment(t,this))}}});MWFCalendar.EventTooltip.AttachmentMin=new Class({Extends:MWF.widget.AttachmentController.AttachmentMin,setEvent:function(){this.node.addEvents({mouseover:function(){if(!this.isSelected)this.node.setStyles(this.css["minAttachmentNode_list_over"])}.bind(this),mouseout:function(){if(!this.isSelected)this.node.setStyles(this.css["minAttachmentNode_list"])}.bind(this),mousedown:function(t){this.selected(t)}.bind(this),click:function(t){this.downloadAttachment(t)}.bind(this)})},downloadAttachment:function(t){if(this.controller.module)this.controller.module.downloadAttachment(t,null,[this])}});
|