Common.js 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587
  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. var form = new MWFCalendar.EventForm(this, this.data, {
  1411. isFull : true
  1412. }, {app:this.app});
  1413. form.view = this.view;
  1414. form.edit();
  1415. this.hide();
  1416. }.bind(this)},
  1417. text : "查看更多"
  1418. }).inject(area);
  1419. },
  1420. loadAttachment: function(){
  1421. if( this.options.isHideAttachment )return;
  1422. if( typeOf(this.data.attachmentList)=="array" && this.data.attachmentList[0] ){
  1423. var area = this.node.getElement("[item='attachment']");
  1424. this.attachmentNode = new Element("div"
  1425. //{"styles": this.css.createCalendarAttachmentNode}
  1426. ).inject(area);
  1427. var attachmentContentNode = new Element("div", {
  1428. //"styles": this.css.createCalendarAttachmentContentNode
  1429. }).inject(this.attachmentNode);
  1430. this.attachmentController = new MWFCalendar.EventTooltip.AttachmentController(attachmentContentNode, this, {
  1431. "size": "min",
  1432. "isSizeChange": false,
  1433. "isReplace": false,
  1434. "isUpload": false,
  1435. "isDelete": false,
  1436. "isDownload": true,
  1437. "readonly": true
  1438. });
  1439. this.attachmentController.load();
  1440. this.data.attachmentList.each(function (att) {
  1441. att.person = att.lastUpdatePerson.split("@")[0];
  1442. var at = this.attachmentController.addAttachment(att);
  1443. }.bind(this));
  1444. }
  1445. },
  1446. downloadAttachment: function(e, node, attachments){
  1447. attachments.each(function(att){
  1448. this.app.actions.getFileDownload(att.data.id);
  1449. }.bind(this));
  1450. },
  1451. openAttachment: function(e, node, attachments){
  1452. attachments.each(function(att){
  1453. this.app.actions.getFile(att.data.id);
  1454. }.bind(this));
  1455. },
  1456. getAttachmentUrl: function(attachment, callback){
  1457. this.app.actions.getFileUrl(attachment.data.id, callback);
  1458. }
  1459. });
  1460. MWFCalendar.EventTooltip.AttachmentController = new Class({
  1461. Extends : MWF.widget.AttachmentController,
  1462. loadMin: function(){
  1463. if (!this.node) this.node = new Element("div", {"styles": this.css.container_min});
  1464. if (!this.minActionAreaNode){
  1465. //this.minActionAreaNode = new Element("div", {"styles": this.css.minActionAreaNode}).inject(this.node);
  1466. this.minContent = new Element("div", {"styles": this.css.minContentNode}).inject(this.node);
  1467. this.minContent.setStyles({
  1468. "margin-right" : "0px"
  1469. });
  1470. //this.min_downloadAction = this.createAction(this.minActionAreaNode, "download", MWF.LP.widget.download, function(e, node){
  1471. // this.downloadAttachment(e, node);
  1472. //}.bind(this));
  1473. this.node.inject(this.container);
  1474. //if (this.options.readonly) this.setReadonly();
  1475. this.checkActions();
  1476. this.setEvent();
  1477. }else{
  1478. //this.minActionAreaNode.setStyle("display", "block");
  1479. this.minContent.setStyle("display", "block");
  1480. this.minContent.empty();
  1481. }
  1482. var atts = [];
  1483. while (this.attachments.length){
  1484. var att = this.attachments.shift();
  1485. atts.push(new MWFCalendar.EventTooltip.AttachmentMin(att.data, this));
  1486. }
  1487. this.attachments = atts;
  1488. },
  1489. addAttachment: function(data){
  1490. if (this.options.size=="min"){
  1491. this.attachments.push(new MWFCalendar.EventTooltip.AttachmentMin(data, this));
  1492. }else{
  1493. this.attachments.push(new MWF.widget.AttachmentController.Attachment(data, this));
  1494. }
  1495. }
  1496. });
  1497. MWFCalendar.EventTooltip.AttachmentMin = new Class({
  1498. Extends : MWF.widget.AttachmentController.AttachmentMin,
  1499. setEvent: function(){
  1500. this.node.addEvents({
  1501. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list_over"])}.bind(this),
  1502. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list"])}.bind(this),
  1503. "mousedown": function(e){this.selected(e);}.bind(this),
  1504. "click": function(e){this.downloadAttachment(e);}.bind(this)
  1505. });
  1506. },
  1507. downloadAttachment: function(e){
  1508. if (this.controller.module) this.controller.module.downloadAttachment(e, null, [this]);
  1509. }
  1510. });