Common.js 70 KB

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