Common.js 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314
  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:100px;height:130px;'></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 : "100px",
  886. height : "100px"
  887. }
  888. }).inject( this.qrCodeArea );
  889. var div = new Element("div",{
  890. text : "打印签到二维码",
  891. styles : {
  892. color : "#3c75b7",
  893. cursor : "pointer"
  894. },
  895. events : {
  896. click : function(){
  897. window.open(o2.filterUrl("../x_component_Meeting/$Main/qrPrint.html?meeting="+this.data.id), "_blank" );
  898. }.bind(this)
  899. }
  900. }).inject( this.qrCodeArea );
  901. }.bind(this));
  902. },
  903. loadAcceptAndReject : function( item ){
  904. var personName = item.data.distinguishedName;
  905. if(this.data.acceptPersonList){
  906. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  907. var acceptNode = new Element("div", {"styles": this.css.acceptIconNode}).inject(item.node, "top");
  908. new Element("div", {
  909. "styles": this.css.acceptTextNode,
  910. "text": this.app.lp.accepted
  911. }).inject(item.inforNode);
  912. }
  913. }
  914. if(this.data.rejectPersonList){
  915. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  916. var rejectNode = new Element("div", {"styles": this.css.rejectIconNode}).inject(item.node, "top");
  917. new Element("div", {
  918. "styles": this.css.rejectTextNode,
  919. "text": this.app.lp.rejected
  920. }).inject(item.inforNode);
  921. }
  922. }
  923. },
  924. getMeetingData : function( callback ){
  925. if( this.data && this.data.id ){
  926. ( this.app.actions || this.actions ).getMeeting( this.data.id, function( json ){
  927. this.data = json.data;
  928. if(callback)callback();
  929. }.bind(this))
  930. }else{
  931. if(callback)callback();
  932. }
  933. },
  934. editMeeting : function(){
  935. this.formTopNode = null;
  936. if(this.setFormNodeSizeFun && this.app ){
  937. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  938. }
  939. if( this.formMaskNode )this.formMaskNode.destroy();
  940. this.formAreaNode.destroy();
  941. this.edit();
  942. },
  943. cancelMeeting: function(e){
  944. var _self = this;
  945. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  946. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 380, 200, function(){
  947. _self._cancelMeeting();
  948. this.close();
  949. _self.close();
  950. }, function(){
  951. this.close();
  952. });
  953. },
  954. _cancelMeeting: function(){
  955. var view = this.view;
  956. this.app.actions.deleteMeeting(this.data.id, function(){
  957. view.reload();
  958. }.bind(this))
  959. },
  960. reset: function(){
  961. this.formTableArea.empty();
  962. this._createTableContent();
  963. },
  964. clearRoom : function(){
  965. this.roomId = "";
  966. if(this.roomInput)this.roomInput.set("text", "");
  967. },
  968. loadSelectRoom_read : function(){
  969. var roomId = this.data.room || this.options.room;
  970. if (roomId){
  971. ( this.app.actions || this.actions ).getRoom(roomId, function(json){
  972. ( this.app.actions || this.actions ).getBuilding(json.data.building, function(bjson){
  973. this.roomId = roomId;
  974. this.meetingRoomArea.set("text", json.data.name+" ("+bjson.data.name+")");
  975. }.bind(this));
  976. }.bind(this));
  977. }
  978. },
  979. loadSelectRoom: function(){
  980. var css = this.app.css;
  981. var lineNode = new Element("div", {"styles": css.createMeetingInfoLineNode}).inject(this.meetingRoomArea);
  982. var editNode = new Element("div", {
  983. "styles": css.createMeetingInfoItemEditNode,
  984. "html": "<div></div>"
  985. }).inject(lineNode);
  986. this.roomInput = editNode.getFirst();
  987. this.roomInput.setStyles( css.createMeetingInfoItemDivNode);
  988. //var downNode = new Element("div", {"styles": this.css.createMeetingInfoItemDownNode}).inject(editNode);
  989. this.roomInput.addEvents({
  990. "click": function(e){this.selectRooms();}.bind(this)
  991. });
  992. var roomId = this.data.room || this.options.room;
  993. if (roomId){
  994. ( this.app.actions || this.actions ).getRoom(roomId, function(json){
  995. ( this.app.actions || this.actions ).getBuilding(json.data.building, function(bjson){
  996. this.roomId = roomId;
  997. this.roomInput.set("text", json.data.name+" ("+bjson.data.name+")");
  998. }.bind(this));
  999. }.bind(this));
  1000. }
  1001. },
  1002. selectRooms: function(){
  1003. this.createRoomNode(function(){
  1004. this.loadSelectRooms();
  1005. this.selectRoomNode.setStyle("display", "block");
  1006. this.hideRoomNodeFun = this.hideRoomNode.bind(this);
  1007. document.body.addEvent("mousedown", this.hideRoomNodeFun);
  1008. //var p = this.selectRoomNode.getPosition(this.selectRoomNode.getOffsetParent());
  1009. this.selectRoomNode.position({
  1010. relativeTo: this.roomInput,
  1011. position: 'bottomLeft',
  1012. edge: 'upperLeft',
  1013. offset: {x: 0, y: 0}
  1014. });
  1015. var size = this.roomInput.getSize();
  1016. var w = size.x-2;
  1017. this.selectRoomNode.setStyle("width", ""+w+"px");
  1018. }.bind(this));
  1019. },
  1020. createRoomNode: function(callback){
  1021. var css = this.app.css;
  1022. if (!this.selectRoomNode){
  1023. this.selectRoomNode = new Element("div", {"styles": css.createMeetingInfoSelectRoomNode}).inject(this.formNode);
  1024. this.selectRoomNode.addEvent("mousedown", function(e){e.stopPropagation();});
  1025. if (callback) callback();
  1026. }else{
  1027. if (callback) callback();
  1028. }
  1029. },
  1030. loadSelectRooms: function(){
  1031. var css = this.app.css;
  1032. var result = this.form.getResult(false,null,false,false,true);
  1033. var d = result.dateInput;
  1034. var bt = result.beginTimeInput;
  1035. var et = result.endTimeInput;
  1036. var start = d+" "+bt;
  1037. var completed = d+" "+et;
  1038. this.app.actions.listBuildingByRange(start, completed, function(json){
  1039. json.data.each(function(building){
  1040. var node = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1Node}).inject(this.selectRoomNode);
  1041. var nodeName = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1NameNode, "text": building.name}).inject(node);
  1042. var nodeAddr = new Element("div", {"styles": css.createMeetingInfoSelectRoomItem1AddrNode, "text": building.address}).inject(node);
  1043. building.roomList.each(function(room, i){
  1044. if (room.available && room.idle) this.createRoomSelectNode(room, i, building);
  1045. }.bind(this));
  1046. }.bind(this));
  1047. }.bind(this));
  1048. },
  1049. createRoomSelectNode: function(room, i, building){
  1050. var css = this.app.css;
  1051. var roomNode = new Element("div", {"styles": css.roomTitleNode}).inject(this.selectRoomNode);
  1052. var capacityNode = new Element("div", {"styles": css.roomTitleCapacityNode, "text": room.capacity+this.lp.person}).inject(roomNode);
  1053. var inforNode = new Element("div", {"styles": css.roomTitleInforNode}).inject(roomNode);
  1054. var node = new Element("div", {"styles": {"height": "20px"}}).inject(inforNode);
  1055. var numberNode = new Element("div", {"styles": css.roomTitleNumberNode, "text": (room.roomNumber) ? "#"+room.roomNumber : ""}).inject(node);
  1056. var nameNode = new Element("div", {"styles": css.roomTitleNameNode, "text": room.name}).inject(node);
  1057. var iconsNode = new Element("div", {"styles": css.roomTitleIconsNode}).inject(inforNode);
  1058. var deviceList = ( room.device || "" ).split("#");
  1059. deviceList.each(function(name){
  1060. if( name ){
  1061. var node = new Element("div", {"styles": css.roomTitleIconNode, "title": this.lp.device[name]}).inject(iconsNode);
  1062. node.setStyle("background-image", "url(../x_component_Meeting/$RoomView/default/icon/device/"+name+"_disable.png)");
  1063. }
  1064. }.bind(this));
  1065. if ((i % 2)!=0) roomNode.setStyle("background-color", "#f4f8ff");
  1066. roomNode.store("room", room);
  1067. var _self = this;
  1068. if (room.idle){
  1069. roomNode.addEvents({
  1070. "mouseover": function(e){
  1071. var color = roomNode.getStyle("background-color");
  1072. this.store("bgcolor", color);
  1073. this.setStyle("background-color", "#e4edfc");
  1074. },
  1075. "mouseout": function(){
  1076. var color = this.retrieve("bgcolor", "#FFF");
  1077. this.setStyle("background-color", color);
  1078. },
  1079. "click": function(){
  1080. var roomData = this.retrieve("room");
  1081. _self.roomId = roomData.id;
  1082. //roomNode.inject(_self.roomInput);
  1083. _self.roomInput.set("text", roomData.name+" ("+building.name+")");
  1084. _self.hideRoomNode();
  1085. }
  1086. });
  1087. }else{
  1088. roomNode.setStyle("background-color", "#fff6f6");
  1089. var disabledNode = new Element("div", {"styles": css.roomTitleDisabledIconNode}).inject(roomNode);
  1090. }
  1091. },
  1092. hideRoomNode: function(){
  1093. this.selectRoomNode.empty();
  1094. this.selectRoomNode.setStyle("display", "none");
  1095. document.body.removeEvent("mousedown", this.hideRoomNodeFun);
  1096. },
  1097. setCreateRoomSelectBuildingNodeSize: function(){
  1098. var p = this.createRoomBuildingInput.getPosition(this.createRoomBuildingInput.getOffsetParent());
  1099. this.createRoomSelectBuildingNode.position({
  1100. relativeTo: this.createRoomBuildingInput,
  1101. position: 'bottomCenter',
  1102. edge: 'upperCenter',
  1103. offset: {x: 0, y: 0}
  1104. });
  1105. this.createRoomSelectBuildingNode.setStyle("left", p.x);
  1106. var size = this.createRoomBuildingInput.getSize();
  1107. var w = size.x-2;
  1108. this.createRoomSelectBuildingNode.setStyle("width", ""+w+"px");
  1109. },
  1110. loadAttachment: function(){
  1111. this.attachmentTr.setStyle("display","");
  1112. this.attachmentNode = new Element("div", {"styles": this.css.createMeetingAttachmentNode}).inject(this.attachmentArea);
  1113. var attachmentContentNode = new Element("div", {"styles": this.css.createMeetingAttachmentContentNode}).inject(this.attachmentNode);
  1114. MWF.require("MWF.widget.AttachmentController", function(){
  1115. this.attachmentController = new MWF.widget.AttachmentController(attachmentContentNode, this, {
  1116. "size": "min",
  1117. "isSizeChange": false,
  1118. "isReplace": false,
  1119. "isUpload": this.isNew || this.isEdited,
  1120. "isDelete": this.isNew || this.isEdited,
  1121. "isDownload": true,
  1122. "readonly": !this.isNew && !this.isEdited
  1123. });
  1124. this.attachmentController.load();
  1125. if( this.data.attachmentList ){
  1126. this.data.attachmentList.each(function (att) {
  1127. att.person = att.lastUpdatePerson.split("@")[0];
  1128. var at = this.attachmentController.addAttachment(att);
  1129. }.bind(this));
  1130. }
  1131. }.bind(this));
  1132. },
  1133. uploadAttachment: function(e, node){
  1134. if (!this.uploadFileAreaNode){
  1135. this.createUploadFileNode();
  1136. }
  1137. this.fileUploadNode.click();
  1138. },
  1139. createUploadFileNode: function(){
  1140. this.uploadFileAreaNode = new Element("div");
  1141. var html = "<input name=\"file\" type=\"file\" multiple/>";
  1142. this.uploadFileAreaNode.set("html", html);
  1143. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  1144. this.fileUploadNode.addEvent("change", function(){
  1145. var files = this.fileUploadNode.files;
  1146. if (files.length){
  1147. for (var i = 0; i < files.length; i++) {
  1148. var file = files.item(i);
  1149. var formData = new FormData();
  1150. formData.append('file', file);
  1151. //formData.append('folder', folderId);
  1152. this.app.actions.addAttachment(this.data.id, formData, file, function(o, text){
  1153. if (o.id){
  1154. this.app.actions.getAttachment(o.id, function(json){
  1155. if (json.data) this.attachmentController.addAttachment(json.data);
  1156. this.attachmentController.checkActions();
  1157. }.bind(this))
  1158. }
  1159. this.attachmentController.checkActions();
  1160. }.bind(this));
  1161. }
  1162. }
  1163. }.bind(this));
  1164. },
  1165. deleteAttachments: function(e, node, attachments){
  1166. var names = [];
  1167. attachments.each(function(attachment){
  1168. names.push(attachment.data.name);
  1169. }.bind(this));
  1170. var _self = this;
  1171. this.app.confirm("warn", e, this.lp.deleteAttachmentTitle, this.lp.deleteAttachment+"( "+names.join(", ")+" )", 300, 120, function(){
  1172. while (attachments.length){
  1173. attachment = attachments.shift();
  1174. _self.deleteAttachment(attachment);
  1175. }
  1176. this.close();
  1177. }, function(){
  1178. this.close();
  1179. }, null);
  1180. },
  1181. deleteAttachment: function(attachment){
  1182. this.app.actions.deleteFile(attachment.data.id, function(josn){
  1183. this.attachmentController.removeAttachment(attachment);
  1184. this.attachmentController.checkActions();
  1185. }.bind(this));
  1186. },
  1187. downloadAttachment: function(e, node, attachments){
  1188. attachments.each(function(att){
  1189. this.app.actions.getFileDownload(att.data.id);
  1190. }.bind(this));
  1191. },
  1192. openAttachment: function(e, node, attachments){
  1193. attachments.each(function(att){
  1194. this.app.actions.getFile(att.data.id);
  1195. }.bind(this));
  1196. },
  1197. getAttachmentUrl: function(attachment, callback){
  1198. this.app.actions.getFileUrl(attachment.data.id, callback);
  1199. },
  1200. save: function(){
  1201. this._save(function(){
  1202. this.app.notice(this.lp.meeting_saveSuccess, "success");
  1203. if (!this.attachmentNode){
  1204. this.loadAttachment();
  1205. }
  1206. }.bind(this));
  1207. },
  1208. _save: function(callback){
  1209. this.getSaveData();
  1210. var now = new Date();
  1211. var errorText = "";
  1212. if (!this.data.subject) errorText +=this.lp.meeting_input_subject_error;
  1213. if (!this.data.room) errorText +=this.lp.meeting_input_room_error;
  1214. if (!this.data.invitePersonList.length) errorText +=this.lp.meeting_input_person_error;
  1215. if( this.data.startTimeDate ){
  1216. if (this.data.startTimeDate.diff(this.data.completedTimeDate, "minute")<1) errorText +=this.lp.meeting_input_time_error;
  1217. if (now.diff(this.data.startTimeDate, "minute")<0) errorText +=this.lp.meeting_input_date_error;
  1218. delete this.data.startTimeDate;
  1219. delete this.data.completedTimeDate;
  1220. }
  1221. if (errorText){
  1222. this.app.notice(this.lp.meeting_input_error+errorText, "error");
  1223. return false;
  1224. }
  1225. this.app.actions.saveMeeting(this.data, function(json){
  1226. this.data.id = json.data.id;
  1227. this.waitReload = true;
  1228. if (callback) callback();
  1229. }.bind(this));
  1230. },
  1231. getSaveData: function(){
  1232. this.data = this.form.getResult(false,null,false,false,true);
  1233. this.data.room = this.roomId;
  1234. if( this.invitePersonList ){
  1235. this.data.invitePersonList = this.invitePersonList;
  1236. }
  1237. var d = this.data.dateInput;
  1238. // if( this.isNew ) {
  1239. var startTime = d + " " + this.data.beginTimeInput + ":0";
  1240. var completedTime = d + " " + this.data.endTimeInput + ":0";
  1241. var startTimeDate = Date.parse(startTime);
  1242. var completedTimeDate = Date.parse(completedTime);
  1243. this.data.startTime = startTime;
  1244. this.data.completedTime = completedTime;
  1245. this.data.startTimeDate = startTimeDate;
  1246. this.data.completedTimeDate = completedTimeDate;
  1247. // }
  1248. if( this.isNew ){
  1249. delete this.data.applicant;
  1250. }else{
  1251. this.data.applicant = this.data.applicant.join(",")
  1252. }
  1253. },
  1254. getPersonByIdentity : function( identity ){
  1255. },
  1256. getPerson : function( source ){
  1257. if( typeOf(source) != "array" )source = [source];
  1258. var target = [];
  1259. source.each( function( s ){
  1260. if( s.split("@").getLast().toLowerCase() == "i" ){
  1261. target.push( this.getPersonByIdentity( s ) )
  1262. }else{
  1263. target.push( s )
  1264. }
  1265. }.bind(this));
  1266. return target;
  1267. },
  1268. reject: function(e){
  1269. var _self = this;
  1270. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  1271. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  1272. _self.rejectMeeting();
  1273. this.close();
  1274. _self.close();
  1275. }, function(){
  1276. this.close();
  1277. });
  1278. },
  1279. rejectMeeting: function(){
  1280. var view = this.view;
  1281. this.app.actions.rejectMeeting(this.data.id, function(){
  1282. view.reload();
  1283. }.bind(this))
  1284. },
  1285. accept: function(e){
  1286. var _self = this;
  1287. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  1288. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  1289. _self.acceptMeeting();
  1290. this.close();
  1291. _self.close();
  1292. }, function(){
  1293. this.close();
  1294. });
  1295. },
  1296. acceptMeeting: function(){
  1297. var view = this.view;
  1298. this.app.actions.acceptMeeting(this.data.id, function(){
  1299. view.reload();
  1300. }.bind(this))
  1301. },
  1302. close: function (e) {
  1303. this.fireEvent("queryClose");
  1304. this._close();
  1305. //if( this.form ){
  1306. // this.form.destroy();
  1307. //}
  1308. if(this.setFormNodeSizeFun && this.app ){
  1309. this.app.removeEvent("resize",this.setFormNodeSizeFun);
  1310. }
  1311. if( this.formMaskNode )this.formMaskNode.destroy();
  1312. this.formAreaNode.destroy();
  1313. this.fireEvent("postClose");
  1314. if( this.waitReload )this.view.reload();
  1315. delete this;
  1316. }
  1317. });
  1318. MWF.xApplication.Meeting.MeetingTooltip = new Class({
  1319. Extends: MTooltips,
  1320. _loadCustom : function( callback ){
  1321. this.loadRoom( function(){
  1322. this.loadInvite();
  1323. this.loadAttachment();
  1324. if(callback)callback();
  1325. }.bind(this) );
  1326. },
  1327. _getHtml : function(){
  1328. var data = this.data;
  1329. var titleStyle = "font-size:14px;color:#333";
  1330. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1331. var persons = [];
  1332. data.invitePersonList.each( function( p ){
  1333. persons.push(p.split("@")[0] )
  1334. }.bind(this));
  1335. var color = "#ccc";
  1336. switch (data.status){
  1337. case "wait":
  1338. color = "#4990E2";
  1339. break;
  1340. case "processing":
  1341. color = "#66CC7F";
  1342. break;
  1343. case "completed":
  1344. color = "#666";
  1345. break;
  1346. }
  1347. if (data.myWaitAccept){
  1348. color = "#F6A623";
  1349. }
  1350. if (data.confilct){
  1351. color = "#FF7F7F";
  1352. }
  1353. var beginDate = Date.parse(data.startTime);
  1354. var endDate = Date.parse(data.completedTime);
  1355. var dateStr = beginDate.format(this.app.lp.dateFormatDay);
  1356. var beginTime = this.getString( beginDate.getHours() ) + ":" + this.getString( beginDate.getMinutes() );
  1357. var endTime = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  1358. var meetingTime = dateStr + " " + beginTime + "-" + endTime;
  1359. var description = (data.description || "")+(data.summary || "");
  1360. var html =
  1361. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1362. " <div style='font-size: 12px;color:#666; float: right'>"+ this.lp.applyPerson +":" + data.applicant.split("@")[0] +"</div>" +
  1363. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.meetingDetail +"</div>"+
  1364. "</div>"+
  1365. "<div style='font-size: 18px;color:#333;padding:0px 10px 15px 20px;'>"+ data.subject +"</div>"+
  1366. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1367. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1368. "<tr><td style='"+titleStyle+";' width='70'>"+this.lp.meetingTime+":</td>" +
  1369. " <td style='"+valueStyle+";color:"+ color +"'>" + meetingTime + "</td></tr>" +
  1370. //"<tr><td style='"+titleStyle+"' width='70'>"+this.lp.beginTime+":</td>" +
  1371. //" <td style='"+valueStyle+"'>" + data.startTime + "</td></tr>" +
  1372. //"<tr><td style='"+titleStyle+"'>"+this.lp.endTime+":</td>" +
  1373. //" <td style='"+valueStyle+"'>" + data.completedTime + "</td></tr>" +
  1374. "<tr><td style='"+titleStyle+"'>"+this.lp.selectRoom +":</td>" +
  1375. " <td style='"+valueStyle+"' item='meetingRoom'></td></tr>" +
  1376. "<tr><td style='"+titleStyle+"'>"+this.lp.invitePerson2+":</td>" +
  1377. " <td style='"+valueStyle+"' item='invitePerson'>"+persons.join(",")+"</td></tr>" +
  1378. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingDescription+":</td>" +
  1379. " <td style='"+valueStyle+"'>"+ description +"</td></tr>" +
  1380. ( this.options.isHideAttachment ? "" :
  1381. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingAttachment+":</td>" +
  1382. " <td style='"+valueStyle+"' item='attachment'></td></tr>"
  1383. )+
  1384. "</table>";
  1385. return html;
  1386. },
  1387. getString : function( str ){
  1388. var s = "00" + str;
  1389. return s.substr(s.length - 2, 2 );
  1390. },
  1391. loadRoom: function( callback ){
  1392. var area = this.node.getElement("[item='meetingRoom']");
  1393. if (this.data.room){
  1394. this.app.actions.getRoom(this.data.room, function(json){
  1395. this.app.actions.getBuilding(json.data.building, function(bjson){
  1396. area.set("text", json.data.name+" ("+bjson.data.name+")");
  1397. if( callback )callback();
  1398. }.bind(this));
  1399. }.bind(this));
  1400. }
  1401. },
  1402. loadInvite : function(){
  1403. this.O2PersonList = [];
  1404. var area = this.node.getElement("[item='invitePerson']");
  1405. MWF.require("MWF.widget.O2Identity", function(){
  1406. area.empty();
  1407. this.data.invitePersonList.each(function( person ){
  1408. var O2person = new MWF.widget.O2Person({name : person}, area, {"style": "room", "onLoadedInfor": function(item){
  1409. this.loadAcceptAndReject( item );
  1410. }.bind(this) });
  1411. this.O2PersonList.push( O2person );
  1412. }.bind(this));
  1413. }.bind(this));
  1414. },
  1415. loadAcceptAndReject : function( item ){
  1416. var personName = item.data.distinguishedName;
  1417. if( this.data.acceptPersonList ){
  1418. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  1419. var acceptNode = new Element("div", {"styles": {
  1420. "height": "20px",
  1421. "width": "14px",
  1422. "margin-right": "3px",
  1423. "float": "left",
  1424. "background": "url(../x_component_Template/$MPopupForm/meeting/icon/accept.png) no-repeat center center"
  1425. }}).inject(item.node, "top");
  1426. new Element("div", {
  1427. "styles" : {"color": "#1fbf04", "clear":"both","text-align":"center"},
  1428. "text": this.app.lp.accepted
  1429. }).inject(item.inforNode);
  1430. }
  1431. }
  1432. if(this.data.rejectPersonList){
  1433. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  1434. var rejectNode = new Element("div", {"styles": {
  1435. "height": "20px",
  1436. "width": "14px",
  1437. "margin-right": "3px",
  1438. "float": "left",
  1439. "background": "url(../x_component_Template/$MPopupForm/meeting/icon/reject.png) no-repeat center center"
  1440. }}).inject(item.node, "top");
  1441. new Element("div", {
  1442. "styles" : {"color": "#FF0000", "clear":"both","text-align":"center"},
  1443. "text": this.app.lp.rejected
  1444. }).inject(item.inforNode);
  1445. }
  1446. }
  1447. },
  1448. destroy: function(){
  1449. if( this.O2PersonList ){
  1450. this.O2PersonList.each(function(p){
  1451. p.destroy();
  1452. })
  1453. }
  1454. if( this.node ){
  1455. this.node.destroy();
  1456. this.node = null;
  1457. }
  1458. },
  1459. loadAttachment: function(){
  1460. if( this.options.isHideAttachment )return;
  1461. if( typeOf(this.data.attachmentList)=="array" && this.data.attachmentList[0] ){
  1462. var area = this.node.getElement("[item='attachment']");
  1463. this.attachmentNode = new Element("div"
  1464. //{"styles": this.css.createMeetingAttachmentNode}
  1465. ).inject(area);
  1466. var attachmentContentNode = new Element("div", {
  1467. //"styles": this.css.createMeetingAttachmentContentNode
  1468. }).inject(this.attachmentNode);
  1469. this.attachmentController = new MWF.xApplication.Meeting.MeetingTooltip.AttachmentController(attachmentContentNode, this, {
  1470. "size": "min",
  1471. "isSizeChange": false,
  1472. "isReplace": false,
  1473. "isUpload": false,
  1474. "isDelete": false,
  1475. "isDownload": true,
  1476. "readonly": true
  1477. });
  1478. this.attachmentController.load();
  1479. this.data.attachmentList.each(function (att) {
  1480. att.person = att.lastUpdatePerson.split("@")[0];
  1481. var at = this.attachmentController.addAttachment(att);
  1482. }.bind(this));
  1483. }
  1484. },
  1485. downloadAttachment: function(e, node, attachments){
  1486. attachments.each(function(att){
  1487. this.app.actions.getFileDownload(att.data.id);
  1488. }.bind(this));
  1489. },
  1490. openAttachment: function(e, node, attachments){
  1491. attachments.each(function(att){
  1492. this.app.actions.getFile(att.data.id);
  1493. }.bind(this));
  1494. },
  1495. getAttachmentUrl: function(attachment, callback){
  1496. this.app.actions.getFileUrl(attachment.data.id, callback);
  1497. }
  1498. });
  1499. MWF.xApplication.Meeting.MeetingTooltip.AttachmentController = new Class({
  1500. Extends : MWF.widget.AttachmentController,
  1501. loadMin: function(){
  1502. if (!this.node) this.node = new Element("div", {"styles": this.css.container_min});
  1503. if (!this.minActionAreaNode){
  1504. //this.minActionAreaNode = new Element("div", {"styles": this.css.minActionAreaNode}).inject(this.node);
  1505. this.minContent = new Element("div", {"styles": this.css.minContentNode}).inject(this.node);
  1506. this.minContent.setStyles({
  1507. "margin-right" : "0px"
  1508. });
  1509. //this.min_downloadAction = this.createAction(this.minActionAreaNode, "download", MWF.LP.widget.download, function(e, node){
  1510. // this.downloadAttachment(e, node);
  1511. //}.bind(this));
  1512. this.node.inject(this.container);
  1513. //if (this.options.readonly) this.setReadonly();
  1514. this.checkActions();
  1515. this.setEvent();
  1516. }else{
  1517. //this.minActionAreaNode.setStyle("display", "block");
  1518. this.minContent.setStyle("display", "block");
  1519. this.minContent.empty();
  1520. }
  1521. var atts = [];
  1522. while (this.attachments.length){
  1523. var att = this.attachments.shift();
  1524. atts.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(att.data, this));
  1525. }
  1526. this.attachments = atts;
  1527. },
  1528. addAttachment: function(data){
  1529. if (this.options.size=="min"){
  1530. this.attachments.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(data, this));
  1531. }else{
  1532. this.attachments.push(new MWF.widget.AttachmentController.Attachment(data, this));
  1533. }
  1534. }
  1535. });
  1536. MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin = new Class({
  1537. Extends : MWF.widget.AttachmentController.AttachmentMin,
  1538. setEvent: function(){
  1539. this.node.addEvents({
  1540. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list_over"])}.bind(this),
  1541. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list"])}.bind(this),
  1542. "mousedown": function(e){this.selected(e);}.bind(this),
  1543. "click": function(e){this.downloadAttachment(e);}.bind(this)
  1544. });
  1545. },
  1546. downloadAttachment: function(e){
  1547. if (this.controller.module) this.controller.module.downloadAttachment(e, null, [this]);
  1548. }
  1549. });
  1550. MWF.xApplication.Meeting.MeetingArea = new Class({
  1551. initialize: function(container, view, data){
  1552. this.container = container;
  1553. this.view = view;
  1554. this.css = this.view.css;
  1555. this.app = this.view.app;
  1556. this.data = data;
  1557. this.beginDate = Date.parse(this.data.startTime);
  1558. this.endDate = Date.parse(this.data.completedTime);
  1559. this.userName = layout.desktop.session.user.distinguishedName;
  1560. this.userId = layout.desktop.session.user.id;
  1561. this.parseData();
  1562. this.path = "../x_component_Meeting/$Common/default/meetingarea/";
  1563. this.cssPath = "../x_component_Meeting/$Common/default/meetingarea/css.wcss";
  1564. this._loadCss();
  1565. this.load();
  1566. },
  1567. load: function(){
  1568. this.node = new Element("div", {"styles": this.css.meetingNode}).inject( this.container );
  1569. this.node.addEvents({
  1570. mouseenter : function(){
  1571. this.node.setStyles( this.css.meetingNode_over );
  1572. this.subjectNode.setStyles( this.css.meetingSubjectNode_over );
  1573. }.bind(this),
  1574. mouseleave : function(){
  1575. this.node.setStyles( this.css.meetingNode );
  1576. this.subjectNode.setStyles( this.css.meetingSubjectNode );
  1577. }.bind(this),
  1578. click : function(){
  1579. this.openMeeting()
  1580. }.bind(this)
  1581. });
  1582. this.colorNode = new Element("div", {"styles": this.css.meetingColorNode}).inject(this.node);
  1583. this.contentNode = new Element("div", {"styles": this.css.meetingContentNode}).inject(this.node);
  1584. var beginTime = (this.beginDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  1585. var endTime = (this.endDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  1586. this.timeNode = new Element("div", {
  1587. "styles": this.css.meetingTimeNode,
  1588. "text" : beginTime + "-" + endTime
  1589. }).inject(this.contentNode);
  1590. this.subjectNode = new Element("div", {
  1591. "styles": this.css.meetingSubjectNode,
  1592. "text": this.data.subject
  1593. }).inject(this.contentNode);
  1594. var description = (this.data.description || "")+(this.data.summary || "");
  1595. this.descriptionNode = new Element("div", {
  1596. "styles": this.css.meetingDescriptionNode,
  1597. "text" : description
  1598. }).inject(this.contentNode);
  1599. this.loadActionBar();
  1600. switch (this.data.status){
  1601. case "wait":
  1602. this.colorNode.setStyles({"background-color": "#4990E2"});
  1603. this.timeNode.setStyles({"color": "#4990E2"});
  1604. break;
  1605. case "processing":
  1606. this.colorNode.setStyles({"background-color": "#66CC7F"});
  1607. this.timeNode.setStyles({"color": "#66CC7F"});
  1608. break;
  1609. case "completed":
  1610. //add attachment
  1611. this.colorNode.setStyles({"background-color": "#ccc"});
  1612. this.timeNode.setStyles({"color": "#ccc"});
  1613. break;
  1614. }
  1615. if (this.data.myWaitAccept){
  1616. this.colorNode.setStyles({"background-color": "#F6A623"});
  1617. this.timeNode.setStyles({"color": "#F6A623"});
  1618. }
  1619. this.resetNodeSize();
  1620. this.loadTooltip();
  1621. },
  1622. parseData : function(){
  1623. if( !this.data.status ){
  1624. var now = new Date();
  1625. var status;
  1626. if( this.beginDate > now ){
  1627. status = "wait";
  1628. }else if( this.endDate < now ){
  1629. status = "completed";
  1630. }else{
  1631. status = "processing";
  1632. }
  1633. this.data.status = status;
  1634. }
  1635. if( typeOf( this.data.myWaitAccept ) != "boolean" ){
  1636. if( this.data.invitePersonList.contains( this.userName ) || this.data.invitePersonList.contains( this.userId ) ){
  1637. this.data.myWaitAccept = ( !this.data.acceptPersonList.contains( this.userName ) || this.data.acceptPersonList.contains( this.userId ) ) &&
  1638. ( !this.data.rejectPersonList.contains( this.userName ) || !this.data.rejectPersonList.contains( this.userId ) )
  1639. }
  1640. }
  1641. },
  1642. loadActionBar : function(){
  1643. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() || this.data.myWaitAccept ){
  1644. }else{
  1645. return;
  1646. }
  1647. this.actionBar = new Element("div", {
  1648. "styles": this.css.actionBar
  1649. }).inject(this.contentNode);
  1650. //this.viewAction = new Element("div", {
  1651. // styles: this.css.action_view,
  1652. // events : {
  1653. // mouseenter : function(){
  1654. // this.viewAction.setStyles( this.css.action_view_over );
  1655. // }.bind(this),
  1656. // mouseleave : function(){
  1657. // this.viewAction.setStyles( this.css.action_view );
  1658. // }.bind(this),
  1659. // click : function(){
  1660. // this.openMeeting()
  1661. // }.bind(this)
  1662. // }
  1663. //}).inject(this.actionBar);
  1664. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() ){
  1665. if( this.data.status=="wait" ){
  1666. this.editAction = new Element("div", {
  1667. styles: this.css.action_edit,
  1668. events : {
  1669. mouseover : function(){
  1670. this.editAction.setStyles( this.css.action_edit_over );
  1671. }.bind(this),
  1672. mouseout : function(){
  1673. this.editAction.setStyles( this.css.action_edit );
  1674. }.bind(this),
  1675. click : function(e){
  1676. this.editMeeting();
  1677. e.stopPropagation();
  1678. }.bind(this)
  1679. }
  1680. }).inject(this.actionBar);
  1681. //if (this.data.myWaitConfirm) this.createConfirmActions();
  1682. //if (this.data.myWaitAccept) this.createAcceptActions();
  1683. //if (this.data.status=="wait" && this.isEdit) this.createCancelActions();
  1684. this.removeAction = new Element("div", {
  1685. styles: this.css.action_remove,
  1686. events : {
  1687. mouseover : function(){
  1688. this.removeAction.setStyles( this.css.action_remove_over );
  1689. }.bind(this),
  1690. mouseout : function(){
  1691. this.removeAction.setStyles( this.css.action_remove );
  1692. }.bind(this),
  1693. click : function( e ){
  1694. this.cancel(e);
  1695. e.stopPropagation();
  1696. }.bind(this)
  1697. }
  1698. }).inject(this.actionBar);
  1699. }
  1700. }
  1701. if (this.data.myWaitAccept){
  1702. this.acceptAction = new Element("div", {
  1703. styles: this.css.action_accept,
  1704. title : this.app.lp.accept,
  1705. events : {
  1706. mouseover : function(){
  1707. this.acceptAction.setStyles( this.css.action_accept_over );
  1708. }.bind(this),
  1709. mouseout : function(){
  1710. this.acceptAction.setStyles( this.css.action_accept );
  1711. }.bind(this),
  1712. click : function( e ){
  1713. this.accept(e);
  1714. e.stopPropagation();
  1715. }.bind(this)
  1716. }
  1717. }).inject(this.actionBar);
  1718. this.rejectAction = new Element("div", {
  1719. styles: this.css.action_reject,
  1720. title : this.app.lp.reject,
  1721. events : {
  1722. mouseover : function(){
  1723. this.rejectAction.setStyles( this.css.action_reject_over );
  1724. }.bind(this),
  1725. mouseout : function(){
  1726. this.rejectAction.setStyles( this.css.action_reject );
  1727. }.bind(this),
  1728. click : function( e ){
  1729. this.reject(e);
  1730. e.stopPropagation();
  1731. }.bind(this)
  1732. }
  1733. }).inject(this.actionBar);
  1734. }
  1735. },
  1736. getString : function( str ){
  1737. var s = "00" + str;
  1738. return s.substr(s.length - 2, 2 );
  1739. },
  1740. _loadCss: function(){
  1741. var key = encodeURIComponent(this.cssPath);
  1742. if (MWF.widget.css[key]){
  1743. this.css = MWF.widget.css[key];
  1744. }else{
  1745. var r = new Request.JSON({
  1746. url: this.cssPath,
  1747. secure: false,
  1748. async: false,
  1749. method: "get",
  1750. noCache: false,
  1751. onSuccess: function(responseJSON, responseText){
  1752. this.css = responseJSON;
  1753. MWF.widget.css[key] = responseJSON;
  1754. }.bind(this),
  1755. onError: function(text, error){
  1756. alert(error + text);
  1757. }
  1758. });
  1759. r.send();
  1760. }
  1761. },
  1762. loadTooltip : function( isHideAttachment ){
  1763. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.node, this.app, this.data, {
  1764. axis : "x",
  1765. hiddenDelay : 300,
  1766. displayDelay : 300,
  1767. isHideAttachment : isHideAttachment
  1768. });
  1769. },
  1770. showTooltip: function( ){
  1771. if( this.tooltip ){
  1772. this.tooltip.load();
  1773. }else{
  1774. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.viewAction, this.app, this.data);
  1775. this.tooltip.load();
  1776. }
  1777. },
  1778. openMeeting: function(){
  1779. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  1780. form.view = this.view;
  1781. form.open();
  1782. },
  1783. resetNodeSize: function(){
  1784. var contentSize = this.contentNode.getSize();
  1785. this.colorNode.setStyle("height", contentSize.y );
  1786. },
  1787. destroy: function(){
  1788. if(this.tooltip)this.tooltip.destroy();
  1789. this.node.destroy();
  1790. MWF.release(this);
  1791. },
  1792. editMeeting : function(){
  1793. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  1794. form.view = this.view;
  1795. form.edit();
  1796. },
  1797. cancel: function(e){
  1798. var _self = this;
  1799. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  1800. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 380, 150, function(){
  1801. _self.cancelMeeting();
  1802. this.close();
  1803. }, function(){
  1804. this.close();
  1805. });
  1806. },
  1807. cancelMeeting: function(){
  1808. var view = this.view;
  1809. this.app.actions.deleteMeeting(this.data.id, function(){
  1810. view.reload();
  1811. }.bind(this))
  1812. },
  1813. reject: function(e){
  1814. var _self = this;
  1815. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  1816. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  1817. _self.rejectMeeting();
  1818. this.close();
  1819. }, function(){
  1820. this.close();
  1821. });
  1822. },
  1823. rejectMeeting: function(){
  1824. var view = this.view;
  1825. this.app.actions.rejectMeeting(this.data.id, function(){
  1826. view.reload();
  1827. }.bind(this))
  1828. },
  1829. accept: function(e){
  1830. var _self = this;
  1831. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  1832. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  1833. _self.acceptMeeting();
  1834. this.close();
  1835. }, function(){
  1836. this.close();
  1837. });
  1838. },
  1839. acceptMeeting: function(){
  1840. var view = this.view;
  1841. this.app.actions.acceptMeeting(this.data.id, function(){
  1842. view.reload();
  1843. }.bind(this))
  1844. },
  1845. disagree: function(e){
  1846. var _self = this;
  1847. var text = this.app.lp.disagree_confirm.replace(/{name}/g, this.data.subject);
  1848. this.app.confirm("infor", e, this.app.lp.disagree_confirm_title, text, 300, 120, function(){
  1849. _self.disagreeMeeting();
  1850. this.close();
  1851. }, function(){
  1852. this.close();
  1853. });
  1854. },
  1855. disagreeMeeting: function(){
  1856. var view = this.view;
  1857. this.app.actions.denyMeeting(this.data.id, function(){
  1858. view.reload();
  1859. }.bind(this))
  1860. },
  1861. agree: function(e){
  1862. var _self = this;
  1863. var text = this.app.lp.agree_confirm.replace(/{name}/g, this.data.subject);
  1864. this.app.confirm("infor", e, this.app.lp.agree_confirm_title, text, 300, 120, function(){
  1865. _self.agreeMeeting();
  1866. this.close();
  1867. }, function(){
  1868. this.close();
  1869. });
  1870. },
  1871. agreeMeeting: function(){
  1872. var view = this.view;
  1873. this.app.actions.allowMeeting(this.data.id, function(){
  1874. view.reload();
  1875. }.bind(this))
  1876. }
  1877. });
  1878. MWF.xApplication.Meeting.SideBar = new Class({
  1879. Extends: MWF.widget.Common,
  1880. Implements: [Options, Events],
  1881. options: {
  1882. "style": "default"
  1883. },
  1884. initialize : function( container, app, options){
  1885. this.setOptions( options );
  1886. this.container = container;
  1887. this.app = app;
  1888. //this.css = this.app.css;
  1889. this.lp = this.app.lp;
  1890. this.isHidden = false;
  1891. this.cssPath = "../x_component_Meeting/$Common/"+this.options.style+"/sidebar/css.wcss";
  1892. this._loadCss();
  1893. this.load();
  1894. },
  1895. load : function(){
  1896. this.node = new Element("div.sideBar", {
  1897. "styles": this.css.node,
  1898. events : {
  1899. mousedown : function( ev ){
  1900. ev.stopPropagation();
  1901. }
  1902. }
  1903. }).inject(this.container);
  1904. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  1905. this.loadStatusArea();
  1906. new Element("div.contentLine", {
  1907. "styles" : this.css.contentLine
  1908. }).inject( this.contentNode );
  1909. this.loadTodayMeetingNode();
  1910. this.trapezoid = new Element("div.trapezoid",{
  1911. "styles":this.css.trapezoid_toRight,
  1912. events : {
  1913. click : function(){
  1914. this.trigger();
  1915. }.bind(this)
  1916. }
  1917. }).inject(this.node);
  1918. //this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  1919. this.loadTodayMeeting( function(){
  1920. var x = this.node.getSize().x - 8;
  1921. this.node.setStyle( "right", "-"+x+"px" );
  1922. this.resetNodeSize();
  1923. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  1924. this.app.addEvent("resize", this.resetNodeSizeFun );
  1925. this.hideFun = this.hide.bind(this);
  1926. this.app.node.addEvent("mousedown", this.hideFun);
  1927. }.bind(this));
  1928. },
  1929. loadStatusArea : function(){
  1930. var area = new Element("div", {
  1931. "styles" : this.css.statusArea
  1932. }).inject( this.contentNode );
  1933. var html = "<div class='titleDiv'>"+this.lp.config.meetingStatus+"</div>" +
  1934. "<div class = 'statusStyle'>"+
  1935. " <div class='statusIconStyle' style='background-color:#4990E2'></div>" +
  1936. " <div class = 'statusTextStyle'>"+this.lp.config.wait+"</div></div>" +
  1937. "</div>"+
  1938. "<div class = 'statusStyle'>"+
  1939. " <div class='statusIconStyle' style='background-color:#66CC7F'></div>" +
  1940. " <div class = 'statusTextStyle'>"+this.lp.config.progress+"</div></div>" +
  1941. "</div>"+
  1942. "<div class = 'statusStyle'>"+
  1943. " <div class='statusIconStyle' style='background-color:#F6A623'></div>" +
  1944. " <div class = 'statusTextStyle'>"+this.lp.config.invite+"</div></div>" +
  1945. "</div>"+
  1946. "<div class = 'statusStyle'>"+
  1947. " <div class='statusIconStyle' style='background-color:#ccc'></div>" +
  1948. " <div class = 'statusTextStyle'>"+this.lp.config.completed+"</div></div>" +
  1949. "</div>"+
  1950. "<div class = 'statusStyle'>"+
  1951. " <div class='statusIconStyle2' style='border:2px solid #FF7F7F;'></div>" +
  1952. " <div class = 'statusTextStyle'>"+this.lp.config.conflict+"</div></div>" +
  1953. "</div>";
  1954. area.set("html", html);
  1955. area.getElements("div.titleDiv").setStyles( this.css.titleDiv );
  1956. area.getElements("div.statusStyle").setStyles( this.css.statusStyle );
  1957. area.getElements("div.statusIconStyle").setStyles( this.css.statusIconStyle );
  1958. area.getElements("div.statusIconStyle2").setStyles( this.css.statusIconStyle2 );
  1959. area.getElements("div.statusTextStyle").setStyles( this.css.statusTextStyle );
  1960. },
  1961. loadTodayMeetingNode: function(){
  1962. var area = new Element("div.meetingArea", {
  1963. "styles" : this.css.meetingArea
  1964. }).inject( this.contentNode );
  1965. new Element("div.titleDiv", {
  1966. "styles" : this.css.titleDiv,
  1967. "text" : this.lp.meetingNotice
  1968. }).inject( area );
  1969. this.meetingNode = Element("div", {
  1970. "styles" : this.css.meetingNode
  1971. }).inject( area );
  1972. },
  1973. loadTodayMeeting : function( callback ){
  1974. var today = new Date();
  1975. var user = layout.desktop.session.user;
  1976. var dn = user.distinguishedName;
  1977. var y = today.getFullYear();
  1978. var m = today.getMonth()+1;
  1979. var d = today.getDate();
  1980. this.app.actions.listMeetingDay(y, m, d, function(json) {
  1981. var data = [];
  1982. json.data.each( function( d ){
  1983. if( d.invitePersonList.contains( dn ) || d.applicant == dn ){
  1984. if( !d.rejectPersonList.contains( dn ) ){
  1985. data.push( d );
  1986. }
  1987. }
  1988. }.bind(this));
  1989. if( user.distinguishedName ){
  1990. var userName = user.distinguishedName.split("@")[0]
  1991. }else{
  1992. var userName = user.name
  1993. }
  1994. var lp = data.length ? this.lp.meetingTopInfor : this.lp.noMeetingTopInfor ;
  1995. this.meetingTopNode = new Element("div", {
  1996. "styles" : this.css.meetingTopNode,
  1997. "html" : lp.replace("{userName}",userName).replace("{count}",data.length )
  1998. }).inject( this.meetingNode );
  1999. this.scrollNode = new Element("div.scrollNode", {
  2000. "styles" : this.css.scrollNode
  2001. }).inject( this.meetingNode );
  2002. this.meetingItemContainer = new Element("div.meetingItemContainer", {
  2003. "styles" : this.css.meetingItemContainer
  2004. }).inject( this.scrollNode );
  2005. data.each( function( d, i ){
  2006. var itemNode = new Element("div.meetingItemNode", {
  2007. "styles" : this.css.meetingItemNode,
  2008. "events" : {
  2009. click : function(){
  2010. this.obj.openMeeting( this.data );
  2011. }.bind({ obj : this, data : d })
  2012. }
  2013. }).inject( this.meetingItemContainer );
  2014. this.tooltipList = this.tooltipList || [];
  2015. this.tooltipList.push( new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, itemNode, this.app, d, {
  2016. axis : "x",
  2017. hiddenDelay : 300,
  2018. displayDelay : 300
  2019. })
  2020. );
  2021. var colorNode = new Element("div.meetingItemColorNode", {
  2022. "styles" : this.css.meetingItemColorNode,
  2023. "text" : i+1
  2024. }).inject( itemNode );
  2025. var textNode = new Element("div.meetingItemTextNode", {
  2026. "styles" : this.css.meetingItemTextNode,
  2027. "text" : d.subject
  2028. }).inject( itemNode );
  2029. switch (d.status){
  2030. case "wait":
  2031. colorNode.setStyles({"background-color": "#4990E2"});
  2032. break;
  2033. case "processing":
  2034. colorNode.setStyles({"background-color": "#66CC7F"});
  2035. break;
  2036. case "completed":
  2037. //add attachment
  2038. colorNode.setStyles({"background-color": "#ccc"});
  2039. break;
  2040. }
  2041. if (d.myWaitAccept){
  2042. colorNode.setStyles({"background-color": "#F6A623"});
  2043. }
  2044. var y = itemNode.getSize().y ;
  2045. colorNode.setStyle("margin-top", ( y - 20)/2 );
  2046. }.bind(this));
  2047. this.setScrollBar( this.scrollNode );
  2048. if( callback )callback();
  2049. }.bind(this));
  2050. },
  2051. trigger : function(){
  2052. this.isHidden ? this.show( true ) : this.hide( true )
  2053. },
  2054. hide: function( isFireEvent ){
  2055. var x = this.node.getSize().x - 9;
  2056. var fx = new Fx.Morph(this.node, {
  2057. "duration": "300",
  2058. "transition": Fx.Transitions.Expo.easeOut
  2059. });
  2060. fx.start({
  2061. //"opacity": 0
  2062. }).chain(function(){
  2063. this.isHidden = true;
  2064. //this.node.setStyle("display", "none");
  2065. this.node.setStyles({
  2066. "right": "-"+x+"px"
  2067. });
  2068. this.trapezoid.setStyles( this.css.trapezoid_toLeft );
  2069. //if(isFireEvent)this.app.fireEvent("resize");
  2070. }.bind(this));
  2071. },
  2072. show: function( isFireEvent ){
  2073. this.node.setStyles(this.css.node);
  2074. this.trapezoid.setStyles( this.css.trapezoid_toRight );
  2075. //var x = this.node.getSize().x - 8;
  2076. //this.node.setStyles( "right", "-"+x+"px" );
  2077. var fx = new Fx.Morph(this.node, {
  2078. "duration": "500",
  2079. "transition": Fx.Transitions.Expo.easeOut
  2080. });
  2081. this.app.fireAppEvent("resize");
  2082. fx.start({
  2083. "opacity": 1
  2084. }).chain(function(){
  2085. this.node.setStyles({
  2086. //"position": "static",
  2087. //"width": "auto"
  2088. "right": "0px"
  2089. });
  2090. this.isHidden = false;
  2091. //if(isFireEvent)this.app.fireEvent("resize");
  2092. }.bind(this))
  2093. },
  2094. //show: function(){
  2095. // this.node.setStyles(this.css.configNode);
  2096. // var fx = new Fx.Morph(this.node, {
  2097. // "duration": "500",
  2098. // "transition": Fx.Transitions.Expo.easeOut
  2099. // });
  2100. // fx.start({
  2101. // "opacity": 1
  2102. // }).chain(function(){
  2103. // this.hideFun = this.hide.bind(this);
  2104. // this.app.content.addEvent("mousedown", this.hideFun);
  2105. // }.bind(this));
  2106. //},
  2107. //hide: function(){
  2108. // this.node.destroy();
  2109. // this.app.content.removeEvent("mousedown", this.hideFun);
  2110. // MWF.release(this);
  2111. //},
  2112. resetNodeSize: function(){
  2113. var size = this.container.getSize();
  2114. this.node.setStyle("height", size.y - 50 );
  2115. this.trapezoid.setStyle("top", ( (size.y - 50)/2 - this.trapezoid.getSize().y/2 ));
  2116. var y = size.y - 395;
  2117. var meetContainerY = this.meetingItemContainer.getSize().y + 12;
  2118. this.scrollNode.setStyle("height", Math.min( y, meetContainerY ) );
  2119. },
  2120. getSize : function(){
  2121. //var size = this.node.getSize();
  2122. //return {
  2123. // x : this.isHidden ? 9 : size.x,
  2124. // y : size.y
  2125. //}
  2126. return { x : 9, y : 0 }
  2127. },
  2128. showByType : function( type ){
  2129. },
  2130. reload : function(){
  2131. this.destory();
  2132. this.app.reload();
  2133. },
  2134. openMeeting : function( data ){
  2135. var form = new MWF.xApplication.Meeting.MeetingForm(this, data, {}, {app:this.app});
  2136. form.view = this.app;
  2137. form.open();
  2138. },
  2139. destory : function(){
  2140. this.tooltipList.each( function( t ){
  2141. t.destory();
  2142. });
  2143. this.app.removeEvent("resize", this.resetNodeSizeFun );
  2144. this.app.node.removeEvent("mousedown", this.hideFun);
  2145. this.node.destory();
  2146. }
  2147. });