Common.js 98 KB

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