Common.js 91 KB

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