Common.js 70 KB

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