Common.js 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582
  1. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  2. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  3. MWF.require("MWF.widget.O2Identity", null, false);
  4. MWF.xDesktop.requireApp("Selector", "package", null, false);
  5. MWF.require("MWF.widget.AttachmentController",null,false);
  6. var MWFCalendar = MWF.xApplication.Calendar = MWF.xApplication.Calendar || {};
  7. MWFCalendar.ColorOptions = {
  8. deep : ["#428ffc","#5bcc61","#f9bf24","#f75f59","#f180f7","#9072f1","#909090","#1462be"],
  9. light : ["#cae2ff","#d0f1b0","#fef4bb","#fdd9d9","#f4c5f7","#d6ccf9","#e7e7e7","#cae2ff"],
  10. getLightColor : function( deepColor ){
  11. var index = this.deep.indexOf(deepColor);
  12. return index > -1 ? this.light[index] : this.light[0];
  13. },
  14. getDeepColor : function( lightColor ){
  15. var index = this.light.indexOf(lightColor);
  16. return index > -1 ? this.deep[index] : this.deep[0];
  17. }
  18. };
  19. MWFCalendar.EventForm = new Class({
  20. Extends: MPopupForm,
  21. Implements: [Options, Events],
  22. options: {
  23. "style": "meeting",
  24. "width": "800",
  25. "height": "475",
  26. "hasTop": true,
  27. "hasIcon": false,
  28. "hasTopIcon" : false,
  29. "hasTopContent" : false,
  30. "draggable": true,
  31. "maxAction" : true,
  32. "closeAction": true,
  33. "isFull" : false,
  34. "startTime" : null,
  35. "endTime" : null,
  36. "isWholeday" : false,
  37. "defaultCalendarId" : ""
  38. },
  39. open: function (e) {
  40. if( this.options.isFull ){
  41. this.options.width = "800";
  42. this.options.height = "630";
  43. }
  44. this.fireEvent("queryOpen");
  45. this.isNew = false;
  46. this.isEdited = false;
  47. this._open();
  48. this.fireEvent("postOpen");
  49. },
  50. create: function () {
  51. if( this.options.isFull ){
  52. this.options.width = "1100";
  53. this.options.height = "630";
  54. }
  55. this.fireEvent("queryCreate");
  56. this.isNew = true;
  57. this._open();
  58. this.fireEvent("postCreate");
  59. },
  60. edit: function () {
  61. if( this.options.isFull ){
  62. this.options.width = "1100";
  63. this.options.height = "630";
  64. }
  65. this.fireEvent("queryEdit");
  66. this.isEdited = true;
  67. this._open();
  68. this.fireEvent("postEdit");
  69. },
  70. _createTableContent : function(){
  71. var path = "/o2_lib/rrule/";
  72. COMMON.AjaxModule.load(path+"rrule.js", function () {
  73. this.app.actions.listMyCalendar( function( json ){
  74. this.calendarIds = [];
  75. this.calendarNames = [];
  76. this.calendarList = [];
  77. (json.data.myCalendars || []).each( function(c){
  78. if(c.publishable || c.manageable )this.calendarList.push(c)
  79. }.bind(this));
  80. ( json.data.unitCalendars || [] ).each( function(c){
  81. if(c.publishable || c.manageable )this.calendarList.push(c)
  82. }.bind(this));
  83. this.calendarList.each( function( d ){
  84. this.calendarIds.push(d.id);
  85. this.calendarNames.push(d.name);
  86. }.bind(this));
  87. if( this.isEdited || this.isNew ){
  88. this._createTableContent_Edit();
  89. }else{
  90. this._createTableContent_Read();
  91. }
  92. }.bind(this))
  93. }.bind(this));
  94. },
  95. _createTableContent_Read : function(){
  96. this.formTopTextNode.set( "text", this.lp.readEvent );
  97. this.formTableContainer.setStyle("width","86%");
  98. var data = this.data;
  99. var beginD = Date.parse(data.startTime);
  100. var endD = Date.parse(data.endTime);
  101. var begin = beginD.format(this.lp.dateFormatAll) + "(" + this.lp.weeks.arr[beginD.get("day")] + ")";
  102. var end = endD.format(this.lp.dateFormatAll) + "(" + this.lp.weeks.arr[endD.get("day")] + ")";
  103. if( data.recurrenceRule ){
  104. this.oldRecurrenceRule = data.recurrenceRule;
  105. this.rRule = RRule.fromString(data.recurrenceRule).origOptions;
  106. }else{
  107. this.rRule = {};
  108. }
  109. var text = ["不","每天","每周","每月(当日)","每年(当日)"];
  110. var value = ["NONE",RRule["DAILY"],RRule["WEEKLY"],RRule["MONTHLY"],RRule["YEARLY"] ];
  111. var repeat;
  112. if( this.rRule.freq ){
  113. repeat = text[ value.indexOf( this.rRule.freq ) ];
  114. if( this.rRule.byweekday ){
  115. var repeatWeeks = this.rRule.byweekday.toString().split(",");
  116. var repeatWeekTextList = [];
  117. var weekArr = this.lp.weeks.arr;
  118. var rruleArr = this.lp.weeks.rruleArr;
  119. repeatWeeks.each( function(r){
  120. repeatWeekTextList.push( weekArr[ rruleArr.indexOf( r ) ] );
  121. });
  122. repeat = "每"+ repeatWeekTextList.join("、")+"重复";
  123. }else{
  124. repeat = repeat+"重复";
  125. }
  126. if( this.rRule.until && repeat!="不重复" ){
  127. repeat += " 结束日期:"+this.rRule.until.format("%Y-%m-%d");
  128. }
  129. }else{
  130. repeat = "不重复"
  131. }
  132. var remind;
  133. if( data.valarmTime_config ){ //天、时、分、秒
  134. var valarmTime_configList = data.valarmTime_config.split(",");
  135. valarmTime_configList.each( function( v, i ){
  136. var unit;
  137. if( i == 0 ){
  138. unit = "天"
  139. }else if( i == 1 ){
  140. unit = "小时";
  141. }else if( i==2 ){
  142. unit = "分钟"
  143. }else{
  144. unit = "秒"
  145. }
  146. if( v && v!="0" ){
  147. remind = "提前"+ Math.abs(v)+unit+"提醒";
  148. }
  149. }.bind(this))
  150. }
  151. var calendarName = this.calendarNames[ this.calendarIds.indexOf( data.calendarId ) ];
  152. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='table-layout:fixed;'>" +
  153. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  154. "<tr><td styles='formTableTitle' width='40'>日历:</td>" +
  155. " <td styles='formTableValue' width='400'>"+calendarName+"</td>" +
  156. "</tr>" +
  157. "<tr><td styles='formTableTitle'>标题:</td>" +
  158. " <td styles='formTableValue'><div styles='colorItem'></div>"+ data.title +"</td></tr>" +
  159. "<tr><td styles='formTableTitle'>开始:</td>" +
  160. " <td styles='formTableValue'>"+ begin +"</td>" +
  161. "</tr>" +
  162. "<tr><td styles='formTableTitle'>结束:</td>" +
  163. " <td styles='formTableValue'>"+end+"</td>" +
  164. "</tr>"+
  165. "<tr><td styles='formTableTitle'>地点:</td>" +
  166. " <td styles='formTableValue'>"+( data.locationName || "" )+"</td>" +
  167. "</tr>";
  168. if( remind ){
  169. html += "<tr><td styles='formTableTitle'>提醒:</td>" +
  170. " <td styles='formTableValue'>"+remind+"</td>" +
  171. "</tr>";
  172. }
  173. if( repeat && repeat!="不" && repeat!="不重复" ){
  174. "<tr><td styles='formTableTitle'>重复:</td>" +
  175. " <td styles='formTableValue'>"+ repeat +"</td>" +
  176. "</tr>";
  177. }
  178. if( data.comment ){
  179. html += "<tr><td styles='formTableTitle'>内容:</td>" +
  180. " <td styles='formTableValue'>"+data.comment+"</td>" +
  181. "</tr>";
  182. }
  183. this.formTableArea.set("html", html );
  184. this.formTableArea.getElements("[styles='formTableTitle']").setStyles({
  185. "color" : "#333",
  186. "font-size": "16px",
  187. "padding": "0px 20px 0px 0px",
  188. "height" : "35px",
  189. "line-height" : "35px",
  190. "text-align": "left"
  191. });
  192. this.formTableArea.getElements("[styles='formTableValue']").setStyles({
  193. "text-align": "left",
  194. "font-size": "16px"
  195. });
  196. var colorItem = this.formTableArea.getElement("[styles='colorItem']");
  197. var div = new Element("div", {
  198. styles : this.css.colorNode
  199. }).inject( colorItem );
  200. div.setStyle("background-color",this.data.color);
  201. },
  202. _createTableContent_Edit: function () {
  203. this.oldCoordinate = null;
  204. var editEnable = this.editEnable = ( this.isEdited || this.isNew );
  205. this.userName = layout.desktop.session.user.distinguishedName;
  206. this.userId = layout.desktop.session.user.id;
  207. if( this.options.isFull ){
  208. this.formTableContainer.setStyles({
  209. "width" : "auto",
  210. "padding-left" : "40px"
  211. });
  212. }else{
  213. this.formTableContainer.setStyle("width","80%");
  214. }
  215. if( this.isNew ){
  216. this.formTopTextNode.set( "text", this.lp.addEvent );
  217. }else if( this.isEdited ){
  218. this.formTopTextNode.set( "text", this.lp.editEvent );
  219. this.options.height = "590";
  220. }
  221. var startTime, endTime, defaultStartDate, defaultStartTime, defaultEndDate, defaultEndTime;
  222. if( this.options.startTime && this.options.endTime ){
  223. startTime= this.date = typeOf( this.options.startTime )=="string" ? Date.parse( this.options.startTime ) : this.options.startTime;
  224. endTime= typeOf( this.options.endTime )=="string" ? Date.parse( this.options.endTime ) : this.options.endTime;
  225. defaultStartDate = startTime.format("%Y-%m-%d");
  226. defaultStartTime = startTime.format("%H:%M");
  227. defaultEndDate = endTime.format("%Y-%m-%d");
  228. defaultEndTime = endTime.format("%H:%M");
  229. }else{
  230. startTime = this.date = new Date().increment("hour",1);
  231. endTime = startTime.clone().increment("hour",1);
  232. defaultStartDate = startTime.format("%Y-%m-%d");
  233. defaultStartTime = startTime.format("%H") + ":00";
  234. defaultEndDate = endTime.format("%Y-%m-%d");
  235. defaultEndTime = endTime.format("%H") + ":00";
  236. }
  237. var data = this.data;
  238. if( this.options.isWholeday && this.isNew ){
  239. data.isAllDayEvent = true;
  240. }
  241. if( data.startTime ){
  242. var beignDate = Date.parse( data.startTime );
  243. data.startDateInput = beignDate.format("%Y-%m-%d");
  244. data.startTimeInput = this.getString( beignDate.getHours() ) + ":" + this.getString( beignDate.getMinutes() );
  245. }
  246. if( data.endTime ){
  247. var endDate = Date.parse( data.endTime );
  248. data.endDateInput = endDate.format("%Y-%m-%d");
  249. data.endTimeInput = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  250. }
  251. //data.rRuleString = "FREQ=WEEKLY;DTSTART=20180523T090000Z;UNTIL=20180523T160000Z;BYDAY=WE,TH,FR";
  252. if( data.recurrenceRule ){
  253. this.oldRecurrenceRule = data.recurrenceRule;
  254. this.rRule = RRule.fromString(data.recurrenceRule).origOptions;
  255. }else{
  256. this.rRule = {};
  257. }
  258. data.repeat = this.rRule.freq || "";
  259. if( this.rRule.until ){
  260. data.repeatUntilAvailable = "AVAILABLE";
  261. data.repeatUntilDate = this.rRule.until.format("%Y-%m-%d");
  262. }
  263. if( this.rRule.byweekday ){
  264. data.repeatWeeks = this.rRule.byweekday.toString().split(",");
  265. }
  266. if( data.valarmTime_config ){ //天、时、分、秒
  267. var valarmTime_configList = data.valarmTime_config.split(",");
  268. valarmTime_configList.each( function( v, i ){
  269. var unit;
  270. if( i == 0 ){
  271. unit = "d"
  272. }else if( i == 1 ){
  273. unit = "h";
  274. }else if( i==2 ){
  275. unit = "m"
  276. }else{
  277. unit = "s"
  278. }
  279. if( v && v!="0" ){
  280. data.remind = v+"_"+unit;
  281. }
  282. }.bind(this))
  283. }
  284. this.formTableArea.set("html", this.getHtml());
  285. this.colorItem = this.formTableArea.getElement("[item='color']");
  286. //this.attachmentTr = this.formTableArea.getElement("[item='attachmentTr']");
  287. //this.attachmentArea = this.formTableArea.getElement("[item='attachment']");
  288. if( !this.data.color ){
  289. if( this.options.defaultCalendarId ){
  290. this.data.color = this.getColorByCalendarId( this.options.defaultCalendarId );
  291. }else{
  292. this.data.color = this.calendarList[0].color;
  293. }
  294. }
  295. MWF.xDesktop.requireApp("Template", "MForm", function () {
  296. this.form = new MForm(this.formTableArea, data, {
  297. isEdited: this.isEdited || this.isNew,
  298. style : "meeting",
  299. hasColon : true,
  300. itemTemplate: {
  301. calendarId : { text : this.lp.calendar, defaultValue : this.options.defaultCalendarId, type : "select", selectValue : this.calendarIds, selectText : this.calendarNames, event : {
  302. change : function( item ){
  303. this.setColorByCalendarId( item.getValue() )
  304. }.bind(this)
  305. }},
  306. startDateInput: { text : this.lp.beginTime ,tType: "date", defaultValue: defaultStartDate , notEmpty : true },
  307. startTimeInput: { tType: "time",
  308. defaultValue: defaultStartTime, className : ( (this.isNew || this.isEdited ) ? "inputTimeUnformatWidth" : "" ),
  309. disable : data.isAllDayEvent
  310. },
  311. endDateInput: { text : this.lp.endTime, tType: "date", defaultValue: defaultEndDate, notEmpty : true },
  312. endTimeInput: { tType: "time",
  313. defaultValue: defaultEndTime, className : ( (this.isNew || this.isEdited ) ? "inputTimeUnformatWidth" : "" ),
  314. disable : data.isAllDayEvent
  315. },
  316. remind : { text : this.lp.remind, type : "select", selectText : ["不提醒","开始时","提前5分钟","提前10分钟","提前15分钟","提前30分钟","提前1小时","提前2小时"],
  317. selectValue : ["", "-5_s","-5_m","-10_m","-15_m","-30_m","-1_h","-2_h"] },
  318. isAllDayEvent : { type : "checkbox", selectValue : ["true"], selectText : ["全天"], event : {
  319. change : function(item ){
  320. var itemStart = item.form.getItem("startTimeInput");
  321. var itemEnd = item.form.getItem("endTimeInput");
  322. if( item.getValue() == "true" && !itemStart.options.disable && !itemEnd.options.disable ){
  323. itemStart.getElements().setStyle("display","none");
  324. itemEnd.getElements().setStyle("display","none")
  325. }else{
  326. if( itemStart.options.disable )itemStart.enable();
  327. if( itemEnd.options.disable )itemEnd.enable();
  328. itemStart.getElements().setStyle("display","");
  329. itemEnd.getElements().setStyle("display","")
  330. }
  331. }.bind(this)
  332. } },
  333. title: { text : this.lp.eventSubject, notEmpty : true },
  334. description: {type: "textarea"},
  335. locationName : { text : "地点" },
  336. repeat : { text : this.lp.repeat, type : "select", defaultValue : "NONE",
  337. selectText : ["不重复","每天","每周","每月(当日)","每年(当日)"],
  338. selectValue : ["NONE",RRule["DAILY"],RRule["WEEKLY"],RRule["MONTHLY"],RRule["YEARLY"] ], event : {
  339. change : function(item){
  340. var val = item.getValue();
  341. var area = this.formTableArea.getElement("[item='repeatUntilArea']");
  342. area.setStyle("display", val == "NONE" ? "none" : "");
  343. if( val == RRule["WEEKLY"] ){
  344. this.showWeek()
  345. }else{
  346. area = this.formTableArea.getElement("[item='repeatWeekArea']");
  347. area.setStyle("display","none");
  348. }
  349. }.bind(this)
  350. }},
  351. repeatUntilAvailable : { text : this.lp.repeatUntilAvailable, type : "radio",
  352. selectText : ["永不", "结束日期"],
  353. selectValue : ["NONE", "AVAILABLE"],
  354. defaultValue : "NONE"
  355. },
  356. repeatUntilDate : { tType : "date", event : {
  357. click : function(){ this.form.getItem("repeatUntilAvailable").setValue("AVAILABLE") }.bind(this)
  358. }},
  359. comment : { text : this.lp.content, type : "rtf", RTFConfig : {
  360. skin : "bootstrapck",
  361. "resize_enabled": false,
  362. toolbar : [
  363. { name: 'document', items : [ 'Preview' ] },
  364. //{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
  365. { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },
  366. //{ name: 'paragraph', items : [ 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ] },
  367. { name: 'list', items : [ 'NumberedList','BulletedList'] },
  368. //{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
  369. //{ name: 'colors', items : [ 'TextColor','BGColor' ] },
  370. { name: 'links', items : [ 'Link','Unlink' ] }
  371. //{ name: 'insert', items : [ 'Image' ] },
  372. //{ name: 'tools', items : [ 'Maximize','-','About' ] }
  373. ]
  374. }
  375. }}
  376. }, this.app);
  377. this.form.load();
  378. if( this.data.repeat == RRule["WEEKLY"] ){
  379. this.showWeek()
  380. }
  381. this.loadColor();
  382. //if( this.data.id )
  383. // this.loadAttachment();
  384. }.bind(this), true);
  385. },
  386. getRRuleString : function( data ){
  387. if( !data )data = this.form.getResult(false,null,false,false,false);
  388. if( !data.repeat || data.repeat == "NONE" )return "";
  389. //var startDate;
  390. //if( data.isAllDayEvent == "true" ){
  391. // startDate = Date.parse( data.startDateInput )
  392. //}else{
  393. // startDate = Date.parse( data.startDateInput + " " + data.startTimeInput )
  394. //}
  395. var options = {
  396. freq : data.repeat //RRule[data.repeat],
  397. //dtstart : startDate
  398. };
  399. if( data.repeatUntilAvailable != "NONE" && data.repeatUntilDate!="" ){
  400. options.until = Date.parse( data.repeatUntilDate )
  401. }
  402. if( data.repeat == RRule["WEEKLY"] ){
  403. options.byweekday = [];
  404. this.getSelectWeek().each( function( w ){
  405. options.byweekday.push( RRule[w] )
  406. })
  407. }
  408. var rule = new RRule( options );
  409. return rule.toString();
  410. },
  411. getHtml : function(){
  412. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  413. if( this.options.isFull ){
  414. var html = "<div style='overflow: hidden;'>" +
  415. "<div item='baseInforContainer' style='float: left; width : 500px;'>" +
  416. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='table-layout:fixed;'>" +
  417. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  418. "<tr><td styles='formTableTitle' width='80' lable='calendarId'></td>" +
  419. " <td styles='formTableValue' item='calendarId' colspan='2' width='400'></td>" +
  420. "</tr>" +
  421. "<tr><td styles='formTableTitle' lable='title'></td>" +
  422. " <td styles='formTableValue' item='title' colspan='2'></td></tr>" +
  423. "<tr><td styles='formTableTitle' lable='startDateInput'></td>" +
  424. " <td styles='formTableValue' item='startDateInput' width='" + ( this.editEnable ? "260" : "100" ) + "'></td>" +
  425. " <td styles='formTableValue' item='startTimeInput'></td>" +
  426. "</tr>" +
  427. "<tr><td styles='formTableTitle' lable='endDateInput'></td>" +
  428. " <td styles='formTableValue' item='endDateInput'></td>" +
  429. " <td styles='formTableValue' item='endTimeInput'></td>" +
  430. "</tr>"+
  431. "<tr><td styles='formTableTitle'></td>" +
  432. " <td styles='formTableValue' item='isAllDayEvent' colspan='2'></td>" +
  433. "</tr>"+
  434. "<tr><td styles='formTableTitle' lable='locationName'></td>" +
  435. " <td styles='formTableValue' item='locationName' colspan='2'></td>" +
  436. "</tr>" +
  437. "<tr><td styles='formTableTitle' lable='remind'></td>" +
  438. " <td styles='formTableValue' item='remind' colspan='2'></td>" +
  439. "</tr>" +
  440. "<tr><td styles='formTableTitle' lable='repeat'></td>" +
  441. " <td styles='formTableValue' item='repeat' colspan='2'></td>" +
  442. "</tr>" +
  443. "<tr item='repeatWeekArea' style='display:"+ ( this.data.repeat == RRule["WEEKLY"] ? "" : "none") +";'><td styles='formTableTitle'></td>" +
  444. " <td styles='formTableValue' item='repeatWeek' colspan='2' style='overflow:hidden;'></td>" +
  445. "</tr>" +
  446. "<tr item='repeatUntilArea' style='display:"+ ( (!this.data.repeat || this.data.repeat == "") ? "none" : "") +";'><td styles='formTableTitle'></td>" +
  447. " <td styles='formTableValue' colspan='2' style='overflow: hidden;line-height:34px;'>" +
  448. " <div lable='repeatUntilAvailable' style='float: left;'></div>"+
  449. " <div item='repeatUntilAvailable' style='float: left;'></div>"+
  450. " <div item='repeatUntilDate' style='float: left;width:170px;'></div>"+
  451. " </td>" +
  452. "</tr>" +
  453. "<tr><td styles='formTableTitle'>"+this.lp.color+":</td>" +
  454. " <td styles='formTableValue' item='color' colspan='2' style='overflow: hidden;'></td>" +
  455. "</tr>" +
  456. "</table>"+
  457. "</div>" +
  458. "<div style='float: left; width : 500px;' item='commentContainer'>" +
  459. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  460. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  461. "<tr><td styles='formTableTitle' ></td>" +
  462. " <td styles='formTableValue' lable='comment' colspan='2'></td>" +
  463. "</tr>" +
  464. "<tr><td styles='formTableTitle' ></td>" +
  465. " <td styles='formTableValue' item='comment' colspan='2'></td>" +
  466. "</tr>" +
  467. //"<tr><td styles='formTableTitle'>"+this.lp.eventDescription+":</td>" +
  468. //" <td styles='formTableValue' item='description' colspan='2'></td></tr>" +
  469. "<tr item='attachmentTr'><td styles='formTableTitle'></td>" +
  470. " <td styles='formTableValue' item='attachment'></td></tr>" +
  471. "</table>"+
  472. "</div>" +
  473. "</div>";
  474. return html;
  475. }else{
  476. return "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  477. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  478. "<tr><td styles='formTableTitle' lable='calendarId'></td>" +
  479. " <td styles='formTableValue' item='calendarId' colspan='2'></td></tr>" +
  480. "<tr><td styles='formTableTitle' lable='title'></td>" +
  481. " <td styles='formTableValue' item='title' colspan='2'></td></tr>" +
  482. "<tr><td styles='formTableTitle' width='100' lable='startDateInput'></td>" +
  483. " <td styles='formTableValue' item='startDateInput' width='300'></td>" +
  484. " <td styles='formTableValue' item='startTimeInput'></td>" +
  485. "</tr>" +
  486. "<tr><td styles='formTableTitle' lable='endDateInput'></td>" +
  487. " <td styles='formTableValue' item='endDateInput'></td>" +
  488. " <td styles='formTableValue' item='endTimeInput'></td>" +
  489. "</tr>" +
  490. "<tr><td styles='formTableTitle'></td>" +
  491. " <td styles='formTableValue' item='isAllDayEvent' colspan='2'></td>" +
  492. "</tr>" +
  493. "<tr><td styles='formTableTitle' lable='remind'></td>" +
  494. " <td styles='formTableValue' item='remind' colspan='2'></td>" +
  495. "</tr>" +
  496. "</table>";
  497. }
  498. },
  499. _setNodesSize : function(width, height, formContentHeight, formTableHeight ){
  500. if( this.options.isFull ){
  501. var baseInforContainer = this.formAreaNode.getElement("[item='baseInforContainer']");
  502. var commentContainer = this.formAreaNode.getElement("[item='commentContainer']");
  503. if(baseInforContainer)baseInforContainer.setStyle("width", (width-100) / 2);
  504. if(commentContainer)commentContainer.setStyle("width", (width-100) / 2)
  505. }
  506. },
  507. getColorByCalendarId : function( calendarId ){
  508. var color;
  509. this.calendarList.each( function( d ){
  510. if( d.id == calendarId ){
  511. color = d.color;
  512. }
  513. }.bind(this));
  514. return color;
  515. },
  516. setColorByCalendarId : function( calendarId ){
  517. var color = this.getColorByCalendarId( calendarId );
  518. if( color ){
  519. this.data.color = color;
  520. this.setColor(color);
  521. }
  522. },
  523. setColor : function( color ){
  524. (this.colorOptions || []).each( function( div ){
  525. if( div.retrieve("color") == color ){
  526. div.click();
  527. }
  528. })
  529. },
  530. loadColor : function(){
  531. if( this.isEdited || this.isNew ){
  532. this.loadColor_Edited();
  533. }else{
  534. this.loadColor_Read();
  535. }
  536. },
  537. loadColor_Read : function(){
  538. if( !this.colorItem )return;
  539. var div = new Element("div", {
  540. styles : this.css.colorNode
  541. }).inject( this.colorItem );
  542. div.setStyle("background-color",this.data.color);
  543. div.setStyles( this.css.colorNode_current );
  544. },
  545. loadColor_Edited : function(){
  546. if( !this.colorItem )return;
  547. this.colorOptions = [];
  548. if( !this.data.color ){
  549. if( this.options.defaultCalendarId ){
  550. this.getColorByCalendarId( this.options.defaultCalendarId );
  551. }else{
  552. this.data.color = this.calendarList[0].color;
  553. }
  554. }
  555. MWFCalendar.ColorOptions.deep.each( function( color , i){
  556. var div = new Element("div", {
  557. styles : this.css.colorNode,
  558. events : {
  559. click : function(ev){
  560. if(this.currentColorNode)this.currentColorNode.setStyles( this.css.colorNode );
  561. ev.target.setStyles( this.css.colorNode_current );
  562. this.currentColorNode = ev.target;
  563. }.bind(this)
  564. }
  565. }).inject( this.colorItem );
  566. div.setStyle("background-color",color);
  567. div.store("color",color);
  568. if( this.data.color ){
  569. if( this.data.color == color ){
  570. div.setStyles( this.css.colorNode_current );
  571. this.currentColorNode = div;
  572. }
  573. }else if(i==0){
  574. div.setStyles( this.css.colorNode_current );
  575. this.currentColorNode = div;
  576. }
  577. this.colorOptions.push( div )
  578. }.bind(this))
  579. },
  580. showWeek : function(){
  581. var area = this.formTableArea.getElement("[item='repeatWeekArea']");
  582. if( !area )return;
  583. area.setStyle("display","");
  584. if( this.isWeekSelectCreated )return;
  585. this.weekItems = [];
  586. var container = this.formTableArea.getElement("[item='repeatWeek']");
  587. var weekDayStyle = this.css.weekDayStyle = {
  588. "border" : "1px solid #ccc",
  589. "border-radius" : "3px",
  590. "height" : "20px",
  591. "line-heigh" : "20px",
  592. "background" : "#f7f7f7",
  593. "color" : "#666",
  594. "padding" : "0px 9px",
  595. "margin-right" : "9px",
  596. "float" : "left",
  597. "font-size" : "12px",
  598. "cursor" : "pointer"
  599. };
  600. var weekDayOnStyle = this.css.weekDayOnStyle = Object.merge( Object.clone(weekDayStyle), {
  601. "border" : "1px solid #3c75b7",
  602. "background" : "#3c75b7",
  603. "color" : "#fff"
  604. });
  605. var repeatWeeks = this.data.repeatWeeks || [ this.lp.weeks.rruleArr[ this.date.getDay() ] ];
  606. for( var i=0; i<7; i++ ){
  607. var rruleWeekString = this.lp.weeks.rruleArr[i];
  608. var isCurrentDay = repeatWeeks.contains( rruleWeekString );
  609. var div = new Element("div",{
  610. styles : isCurrentDay ? weekDayOnStyle : weekDayStyle,
  611. text : this.lp.weeks.arr[i],
  612. events : {
  613. click : function(ev){
  614. this.triggerWeek( ev.target )
  615. }.bind(this)
  616. }
  617. }).inject(container);
  618. if( isCurrentDay ){
  619. if( this.date.getDay() == i ){
  620. this.currrentWeekDayItem = div;
  621. }
  622. div.store("isOn", true);
  623. }
  624. div.store( "weekDay", rruleWeekString );
  625. this.weekItems.push(div);
  626. }
  627. this.isWeekSelectCreated = true;
  628. },
  629. triggerWeek : function(item){
  630. if(item.retrieve("isOn")){
  631. item.store("isOn", false);
  632. item.setStyles( this.css.weekDayStyle )
  633. }else{
  634. item.store("isOn", true);
  635. item.setStyles( this.css.weekDayOnStyle )
  636. }
  637. if( this.getSelectWeek().length==0 ){
  638. this.triggerWeek( this.currrentWeekDayItem );
  639. }
  640. },
  641. getSelectWeek : function(){
  642. if( !this.weekItems )return [];
  643. var weekDay = [];
  644. this.weekItems.each(function(item){
  645. if( item.retrieve("isOn") ){
  646. weekDay.push( item.retrieve("weekDay"));
  647. }
  648. });
  649. return weekDay;
  650. },
  651. _createBottomContent : function(){
  652. var html = "<div style='width:700px;margin:0px auto;'><table width='700' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  653. "<tr><td styles='formTableValue' width='100'></td>" +
  654. " <td styles='formTableValue' style='padding-top: 15px;'>"+
  655. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  656. " <div item='editAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "none" : "") +";'></div>"+
  657. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  658. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew ) ? "float:left;" : "float:left")+"'></div>"+
  659. " <div item='moreInfor' style='float: right;margin-top:5px;'></div>"+
  660. " </td></tr>" +
  661. "</table></div>";
  662. this.formBottomNode.set("html", html);
  663. MWF.xDesktop.requireApp("Template", "MForm", function () {
  664. var form = new MForm(this.formBottomNode, {}, {
  665. isEdited: this.isEdited || this.isNew,
  666. style : "meeting",
  667. hasColon : true,
  668. itemTemplate: {
  669. moreInfor : {
  670. type : "a", value : "更多编辑", event : {
  671. click : function(){ this.openMoreInfor() }.bind(this)
  672. }, disable : this.options.isFull
  673. },
  674. saveAction : { type : "button", className : "inputOkButton", value : this.lp.save, event : {
  675. click : function(){ this.save();}.bind(this)
  676. } },
  677. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.cancelEvent , event : {
  678. click : function( item, ev ){ this.cancelEvent(ev); }.bind(this)
  679. } },
  680. editAction : { type : "button", className : "inputOkButton", value : this.lp.editEvent , event : {
  681. click : function(){ this.editEvent(); }.bind(this)
  682. } },
  683. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  684. click : function(){ this.close(); }.bind(this)
  685. } }
  686. }
  687. }, this.app);
  688. form.load();
  689. }.bind(this), true);
  690. },
  691. openMoreInfor : function(){
  692. this.options.isFull = true;
  693. this.options.width = "1100";
  694. this.options.height = "620";
  695. this.isWeekSelectCreated = false;
  696. this.reload( true );
  697. },
  698. getString : function( str ){
  699. var s = "00" + str;
  700. return s.substr(s.length - 2, 2 );
  701. },
  702. getEventData : function( callback ){
  703. if( this.data && this.data.id ){
  704. this.app.actions.getEvent( this.data.id, function( json ){
  705. this.data = json.data;
  706. if(callback)callback();
  707. }.bind(this))
  708. }else{
  709. if(callback)callback();
  710. }
  711. },
  712. editEvent : function(){
  713. this.isWeekSelectCreated = false;
  714. this.formTopNode = null;
  715. if(this.setFormNodeSizeFun && this.app && this.app.removeEvent ){
  716. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  717. }
  718. if( this.formMaskNode )this.formMaskNode.destroy();
  719. this.formAreaNode.destroy();
  720. this.edit();
  721. },
  722. reset: function(){
  723. this.formTableArea.empty();
  724. this._createTableContent();
  725. },
  726. loadAttachment: function(){
  727. if(!this.attachmentTr)return;
  728. this.attachmentTr.setStyle("display","");
  729. this.attachmentNode = new Element("div", {"styles": this.css.createEventAttachmentNode}).inject(this.attachmentArea);
  730. var attachmentContentNode = new Element("div", {"styles": this.css.createEventAttachmentContentNode}).inject(this.attachmentNode);
  731. MWF.require("MWF.widget.AttachmentController", function(){
  732. this.attachmentController = new MWF.widget.AttachmentController(attachmentContentNode, this, {
  733. "size": "min",
  734. "isSizeChange": false,
  735. "isReplace": false,
  736. "isUpload": this.isNew || this.isEdited,
  737. "isDelete": this.isNew || this.isEdited,
  738. "isDownload": true,
  739. "readonly": !this.isNew && !this.isEdited
  740. });
  741. this.attachmentController.load();
  742. if( this.data.attachmentList ){
  743. this.data.attachmentList.each(function (att) {
  744. att.person = att.lastUpdatePerson.split("@")[0];
  745. var at = this.attachmentController.addAttachment(att);
  746. }.bind(this));
  747. }
  748. }.bind(this));
  749. },
  750. uploadAttachment: function(e, node){
  751. if (!this.uploadFileAreaNode){
  752. this.createUploadFileNode();
  753. }
  754. this.fileUploadNode.click();
  755. },
  756. createUploadFileNode: function(){
  757. this.uploadFileAreaNode = new Element("div");
  758. var html = "<input name=\"file\" type=\"file\" multiple/>";
  759. this.uploadFileAreaNode.set("html", html);
  760. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  761. this.fileUploadNode.addEvent("change", function(){
  762. var files = this.fileUploadNode.files;
  763. if (files.length){
  764. for (var i = 0; i < files.length; i++) {
  765. var file = files.item(i);
  766. var formData = new FormData();
  767. formData.append('file', file);
  768. //formData.append('folder', folderId);
  769. this.app.actions.addAttachment(function(o, text){
  770. if (o.id){
  771. this.app.actions.getAttachment(o.id, function(json){
  772. if (json.data) this.attachmentController.addAttachment(json.data);
  773. this.attachmentController.checkActions();
  774. }.bind(this))
  775. }
  776. this.attachmentController.checkActions();
  777. }.bind(this), null, formData, this.data.id, file);
  778. }
  779. }
  780. }.bind(this));
  781. },
  782. deleteAttachments: function(e, node, attachments){
  783. var names = [];
  784. attachments.each(function(attachment){
  785. names.push(attachment.data.name);
  786. }.bind(this));
  787. var _self = this;
  788. var confirm = ( this.app && this.app.confirm ) ? this.app.confirm : MWF.xDesktop.confirm;
  789. confirm("warn", e, this.lp.deleteAttachmentTitle, this.lp.deleteAttachment+"( "+names.join(", ")+" )", 300, 120, function(){
  790. while (attachments.length){
  791. attachment = attachments.shift();
  792. _self.deleteAttachment(attachment);
  793. }
  794. this.close();
  795. }, function(){
  796. this.close();
  797. }, null);
  798. },
  799. deleteAttachment: function(attachment){
  800. this.app.actions.deleteFile(attachment.data.id, function(josn){
  801. this.attachmentController.removeAttachment(attachment);
  802. this.attachmentController.checkActions();
  803. }.bind(this));
  804. },
  805. downloadAttachment: function(e, node, attachments){
  806. attachments.each(function(att){
  807. this.app.actions.getFileDownload(att.data.id);
  808. }.bind(this));
  809. },
  810. openAttachment: function(e, node, attachments){
  811. attachments.each(function(att){
  812. this.app.actions.getFile(att.data.id);
  813. }.bind(this));
  814. },
  815. getAttachmentUrl: function(attachment, callback){
  816. this.app.actions.getFileUrl(attachment.data.id, callback);
  817. },
  818. cancelEvent: function(e){
  819. var _self = this;
  820. var data = this.data;
  821. var postDelete = function(){
  822. this.view.reload();
  823. this.close();
  824. }.bind(this);
  825. if( this.oldRecurrenceRule ) { //如果是原来是重复的
  826. this.openDeleteOptionForm( function( saveOptions ){
  827. if( saveOptions == "single" ){
  828. this.app.actions.deleteSingleEvent(data.id, function(json){ postDelete(json); }.bind(this));
  829. }else if( saveOptions == "after" ){
  830. this.app.actions.deleteAfterEvent(data.id, function(json){ postDelete(json); }.bind(this));
  831. }else if( saveOptions == "all" ){
  832. this.app.actions.deleteAllEventsWithRepeatMaster(data.id, function(json){ postDelete(json); }.bind(this));
  833. }
  834. }.bind(this))
  835. }else if( data.id ){ //编辑
  836. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.title);
  837. var confirm = ( this.app && this.app.confirm ) ? this.app.confirm : MWF.xDesktop.confirm;
  838. confirm("infor", e, this.app.lp.cancel_confirm_title, text, 380, 200, function(){
  839. _self._cancelEvent();
  840. this.close();
  841. }, function(){
  842. this.close();
  843. });
  844. }
  845. },
  846. _cancelEvent: function(){
  847. var view = this.view;
  848. this.app.actions.deleteSingleEvent(this.data.id, function(){
  849. view.reload();
  850. this.close();
  851. }.bind(this))
  852. },
  853. openDeleteOptionForm : function( callback ){
  854. this.deleteOptionsForm = new MWFCalendar.DeleteOptionDialog( this, {}, {
  855. onPostOk : function( saveOptions ){
  856. if(callback){
  857. callback(saveOptions)
  858. }
  859. }.bind(this)
  860. }, {});
  861. this.deleteOptionsForm.edit();
  862. },
  863. save: function(){
  864. this._save(function(){
  865. if( this.app && this.app.notice ){
  866. this.app.notice(this.lp.event_saveSuccess, "success");
  867. }else{
  868. MWF.xDesktop.notice("ok", {"x": "right", "y": "top"}, this.lp.event_saveSuccess, $(document.body))
  869. }
  870. this.close();
  871. //if (!this.attachmentNode){
  872. // this.loadAttachment();
  873. //}
  874. }.bind(this));
  875. },
  876. _save: function(callback){
  877. var data = this.getSaveData();
  878. if( !data )return;
  879. var errorText = "";
  880. if (!data.title) errorText +=this.lp.event_input_subject_error;
  881. if( data.startTime ){
  882. if ( (Date.parse(data.startTime) - Date.parse(data.endTime)) > 0) errorText +=this.lp.event_input_time_error;
  883. //if (now.diff(this.data.startTime, "minute")<0) errorText +=this.lp.event_input_date_error;
  884. //
  885. //delete this.data.startTimeDate;
  886. //delete this.data.completedTimeDate;
  887. }
  888. if (errorText){
  889. if( this.app && this.app.notice ){
  890. this.app.notice(this.lp.event_input_error+errorText, "error");
  891. }else{
  892. MWF.xDesktop.notice("error", {"x": "right", "y": "top"}, this.lp.event_input_error+errorText, $(document.body));
  893. }
  894. return false;
  895. }
  896. var postSave = function( json ){
  897. this.data.id = json.data.id;
  898. this.oldRecurrenceRule = data.recurrenceRule;
  899. this.waitReload = true;
  900. if (callback) callback();
  901. }.bind(this);
  902. this.data = data;
  903. if( this.oldRecurrenceRule ) { //如果是原来是重复的
  904. this.openSaveOptionForm( function( saveOptions ){
  905. if( saveOptions == "single" ){
  906. this.app.actions.updateSingleEvent(data.id, this.data, function(json){ postSave(json); }.bind(this));
  907. }else if( saveOptions == "after" ){
  908. this.app.actions.updateAfterEvent(data.id, this.data, function(json){ postSave(json); }.bind(this));
  909. }else if( saveOptions == "all" ){
  910. this.app.actions.updateAllEventsWithRepeatMaster(data.id, this.data, function(json){ postSave(json); }.bind(this));
  911. }
  912. }.bind(this))
  913. }else if( data.id ){ //编辑
  914. this.app.actions.updateSingleEvent(data.id, this.data, function(json){ postSave(json); }.bind(this));
  915. }else{ //新增
  916. this.app.actions.addEvent(this.data, function(json){ postSave(json); }.bind(this));
  917. }
  918. },
  919. openSaveOptionForm : function( callback ){
  920. this.saveOptionsForm = new MWFCalendar.SaveOptionDialog( this, {}, {
  921. onPostOk : function( saveOptions ){
  922. if(callback){
  923. callback(saveOptions)
  924. }
  925. }.bind(this)
  926. }, {});
  927. this.saveOptionsForm.edit();
  928. },
  929. getSaveData: function(){
  930. var data = this.form.getResult(true,"",true,false,true);
  931. if( !data )return null;
  932. if( data ){
  933. data.isAllDayEvent = typeOf( data.isAllDayEvent ) == "array" ? data.isAllDayEvent.join("") : data.isAllDayEvent;
  934. if( data.isAllDayEvent == "true"){
  935. data.startTime = this.data.startDateInput + " " + "00:00:00";
  936. data.endTime = this.data.endDateInput + " " + "23:59:59";
  937. }else{
  938. data.startTime = this.data.startDateInput + " " + this.data.startTimeInput + ":00";
  939. data.endTime = this.data.endDateInput + " " + this.data.endTimeInput + ":00";
  940. }
  941. data.recurrenceRule = this.getRRuleString( data );
  942. if( data.remind ){
  943. var valarmTime_config = [0,0,0,0];
  944. var r = data.remind.split("_");
  945. var n = parseInt( r[0] );
  946. if( r[1] == "d" ){
  947. valarmTime_config[0] = n;
  948. }else if( r[1] == "h" ){
  949. valarmTime_config[1] = n;
  950. }else if( r[1] == "m" ){
  951. valarmTime_config[2] = n;
  952. }else if( r[1] == "s" ){
  953. valarmTime_config[3] = n;
  954. }
  955. data.valarmTime_config = valarmTime_config.join(",");
  956. }
  957. if( !data.calendarId ){
  958. data.calendarId = this.app.currentCalendarData.id;
  959. }
  960. if( this.currentColorNode ){
  961. data.color = this.currentColorNode.retrieve("color");
  962. }else if( data.calendarId ){
  963. data.color = this.getColorByCalendarId(data.calendarId);
  964. }else{
  965. data.color = MWFCalendar.ColorOptions.deep[0];
  966. }
  967. delete data.range;
  968. }
  969. return data;
  970. },
  971. close: function (e) {
  972. this.fireEvent("queryClose");
  973. this._close();
  974. //if( this.form ){
  975. // this.form.destroy();
  976. //}
  977. if(this.setFormNodeSizeFun && this.app && this.app.removeEvent ){
  978. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  979. }
  980. if( this.formMaskNode )this.formMaskNode.destroy();
  981. this.formAreaNode.destroy();
  982. this.fireEvent("postClose");
  983. if( this.waitReload )this.view.reload();
  984. delete this;
  985. }
  986. });
  987. MWFCalendar.CalendarForm = new Class({
  988. Extends: MPopupForm,
  989. Implements: [Options, Events],
  990. options: {
  991. "style": "meeting",
  992. "width": "800",
  993. "height": "500",
  994. "hasTop": true,
  995. "hasIcon": false,
  996. "hasTopIcon" : false,
  997. "hasTopContent" : false,
  998. "draggable": true,
  999. "maxAction" : true,
  1000. "resizeable" : true,
  1001. "closeAction": true,
  1002. "resultSeparator" : null
  1003. },
  1004. _createTableContent: function () {
  1005. var data = this.data;
  1006. var editEnable = this.editEnable = ( !this.isEdited && !this.isNew && this.data.manageable );
  1007. this.userName = ( layout.desktop.session.user || layout.user ).distinguishedName;
  1008. this.userId = ( layout.desktop.session.user || layout.user ).id;
  1009. if( data.type == "UNIT" ){
  1010. this.options.height = "650"
  1011. }
  1012. if( this.isNew ){
  1013. this.formTopTextNode.set( "text", "新建日历" );
  1014. }else if( this.isEdited ){
  1015. this.formTopTextNode.set( "text", "编辑日历" );
  1016. }else{
  1017. this.formTopTextNode.set( "text", "日历" );
  1018. }
  1019. this.formTableArea.set("html", this.getHtml());
  1020. this.formTableContainer.setStyle("width","80%");
  1021. this.colorItem = this.formTableArea.getElement("[item='color']");
  1022. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1023. this.form = new MForm(this.formTableArea, data, {
  1024. isEdited: this.isEdited || this.isNew,
  1025. style : "meeting",
  1026. hasColon : true,
  1027. itemTemplate: {
  1028. name: { text : "日历名称", notEmpty : true },
  1029. description: {text : "备注", type: "textarea"},
  1030. type : { text : "类型", type : "select", isEdited : this.isNew,
  1031. selectValue : ["PERSON", "UNIT"],
  1032. selectText : ["个人日历", "组织日历"],
  1033. defaultValue : "PERSON",
  1034. event : {
  1035. change : function(item){
  1036. this.changeType( item.getValue() )
  1037. }.bind(this)
  1038. }
  1039. },
  1040. target : { text : "所属组织", type : "org", orgType : "unit", validRule : { empty : function( value, item){
  1041. if( item.form.getItem("type").getValue() == "UNIT" && value == ""){ return false }else{ return true };
  1042. }}, validMessage : { empty : "所属组织不能为空"} },
  1043. isPublic : { text : "是否公开", type : "select", selectValue : ["true","false"], selectText : ["是","否"], defaultValue : "false" },
  1044. status : { text : "是否启用", type : "radio", selectValue : ["OPEN","CLOSE"], selectText : ["是","否"], defaultValue : "OPEN" },
  1045. manageablePersonList : { text : "管理者", type : "org", orgType : "person", count : 0},
  1046. viewerList : { text : "可见范围", type : "org", orgType : ["person","unit","group"], count : 0, value : function(){
  1047. return ( data.viewablePersonList || [] ).combine( data.viewableUnitList || [] ).combine( data.viewableGroupList || [] )
  1048. }.bind(this)},
  1049. publisherList : { text : "可新建范围", type : "org", orgType : ["person","unit","group"], count : 0, value : function(){
  1050. return ( data.publishablePersonList || [] ).combine( data.publishableUnitList || [] ).combine( data.publishableGroupList || [] )
  1051. }.bind(this)}
  1052. }
  1053. }, this.app);
  1054. this.form.load();
  1055. this.loadColor();
  1056. //this.loadPermission();
  1057. }.bind(this), true);
  1058. },
  1059. getHtml : function(){
  1060. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  1061. var targetStyle = this.data.type != "UNIT" ? "style='display:none'" : "";
  1062. var permissionStyle = this.data.type != "UNIT" ? "style='display:none'" : "";
  1063. return "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='table-layout:fixed;'>" +
  1064. "<tr><td styles='formTableTitle' width='80' lable='name'></td>" +
  1065. " <td styles='formTableValue' item='name' width='400' colspan='3'></td></tr>" +
  1066. "<tr><td styles='formTableTitle'>"+this.lp.color+":</td>" +
  1067. " <td styles='formTableValue' item='color' style='overflow: hidden;' colspan='3'></td></tr>" +
  1068. "<tr><td styles='formTableTitle' lable='type' width='80'></td>" +
  1069. " <td styles='formTableValue' item='type'></td>" +
  1070. " <td styles='formTableTitleRight' lable='isPublic' width='50'></td>" +
  1071. " <td styles='formTableValue' item='isPublic'></td></tr>" +
  1072. "<tr><td styles='formTableTitle' lable='description'></td>" +
  1073. " <td styles='formTableValue' item='description' colspan='3'></td></tr>" +
  1074. "<tr "+targetStyle+"><td styles='formTableTitle' lable='target'></td>" +
  1075. " <td styles='formTableValue' item='target' colspan='3'></td></tr>" +
  1076. "<tr "+permissionStyle+"><td styles='formTableTitle' lable='manageablePersonList'></td>" +
  1077. " <td styles='formTableValue' item='manageablePersonList' colspan='3'></td></tr>" +
  1078. "<tr "+permissionStyle+"><td styles='formTableTitle' lable='viewerList'></td>" +
  1079. " <td styles='formTableValue' item='viewerList' colspan='3'></td></tr>" +
  1080. "<tr "+permissionStyle+"><td styles='formTableTitle' lable='publisherList'></td>" +
  1081. " <td styles='formTableValue' item='publisherList' colspan='3'></td></tr>" +
  1082. "</tr>" +
  1083. "<tr><td styles='formTableTitle' lable='status'></td>" +
  1084. " <td styles='formTableValue' item='status' colspan='3'></td></tr>" +
  1085. "</table>"
  1086. },
  1087. changeType : function( type ){
  1088. var changeItemName = ["target","manageablePersonList","viewerList","publisherList"];
  1089. changeItemName.each( function(name){
  1090. this.formTableArea.getElement("[item='"+name+"']").getParent().setStyle("display",type == "UNIT" ? "" : "none");
  1091. }.bind(this));
  1092. this.options.height = type == "UNIT" ? "650" : "500";
  1093. this.setFormNodeSize();
  1094. },
  1095. loadColor : function(){
  1096. if( this.isEdited || this.isNew ){
  1097. this.loadColor_Edited();
  1098. }else{
  1099. this.loadColor_Read();
  1100. }
  1101. },
  1102. loadColor_Read : function(){
  1103. if( !this.colorItem )return;
  1104. var div = new Element("div", {
  1105. styles : this.css.colorNode
  1106. }).inject( this.colorItem );
  1107. div.setStyle("background-color",this.data.color);
  1108. div.setStyles( this.css.colorNode_current );
  1109. },
  1110. loadColor_Edited : function(){
  1111. if( !this.colorItem )return;
  1112. this.colorOptions = [];
  1113. MWFCalendar.ColorOptions.deep.each( function( color , i){
  1114. var div = new Element("div", {
  1115. styles : this.css.colorNode,
  1116. events : {
  1117. click : function(ev){
  1118. if(this.currentColorNode)this.currentColorNode.setStyles( this.css.colorNode );
  1119. ev.target.setStyles( this.css.colorNode_current );
  1120. this.currentColorNode = ev.target;
  1121. }.bind(this)
  1122. }
  1123. }).inject( this.colorItem );
  1124. div.setStyle("background-color",color);
  1125. div.store("color",color);
  1126. if( this.data.color ){
  1127. if( this.data.color == color ){
  1128. div.setStyles( this.css.colorNode_current );
  1129. this.currentColorNode = div;
  1130. }
  1131. }else if(i==0){
  1132. div.setStyles( this.css.colorNode_current );
  1133. this.currentColorNode = div;
  1134. }
  1135. this.colorOptions.push( div )
  1136. }.bind(this))
  1137. },
  1138. _createBottomContent : function(){
  1139. var html = "<div style='width:700px;margin:0px auto;'><table width='700' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  1140. "<tr><td styles='formTableValue' width='100'></td>" +
  1141. " <td styles='formTableValue' style='padding-top: 15px;'>"+
  1142. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  1143. " <div item='editAction' style='float:left;display:"+ ( this.editEnable ? "" : "none") +";'></div>"+
  1144. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  1145. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew || this.editEnable) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  1146. " </td></tr>" +
  1147. "</table></div>";
  1148. this.formBottomNode.set("html", html);
  1149. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1150. var form = new MForm(this.formBottomNode, {}, {
  1151. isEdited: this.isEdited || this.isNew,
  1152. style : "meeting",
  1153. hasColon : true,
  1154. itemTemplate: {
  1155. saveAction : { type : "button", className : "inputOkButton", value : this.lp.save, event : {
  1156. click : function(){ this.ok();}.bind(this)
  1157. } },
  1158. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.deleteCalendar , event : {
  1159. click : function( item, ev ){ this.deleteCalendar(ev); }.bind(this)
  1160. } },
  1161. editAction : { type : "button", className : "inputOkButton", value : this.lp.editCalendar , event : {
  1162. click : function(){ this.editCalendar(); }.bind(this)
  1163. } },
  1164. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  1165. click : function(){ this.close(); }.bind(this)
  1166. } }
  1167. }
  1168. }, this.app);
  1169. form.load();
  1170. }.bind(this), true);
  1171. },
  1172. deleteCalendar : function(){
  1173. },
  1174. editCalendar : function(){
  1175. this.formTopNode = null;
  1176. if(this.setFormNodeSizeFun && this.app && this.app.removeEvent ){
  1177. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1178. }
  1179. if( this.formMaskNode )this.formMaskNode.destroy();
  1180. this.formAreaNode.destroy();
  1181. this.edit();
  1182. },
  1183. reset: function(){
  1184. this.formTableArea.empty();
  1185. this._createTableContent();
  1186. },
  1187. _ok : function( data, callback ){
  1188. if( data.type == "UNIT" ){
  1189. var viewerItem = this.form.getItem("viewerList").dom;
  1190. data.viewablePersonList = viewerItem.getValueByType("person");
  1191. data.viewableUnitList = viewerItem.getValueByType("unit");
  1192. data.viewableGroupList = viewerItem.getValueByType("group");
  1193. var publisherItem = this.form.getItem("publisherList").dom;
  1194. data.publishablePersonList = publisherItem.getValueByType("person");
  1195. data.publishableUnitList = publisherItem.getValueByType("unit");
  1196. data.publishableGroupList = publisherItem.getValueByType("group");
  1197. data.target = data.target.join("");
  1198. }else{
  1199. data.target = this.userName;
  1200. ["manageablePersonList","viewablePersonList","publishablePersonList"].each( function( name ){
  1201. data[name] = [ this.userName ];
  1202. }.bind(this));
  1203. ["viewableUnitList","viewableGroupList","publishableUnitList","publishableGroupList"].each( function( name ){
  1204. data[name] = [];
  1205. });
  1206. }
  1207. if( this.currentColorNode ){
  1208. data.color = this.currentColorNode.retrieve("color");
  1209. }else{
  1210. data.color = MWFCalendar.ColorOptions.deep[0];
  1211. }
  1212. delete data.viewerList;
  1213. delete data.publisherList;
  1214. this.app.actions.saveCalendar(data, function(json){
  1215. if( this.view )this.view.reload();
  1216. callback(json);
  1217. }.bind(this));
  1218. },
  1219. close: function (e) {
  1220. this.fireEvent("queryClose");
  1221. this._close();
  1222. //if( this.form ){
  1223. // this.form.destroy();
  1224. //}
  1225. if(this.setFormNodeSizeFun && this.app && this.app.removeEvent){
  1226. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1227. }
  1228. if( this.formMaskNode )this.formMaskNode.destroy();
  1229. this.formAreaNode.destroy();
  1230. this.fireEvent("postClose");
  1231. if( this.waitReload )this.view.reload();
  1232. delete this;
  1233. }
  1234. });
  1235. MWFCalendar.SaveOptionDialog = new Class({
  1236. Extends: MPopupForm,
  1237. Implements: [Options, Events],
  1238. options: {
  1239. "style": "meeting",
  1240. "width": "470",
  1241. "height": "325",
  1242. "hasTop": true,
  1243. "hasIcon": false,
  1244. "hasTopIcon" : false,
  1245. "hasTopContent" : false,
  1246. "draggable": true,
  1247. //"maxAction" : true,
  1248. "closeAction": true,
  1249. "title" : "修改重复日程"
  1250. },
  1251. _createTableContent : function(){
  1252. this.formTableContainer.setStyles({
  1253. "width" : "auto",
  1254. "padding-top" : "20px",
  1255. "padding-left" : "40px"
  1256. });
  1257. this.lp = { ok : "确定修改", cancel : "取消" };
  1258. var html = "<table width='80%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1259. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  1260. "<tr><td styles='formTableTitle' lable='saveOption'></td>" +
  1261. "<tr><td styles='formTableValue' item='saveOption'></td></tr>" +
  1262. "</table>";
  1263. this.formTableArea.set("html", html);
  1264. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1265. this.form = new MForm(this.formTableArea, {empName: "xadmin"}, {
  1266. style : "meeting",
  1267. isEdited: this.isEdited || this.isNew,
  1268. itemTemplate: {
  1269. saveOption: {
  1270. defaultValue : "single",
  1271. text: "请选择您要修改日程的类型",
  1272. type: "radio",
  1273. selectText: ["只修改当前日程", "修改当前日程和之后的此重复日程","修改所有此重复日程"],
  1274. selectValue: ["single", "after", "all"]
  1275. }
  1276. }
  1277. }, this.app);
  1278. this.form.load();
  1279. }.bind(this), true);
  1280. },
  1281. ok: function (e) {
  1282. this.fireEvent("queryOk");
  1283. var data = this.form.getResult(true, this.options.resultSeparator, true, false, true);
  1284. if (data) {
  1285. if( this.formMaskNode )this.formMaskNode.destroy();
  1286. this.formAreaNode.destroy();
  1287. this.fireEvent("postOk", data.saveOption );
  1288. }
  1289. }
  1290. });
  1291. MWFCalendar.DeleteOptionDialog = new Class({
  1292. Extends: MPopupForm,
  1293. Implements: [Options, Events],
  1294. options: {
  1295. "style": "meeting",
  1296. "width": "470",
  1297. "height": "325",
  1298. "hasTop": true,
  1299. "hasIcon": false,
  1300. "hasTopIcon" : false,
  1301. "hasTopContent" : false,
  1302. "draggable": true,
  1303. //"maxAction" : true,
  1304. "closeAction": true,
  1305. "title" : "删除重复日程"
  1306. },
  1307. _createTableContent : function(){
  1308. this.formTableContainer.setStyles({
  1309. "width" : "auto",
  1310. "padding-top" : "20px",
  1311. "padding-left" : "40px"
  1312. });
  1313. this.lp = { ok : "确定删除", cancel : "取消" };
  1314. var html = "<table width='80%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1315. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  1316. "<tr><td styles='formTableTitle' lable='saveOption'></td>" +
  1317. "<tr><td styles='formTableValue' item='saveOption'></td></tr>" +
  1318. "</table>";
  1319. this.formTableArea.set("html", html);
  1320. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1321. this.form = new MForm(this.formTableArea, {empName: "xadmin"}, {
  1322. isEdited: this.isEdited || this.isNew,
  1323. style : "meeting",
  1324. itemTemplate: {
  1325. saveOption: {
  1326. defaultValue : "single",
  1327. text: "请选择您要删除日程的类型",
  1328. type: "radio",
  1329. selectText: ["只删除当前日程", "删除当前日程和之后的此重复日程","删除所有此重复日程"],
  1330. selectValue: ["single", "after", "all"]
  1331. }
  1332. }
  1333. }, this.app);
  1334. this.form.load();
  1335. }.bind(this), true);
  1336. },
  1337. ok: function (e) {
  1338. this.fireEvent("queryOk");
  1339. var data = this.form.getResult(true, this.options.resultSeparator, true, false, true);
  1340. if (data) {
  1341. if( this.formMaskNode )this.formMaskNode.destroy();
  1342. this.formAreaNode.destroy();
  1343. this.fireEvent("postOk", data.saveOption );
  1344. }
  1345. }
  1346. });
  1347. MWFCalendar.EventTooltip = new Class({
  1348. Extends: MTooltips,
  1349. options : {
  1350. displayDelay : 300
  1351. },
  1352. _loadCustom : function( callback ){
  1353. this.loadAttachment();
  1354. this.loadButton();
  1355. if(callback)callback();
  1356. },
  1357. _getHtml : function(){
  1358. var data = this.data;
  1359. var titleStyle = "font-size:14px;color:#333";
  1360. var valueStyle = "font-size:14px;color:#666;padding-right:10px";
  1361. var beginD = Date.parse(this.data.startTime);
  1362. var endD = Date.parse(this.data.endTime);
  1363. var begin = beginD.format(this.lp.dateFormatAll) + "(" + this.lp.weeks.arr[beginD.get("day")] + ")";
  1364. var end = endD.format(this.lp.dateFormatAll) + "(" + this.lp.weeks.arr[endD.get("day")] + ")";
  1365. var html =
  1366. "<div style='font-size: 16px;color:#333;padding:10px 10px 10px 20px;'>"+ data.title +"</div>"+
  1367. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1368. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1369. "<tr><td style='"+titleStyle+";' width='40'>开始:</td>" +
  1370. " <td style='"+valueStyle+"'>" + begin + "</td></tr>" +
  1371. "<tr><td style='"+titleStyle+"'>结束:</td>" +
  1372. " <td style='"+valueStyle+ "'>"+ end +"</td></tr>" +
  1373. "<tr><td style='"+titleStyle+"'>"+this.lp.locationName+":</td>" +
  1374. " <td style='"+valueStyle+ "'>"+ (this.data.locationName||"") +"</td></tr>" +
  1375. //( this.options.isHideAttachment ? "" :
  1376. //"<tr><td style='"+titleStyle+"'>"+this.lp.eventAttachment+":</td>" +
  1377. //" <td style='"+valueStyle+"' item='attachment'></td></tr>"+
  1378. //)+
  1379. "<tr><td style='"+titleStyle+"'></td>" +
  1380. " <td style='"+valueStyle+ "' item='seeMore'></td></tr>"+
  1381. "</table>";
  1382. return html;
  1383. },
  1384. destroy: function(){
  1385. if( this.node ){
  1386. this.node.destroy();
  1387. this.node = null;
  1388. }
  1389. },
  1390. loadButton : function(){
  1391. var area = this.node.getElement("[item='seeMore']");
  1392. new Element("div",{
  1393. styles : {
  1394. "background-color" : "#3c75b7",
  1395. "height" : "28px",
  1396. "line-height" : "28px",
  1397. "border-radius" : "5px",
  1398. "width" : "80px",
  1399. "text-align" : "center",
  1400. "font-size" : "12px",
  1401. "cursor" : "pointer",
  1402. "color" : "#fff"
  1403. },
  1404. events : { click : function() {
  1405. var form = new MWFCalendar.EventForm(this, this.data, {
  1406. isFull : true
  1407. }, {app:this.app});
  1408. form.view = this.view;
  1409. form.edit();
  1410. this.hide();
  1411. }.bind(this)},
  1412. text : "查看更多"
  1413. }).inject(area);
  1414. },
  1415. loadAttachment: function(){
  1416. if( this.options.isHideAttachment )return;
  1417. if( typeOf(this.data.attachmentList)=="array" && this.data.attachmentList[0] ){
  1418. var area = this.node.getElement("[item='attachment']");
  1419. this.attachmentNode = new Element("div"
  1420. //{"styles": this.css.createCalendarAttachmentNode}
  1421. ).inject(area);
  1422. var attachmentContentNode = new Element("div", {
  1423. //"styles": this.css.createCalendarAttachmentContentNode
  1424. }).inject(this.attachmentNode);
  1425. this.attachmentController = new MWFCalendar.EventTooltip.AttachmentController(attachmentContentNode, this, {
  1426. "size": "min",
  1427. "isSizeChange": false,
  1428. "isReplace": false,
  1429. "isUpload": false,
  1430. "isDelete": false,
  1431. "isDownload": true,
  1432. "readonly": true
  1433. });
  1434. this.attachmentController.load();
  1435. this.data.attachmentList.each(function (att) {
  1436. att.person = att.lastUpdatePerson.split("@")[0];
  1437. var at = this.attachmentController.addAttachment(att);
  1438. }.bind(this));
  1439. }
  1440. },
  1441. downloadAttachment: function(e, node, attachments){
  1442. attachments.each(function(att){
  1443. this.app.actions.getFileDownload(att.data.id);
  1444. }.bind(this));
  1445. },
  1446. openAttachment: function(e, node, attachments){
  1447. attachments.each(function(att){
  1448. this.app.actions.getFile(att.data.id);
  1449. }.bind(this));
  1450. },
  1451. getAttachmentUrl: function(attachment, callback){
  1452. this.app.actions.getFileUrl(attachment.data.id, callback);
  1453. }
  1454. });
  1455. MWFCalendar.EventTooltip.AttachmentController = new Class({
  1456. Extends : MWF.widget.AttachmentController,
  1457. loadMin: function(){
  1458. if (!this.node) this.node = new Element("div", {"styles": this.css.container_min});
  1459. if (!this.minActionAreaNode){
  1460. //this.minActionAreaNode = new Element("div", {"styles": this.css.minActionAreaNode}).inject(this.node);
  1461. this.minContent = new Element("div", {"styles": this.css.minContentNode}).inject(this.node);
  1462. this.minContent.setStyles({
  1463. "margin-right" : "0px"
  1464. });
  1465. //this.min_downloadAction = this.createAction(this.minActionAreaNode, "download", MWF.LP.widget.download, function(e, node){
  1466. // this.downloadAttachment(e, node);
  1467. //}.bind(this));
  1468. this.node.inject(this.container);
  1469. //if (this.options.readonly) this.setReadonly();
  1470. this.checkActions();
  1471. this.setEvent();
  1472. }else{
  1473. //this.minActionAreaNode.setStyle("display", "block");
  1474. this.minContent.setStyle("display", "block");
  1475. this.minContent.empty();
  1476. }
  1477. var atts = [];
  1478. while (this.attachments.length){
  1479. var att = this.attachments.shift();
  1480. atts.push(new MWFCalendar.EventTooltip.AttachmentMin(att.data, this));
  1481. }
  1482. this.attachments = atts;
  1483. },
  1484. addAttachment: function(data){
  1485. if (this.options.size=="min"){
  1486. this.attachments.push(new MWFCalendar.EventTooltip.AttachmentMin(data, this));
  1487. }else{
  1488. this.attachments.push(new MWF.widget.AttachmentController.Attachment(data, this));
  1489. }
  1490. }
  1491. });
  1492. MWFCalendar.EventTooltip.AttachmentMin = new Class({
  1493. Extends : MWF.widget.AttachmentController.AttachmentMin,
  1494. setEvent: function(){
  1495. this.node.addEvents({
  1496. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list_over"])}.bind(this),
  1497. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list"])}.bind(this),
  1498. "mousedown": function(e){this.selected(e);}.bind(this),
  1499. "click": function(e){this.downloadAttachment(e);}.bind(this)
  1500. });
  1501. },
  1502. downloadAttachment: function(e){
  1503. if (this.controller.module) this.controller.module.downloadAttachment(e, null, [this]);
  1504. }
  1505. });