Common.js 98 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326
  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. MWF.xApplication.Meeting = MWF.xApplication.Meeting || {};
  7. MWF.xApplication.Meeting.BuildingForm = new Class({
  8. Extends: MPopupForm,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "meeting",
  12. "width": "800",
  13. "height": "300",
  14. "hasTop": true,
  15. "hasIcon": false,
  16. "hasTopIcon" : false,
  17. "hasTopContent" : false,
  18. "hasBottom": false,
  19. "draggable": true,
  20. "closeAction": true
  21. },
  22. _createTableContent: function () {
  23. this.formTopTextNode.set( "text", this.lp.editBuilding );
  24. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  25. "<tr><td styles='formTableTitle' lable='name'></td>" +
  26. " <td styles='formTableValue' item='name' colspan='3' ></td></tr>" +
  27. "<tr><td styles='formTableTitle' lable='address'></td>" +
  28. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  29. "<tr><td styles='formTableTitle'></td>" +
  30. " <td styles='formTableValue' colspan='3' style='padding-top: 30px;'>"+
  31. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  32. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  33. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew ) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  34. " </td></tr>" +
  35. "</table>";
  36. this.formTableArea.set("html", html);
  37. MWF.xDesktop.requireApp("Template", "MForm", function () {
  38. this.form = new MForm(this.formTableArea, this.data, {
  39. isEdited: this.isEdited || this.isNew,
  40. style : "meeting",
  41. itemTemplate: {
  42. name: { text : this.lp.name, notEmpty : true },
  43. address: { text : this.lp.address },
  44. saveAction : { type : "button", className : "inputOkButton", value : this.lp.save, event : {
  45. click : function(){ this.save();}.bind(this)
  46. } },
  47. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.delete , event : {
  48. click : function( item, ev ){ this.removeBuilding(ev); }.bind(this)
  49. } },
  50. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  51. click : function(){ this.close(); }.bind(this)
  52. } }
  53. }
  54. }, this.app);
  55. this.form.load();
  56. }.bind(this), true);
  57. },
  58. save: function(){
  59. var data = this.form.getResult(true,null,true,false,true);
  60. this.actions.saveBuilding( data, function(json){
  61. this.app.notice(this.lp.save_success, "success");
  62. var view = this.view;
  63. this.fireEvent("postSave", [data]);
  64. this.close();
  65. if(view)view.reload();
  66. }.bind(this));
  67. },
  68. removeBuilding: function(e) {
  69. var info = this.app.lp.delete_building;
  70. info = info.replace(/{name}/g, this.data.name);
  71. var _self = this;
  72. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  73. _self.remove();
  74. this.close();
  75. }, function(){
  76. this.close();
  77. });
  78. },
  79. remove: function(){
  80. var view = this.view;
  81. this.app.actions.deleteBuilding(this.data.id, function(){
  82. view.reload();
  83. }.bind(this));
  84. }
  85. });
  86. MWF.xApplication.Meeting.BuildingTooltip = new Class({
  87. Extends: MTooltips,
  88. _loadCustom : function( callback ){
  89. this.loadActionBar();
  90. if(callback)callback();
  91. },
  92. _getHtml : function(){
  93. var data = this.data;
  94. var html =
  95. "<div item='containr' style='height:16px;line-height:16px;'><div style='font-size: 14px;color:#666;float:left; '>"+ (data.address ? data.address : this.lp.noAddress) +"</div></div>";
  96. return html;
  97. },
  98. loadActionBar : function(){
  99. if( MWF.AC.isMeetingAdministrator() ){
  100. //this.actionBar = new Element("div", {
  101. // "styles": this.css.actionBar
  102. //}).inject(this.node);
  103. var container = this.node.getElement("[item='containr']");
  104. this.editAction = new Element("div", {
  105. styles: this.css.action_edit,
  106. title : this.lp.editAddress,
  107. events : {
  108. mouseover : function(){
  109. this.editAction.setStyles( this.css.action_edit_over );
  110. }.bind(this),
  111. mouseout : function(){
  112. this.editAction.setStyles( this.css.action_edit );
  113. }.bind(this),
  114. click : function(){
  115. this.editBuilding( function(data){
  116. this.node.getElement("[item='containr']").getFirst().set("text", (data.address ? data.address : this.lp.noAddress))
  117. }.bind(this))
  118. }.bind(this)
  119. }
  120. }).inject(container);
  121. this.removeAction = new Element("div", {
  122. styles: this.css.action_remove,
  123. title: this.lp.removeBuilding,
  124. events : {
  125. mouseover : function(){
  126. this.removeAction.setStyles( this.css.action_remove_over );
  127. }.bind(this),
  128. mouseout : function(){
  129. this.removeAction.setStyles( this.css.action_remove );
  130. }.bind(this),
  131. click : function( e ){
  132. this.removeBuilding(e);
  133. }.bind(this)
  134. }
  135. }).inject(container);
  136. }
  137. },
  138. editBuilding : function( save_callback ){
  139. var options = save_callback ? {
  140. "onPostSave" : save_callback
  141. } : {};
  142. var form = new MWF.xApplication.Meeting.BuildingForm(this,this.data, options, {app:this.app});
  143. form.edit();
  144. },
  145. removeBuilding: function(e) {
  146. this.app.actions.getBuilding( this.data.id, function( json ){
  147. if( json.data.roomList && json.data.roomList.length > 0 ){
  148. this.app.notice( this.app.lp.delete_building_hasRoom.replace(/{name}/g, this.data.name),"error", e.target );
  149. }else{
  150. var info = this.app.lp.delete_building;
  151. info = info.replace(/{name}/g, this.data.name);
  152. var _self = this;
  153. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  154. _self.remove();
  155. this.close();
  156. }, function(){
  157. this.close();
  158. });
  159. }
  160. }.bind(this));
  161. },
  162. remove: function(){
  163. var view = this.view;
  164. this.app.actions.deleteBuilding(this.data.id, function(){
  165. view.reload();
  166. }.bind(this));
  167. },
  168. reload : function(){
  169. this.view.reload();
  170. }
  171. });
  172. MWF.xApplication.Meeting.RoomForm = new Class({
  173. Extends: MPopupForm,
  174. Implements: [Options, Events],
  175. options: {
  176. "style": "meeting",
  177. "width": "900",
  178. "height": "500",
  179. "hasTop": true,
  180. "hasIcon": false,
  181. "hasTopIcon" : false,
  182. "hasTopContent" : false,
  183. "hasBottom": false,
  184. "draggable": true,
  185. "closeAction": true
  186. },
  187. _createTableContent: function () {
  188. if( this.isNew ){
  189. this.formTopTextNode.set( "text", this.lp.addRoom );
  190. }else if( this.isEdited ){
  191. this.formTopTextNode.set( "text", this.lp.editRoom );
  192. //this.options.height = "550";
  193. }else{
  194. this.formTopTextNode.set( "text", this.lp.room );
  195. //this.options.height = "460";
  196. }
  197. var lp = this.lp.roomForm;
  198. var editEnable = ( !this.isEdited && !this.isNew && MWF.AC.isMeetingAdministrator() );
  199. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  200. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  201. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  202. "<tr><td styles='formTableTitle'>"+ lp.name+":</td>" +
  203. " <td styles='formTableValue' item='name' colspan='3' ></td></tr>" +
  204. "<tr><td styles='formTableTitle'>"+ lp.building +":</td>" +
  205. " <td styles='formTableValue' item='buildingName' colspan='3'></td></tr>" +
  206. "<tr><td styles='formTableTitle'>"+ lp.floor +":</td>" +
  207. " <td styles='formTableValue' item='floor'></td>"+
  208. " <td styles='formTableTitle2'>"+ lp.capacity +":</td>" +
  209. " <td styles='formTableValue' item='capacity'></td></tr>" +
  210. "<tr><td styles='formTableTitle'>"+lp.roomNumber+":</td>" +
  211. " <td styles='formTableValue' item='roomNumber'></td>" +
  212. " <td styles='formTableTitle2'>"+lp.phone+":</td>" +
  213. " <td styles='formTableValue' item='phoneNumber'></td></tr>" +
  214. "<tr><td styles='formTableTitle'>"+lp.device+":</td>" +
  215. " <td styles='formTableValue' colspan='3'>" +
  216. " <div item='deviceList' style='"+ boxStyle +"'></div>" +
  217. "</td></tr>" +
  218. "<tr><td styles='formTableTitle'>"+lp.available+":</td>" +
  219. " <td styles='formTableValue' colspan='3'>" +
  220. " <div item='available' style='"+ boxStyle +"'></div>" +
  221. "</td></tr>" +
  222. "<tr><td styles='formTableTitle'></td>" +
  223. " <td styles='formTableValue' colspan='3' style='padding-top: 30px;'>"+
  224. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  225. " <div item='editAction' style='float:left;display:"+ ( editEnable ? "" : "none") +";'></div>"+
  226. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  227. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew || editEnable) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  228. " </td></tr>" +
  229. "</table>";
  230. this.formTableArea.set("html", html);
  231. var data = this.data || {};
  232. this.buildingId = data.building;
  233. if( this.buildingId ){
  234. this.getBuliding()
  235. }
  236. MWF.xDesktop.requireApp("Template", "MForm", function () {
  237. this.form = new MForm(this.formTableArea, data, {
  238. isEdited: this.isEdited || this.isNew,
  239. style : "meeting",
  240. itemTemplate: {
  241. name: { text : lp.name, notEmpty : true },
  242. buildingName: {
  243. text : lp.building, notEmpty : true,
  244. value : this.buildingName || "",
  245. event : {
  246. "click": function(){this.listBuilding();}.bind(this),
  247. //"blur": function(){}.bind(this),
  248. "change": function(){ this.buildingId = null; }.bind(this),
  249. "focus": function(){
  250. this.listBuildingHide();
  251. this.listBuilding();
  252. }.bind(this),
  253. "keydown": function(e){
  254. //if ([13,40,38].indexOf(e.code)!=-1){
  255. // if (!this.selectBuildingNode){
  256. // this.listBuilding();
  257. // }
  258. //}
  259. switch (e.code){
  260. case 13:
  261. this.listBuildingHide();
  262. this.listBuilding();
  263. break;
  264. case 40:
  265. this.selectBuildingNext();
  266. break;
  267. case 38:
  268. this.selectBuildingPrev();
  269. break;
  270. case 38:
  271. this.selectBuildingConfirm();
  272. break;
  273. default:
  274. // this.listBuildingHide();
  275. // this.listBuilding();
  276. }
  277. // if (e.code==13){
  278. // this.listBuildingHide();
  279. // this.listBuilding();
  280. // }
  281. // if (e.code==40) this.selectBuildingNext();
  282. // if (e.code==38) this.selectBuildingPrev();
  283. // if (e.code==32) this.selectBuildingConfirm(e);
  284. }.bind(this)
  285. }
  286. },
  287. floor: { type: "select", defaultValue: "1", notEmpty : true, text : lp.floor,
  288. selectText : function(){
  289. var floors = [];
  290. for (var i=-2; i<=50; i++){
  291. if( i != 0 )floors.push(i+ this.lp.floor )
  292. }
  293. return floors;
  294. }.bind(this), selectValue : function(){
  295. var floors = [];
  296. for (var i=-2; i<=50; i++){
  297. if( i != 0 )floors.push(i)
  298. }
  299. return floors;
  300. }.bind(this)
  301. },
  302. capacity: { notEmpty : true, tType: "number", text : lp.capacity },
  303. roomNumber: {},
  304. phoneNumber: {},
  305. deviceList: { type : "checkbox",
  306. value : this.data.device ? this.data.device.split("#") : "",
  307. selectValue : function(){ return Object.keys(this.lp.device); }.bind(this),
  308. selectText : function(){ return Object.values(this.lp.device); }.bind(this)
  309. },
  310. available: { type : "radio", defaultValue : "true",
  311. selectValue : [ "true", "false" ],
  312. selectText : [ this.lp.enable, this.lp.disable ]
  313. },
  314. saveAction : { type : "button", className : "inputOkButton", value : this.lp.save, event : {
  315. click : function(){ this.save();}.bind(this)
  316. } },
  317. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.delete , event : {
  318. click : function( item, ev ){ this.removeRoom(ev); }.bind(this)
  319. } },
  320. editAction : { type : "button", className : "inputOkButton", value : this.lp.editRoom , event : {
  321. click : function(){ this.editRoom(); }.bind(this)
  322. } },
  323. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  324. click : function(){ this.close(); }.bind(this)
  325. } }
  326. }
  327. }, this.app);
  328. this.form.load();
  329. }.bind(this), true);
  330. },
  331. editRoom : function(){
  332. this.formTopNode = null;
  333. if(this.setFormNodeSizeFun && this.app ){
  334. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  335. }
  336. if( this.formMaskNode )this.formMaskNode.destroy();
  337. this.formAreaNode.destroy();
  338. this.edit();
  339. },
  340. getBuliding : function(){
  341. this.actions.getBuilding( this.buildingId, function(json){
  342. this.buildingName = json.data.name
  343. }.bind(this), null, false )
  344. },
  345. reset: function(){
  346. this.formTableArea.empty();
  347. this._createTableContent();
  348. },
  349. removeRoom: function(e) {
  350. var info = this.app.lp.delete_room;
  351. info = info.replace(/{name}/g, this.data.name);
  352. var _self = this;
  353. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  354. _self.remove();
  355. this.close();
  356. }, function(){
  357. this.close();
  358. });
  359. },
  360. remove: function(){
  361. var view = this.view;
  362. this.app.actions.deleteRoom(this.data.id, function(){
  363. this.close();
  364. view.reload();
  365. }.bind(this));
  366. },
  367. selectBuildingNext: function(){
  368. if (this.selectBuildingNode){
  369. var node=null;
  370. if (this.selectBuildingNode.selectedNode){
  371. node = this.selectBuildingNode.selectedNode.getNext();
  372. if (!node) node = this.selectBuildingNode.getFirst();
  373. this.selectBuildingNode.selectedNode.setStyle("background-color", this.selectBuildingNode.selectedNode.retrieve("bg"));
  374. }else{
  375. node = this.selectBuildingNode.getFirst();
  376. }
  377. if (node){
  378. var color = node.getStyle("background-color");
  379. node.store("bg", color);
  380. node.setStyles(this.css.createRoomBuildingSelectItem_over);
  381. this.selectBuildingNode.selectedNode = node;
  382. }
  383. }
  384. },
  385. selectBuildingPrev: function(){
  386. if (this.selectBuildingNode){
  387. var node = null;
  388. if (this.selectBuildingNode.selectedNode){
  389. var node = this.selectBuildingNode.selectedNode.getPrevious();
  390. if (!node) node = this.selectBuildingNode.getLast();
  391. this.selectBuildingNode.selectedNode.setStyle("background-color", this.selectBuildingNode.selectedNode.retrieve("bg"));
  392. }else{
  393. node = this.selectBuildingNode.getLast();
  394. }
  395. if (node){
  396. var color = node.getStyle("background-color");
  397. node.store("bg", color);
  398. node.setStyles(this.css.createRoomBuildingSelectItem_over);
  399. this.selectBuildingNode.selectedNode = node;
  400. }
  401. }
  402. },
  403. selectBuildingConfirm: function(e){
  404. if (this.selectBuildingNode.selectedNode){
  405. this.selectBuilding(this.selectBuildingNode.selectedNode);
  406. e.preventDefault();
  407. }
  408. },
  409. //cancelCreateRoom: function(){
  410. // this.createRoomNode.destroy();
  411. //},
  412. listBuildingData: function(key, callback){
  413. if (key){
  414. this.actions.listBuildingByKey(key, function(json){
  415. if (callback) callback(json);
  416. });
  417. }else{
  418. this.actions.listBuilding(function(json){
  419. if (callback) callback(json);
  420. });
  421. }
  422. },
  423. listBuilding: function(){
  424. debugger;
  425. if( this.selectBuildingNode )return;
  426. if( this.listing )return;
  427. this.listing = true;
  428. var item = this.form.getItem("buildingName");
  429. var key = item.getValue();
  430. this.listBuildingData(key, function(json){
  431. if (json.data && json.data.length){
  432. this.selectBuildingNode = new Element("div", {"styles": this.css.createRoomSelectBuildingNode}).inject(item.container);
  433. this.setSelectBuildingNodeSize();
  434. this.listBuildingHideFun = this.listBuildingHide.bind(this);
  435. this.formMaskNode.addEvent("mousedown", this.listBuildingHideFun);
  436. this.formNode.addEvent("mousedown", this.listBuildingHideFun);
  437. var _self = this;
  438. json.data.each(function(building, idx){
  439. var node = new Element("div", {"styles": this.css.createRoomBuildingSelectItem}).inject(this.selectBuildingNode);
  440. var nameNode = new Element("div", {"styles": this.css.createRoomBuildingSelectItemName, "text": building.name}).inject(node);
  441. var addrNode = new Element("div", {"styles": this.css.createRoomBuildingSelectItemAddr, "text": building.address}).inject(node);
  442. if ((idx % 2)==1) node.setStyle("background-color", "#f1f6ff");
  443. node.store("building", building.id);
  444. node.addEvents({
  445. "mouseover": function(e){
  446. var color = this.getStyle("background-color");
  447. this.store("bg", color);
  448. this.setStyles(_self.css.createRoomBuildingSelectItem_over);
  449. },
  450. "mouseout": function(e){
  451. this.setStyle("background-color", this.retrieve("bg"));
  452. },
  453. "mousedown": function(e){e.stopPropagation();},
  454. "click": function(e){
  455. _self.selectBuilding(this);
  456. }
  457. });
  458. }.bind(this));
  459. }
  460. this.listing = false;
  461. }.bind(this));
  462. // if( !key ){
  463. // listBuilding
  464. // }else{
  465. //
  466. // }
  467. // this.actions.listBuildingByKey(key, function(json){
  468. //
  469. // }.bind(this));
  470. },
  471. selectBuilding: function(node){
  472. var id = node.retrieve("building");
  473. var text = node.getFirst().get("text");
  474. this.form.getItem("buildingName").setValue(text);
  475. this.buildingId = id;
  476. this.listBuildingHide();
  477. },
  478. setSelectBuildingNodeSize: function(){
  479. var buildingInput = this.form.getItem("buildingName").getElements()[0];
  480. //var p = buildingInput.getPosition(buildingInput.getOffsetParent());
  481. this.selectBuildingNode.position({
  482. relativeTo: buildingInput,
  483. position: 'bottomLeft',
  484. edge: 'upperCenter',
  485. offset: {x: 4, y: 0}
  486. });
  487. //this.selectBuildingNode.setStyle("left", p.x);
  488. var size = buildingInput.getSize();
  489. var w = size.x-8;
  490. this.selectBuildingNode.setStyle("width", ""+w+"px");
  491. },
  492. listBuildingHide: function(){
  493. if (this.selectBuildingNode){
  494. //this.removeEvent("resize", this.setSelectBuildingNodeSizeFun);
  495. this.selectBuildingNode.destroy();
  496. this.selectBuildingNode = null;
  497. this.formMaskNode.removeEvent("mousedown", this.listBuildingHideFun);
  498. this.formNode.removeEvent("mousedown", this.listBuildingHideFun);
  499. }
  500. },
  501. save: function(){
  502. this.getData(function(data){
  503. this.actions.saveRoom(data, function(json){
  504. this.app.notice(this.lp.roomForm.save_success, "success");
  505. var view = this.view;
  506. this.close();
  507. view.reload();
  508. }.bind(this));
  509. }.bind(this));
  510. },
  511. getData: function(callback){
  512. var data = this.form.getResult(true,null,true,false,true);
  513. if( !data )return;
  514. data.device = data.deviceList.join("#");
  515. data.available = data.available == "true";
  516. if (!this.buildingId){
  517. this.actions.saveBuilding({"name": data.buildingName, "address": ""}, function(json){
  518. data.building = json.data.id;
  519. if (callback) callback(data);
  520. }.bind(this));
  521. }else{
  522. data.building = this.buildingId;
  523. if (callback) callback(data);
  524. }
  525. }
  526. });
  527. MWF.xApplication.Meeting.RoomTooltip = new Class({
  528. Extends: MTooltips,
  529. _loadCustom : function( callback ){
  530. this.loadBuilding( function(){
  531. if(callback)callback();
  532. }.bind(this) );
  533. },
  534. _getHtml : function(){
  535. var data = this.data;
  536. var lp = this.lp.device;
  537. var titleStyle = "font-size:14px;color:#333";
  538. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  539. var device = [];
  540. ( data.device || "" ).split("#").each( function( d ){
  541. device.push( lp[d] );
  542. }.bind(this));
  543. lp = this.lp.roomForm;
  544. var html =
  545. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  546. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.room +"</div>"+
  547. "</div>"+
  548. "<div style='font-size: 18px;color:#333;padding:0px 10px 15px 20px;'>"+ data.name +"</div>"+
  549. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  550. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  551. "<tr><td style='"+titleStyle+"' width='100'>"+ lp.building+":</td>" +
  552. " <td style='"+valueStyle+"' item='building'></td></tr>" +
  553. "<tr><td style='"+titleStyle+"'>" + lp.floor+":</td>" +
  554. " <td style='"+valueStyle+"'>" + data.floor + "</td></tr>" +
  555. "<tr><td style='"+titleStyle+"'>"+ lp.capacity +":</td>" +
  556. " <td style='"+valueStyle+"'>"+ data.capacity+"</td></tr>" +
  557. "<tr><td style='"+titleStyle+"'>"+ lp.roomNumber +":</td>" +
  558. " <td style='"+valueStyle+"'>"+ data.roomNumber+"</td></tr>" +
  559. "<tr><td style='"+titleStyle+"'>"+ lp.phone+":</td>" +
  560. " <td style='"+valueStyle+"'>"+ data.phoneNumber +"</td></tr>" +
  561. "<tr><td style='"+titleStyle+"'>"+ lp.device +":</td>" +
  562. " <td style='"+valueStyle+"'>"+ device.join( "," ) +"</td></tr>"+
  563. "<tr><td style='"+titleStyle+"'>"+ lp.available +":</td>" +
  564. " <td style='"+valueStyle+"'>" + ( !data.available ? this.lp.disable : this.lp.enable ) + "</td></tr>"+
  565. "</table>";
  566. return html;
  567. },
  568. loadBuilding: function( callback ){
  569. var area = this.node.getElement("[item='building']");
  570. if (this.data.building){
  571. this.app.actions.getBuilding(this.data.building, function(bjson){
  572. area.set("text", bjson.data.name );
  573. if( callback )callback();
  574. }.bind(this));
  575. }
  576. }
  577. });
  578. MWF.xApplication.Meeting.MeetingForm = new Class({
  579. Extends: MPopupForm,
  580. Implements: [Options, Events],
  581. options: {
  582. "style": "meeting",
  583. "width": "900",
  584. "height": "640",
  585. "hasTop": true,
  586. "hasIcon": false,
  587. "hasTopIcon" : false,
  588. "hasTopContent" : false,
  589. "hasBottom": false,
  590. "draggable": true,
  591. "closeAction": true,
  592. "maxAction" : true
  593. },
  594. open: function (e) {
  595. this.fireEvent("queryOpen");
  596. this.isNew = false;
  597. this.isEdited = false;
  598. this.getMeetingData( function(){
  599. this._open();
  600. }.bind(this));
  601. this.fireEvent("postOpen");
  602. },
  603. create: function () {
  604. this.fireEvent("queryCreate");
  605. this.isNew = true;
  606. this._open();
  607. this.fireEvent("postCreate");
  608. },
  609. edit: function () {
  610. this.fireEvent("queryEdit");
  611. this.isEdited = true;
  612. this.getMeetingData( function(){
  613. this._open();
  614. }.bind(this));
  615. this.fireEvent("postEdit");
  616. },
  617. _createTableContent: function () {
  618. this.userName = layout.desktop.session.user.distinguishedName;
  619. this.userId = layout.desktop.session.user.id;
  620. if( this.isNew ){
  621. this.formTopTextNode.set( "text", this.lp.addMeeting );
  622. }else if( this.isEdited ){
  623. this.formTopTextNode.set( "text", this.lp.editMeeting );
  624. this.options.height = "630";
  625. }else{
  626. this.formTopTextNode.set( "text", this.lp.metting );
  627. this.options.height = "540";
  628. }
  629. var defaultDate, defaultBeginTime, date1, defaultEndTime;
  630. if( this.options.date || this.options.minute ){
  631. this.date = typeOf( this.options.date )=="string" ? Date.parse( this.options.date ) : this.options.date;
  632. defaultDate = this.date.clone().format("%Y-%m-%d");
  633. if( this.date.getHours() ){
  634. defaultBeginTime = this.getString( this.date.getHours() )+":"+ this.getString( this.date.getMinutes() );
  635. date1 = this.date.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  636. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  637. defaultEndTime = this.getString( date1.getHours() )+":"+ this.getString( date1.getMinutes() );
  638. }else{
  639. var now = new Date();
  640. defaultBeginTime = (now.getHours()+1)+":"+"00";
  641. date1 = now.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  642. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  643. defaultEndTime = (date1.getHours()+1)+":"+"00";
  644. }
  645. }else{
  646. this.date = new Date();
  647. defaultDate = this.date.clone().format("%Y-%m-%d");
  648. defaultBeginTime = (this.date.getHours()+1)+":"+"00";
  649. date1 = this.date.clone().increment("hour", this.options.hour ? parseInt( this.options.hour ) : 1 );
  650. if(this.options.minute)date1 = date1.increment("minute", parseInt( this.options.minute ) );
  651. defaultEndTime = (date1.getHours()+1)+":"+"00";
  652. }
  653. this.formTableArea.setStyle("position","relative");
  654. var data = this.data;
  655. var isEditer = this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator();
  656. var editEnable = ( !this.isEdited && !this.isNew && this.data.status == "wait" && isEditer );
  657. var isEditing = this.isNew || (this.isEdited && this.data.status == "wait" && isEditer);
  658. var startImmediatelyEnable = false;
  659. if( editEnable ){
  660. if( MWF.AC.isMeetingAdministrator() ){
  661. startImmediatelyEnable = true;
  662. }else{
  663. if( this.userName == this.data.applicant || this.userId == this.data.applicant ){
  664. if( !this.app.meetingConfig.process )startImmediatelyEnable = true;
  665. }
  666. }
  667. }
  668. var finishImmediatelyEnable = false;
  669. if( isEditer && !this.isEdited && !this.isNew && this.data.status == "processing" ){
  670. finishImmediatelyEnable = true;
  671. }
  672. var html = "<div item='qrCode' style='position: absolute;right:0px;top:-20px;width:150px;height:180px;'></div><table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable'>" +
  673. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  674. "<tr>"+
  675. " <td styles='formTableTitle' width='70'>"+this.lp.applyPerson+":</td>" +
  676. " <td styles='formTableValue' item='applicant'></td>" +
  677. "</tr>"+
  678. "<tr><td styles='formTableTitle' width='100'>"+this.lp.beginDate+":</td>" +
  679. " <td styles='formTableValue' item='dateInput'></td>" +
  680. "</tr>" +
  681. "<tr><td styles='formTableTitle'>"+ this.lp.time +":</td>" +
  682. " <td styles='formTableValue'>" +
  683. " <div item='beginTimeInput' style='float:left'></div>"+
  684. " <div style='float:left; "+ ( isEditing ? "margin:5px;" : "margin:0px 5px;") + "'>"+ this.lp.to+ "</div>"+
  685. " <div item='endTimeInput' style='float:left'></div>"+
  686. " </td></tr>" +
  687. "<tr><td styles='formTableTitle'>"+ this.lp.selectRoom +":</td>" +
  688. " <td styles='formTableValue' item='meetingRoom'></td></tr>" +
  689. "<tr><td styles='formTableTitle'>"+this.lp.invitePerson2+":</td>" +
  690. " <td styles='formTableValue'>" +
  691. " <div item='invitePersonList'></div>" +
  692. " <div style='display:"+ ( this.isEdited ? "" : "none") +";' item='selectinvitePerson'></div>" +
  693. (( !this.isNew && this.data.myWaitAccept ) ?
  694. " <tr><td></td><td styles='formTableValue'><div item='acceptAction'></div><div item='rejectAction'></div></td></tr>" : ""
  695. ) +
  696. " </td>" +
  697. "</tr>" +
  698. "<tr style='display:"+ ( this.isNew ? "none" : "") +" ;' item='checkPersonTr'><td styles='formTableTitle'>签到人员:</td>" +
  699. " <td styles='formTableValue' item='checkinPersonList'></td></tr>" +
  700. "<tr><td styles='formTableTitle'>"+this.lp.meetingSubject+":</td>" +
  701. " <td styles='formTableValue' item='subject'></td></tr>" +
  702. "<tr><td styles='formTableTitle'>"+this.lp.meetingDescription+":</td>" +
  703. " <td styles='formTableValue' item='summary'></td></tr>" +
  704. "<tr style='display:none ;' item='attachmentTr'><td styles='formTableTitle'>"+this.lp.meetingAttachment+":</td>" +
  705. " <td styles='formTableValue' item='attachment'></td></tr>" +
  706. "<tr><td styles='formTableTitle'></td>" +
  707. " <td styles='formTableValue' style='padding-top: 10px;'>"+
  708. " <div item='saveAction' style='float:left;display:"+ ( (this.isEdited || this.isNew) ? "" : "none") +";'></div>"+
  709. " <div item='editAction' style='float:left;display:"+ ( editEnable ? "" : "none") +";'></div>"+
  710. " <div item='startImmediatelyAction' style='float:left;display:"+ ( startImmediatelyEnable ? "" : "none") +";'></div>"+
  711. " <div item='finishImmediatelyAction' style='float:left;display:"+ ( finishImmediatelyEnable ? "" : "none") +";'></div>"+
  712. " <div item='removeAction' style='float:left;display:"+ ( this.isEdited ? "" : "none") +";'></div>"+
  713. " <div item='cancelAction' style='"+( (this.isEdited || this.isNew || editEnable || startImmediatelyEnable || finishImmediatelyEnable ) ? "float:left;" : "float:right;margin-right:15px;")+"'></div>"+
  714. " </td></tr>" +
  715. "</table>";
  716. this.formTableArea.set("html", html);
  717. if( data.startTime ){
  718. var beignDate = Date.parse( data.startTime );
  719. data.dateInput = beignDate.format("%Y-%m-%d");
  720. data.beginTimeInput = this.getString( beignDate.getHours() ) + ":" + this.getString( beignDate.getMinutes() );
  721. }
  722. if( data.completedTime ){
  723. var endDate = Date.parse( data.completedTime );
  724. data.endTimeInput = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  725. }
  726. this.meetingRoomArea = this.formTableArea.getElement("[item='meetingRoom']");
  727. this.attachmentTr = this.formTableArea.getElement("[item='attachmentTr']");
  728. this.attachmentArea = this.formTableArea.getElement("[item='attachment']");
  729. this.qrCodeArea = this.formTableArea.getElement("[item='qrCode']");
  730. MWF.xDesktop.requireApp("Template", "MForm", function () {
  731. this.form = new MForm(this.formTableArea, data, {
  732. isEdited: this.isEdited || this.isNew,
  733. style : "meeting",
  734. itemTemplate: {
  735. applicant : { type : "org", orgType : "person", isEdited : false,
  736. defaultValue : this.userName
  737. },
  738. dateInput: {tType: "date", isEdited : isEditing, defaultValue: defaultDate,
  739. event : {
  740. change : function( item, ev ){
  741. this.clearRoom();
  742. }.bind(this)
  743. }
  744. },
  745. beginTimeInput: { tType: "time", isEdited : isEditing,
  746. defaultValue: defaultBeginTime, className : ( isEditing ? "inputTimeUnformatWidth" : "" ),
  747. event : {
  748. change : function( item, ev ){
  749. this.clearRoom();
  750. }.bind(this)
  751. }
  752. },
  753. endTimeInput: { tType: "time", isEdited : isEditing,
  754. defaultValue: defaultEndTime, className : ( isEditing ? "inputTimeUnformatWidth" : "" ),
  755. event : {
  756. change : function( item, ev ){
  757. this.clearRoom();
  758. }.bind(this)
  759. }
  760. },
  761. invitePersonList: { type: "org", isEdited : this.isNew, orgType: ["identity","person"], count : 0, orgWidgetOptions : {
  762. "onLoadedInfor": function(item){
  763. this.loadAcceptAndReject( item );
  764. }.bind(this)
  765. }},
  766. checkinPersonList : { type: "org", isEdited : false, orgType: ["identity","person"], count : 0},
  767. selectinvitePerson : { type : "button", value : this.lp.addInvitePerson1, style : {"margin-left": "20px"}, event : {
  768. click : function( it ){
  769. var options = {
  770. "type" : "",
  771. "types": ["identity","person"],
  772. "exclude" : this.getInvitePersonExclude(),
  773. "values": [],
  774. "count": 0,
  775. "onComplete": function(items){
  776. MWF.require("MWF.widget.O2Identity", function(){
  777. var invitePersonList = [];
  778. items.each(function(item){
  779. var _self = this;
  780. if( item.data.distinguishedName.split("@").getLast().toLowerCase() == "i" ){
  781. var person = new MWF.widget.O2Identity(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  782. invitePersonList.push( item.data.distinguishedName );
  783. }else{
  784. var person = new MWF.widget.O2Person(item.data, it.form.getItem("invitePersonList").container, {"style": "room"});
  785. invitePersonList.push(item.data.distinguishedName);
  786. }
  787. }.bind(this));
  788. this.app.actions.addMeetingInvite(this.data.id, {"invitePersonList": invitePersonList, "id": this.data.id}, function(json){
  789. this.app.actions.getMeeting(json.data.id, function(meeting){
  790. this.invitePersonList = meeting.data.invitePersonList;
  791. this.app.notice(this.app.lp.addedInvitePerson1, "success", this.node );
  792. }.bind(this));
  793. }.bind(this));
  794. }.bind(this));
  795. }.bind(this)
  796. };
  797. var selector = new MWF.O2Selector(this.app.content, options);
  798. }.bind(this)
  799. } },
  800. subject: {},
  801. summary: {type: "textarea"},
  802. acceptAction : { type : "button", value : this.lp.accept, className : "inputAcceptButton",
  803. event : { click : function( it, ev ){ this.accept(ev); }.bind(this) }
  804. },
  805. rejectAction : { type : "button", value : this.lp.reject, style : {"margin-left": "20px"}, className : "inputDenyButton",
  806. event : { click : function( it, ev ){ this.reject(ev) }.bind(this) }
  807. },
  808. saveAction : { type : "button", className : "inputOkButton", value : this.lp.save, event : {
  809. click : function(){ this.save();}.bind(this)
  810. } },
  811. removeAction : { type : "button", className : "inputCancelButton", value : this.lp.cancelMeeting , event : {
  812. click : function( item, ev ){ this.cancelMeeting(ev); }.bind(this)
  813. } },
  814. editAction : { type : "button", className : "inputOkButton", value : this.lp.editMeeting , event : {
  815. click : function(){ this.editMeeting(); }.bind(this)
  816. } },
  817. startImmediatelyAction : { type : "button", className : "inputCancelButton", value : this.lp.startMeetingImmediately , event : {
  818. click : function(){ this.startImmediately(); }.bind(this)
  819. } },
  820. finishImmediatelyAction : { type : "button", className : "inputCancelButton", value : this.lp.endMeetingImmediately , event : {
  821. click : function(){ this.finishImmediately(); }.bind(this)
  822. } },
  823. cancelAction : { type : "button", className : "inputCancelButton", value : this.lp.close , event : {
  824. click : function(){ this.close(); }.bind(this)
  825. } }
  826. }
  827. }, this.app);
  828. this.form.load();
  829. if( isEditing ){
  830. this.loadSelectRoom();
  831. }else{
  832. this.loadSelectRoom_read();
  833. }
  834. if( this.data.id )this.loadAttachment();
  835. if( isEditer && !this.isNew && !this.isEdited ){
  836. this.loadQrCode();
  837. }else{
  838. this.qrCodeArea.destroy();
  839. }
  840. }.bind(this), true);
  841. },
  842. startImmediately : function(){
  843. o2.Actions.load("x_meeting_assemble_control").MeetingAction.editStartTime( this.data.id, {
  844. room : this.roomId || this.data.room,
  845. startTime : ( new Date() ).format("db")
  846. }, function () {
  847. this.app.notice( this.lp.startMeetingSucccess, "success");
  848. this.waitReload = true;
  849. this.reload()
  850. }.bind(this))
  851. },
  852. finishImmediately : function(){
  853. o2.Actions.load("x_meeting_assemble_control").MeetingAction.editCompletedTime( this.data.id, {
  854. room : this.roomId || this.data.room,
  855. completedTime : ( new Date() ).format("db")
  856. }, function () {
  857. this.app.notice( this.lp.endMeetingSucccess, "success");
  858. this.waitReload = true;
  859. this.reload()
  860. }.bind(this))
  861. },
  862. getInvitePersonExclude : function(){
  863. var invitePersonList = this.invitePersonList || this.data.invitePersonList;
  864. var identityList = [];
  865. if( invitePersonList.length > 0 ){
  866. o2.Actions.load("x_organization_assemble_express").IdentityAction.listWithPerson({
  867. personList : invitePersonList
  868. }, function( json ){
  869. identityList = json.data ? json.data.identityList : [];
  870. }, null ,false );
  871. return ( identityList || [] ).concat(invitePersonList);
  872. }else{
  873. return [];
  874. }
  875. },
  876. getString : function( str ){
  877. var s = "00" + str;
  878. return s.substr(s.length - 2, 2 );
  879. },
  880. loadQrCode : function(){
  881. this.actions.getCheckinQrCode( this.data.id, function(json){
  882. var img = new Element("img",{
  883. src : "data:image/png;base64,"+json.data.image,
  884. styles : {
  885. width : "150px",
  886. height : "150px"
  887. }
  888. }).inject( this.qrCodeArea );
  889. var div = new Element("div",{
  890. text : "打印签到二维码",
  891. styles : {
  892. "color" : "#3c75b7",
  893. "cursor" : "pointer",
  894. "text-align": "center"
  895. },
  896. events : {
  897. click : function(){
  898. window.open(o2.filterUrl("../x_desktop/meetingQrPrint.html?meeting="+this.data.id), "_blank" );
  899. }.bind(this)
  900. }
  901. }).inject( this.qrCodeArea );
  902. }.bind(this));
  903. },
  904. loadAcceptAndReject : function( item ){
  905. var personName = item.data.distinguishedName;
  906. if(this.data.acceptPersonList){
  907. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  908. var acceptNode = new Element("div", {"styles": this.css.acceptIconNode}).inject(item.node, "top");
  909. new Element("div", {
  910. "styles": this.css.acceptTextNode,
  911. "text": this.app.lp.accepted
  912. }).inject(item.inforNode);
  913. }
  914. }
  915. if(this.data.rejectPersonList){
  916. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  917. var rejectNode = new Element("div", {"styles": this.css.rejectIconNode}).inject(item.node, "top");
  918. new Element("div", {
  919. "styles": this.css.rejectTextNode,
  920. "text": this.app.lp.rejected
  921. }).inject(item.inforNode);
  922. }
  923. }
  924. },
  925. getMeetingData : function( callback ){
  926. if( this.data && this.data.id ){
  927. ( this.app.actions || this.actions ).getMeeting( this.data.id, function( json ){
  928. this.data = json.data;
  929. if(callback)callback();
  930. }.bind(this))
  931. }else{
  932. if(callback)callback();
  933. }
  934. },
  935. editMeeting : function(){
  936. this.formTopNode = null;
  937. if(this.setFormNodeSizeFun && this.app ){
  938. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  939. }
  940. if( this.formMaskNode )this.formMaskNode.destroy();
  941. this.formAreaNode.destroy();
  942. this.edit();
  943. },
  944. cancelMeeting: function(e){
  945. var _self = this;
  946. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  947. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 380, 200, function(){
  948. _self._cancelMeeting();
  949. this.close();
  950. _self.close();
  951. }, function(){
  952. this.close();
  953. });
  954. },
  955. _cancelMeeting: function(){
  956. var view = this.view;
  957. this.app.actions.deleteMeeting(this.data.id, function(){
  958. view.reload();
  959. }.bind(this))
  960. },
  961. reset: function(){
  962. this.formTableArea.empty();
  963. this._createTableContent();
  964. },
  965. clearRoom : function(){
  966. this.roomId = "";
  967. if(this.roomInput)this.roomInput.set("text", "");
  968. },
  969. loadSelectRoom_read : function(){
  970. var roomId = this.data.room || this.options.room;
  971. if (roomId){
  972. ( this.app.actions || this.actions ).getRoom(roomId, function(json){
  973. ( this.app.actions || this.actions ).getBuilding(json.data.building, function(bjson){
  974. this.roomId = roomId;
  975. this.meetingRoomArea.set("text", json.data.name+" ("+bjson.data.name+")");
  976. }.bind(this));
  977. }.bind(this));
  978. }
  979. },
  980. loadSelectRoom: function(){
  981. var css = this.app.css;
  982. var lineNode = new Element("div", {"styles": css.createMeetingInfoLineNode}).inject(this.meetingRoomArea);
  983. var editNode = new Element("div", {
  984. "styles": css.createMeetingInfoItemEditNode,
  985. "html": "<div></div>"
  986. }).inject(lineNode);
  987. this.roomInput = editNode.getFirst();
  988. this.roomInput.setStyles( css.createMeetingInfoItemDivNode);
  989. //var downNode = new Element("div", {"styles": this.css.createMeetingInfoItemDownNode}).inject(editNode);
  990. this.roomInput.addEvents({
  991. "click": function(e){this.selectRooms();}.bind(this)
  992. });
  993. var roomId = this.data.room || this.options.room;
  994. if (roomId){
  995. ( this.app.actions || this.actions ).getRoom(roomId, function(json){
  996. ( this.app.actions || this.actions ).getBuilding(json.data.building, function(bjson){
  997. this.roomId = roomId;
  998. this.roomInput.set("text", json.data.name+" ("+bjson.data.name+")");
  999. }.bind(this));
  1000. }.bind(this));
  1001. }
  1002. },
  1003. selectRooms: function(){
  1004. this.createRoomNode(function(){
  1005. this.loadSelectRooms();
  1006. this.selectRoomNode.setStyle("display", "block");
  1007. this.hideRoomNodeFun = this.hideRoomNode.bind(this);
  1008. document.body.addEvent("mousedown", this.hideRoomNodeFun);
  1009. //var p = this.selectRoomNode.getPosition(this.selectRoomNode.getOffsetParent());
  1010. this.selectRoomNode.position({
  1011. relativeTo: this.roomInput,
  1012. position: 'bottomLeft',
  1013. edge: 'upperLeft',
  1014. offset: {x: 0, y: 0}
  1015. });
  1016. var size = this.roomInput.getSize();
  1017. var w = size.x-2;
  1018. this.selectRoomNode.setStyle("width", ""+w+"px");
  1019. }.bind(this));
  1020. },
  1021. createRoomNode: function(callback){
  1022. var css = this.app.css;
  1023. if (!this.selectRoomNode){
  1024. this.selectRoomNode = new Element("div", {"styles": css.createMeetingInfoSelectRoomNode}).inject(this.formNode);
  1025. this.selectRoomNode.addEvent("mousedown", function(e){e.stopPropagation();});
  1026. if (callback) callback();
  1027. }else{
  1028. if (callback) callback();
  1029. }
  1030. },
  1031. loadSelectRooms: function(){
  1032. var css = this.app.css;
  1033. var result = this.form.getResult(false,null,false,false,true);
  1034. var d = result.dateInput;
  1035. var bt = result.beginTimeInput;
  1036. var et = result.endTimeInput;
  1037. var start = d+" "+bt;
  1038. var completed = d+" "+et;
  1039. var success = function(json){
  1040. json.data.each(function(building){
  1041. var node = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1Node}).inject(this.selectRoomNode);
  1042. var nodeName = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1NameNode, "text": building.name}).inject(node);
  1043. var nodeAddr = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1AddrNode, "text": building.address}).inject(node);
  1044. building.roomList.each(function(room, i){
  1045. if (room.available && room.idle) this.createRoomSelectNode(room, i, building);
  1046. }.bind(this));
  1047. }.bind(this));
  1048. }.bind(this);
  1049. if( this.isEdited && this.data.room ){
  1050. o2.Actions.load("x_meeting_assemble_control").BuildingAction.listWithStartCompletedRoom( start, completed, this.data.room, this.data.id, function ( json ) {
  1051. success( json );
  1052. }
  1053. )
  1054. }else{
  1055. this.app.actions.listBuildingByRange(start, completed, function(json){
  1056. success( json )
  1057. }.bind(this));
  1058. }
  1059. },
  1060. createRoomSelectNode: function(room, i, building){
  1061. var css = this.app.css;
  1062. var roomNode = new Element("div", {"styles": css.roomTitleNode}).inject(this.selectRoomNode);
  1063. var capacityNode = new Element("div", {"styles": css.roomTitleCapacityNode, "text": room.capacity+this.lp.person}).inject(roomNode);
  1064. var inforNode = new Element("div", {"styles": css.roomTitleInforNode}).inject(roomNode);
  1065. var node = new Element("div", {"styles": {"height": "20px"}}).inject(inforNode);
  1066. var numberNode = new Element("div", {"styles": css.roomTitleNumberNode, "text": (room.roomNumber) ? "#"+room.roomNumber : ""}).inject(node);
  1067. var nameNode = new Element("div", {"styles": css.roomTitleNameNode, "text": room.name}).inject(node);
  1068. var iconsNode = new Element("div", {"styles": css.roomTitleIconsNode}).inject(inforNode);
  1069. var deviceList = ( room.device || "" ).split("#");
  1070. deviceList.each(function(name){
  1071. if( name ){
  1072. var node = new Element("div", {"styles": css.roomTitleIconNode, "title": this.lp.device[name]}).inject(iconsNode);
  1073. node.setStyle("background-image", "url(../x_component_Meeting/$RoomView/default/icon/device/"+name+"_disable.png)");
  1074. }
  1075. }.bind(this));
  1076. if ((i % 2)!=0) roomNode.setStyle("background-color", "#f4f8ff");
  1077. roomNode.store("room", room);
  1078. var _self = this;
  1079. if (room.idle){
  1080. roomNode.addEvents({
  1081. "mouseover": function(e){
  1082. var color = roomNode.getStyle("background-color");
  1083. this.store("bgcolor", color);
  1084. this.setStyle("background-color", "#e4edfc");
  1085. },
  1086. "mouseout": function(){
  1087. var color = this.retrieve("bgcolor", "#FFF");
  1088. this.setStyle("background-color", color);
  1089. },
  1090. "click": function(){
  1091. var roomData = this.retrieve("room");
  1092. _self.roomId = roomData.id;
  1093. //roomNode.inject(_self.roomInput);
  1094. _self.roomInput.set("text", roomData.name+" ("+building.name+")");
  1095. _self.hideRoomNode();
  1096. }
  1097. });
  1098. }else{
  1099. roomNode.setStyle("background-color", "#fff6f6");
  1100. var disabledNode = new Element("div", {"styles": css.roomTitleDisabledIconNode}).inject(roomNode);
  1101. }
  1102. },
  1103. hideRoomNode: function(){
  1104. this.selectRoomNode.empty();
  1105. this.selectRoomNode.setStyle("display", "none");
  1106. document.body.removeEvent("mousedown", this.hideRoomNodeFun);
  1107. },
  1108. setCreateRoomSelectBuildingNodeSize: function(){
  1109. var p = this.createRoomBuildingInput.getPosition(this.createRoomBuildingInput.getOffsetParent());
  1110. this.createRoomSelectBuildingNode.position({
  1111. relativeTo: this.createRoomBuildingInput,
  1112. position: 'bottomCenter',
  1113. edge: 'upperCenter',
  1114. offset: {x: 0, y: 0}
  1115. });
  1116. this.createRoomSelectBuildingNode.setStyle("left", p.x);
  1117. var size = this.createRoomBuildingInput.getSize();
  1118. var w = size.x-2;
  1119. this.createRoomSelectBuildingNode.setStyle("width", ""+w+"px");
  1120. },
  1121. loadAttachment: function(){
  1122. this.attachmentTr.setStyle("display","");
  1123. this.attachmentNode = new Element("div", {"styles": this.css.createMeetingAttachmentNode}).inject(this.attachmentArea);
  1124. var attachmentContentNode = new Element("div", {"styles": this.css.createMeetingAttachmentContentNode}).inject(this.attachmentNode);
  1125. MWF.require("MWF.widget.AttachmentController", function(){
  1126. this.attachmentController = new MWF.widget.AttachmentController(attachmentContentNode, this, {
  1127. "size": "min",
  1128. "isSizeChange": false,
  1129. "isReplace": false,
  1130. "isUpload": this.isNew || this.isEdited,
  1131. "isDelete": this.isNew || this.isEdited,
  1132. "isDownload": true,
  1133. "readonly": !this.isNew && !this.isEdited
  1134. });
  1135. this.attachmentController.load();
  1136. if( this.data.attachmentList ){
  1137. this.data.attachmentList.each(function (att) {
  1138. att.person = att.lastUpdatePerson.split("@")[0];
  1139. var at = this.attachmentController.addAttachment(att);
  1140. }.bind(this));
  1141. }
  1142. }.bind(this));
  1143. },
  1144. uploadAttachment: function(e, node){
  1145. if (!this.uploadFileAreaNode){
  1146. this.createUploadFileNode();
  1147. }
  1148. this.fileUploadNode.click();
  1149. },
  1150. createUploadFileNode: function(){
  1151. this.uploadFileAreaNode = new Element("div");
  1152. var html = "<input name=\"file\" type=\"file\" multiple/>";
  1153. this.uploadFileAreaNode.set("html", html);
  1154. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  1155. this.fileUploadNode.addEvent("change", function(){
  1156. var files = this.fileUploadNode.files;
  1157. if (files.length){
  1158. for (var i = 0; i < files.length; i++) {
  1159. var file = files.item(i);
  1160. var formData = new FormData();
  1161. formData.append('file', file);
  1162. //formData.append('folder', folderId);
  1163. this.app.actions.addAttachment(this.data.id, formData, file, function(o, text){
  1164. if (o.id){
  1165. this.app.actions.getAttachment(o.id, function(json){
  1166. if (json.data) this.attachmentController.addAttachment(json.data);
  1167. this.attachmentController.checkActions();
  1168. }.bind(this))
  1169. }
  1170. this.attachmentController.checkActions();
  1171. }.bind(this));
  1172. }
  1173. }
  1174. }.bind(this));
  1175. },
  1176. deleteAttachments: function(e, node, attachments){
  1177. var names = [];
  1178. attachments.each(function(attachment){
  1179. names.push(attachment.data.name);
  1180. }.bind(this));
  1181. var _self = this;
  1182. this.app.confirm("warn", e, this.lp.deleteAttachmentTitle, this.lp.deleteAttachment+"( "+names.join(", ")+" )", 300, 120, function(){
  1183. while (attachments.length){
  1184. attachment = attachments.shift();
  1185. _self.deleteAttachment(attachment);
  1186. }
  1187. this.close();
  1188. }, function(){
  1189. this.close();
  1190. }, null);
  1191. },
  1192. deleteAttachment: function(attachment){
  1193. this.app.actions.deleteFile(attachment.data.id, function(josn){
  1194. this.attachmentController.removeAttachment(attachment);
  1195. this.attachmentController.checkActions();
  1196. }.bind(this));
  1197. },
  1198. downloadAttachment: function(e, node, attachments){
  1199. attachments.each(function(att){
  1200. this.app.actions.getFileDownload(att.data.id);
  1201. }.bind(this));
  1202. },
  1203. openAttachment: function(e, node, attachments){
  1204. attachments.each(function(att){
  1205. this.app.actions.getFile(att.data.id);
  1206. }.bind(this));
  1207. },
  1208. getAttachmentUrl: function(attachment, callback){
  1209. this.app.actions.getFileUrl(attachment.data.id, callback);
  1210. },
  1211. save: function(){
  1212. this._save(function(){
  1213. this.app.notice(this.lp.meeting_saveSuccess, "success");
  1214. if (!this.attachmentNode){
  1215. this.loadAttachment();
  1216. }
  1217. }.bind(this));
  1218. },
  1219. _save: function(callback){
  1220. this.getSaveData();
  1221. var now = new Date();
  1222. var errorText = "";
  1223. if (!this.data.subject) errorText +=this.lp.meeting_input_subject_error;
  1224. if (!this.data.room) errorText +=this.lp.meeting_input_room_error;
  1225. if (!this.data.invitePersonList.length) errorText +=this.lp.meeting_input_person_error;
  1226. if( this.data.startTimeDate ){
  1227. if (this.data.startTimeDate.diff(this.data.completedTimeDate, "minute")<1) errorText +=this.lp.meeting_input_time_error;
  1228. if (now.diff(this.data.startTimeDate, "minute")<0) errorText +=this.lp.meeting_input_date_error;
  1229. delete this.data.startTimeDate;
  1230. delete this.data.completedTimeDate;
  1231. }
  1232. if (errorText){
  1233. this.app.notice(this.lp.meeting_input_error+errorText, "error");
  1234. return false;
  1235. }
  1236. this.app.actions.saveMeeting(this.data, function(json){
  1237. this.data.id = json.data.id;
  1238. this.waitReload = true;
  1239. if (callback) callback();
  1240. }.bind(this));
  1241. },
  1242. getSaveData: function(){
  1243. this.data = this.form.getResult(false,null,false,false,true);
  1244. this.data.room = this.roomId;
  1245. if( this.invitePersonList ){
  1246. this.data.invitePersonList = this.invitePersonList;
  1247. }
  1248. var d = this.data.dateInput;
  1249. // if( this.isNew ) {
  1250. var startTime = d + " " + this.data.beginTimeInput + ":0";
  1251. var completedTime = d + " " + this.data.endTimeInput + ":0";
  1252. var startTimeDate = Date.parse(startTime);
  1253. var completedTimeDate = Date.parse(completedTime);
  1254. this.data.startTime = startTime;
  1255. this.data.completedTime = completedTime;
  1256. this.data.startTimeDate = startTimeDate;
  1257. this.data.completedTimeDate = completedTimeDate;
  1258. // }
  1259. if( this.isNew ){
  1260. delete this.data.applicant;
  1261. }else{
  1262. this.data.applicant = this.data.applicant.join(",")
  1263. }
  1264. },
  1265. getPersonByIdentity : function( identity ){
  1266. },
  1267. getPerson : function( source ){
  1268. if( typeOf(source) != "array" )source = [source];
  1269. var target = [];
  1270. source.each( function( s ){
  1271. if( s.split("@").getLast().toLowerCase() == "i" ){
  1272. target.push( this.getPersonByIdentity( s ) )
  1273. }else{
  1274. target.push( s )
  1275. }
  1276. }.bind(this));
  1277. return target;
  1278. },
  1279. reject: function(e){
  1280. var _self = this;
  1281. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  1282. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  1283. _self.rejectMeeting();
  1284. this.close();
  1285. _self.close();
  1286. }, function(){
  1287. this.close();
  1288. });
  1289. },
  1290. rejectMeeting: function(){
  1291. var view = this.view;
  1292. this.app.actions.rejectMeeting(this.data.id, function(){
  1293. view.reload();
  1294. }.bind(this))
  1295. },
  1296. accept: function(e){
  1297. var _self = this;
  1298. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  1299. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  1300. _self.acceptMeeting();
  1301. this.close();
  1302. _self.close();
  1303. }, function(){
  1304. this.close();
  1305. });
  1306. },
  1307. acceptMeeting: function(){
  1308. var view = this.view;
  1309. this.app.actions.acceptMeeting(this.data.id, function(){
  1310. view.reload();
  1311. }.bind(this))
  1312. },
  1313. close: function (e) {
  1314. this.fireEvent("queryClose");
  1315. this._close();
  1316. //if( this.form ){
  1317. // this.form.destroy();
  1318. //}
  1319. if(this.setFormNodeSizeFun && this.app ){
  1320. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1321. }
  1322. if( this.formMaskNode )this.formMaskNode.destroy();
  1323. this.formAreaNode.destroy();
  1324. this.fireEvent("postClose");
  1325. if( this.waitReload )this.view.reload();
  1326. delete this;
  1327. }
  1328. });
  1329. MWF.xApplication.Meeting.MeetingTooltip = new Class({
  1330. Extends: MTooltips,
  1331. _loadCustom : function( callback ){
  1332. this.loadRoom( function(){
  1333. this.loadInvite();
  1334. this.loadAttachment();
  1335. if(callback)callback();
  1336. }.bind(this) );
  1337. },
  1338. _getHtml : function(){
  1339. var data = this.data;
  1340. var titleStyle = "font-size:14px;color:#333";
  1341. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1342. var persons = [];
  1343. data.invitePersonList.each( function( p ){
  1344. persons.push(p.split("@")[0] )
  1345. }.bind(this));
  1346. var color = "#ccc";
  1347. switch (data.status){
  1348. case "wait":
  1349. color = "#4990E2";
  1350. break;
  1351. case "processing":
  1352. color = "#66CC7F";
  1353. break;
  1354. case "completed":
  1355. color = "#666";
  1356. break;
  1357. }
  1358. if (data.myWaitAccept){
  1359. color = "#F6A623";
  1360. }
  1361. if (data.confilct){
  1362. color = "#FF7F7F";
  1363. }
  1364. var beginDate = Date.parse(data.startTime);
  1365. var endDate = Date.parse(data.completedTime);
  1366. var dateStr = beginDate.format(this.app.lp.dateFormatDay);
  1367. var beginTime = this.getString( beginDate.getHours() ) + ":" + this.getString( beginDate.getMinutes() );
  1368. var endTime = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  1369. var meetingTime = dateStr + " " + beginTime + "-" + endTime;
  1370. var description = (data.description || "")+(data.summary || "");
  1371. var html =
  1372. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1373. " <div style='font-size: 12px;color:#666; float: right'>"+ this.lp.applyPerson +":" + data.applicant.split("@")[0] +"</div>" +
  1374. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.meetingDetail +"</div>"+
  1375. "</div>"+
  1376. "<div style='font-size: 18px;color:#333;padding:0px 10px 15px 20px;'>"+ data.subject +"</div>"+
  1377. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1378. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1379. "<tr><td style='"+titleStyle+";' width='70'>"+this.lp.meetingTime+":</td>" +
  1380. " <td style='"+valueStyle+";color:"+ color +"'>" + meetingTime + "</td></tr>" +
  1381. //"<tr><td style='"+titleStyle+"' width='70'>"+this.lp.beginTime+":</td>" +
  1382. //" <td style='"+valueStyle+"'>" + data.startTime + "</td></tr>" +
  1383. //"<tr><td style='"+titleStyle+"'>"+this.lp.endTime+":</td>" +
  1384. //" <td style='"+valueStyle+"'>" + data.completedTime + "</td></tr>" +
  1385. "<tr><td style='"+titleStyle+"'>"+this.lp.selectRoom +":</td>" +
  1386. " <td style='"+valueStyle+"' item='meetingRoom'></td></tr>" +
  1387. "<tr><td style='"+titleStyle+"'>"+this.lp.invitePerson2+":</td>" +
  1388. " <td style='"+valueStyle+"' item='invitePerson'>"+persons.join(",")+"</td></tr>" +
  1389. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingDescription+":</td>" +
  1390. " <td style='"+valueStyle+"'>"+ description +"</td></tr>" +
  1391. ( this.options.isHideAttachment ? "" :
  1392. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingAttachment+":</td>" +
  1393. " <td style='"+valueStyle+"' item='attachment'></td></tr>"
  1394. )+
  1395. "</table>";
  1396. return html;
  1397. },
  1398. getString : function( str ){
  1399. var s = "00" + str;
  1400. return s.substr(s.length - 2, 2 );
  1401. },
  1402. loadRoom: function( callback ){
  1403. var area = this.node.getElement("[item='meetingRoom']");
  1404. if (this.data.room){
  1405. this.app.actions.getRoom(this.data.room, function(json){
  1406. this.app.actions.getBuilding(json.data.building, function(bjson){
  1407. area.set("text", json.data.name+" ("+bjson.data.name+")");
  1408. if( callback )callback();
  1409. }.bind(this));
  1410. }.bind(this));
  1411. }
  1412. },
  1413. loadInvite : function(){
  1414. this.O2PersonList = [];
  1415. var area = this.node.getElement("[item='invitePerson']");
  1416. MWF.require("MWF.widget.O2Identity", function(){
  1417. area.empty();
  1418. this.data.invitePersonList.each(function( person ){
  1419. var O2person = new MWF.widget.O2Person({name : person}, area, {"style": "room", "onLoadedInfor": function(item){
  1420. this.loadAcceptAndReject( item );
  1421. }.bind(this) });
  1422. this.O2PersonList.push( O2person );
  1423. }.bind(this));
  1424. }.bind(this));
  1425. },
  1426. loadAcceptAndReject : function( item ){
  1427. var personName = item.data.distinguishedName;
  1428. if( this.data.acceptPersonList ){
  1429. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  1430. var acceptNode = new Element("div", {"styles": {
  1431. "height": "20px",
  1432. "width": "14px",
  1433. "margin-right": "3px",
  1434. "float": "left",
  1435. "background": "url(../x_component_Template/$MPopupForm/meeting/icon/accept.png) no-repeat center center"
  1436. }}).inject(item.node, "top");
  1437. new Element("div", {
  1438. "styles" : {"color": "#1fbf04", "clear":"both","text-align":"center"},
  1439. "text": this.app.lp.accepted
  1440. }).inject(item.inforNode);
  1441. }
  1442. }
  1443. if(this.data.rejectPersonList){
  1444. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  1445. var rejectNode = new Element("div", {"styles": {
  1446. "height": "20px",
  1447. "width": "14px",
  1448. "margin-right": "3px",
  1449. "float": "left",
  1450. "background": "url(../x_component_Template/$MPopupForm/meeting/icon/reject.png) no-repeat center center"
  1451. }}).inject(item.node, "top");
  1452. new Element("div", {
  1453. "styles" : {"color": "#FF0000", "clear":"both","text-align":"center"},
  1454. "text": this.app.lp.rejected
  1455. }).inject(item.inforNode);
  1456. }
  1457. }
  1458. },
  1459. destroy: function(){
  1460. if( this.O2PersonList ){
  1461. this.O2PersonList.each(function(p){
  1462. p.destroy();
  1463. })
  1464. }
  1465. if( this.node ){
  1466. this.node.destroy();
  1467. this.node = null;
  1468. }
  1469. },
  1470. loadAttachment: function(){
  1471. if( this.options.isHideAttachment )return;
  1472. if( typeOf(this.data.attachmentList)=="array" && this.data.attachmentList[0] ){
  1473. var area = this.node.getElement("[item='attachment']");
  1474. this.attachmentNode = new Element("div"
  1475. //{"styles": this.css.createMeetingAttachmentNode}
  1476. ).inject(area);
  1477. var attachmentContentNode = new Element("div", {
  1478. //"styles": this.css.createMeetingAttachmentContentNode
  1479. }).inject(this.attachmentNode);
  1480. this.attachmentController = new MWF.xApplication.Meeting.MeetingTooltip.AttachmentController(attachmentContentNode, this, {
  1481. "size": "min",
  1482. "isSizeChange": false,
  1483. "isReplace": false,
  1484. "isUpload": false,
  1485. "isDelete": false,
  1486. "isDownload": true,
  1487. "readonly": true
  1488. });
  1489. this.attachmentController.load();
  1490. this.data.attachmentList.each(function (att) {
  1491. att.person = att.lastUpdatePerson.split("@")[0];
  1492. var at = this.attachmentController.addAttachment(att);
  1493. }.bind(this));
  1494. }
  1495. },
  1496. downloadAttachment: function(e, node, attachments){
  1497. attachments.each(function(att){
  1498. this.app.actions.getFileDownload(att.data.id);
  1499. }.bind(this));
  1500. },
  1501. openAttachment: function(e, node, attachments){
  1502. attachments.each(function(att){
  1503. this.app.actions.getFile(att.data.id);
  1504. }.bind(this));
  1505. },
  1506. getAttachmentUrl: function(attachment, callback){
  1507. this.app.actions.getFileUrl(attachment.data.id, callback);
  1508. }
  1509. });
  1510. MWF.xApplication.Meeting.MeetingTooltip.AttachmentController = new Class({
  1511. Extends : MWF.widget.AttachmentController,
  1512. loadMin: function(){
  1513. if (!this.node) this.node = new Element("div", {"styles": this.css.container_min});
  1514. if (!this.minActionAreaNode){
  1515. //this.minActionAreaNode = new Element("div", {"styles": this.css.minActionAreaNode}).inject(this.node);
  1516. this.minContent = new Element("div", {"styles": this.css.minContentNode}).inject(this.node);
  1517. this.minContent.setStyles({
  1518. "margin-right" : "0px"
  1519. });
  1520. //this.min_downloadAction = this.createAction(this.minActionAreaNode, "download", MWF.LP.widget.download, function(e, node){
  1521. // this.downloadAttachment(e, node);
  1522. //}.bind(this));
  1523. this.node.inject(this.container);
  1524. //if (this.options.readonly) this.setReadonly();
  1525. this.checkActions();
  1526. this.setEvent();
  1527. }else{
  1528. //this.minActionAreaNode.setStyle("display", "block");
  1529. this.minContent.setStyle("display", "block");
  1530. this.minContent.empty();
  1531. }
  1532. var atts = [];
  1533. while (this.attachments.length){
  1534. var att = this.attachments.shift();
  1535. atts.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(att.data, this));
  1536. }
  1537. this.attachments = atts;
  1538. },
  1539. addAttachment: function(data){
  1540. if (this.options.size=="min"){
  1541. this.attachments.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(data, this));
  1542. }else{
  1543. this.attachments.push(new MWF.widget.AttachmentController.Attachment(data, this));
  1544. }
  1545. }
  1546. });
  1547. MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin = new Class({
  1548. Extends : MWF.widget.AttachmentController.AttachmentMin,
  1549. setEvent: function(){
  1550. this.node.addEvents({
  1551. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list_over"])}.bind(this),
  1552. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list"])}.bind(this),
  1553. "mousedown": function(e){this.selected(e);}.bind(this),
  1554. "click": function(e){this.downloadAttachment(e);}.bind(this)
  1555. });
  1556. },
  1557. downloadAttachment: function(e){
  1558. if (this.controller.module) this.controller.module.downloadAttachment(e, null, [this]);
  1559. }
  1560. });
  1561. MWF.xApplication.Meeting.MeetingArea = new Class({
  1562. initialize: function(container, view, data){
  1563. this.container = container;
  1564. this.view = view;
  1565. this.css = this.view.css;
  1566. this.app = this.view.app;
  1567. this.data = data;
  1568. this.beginDate = Date.parse(this.data.startTime);
  1569. this.endDate = Date.parse(this.data.completedTime);
  1570. this.userName = layout.desktop.session.user.distinguishedName;
  1571. this.userId = layout.desktop.session.user.id;
  1572. this.parseData();
  1573. this.path = "../x_component_Meeting/$Common/default/meetingarea/";
  1574. this.cssPath = "../x_component_Meeting/$Common/default/meetingarea/css.wcss";
  1575. this._loadCss();
  1576. this.load();
  1577. },
  1578. load: function(){
  1579. this.node = new Element("div", {"styles": this.css.meetingNode}).inject( this.container );
  1580. this.node.addEvents({
  1581. mouseenter : function(){
  1582. this.node.setStyles( this.css.meetingNode_over );
  1583. this.subjectNode.setStyles( this.css.meetingSubjectNode_over );
  1584. }.bind(this),
  1585. mouseleave : function(){
  1586. this.node.setStyles( this.css.meetingNode );
  1587. this.subjectNode.setStyles( this.css.meetingSubjectNode );
  1588. }.bind(this),
  1589. click : function(){
  1590. this.openMeeting()
  1591. }.bind(this)
  1592. });
  1593. this.colorNode = new Element("div", {"styles": this.css.meetingColorNode}).inject(this.node);
  1594. this.contentNode = new Element("div", {"styles": this.css.meetingContentNode}).inject(this.node);
  1595. var beginTime = (this.beginDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  1596. var endTime = (this.endDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  1597. this.timeNode = new Element("div", {
  1598. "styles": this.css.meetingTimeNode,
  1599. "text" : beginTime + "-" + endTime
  1600. }).inject(this.contentNode);
  1601. this.subjectNode = new Element("div", {
  1602. "styles": this.css.meetingSubjectNode,
  1603. "text": this.data.subject
  1604. }).inject(this.contentNode);
  1605. var description = (this.data.description || "")+(this.data.summary || "");
  1606. this.descriptionNode = new Element("div", {
  1607. "styles": this.css.meetingDescriptionNode,
  1608. "text" : description
  1609. }).inject(this.contentNode);
  1610. this.loadActionBar();
  1611. switch (this.data.status){
  1612. case "wait":
  1613. this.colorNode.setStyles({"background-color": "#4990E2"});
  1614. this.timeNode.setStyles({"color": "#4990E2"});
  1615. break;
  1616. case "processing":
  1617. this.colorNode.setStyles({"background-color": "#66CC7F"});
  1618. this.timeNode.setStyles({"color": "#66CC7F"});
  1619. break;
  1620. case "completed":
  1621. //add attachment
  1622. this.colorNode.setStyles({"background-color": "#ccc"});
  1623. this.timeNode.setStyles({"color": "#ccc"});
  1624. break;
  1625. }
  1626. if (this.data.myWaitAccept){
  1627. this.colorNode.setStyles({"background-color": "#F6A623"});
  1628. this.timeNode.setStyles({"color": "#F6A623"});
  1629. }
  1630. this.resetNodeSize();
  1631. this.loadTooltip();
  1632. },
  1633. parseData : function(){
  1634. if( !this.data.status ){
  1635. var now = new Date();
  1636. var status;
  1637. if( this.beginDate > now ){
  1638. status = "wait";
  1639. }else if( this.endDate < now ){
  1640. status = "completed";
  1641. }else{
  1642. status = "processing";
  1643. }
  1644. this.data.status = status;
  1645. }
  1646. if( typeOf( this.data.myWaitAccept ) != "boolean" ){
  1647. if( this.data.invitePersonList.contains( this.userName ) || this.data.invitePersonList.contains( this.userId ) ){
  1648. this.data.myWaitAccept = ( !this.data.acceptPersonList.contains( this.userName ) || this.data.acceptPersonList.contains( this.userId ) ) &&
  1649. ( !this.data.rejectPersonList.contains( this.userName ) || !this.data.rejectPersonList.contains( this.userId ) )
  1650. }
  1651. }
  1652. },
  1653. loadActionBar : function(){
  1654. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() || this.data.myWaitAccept ){
  1655. }else{
  1656. return;
  1657. }
  1658. this.actionBar = new Element("div", {
  1659. "styles": this.css.actionBar
  1660. }).inject(this.contentNode);
  1661. //this.viewAction = new Element("div", {
  1662. // styles: this.css.action_view,
  1663. // events : {
  1664. // mouseenter : function(){
  1665. // this.viewAction.setStyles( this.css.action_view_over );
  1666. // }.bind(this),
  1667. // mouseleave : function(){
  1668. // this.viewAction.setStyles( this.css.action_view );
  1669. // }.bind(this),
  1670. // click : function(){
  1671. // this.openMeeting()
  1672. // }.bind(this)
  1673. // }
  1674. //}).inject(this.actionBar);
  1675. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() ){
  1676. if( this.data.status=="wait" ){
  1677. this.editAction = new Element("div", {
  1678. styles: this.css.action_edit,
  1679. events : {
  1680. mouseover : function(){
  1681. this.editAction.setStyles( this.css.action_edit_over );
  1682. }.bind(this),
  1683. mouseout : function(){
  1684. this.editAction.setStyles( this.css.action_edit );
  1685. }.bind(this),
  1686. click : function(e){
  1687. this.editMeeting();
  1688. e.stopPropagation();
  1689. }.bind(this)
  1690. }
  1691. }).inject(this.actionBar);
  1692. //if (this.data.myWaitConfirm) this.createConfirmActions();
  1693. //if (this.data.myWaitAccept) this.createAcceptActions();
  1694. //if (this.data.status=="wait" && this.isEdit) this.createCancelActions();
  1695. this.removeAction = new Element("div", {
  1696. styles: this.css.action_remove,
  1697. events : {
  1698. mouseover : function(){
  1699. this.removeAction.setStyles( this.css.action_remove_over );
  1700. }.bind(this),
  1701. mouseout : function(){
  1702. this.removeAction.setStyles( this.css.action_remove );
  1703. }.bind(this),
  1704. click : function( e ){
  1705. this.cancel(e);
  1706. e.stopPropagation();
  1707. }.bind(this)
  1708. }
  1709. }).inject(this.actionBar);
  1710. }
  1711. }
  1712. if (this.data.myWaitAccept){
  1713. this.acceptAction = new Element("div", {
  1714. styles: this.css.action_accept,
  1715. title : this.app.lp.accept,
  1716. events : {
  1717. mouseover : function(){
  1718. this.acceptAction.setStyles( this.css.action_accept_over );
  1719. }.bind(this),
  1720. mouseout : function(){
  1721. this.acceptAction.setStyles( this.css.action_accept );
  1722. }.bind(this),
  1723. click : function( e ){
  1724. this.accept(e);
  1725. e.stopPropagation();
  1726. }.bind(this)
  1727. }
  1728. }).inject(this.actionBar);
  1729. this.rejectAction = new Element("div", {
  1730. styles: this.css.action_reject,
  1731. title : this.app.lp.reject,
  1732. events : {
  1733. mouseover : function(){
  1734. this.rejectAction.setStyles( this.css.action_reject_over );
  1735. }.bind(this),
  1736. mouseout : function(){
  1737. this.rejectAction.setStyles( this.css.action_reject );
  1738. }.bind(this),
  1739. click : function( e ){
  1740. this.reject(e);
  1741. e.stopPropagation();
  1742. }.bind(this)
  1743. }
  1744. }).inject(this.actionBar);
  1745. }
  1746. },
  1747. getString : function( str ){
  1748. var s = "00" + str;
  1749. return s.substr(s.length - 2, 2 );
  1750. },
  1751. _loadCss: function(){
  1752. var key = encodeURIComponent(this.cssPath);
  1753. if (MWF.widget.css[key]){
  1754. this.css = MWF.widget.css[key];
  1755. }else{
  1756. var r = new Request.JSON({
  1757. url: this.cssPath,
  1758. secure: false,
  1759. async: false,
  1760. method: "get",
  1761. noCache: false,
  1762. onSuccess: function(responseJSON, responseText){
  1763. this.css = responseJSON;
  1764. MWF.widget.css[key] = responseJSON;
  1765. }.bind(this),
  1766. onError: function(text, error){
  1767. alert(error + text);
  1768. }
  1769. });
  1770. r.send();
  1771. }
  1772. },
  1773. loadTooltip : function( isHideAttachment ){
  1774. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.node, this.app, this.data, {
  1775. axis : "x",
  1776. hiddenDelay : 300,
  1777. displayDelay : 300,
  1778. isHideAttachment : isHideAttachment
  1779. });
  1780. },
  1781. showTooltip: function( ){
  1782. if( this.tooltip ){
  1783. this.tooltip.load();
  1784. }else{
  1785. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.viewAction, this.app, this.data);
  1786. this.tooltip.load();
  1787. }
  1788. },
  1789. openMeeting: function(){
  1790. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  1791. form.view = this.view;
  1792. form.open();
  1793. },
  1794. resetNodeSize: function(){
  1795. var contentSize = this.contentNode.getSize();
  1796. this.colorNode.setStyle("height", contentSize.y );
  1797. },
  1798. destroy: function(){
  1799. if(this.tooltip)this.tooltip.destroy();
  1800. this.node.destroy();
  1801. MWF.release(this);
  1802. },
  1803. editMeeting : function(){
  1804. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  1805. form.view = this.view;
  1806. form.edit();
  1807. },
  1808. cancel: function(e){
  1809. var _self = this;
  1810. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  1811. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 380, 150, function(){
  1812. _self.cancelMeeting();
  1813. this.close();
  1814. }, function(){
  1815. this.close();
  1816. });
  1817. },
  1818. cancelMeeting: function(){
  1819. var view = this.view;
  1820. this.app.actions.deleteMeeting(this.data.id, function(){
  1821. view.reload();
  1822. }.bind(this))
  1823. },
  1824. reject: function(e){
  1825. var _self = this;
  1826. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  1827. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  1828. _self.rejectMeeting();
  1829. this.close();
  1830. }, function(){
  1831. this.close();
  1832. });
  1833. },
  1834. rejectMeeting: function(){
  1835. var view = this.view;
  1836. this.app.actions.rejectMeeting(this.data.id, function(){
  1837. view.reload();
  1838. }.bind(this))
  1839. },
  1840. accept: function(e){
  1841. var _self = this;
  1842. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  1843. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  1844. _self.acceptMeeting();
  1845. this.close();
  1846. }, function(){
  1847. this.close();
  1848. });
  1849. },
  1850. acceptMeeting: function(){
  1851. var view = this.view;
  1852. this.app.actions.acceptMeeting(this.data.id, function(){
  1853. view.reload();
  1854. }.bind(this))
  1855. },
  1856. disagree: function(e){
  1857. var _self = this;
  1858. var text = this.app.lp.disagree_confirm.replace(/{name}/g, this.data.subject);
  1859. this.app.confirm("infor", e, this.app.lp.disagree_confirm_title, text, 300, 120, function(){
  1860. _self.disagreeMeeting();
  1861. this.close();
  1862. }, function(){
  1863. this.close();
  1864. });
  1865. },
  1866. disagreeMeeting: function(){
  1867. var view = this.view;
  1868. this.app.actions.denyMeeting(this.data.id, function(){
  1869. view.reload();
  1870. }.bind(this))
  1871. },
  1872. agree: function(e){
  1873. var _self = this;
  1874. var text = this.app.lp.agree_confirm.replace(/{name}/g, this.data.subject);
  1875. this.app.confirm("infor", e, this.app.lp.agree_confirm_title, text, 300, 120, function(){
  1876. _self.agreeMeeting();
  1877. this.close();
  1878. }, function(){
  1879. this.close();
  1880. });
  1881. },
  1882. agreeMeeting: function(){
  1883. var view = this.view;
  1884. this.app.actions.allowMeeting(this.data.id, function(){
  1885. view.reload();
  1886. }.bind(this))
  1887. }
  1888. });
  1889. MWF.xApplication.Meeting.SideBar = new Class({
  1890. Extends: MWF.widget.Common,
  1891. Implements: [Options, Events],
  1892. options: {
  1893. "style": "default"
  1894. },
  1895. initialize : function( container, app, options){
  1896. this.setOptions( options );
  1897. this.container = container;
  1898. this.app = app;
  1899. //this.css = this.app.css;
  1900. this.lp = this.app.lp;
  1901. this.isHidden = false;
  1902. this.cssPath = "../x_component_Meeting/$Common/"+this.options.style+"/sidebar/css.wcss";
  1903. this._loadCss();
  1904. this.load();
  1905. },
  1906. load : function(){
  1907. this.node = new Element("div.sideBar", {
  1908. "styles": this.css.node,
  1909. events : {
  1910. mousedown : function( ev ){
  1911. ev.stopPropagation();
  1912. }
  1913. }
  1914. }).inject(this.container);
  1915. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  1916. this.loadStatusArea();
  1917. new Element("div.contentLine", {
  1918. "styles" : this.css.contentLine
  1919. }).inject( this.contentNode );
  1920. this.loadTodayMeetingNode();
  1921. this.trapezoid = new Element("div.trapezoid",{
  1922. "styles":this.css.trapezoid_toRight,
  1923. events : {
  1924. click : function(){
  1925. this.trigger();
  1926. }.bind(this)
  1927. }
  1928. }).inject(this.node);
  1929. //this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  1930. this.loadTodayMeeting( function(){
  1931. var x = this.node.getSize().x - 8;
  1932. this.node.setStyle( "right", "-"+x+"px" );
  1933. this.resetNodeSize();
  1934. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  1935. this.app.addEvent("resize", this.resetNodeSizeFun );
  1936. this.hideFun = this.hide.bind(this);
  1937. this.app.node.addEvent("mousedown", this.hideFun);
  1938. }.bind(this));
  1939. },
  1940. loadStatusArea : function(){
  1941. var area = new Element("div", {
  1942. "styles" : this.css.statusArea
  1943. }).inject( this.contentNode );
  1944. var html = "<div class='titleDiv'>"+this.lp.config.meetingStatus+"</div>" +
  1945. "<div class = 'statusStyle'>"+
  1946. " <div class='statusIconStyle' style='background-color:#4990E2'></div>" +
  1947. " <div class = 'statusTextStyle'>"+this.lp.config.wait+"</div></div>" +
  1948. "</div>"+
  1949. "<div class = 'statusStyle'>"+
  1950. " <div class='statusIconStyle' style='background-color:#66CC7F'></div>" +
  1951. " <div class = 'statusTextStyle'>"+this.lp.config.progress+"</div></div>" +
  1952. "</div>"+
  1953. "<div class = 'statusStyle'>"+
  1954. " <div class='statusIconStyle' style='background-color:#F6A623'></div>" +
  1955. " <div class = 'statusTextStyle'>"+this.lp.config.invite+"</div></div>" +
  1956. "</div>"+
  1957. "<div class = 'statusStyle'>"+
  1958. " <div class='statusIconStyle' style='background-color:#ccc'></div>" +
  1959. " <div class = 'statusTextStyle'>"+this.lp.config.completed+"</div></div>" +
  1960. "</div>"+
  1961. "<div class = 'statusStyle'>"+
  1962. " <div class='statusIconStyle2' style='border:2px solid #FF7F7F;'></div>" +
  1963. " <div class = 'statusTextStyle'>"+this.lp.config.conflict+"</div></div>" +
  1964. "</div>";
  1965. area.set("html", html);
  1966. area.getElements("div.titleDiv").setStyles( this.css.titleDiv );
  1967. area.getElements("div.statusStyle").setStyles( this.css.statusStyle );
  1968. area.getElements("div.statusIconStyle").setStyles( this.css.statusIconStyle );
  1969. area.getElements("div.statusIconStyle2").setStyles( this.css.statusIconStyle2 );
  1970. area.getElements("div.statusTextStyle").setStyles( this.css.statusTextStyle );
  1971. },
  1972. loadTodayMeetingNode: function(){
  1973. var area = new Element("div.meetingArea", {
  1974. "styles" : this.css.meetingArea
  1975. }).inject( this.contentNode );
  1976. new Element("div.titleDiv", {
  1977. "styles" : this.css.titleDiv,
  1978. "text" : this.lp.meetingNotice
  1979. }).inject( area );
  1980. this.meetingNode = Element("div", {
  1981. "styles" : this.css.meetingNode
  1982. }).inject( area );
  1983. },
  1984. loadTodayMeeting : function( callback ){
  1985. var today = new Date();
  1986. var user = layout.desktop.session.user;
  1987. var dn = user.distinguishedName;
  1988. var y = today.getFullYear();
  1989. var m = today.getMonth()+1;
  1990. var d = today.getDate();
  1991. this.app.actions.listMeetingDay(y, m, d, function(json) {
  1992. var data = [];
  1993. json.data.each( function( d ){
  1994. if( d.invitePersonList.contains( dn ) || d.applicant == dn ){
  1995. if( !d.rejectPersonList.contains( dn ) ){
  1996. data.push( d );
  1997. }
  1998. }
  1999. }.bind(this));
  2000. if( user.distinguishedName ){
  2001. var userName = user.distinguishedName.split("@")[0]
  2002. }else{
  2003. var userName = user.name
  2004. }
  2005. var lp = data.length ? this.lp.meetingTopInfor : this.lp.noMeetingTopInfor ;
  2006. this.meetingTopNode = new Element("div", {
  2007. "styles" : this.css.meetingTopNode,
  2008. "html" : lp.replace("{userName}",userName).replace("{count}",data.length )
  2009. }).inject( this.meetingNode );
  2010. this.scrollNode = new Element("div.scrollNode", {
  2011. "styles" : this.css.scrollNode
  2012. }).inject( this.meetingNode );
  2013. this.meetingItemContainer = new Element("div.meetingItemContainer", {
  2014. "styles" : this.css.meetingItemContainer
  2015. }).inject( this.scrollNode );
  2016. data.each( function( d, i ){
  2017. var itemNode = new Element("div.meetingItemNode", {
  2018. "styles" : this.css.meetingItemNode,
  2019. "events" : {
  2020. click : function(){
  2021. this.obj.openMeeting( this.data );
  2022. }.bind({ obj : this, data : d })
  2023. }
  2024. }).inject( this.meetingItemContainer );
  2025. this.tooltipList = this.tooltipList || [];
  2026. this.tooltipList.push( new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, itemNode, this.app, d, {
  2027. axis : "x",
  2028. hiddenDelay : 300,
  2029. displayDelay : 300
  2030. })
  2031. );
  2032. var colorNode = new Element("div.meetingItemColorNode", {
  2033. "styles" : this.css.meetingItemColorNode,
  2034. "text" : i+1
  2035. }).inject( itemNode );
  2036. var textNode = new Element("div.meetingItemTextNode", {
  2037. "styles" : this.css.meetingItemTextNode,
  2038. "text" : d.subject
  2039. }).inject( itemNode );
  2040. switch (d.status){
  2041. case "wait":
  2042. colorNode.setStyles({"background-color": "#4990E2"});
  2043. break;
  2044. case "processing":
  2045. colorNode.setStyles({"background-color": "#66CC7F"});
  2046. break;
  2047. case "completed":
  2048. //add attachment
  2049. colorNode.setStyles({"background-color": "#ccc"});
  2050. break;
  2051. }
  2052. if (d.myWaitAccept){
  2053. colorNode.setStyles({"background-color": "#F6A623"});
  2054. }
  2055. var y = itemNode.getSize().y ;
  2056. colorNode.setStyle("margin-top", ( y - 20)/2 );
  2057. }.bind(this));
  2058. this.setScrollBar( this.scrollNode );
  2059. if( callback )callback();
  2060. }.bind(this));
  2061. },
  2062. trigger : function(){
  2063. this.isHidden ? this.show( true ) : this.hide( true )
  2064. },
  2065. hide: function( isFireEvent ){
  2066. var x = this.node.getSize().x - 9;
  2067. var fx = new Fx.Morph(this.node, {
  2068. "duration": "300",
  2069. "transition": Fx.Transitions.Expo.easeOut
  2070. });
  2071. fx.start({
  2072. //"opacity": 0
  2073. }).chain(function(){
  2074. this.isHidden = true;
  2075. //this.node.setStyle("display", "none");
  2076. this.node.setStyles({
  2077. "right": "-"+x+"px"
  2078. });
  2079. this.trapezoid.setStyles( this.css.trapezoid_toLeft );
  2080. //if(isFireEvent)this.app.fireEvent("resize");
  2081. }.bind(this));
  2082. },
  2083. show: function( isFireEvent ){
  2084. this.node.setStyles(this.css.node);
  2085. this.trapezoid.setStyles( this.css.trapezoid_toRight );
  2086. //var x = this.node.getSize().x - 8;
  2087. //this.node.setStyles( "right", "-"+x+"px" );
  2088. var fx = new Fx.Morph(this.node, {
  2089. "duration": "500",
  2090. "transition": Fx.Transitions.Expo.easeOut
  2091. });
  2092. this.app.fireAppEvent("resize");
  2093. fx.start({
  2094. "opacity": 1
  2095. }).chain(function(){
  2096. this.node.setStyles({
  2097. //"position": "static",
  2098. //"width": "auto"
  2099. "right": "0px"
  2100. });
  2101. this.isHidden = false;
  2102. //if(isFireEvent)this.app.fireEvent("resize");
  2103. }.bind(this))
  2104. },
  2105. //show: function(){
  2106. // this.node.setStyles(this.css.configNode);
  2107. // var fx = new Fx.Morph(this.node, {
  2108. // "duration": "500",
  2109. // "transition": Fx.Transitions.Expo.easeOut
  2110. // });
  2111. // fx.start({
  2112. // "opacity": 1
  2113. // }).chain(function(){
  2114. // this.hideFun = this.hide.bind(this);
  2115. // this.app.content.addEvent("mousedown", this.hideFun);
  2116. // }.bind(this));
  2117. //},
  2118. //hide: function(){
  2119. // this.node.destroy();
  2120. // this.app.content.removeEvent("mousedown", this.hideFun);
  2121. // MWF.release(this);
  2122. //},
  2123. resetNodeSize: function(){
  2124. var size = this.container.getSize();
  2125. this.node.setStyle("height", size.y - 50 );
  2126. this.trapezoid.setStyle("top", ( (size.y - 50)/2 - this.trapezoid.getSize().y/2 ));
  2127. var y = size.y - 395;
  2128. var meetContainerY = this.meetingItemContainer.getSize().y + 12;
  2129. this.scrollNode.setStyle("height", Math.min( y, meetContainerY ) );
  2130. },
  2131. getSize : function(){
  2132. //var size = this.node.getSize();
  2133. //return {
  2134. // x : this.isHidden ? 9 : size.x,
  2135. // y : size.y
  2136. //}
  2137. return { x : 9, y : 0 }
  2138. },
  2139. showByType : function( type ){
  2140. },
  2141. reload : function(){
  2142. this.destory();
  2143. this.app.reload();
  2144. },
  2145. openMeeting : function( data ){
  2146. var form = new MWF.xApplication.Meeting.MeetingForm(this, data, {}, {app:this.app});
  2147. form.view = this.app;
  2148. form.open();
  2149. },
  2150. destory : function(){
  2151. this.tooltipList.each( function( t ){
  2152. t.destory();
  2153. });
  2154. this.app.removeEvent("resize", this.resetNodeSizeFun );
  2155. this.app.node.removeEvent("mousedown", this.hideFun);
  2156. this.node.destory();
  2157. }
  2158. });