Common.js 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602
  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( e ){
  1182. var _self = this;
  1183. _self.app.confirm("warn", e, "删除确认", "删除后无法恢复,确定要删除“"+ _self.data.name +"”?", 300, 120, function(){
  1184. _self.app.actions.deleteCalendar( _self.data.id, function( json ){
  1185. _self.close();
  1186. _self.app.notice("删除成功");
  1187. _self.app.leftNavi.reload();
  1188. }.bind(this));
  1189. this.close();
  1190. }, function(){
  1191. this.close();
  1192. }, null);
  1193. },
  1194. editCalendar : function(){
  1195. this.formTopNode = null;
  1196. if(this.setFormNodeSizeFun && this.app && this.app.removeEvent ){
  1197. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1198. }
  1199. if( this.formMaskNode )this.formMaskNode.destroy();
  1200. this.formAreaNode.destroy();
  1201. this.edit();
  1202. },
  1203. reset: function(){
  1204. this.formTableArea.empty();
  1205. this._createTableContent();
  1206. },
  1207. _ok : function( data, callback ){
  1208. if( data.type == "UNIT" ){
  1209. var viewerItem = this.form.getItem("viewerList").dom;
  1210. data.viewablePersonList = viewerItem.getValueByType("person");
  1211. data.viewableUnitList = viewerItem.getValueByType("unit");
  1212. data.viewableGroupList = viewerItem.getValueByType("group");
  1213. var publisherItem = this.form.getItem("publisherList").dom;
  1214. data.publishablePersonList = publisherItem.getValueByType("person");
  1215. data.publishableUnitList = publisherItem.getValueByType("unit");
  1216. data.publishableGroupList = publisherItem.getValueByType("group");
  1217. data.target = data.target.join("");
  1218. }else{
  1219. data.target = this.userName;
  1220. ["manageablePersonList","viewablePersonList","publishablePersonList"].each( function( name ){
  1221. data[name] = [ this.userName ];
  1222. }.bind(this));
  1223. ["viewableUnitList","viewableGroupList","publishableUnitList","publishableGroupList"].each( function( name ){
  1224. data[name] = [];
  1225. });
  1226. }
  1227. if( this.currentColorNode ){
  1228. data.color = this.currentColorNode.retrieve("color");
  1229. }else{
  1230. data.color = MWFCalendar.ColorOptions.deep[0];
  1231. }
  1232. delete data.viewerList;
  1233. delete data.publisherList;
  1234. this.app.actions.saveCalendar(data, function(json){
  1235. if( this.view )this.view.reload();
  1236. callback(json);
  1237. }.bind(this));
  1238. },
  1239. close: function (e) {
  1240. this.fireEvent("queryClose");
  1241. this._close();
  1242. //if( this.form ){
  1243. // this.form.destroy();
  1244. //}
  1245. if(this.setFormNodeSizeFun && this.app && this.app.removeEvent){
  1246. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1247. }
  1248. if( this.formMaskNode )this.formMaskNode.destroy();
  1249. this.formAreaNode.destroy();
  1250. this.fireEvent("postClose");
  1251. if( this.waitReload && this.view)this.view.reload();
  1252. delete this;
  1253. }
  1254. });
  1255. MWFCalendar.SaveOptionDialog = new Class({
  1256. Extends: MPopupForm,
  1257. Implements: [Options, Events],
  1258. options: {
  1259. "style": "meeting",
  1260. "width": "470",
  1261. "height": "325",
  1262. "hasTop": true,
  1263. "hasIcon": false,
  1264. "hasTopIcon" : false,
  1265. "hasTopContent" : false,
  1266. "draggable": true,
  1267. //"maxAction" : true,
  1268. "closeAction": true,
  1269. "title" : "修改重复日程"
  1270. },
  1271. _createTableContent : function(){
  1272. this.formTableContainer.setStyles({
  1273. "width" : "auto",
  1274. "padding-top" : "20px",
  1275. "padding-left" : "40px"
  1276. });
  1277. this.lp = { ok : "确定修改", cancel : "取消" };
  1278. var html = "<table width='80%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1279. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  1280. "<tr><td styles='formTableTitle' lable='saveOption'></td>" +
  1281. "<tr><td styles='formTableValue' item='saveOption'></td></tr>" +
  1282. "</table>";
  1283. this.formTableArea.set("html", html);
  1284. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1285. this.form = new MForm(this.formTableArea, {empName: "xadmin"}, {
  1286. style : "meeting",
  1287. isEdited: this.isEdited || this.isNew,
  1288. itemTemplate: {
  1289. saveOption: {
  1290. defaultValue : "single",
  1291. text: "请选择您要修改日程的类型",
  1292. type: "radio",
  1293. selectText: ["只修改当前日程", "修改当前日程和之后的此重复日程","修改所有此重复日程"],
  1294. selectValue: ["single", "after", "all"]
  1295. }
  1296. }
  1297. }, this.app);
  1298. this.form.load();
  1299. }.bind(this), true);
  1300. },
  1301. ok: function (e) {
  1302. this.fireEvent("queryOk");
  1303. var data = this.form.getResult(true, this.options.resultSeparator, true, false, true);
  1304. if (data) {
  1305. if( this.formMaskNode )this.formMaskNode.destroy();
  1306. this.formAreaNode.destroy();
  1307. this.fireEvent("postOk", data.saveOption );
  1308. }
  1309. }
  1310. });
  1311. MWFCalendar.DeleteOptionDialog = new Class({
  1312. Extends: MPopupForm,
  1313. Implements: [Options, Events],
  1314. options: {
  1315. "style": "meeting",
  1316. "width": "470",
  1317. "height": "325",
  1318. "hasTop": true,
  1319. "hasIcon": false,
  1320. "hasTopIcon" : false,
  1321. "hasTopContent" : false,
  1322. "draggable": true,
  1323. //"maxAction" : true,
  1324. "closeAction": true,
  1325. "title" : "删除重复日程"
  1326. },
  1327. _createTableContent : function(){
  1328. this.formTableContainer.setStyles({
  1329. "width" : "auto",
  1330. "padding-top" : "20px",
  1331. "padding-left" : "40px"
  1332. });
  1333. this.lp = { ok : "确定删除", cancel : "取消" };
  1334. var html = "<table width='80%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1335. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  1336. "<tr><td styles='formTableTitle' lable='saveOption'></td>" +
  1337. "<tr><td styles='formTableValue' item='saveOption'></td></tr>" +
  1338. "</table>";
  1339. this.formTableArea.set("html", html);
  1340. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1341. this.form = new MForm(this.formTableArea, {empName: "xadmin"}, {
  1342. isEdited: this.isEdited || this.isNew,
  1343. style : "meeting",
  1344. itemTemplate: {
  1345. saveOption: {
  1346. defaultValue : "single",
  1347. text: "请选择您要删除日程的类型",
  1348. type: "radio",
  1349. selectText: ["只删除当前日程", "删除当前日程和之后的此重复日程","删除所有此重复日程"],
  1350. selectValue: ["single", "after", "all"]
  1351. }
  1352. }
  1353. }, this.app);
  1354. this.form.load();
  1355. }.bind(this), true);
  1356. },
  1357. ok: function (e) {
  1358. this.fireEvent("queryOk");
  1359. var data = this.form.getResult(true, this.options.resultSeparator, true, false, true);
  1360. if (data) {
  1361. if( this.formMaskNode )this.formMaskNode.destroy();
  1362. this.formAreaNode.destroy();
  1363. this.fireEvent("postOk", data.saveOption );
  1364. }
  1365. }
  1366. });
  1367. MWFCalendar.EventTooltip = new Class({
  1368. Extends: MTooltips,
  1369. options : {
  1370. displayDelay : 300
  1371. },
  1372. _loadCustom : function( callback ){
  1373. this.loadAttachment();
  1374. this.loadButton();
  1375. if(callback)callback();
  1376. },
  1377. _getHtml : function(){
  1378. var data = this.data;
  1379. var titleStyle = "font-size:14px;color:#333";
  1380. var valueStyle = "font-size:14px;color:#666;padding-right:10px";
  1381. var beginD = Date.parse(this.data.startTime);
  1382. var endD = Date.parse(this.data.endTime);
  1383. var begin = beginD.format(this.lp.dateFormatAll) + "(" + this.lp.weeks.arr[beginD.get("day")] + ")";
  1384. var end = endD.format(this.lp.dateFormatAll) + "(" + this.lp.weeks.arr[endD.get("day")] + ")";
  1385. var html =
  1386. "<div style='font-size: 16px;color:#333;padding:10px 10px 10px 20px;'>"+ data.title +"</div>"+
  1387. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1388. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1389. "<tr><td style='"+titleStyle+";' width='40'>开始:</td>" +
  1390. " <td style='"+valueStyle+"'>" + begin + "</td></tr>" +
  1391. "<tr><td style='"+titleStyle+"'>结束:</td>" +
  1392. " <td style='"+valueStyle+ "'>"+ end +"</td></tr>" +
  1393. "<tr><td style='"+titleStyle+"'>"+this.lp.locationName+":</td>" +
  1394. " <td style='"+valueStyle+ "'>"+ (this.data.locationName||"") +"</td></tr>" +
  1395. //( this.options.isHideAttachment ? "" :
  1396. //"<tr><td style='"+titleStyle+"'>"+this.lp.eventAttachment+":</td>" +
  1397. //" <td style='"+valueStyle+"' item='attachment'></td></tr>"+
  1398. //)+
  1399. "<tr><td style='"+titleStyle+"'></td>" +
  1400. " <td style='"+valueStyle+ "' item='seeMore'></td></tr>"+
  1401. "</table>";
  1402. return html;
  1403. },
  1404. destroy: function(){
  1405. if( this.node ){
  1406. this.node.destroy();
  1407. this.node = null;
  1408. }
  1409. },
  1410. loadButton : function(){
  1411. var area = this.node.getElement("[item='seeMore']");
  1412. new Element("div",{
  1413. styles : {
  1414. "background-color" : "#3c75b7",
  1415. "height" : "28px",
  1416. "line-height" : "28px",
  1417. "border-radius" : "5px",
  1418. "width" : "80px",
  1419. "text-align" : "center",
  1420. "font-size" : "12px",
  1421. "cursor" : "pointer",
  1422. "color" : "#fff"
  1423. },
  1424. events : { click : function() {
  1425. debugger;
  1426. var form = new MWFCalendar.EventForm(this, this.data, {
  1427. isFull : true
  1428. }, {app:this.app});
  1429. form.view = this.view;
  1430. form.edit();
  1431. this.hide();
  1432. }.bind(this)},
  1433. text : "查看更多"
  1434. }).inject(area);
  1435. },
  1436. loadAttachment: function(){
  1437. if( this.options.isHideAttachment )return;
  1438. if( typeOf(this.data.attachmentList)=="array" && this.data.attachmentList[0] ){
  1439. var area = this.node.getElement("[item='attachment']");
  1440. this.attachmentNode = new Element("div"
  1441. //{"styles": this.css.createCalendarAttachmentNode}
  1442. ).inject(area);
  1443. var attachmentContentNode = new Element("div", {
  1444. //"styles": this.css.createCalendarAttachmentContentNode
  1445. }).inject(this.attachmentNode);
  1446. this.attachmentController = new MWFCalendar.EventTooltip.AttachmentController(attachmentContentNode, this, {
  1447. "size": "min",
  1448. "isSizeChange": false,
  1449. "isReplace": false,
  1450. "isUpload": false,
  1451. "isDelete": false,
  1452. "isDownload": true,
  1453. "readonly": true
  1454. });
  1455. this.attachmentController.load();
  1456. this.data.attachmentList.each(function (att) {
  1457. att.person = att.lastUpdatePerson.split("@")[0];
  1458. var at = this.attachmentController.addAttachment(att);
  1459. }.bind(this));
  1460. }
  1461. },
  1462. downloadAttachment: function(e, node, attachments){
  1463. attachments.each(function(att){
  1464. this.app.actions.getFileDownload(att.data.id);
  1465. }.bind(this));
  1466. },
  1467. openAttachment: function(e, node, attachments){
  1468. attachments.each(function(att){
  1469. this.app.actions.getFile(att.data.id);
  1470. }.bind(this));
  1471. },
  1472. getAttachmentUrl: function(attachment, callback){
  1473. this.app.actions.getFileUrl(attachment.data.id, callback);
  1474. }
  1475. });
  1476. MWFCalendar.EventTooltip.AttachmentController = new Class({
  1477. Extends : MWF.widget.AttachmentController,
  1478. loadMin: function(){
  1479. if (!this.node) this.node = new Element("div", {"styles": this.css.container_min});
  1480. if (!this.minActionAreaNode){
  1481. //this.minActionAreaNode = new Element("div", {"styles": this.css.minActionAreaNode}).inject(this.node);
  1482. this.minContent = new Element("div", {"styles": this.css.minContentNode}).inject(this.node);
  1483. this.minContent.setStyles({
  1484. "margin-right" : "0px"
  1485. });
  1486. //this.min_downloadAction = this.createAction(this.minActionAreaNode, "download", MWF.LP.widget.download, function(e, node){
  1487. // this.downloadAttachment(e, node);
  1488. //}.bind(this));
  1489. this.node.inject(this.container);
  1490. //if (this.options.readonly) this.setReadonly();
  1491. this.checkActions();
  1492. this.setEvent();
  1493. }else{
  1494. //this.minActionAreaNode.setStyle("display", "block");
  1495. this.minContent.setStyle("display", "block");
  1496. this.minContent.empty();
  1497. }
  1498. var atts = [];
  1499. while (this.attachments.length){
  1500. var att = this.attachments.shift();
  1501. atts.push(new MWFCalendar.EventTooltip.AttachmentMin(att.data, this));
  1502. }
  1503. this.attachments = atts;
  1504. },
  1505. addAttachment: function(data){
  1506. if (this.options.size=="min"){
  1507. this.attachments.push(new MWFCalendar.EventTooltip.AttachmentMin(data, this));
  1508. }else{
  1509. this.attachments.push(new MWF.widget.AttachmentController.Attachment(data, this));
  1510. }
  1511. }
  1512. });
  1513. MWFCalendar.EventTooltip.AttachmentMin = new Class({
  1514. Extends : MWF.widget.AttachmentController.AttachmentMin,
  1515. setEvent: function(){
  1516. this.node.addEvents({
  1517. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list_over"])}.bind(this),
  1518. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list"])}.bind(this),
  1519. "mousedown": function(e){this.selected(e);}.bind(this),
  1520. "click": function(e){this.downloadAttachment(e);}.bind(this)
  1521. });
  1522. },
  1523. downloadAttachment: function(e){
  1524. if (this.controller.module) this.controller.module.downloadAttachment(e, null, [this]);
  1525. }
  1526. });