Common.js 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181
  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. if( this.waitReload )this.view.reload();
  1191. delete this;
  1192. }
  1193. });
  1194. MWF.xApplication.Meeting.MeetingTooltip = new Class({
  1195. Extends: MTooltips,
  1196. _loadCustom : function( callback ){
  1197. this.loadRoom( function(){
  1198. this.loadInvite();
  1199. this.loadAttachment();
  1200. if(callback)callback();
  1201. }.bind(this) );
  1202. },
  1203. _getHtml : function(){
  1204. var data = this.data;
  1205. var titleStyle = "font-size:14px;color:#333";
  1206. var valueStyle = "font-size:14px;color:#666;padding-right:20px";
  1207. var persons = [];
  1208. data.invitePersonList.each( function( p ){
  1209. persons.push(p.split("@")[0] )
  1210. }.bind(this));
  1211. var color = "#ccc";
  1212. switch (data.status){
  1213. case "wait":
  1214. color = "#4990E2";
  1215. break;
  1216. case "processing":
  1217. color = "#66CC7F";
  1218. break;
  1219. case "completed":
  1220. color = "#666";
  1221. break;
  1222. }
  1223. if (data.myWaitAccept){
  1224. color = "#F6A623";
  1225. }
  1226. if (data.confilct){
  1227. color = "#FF7F7F";
  1228. }
  1229. var beginDate = Date.parse(data.startTime);
  1230. var endDate = Date.parse(data.completedTime);
  1231. var dateStr = beginDate.format(this.app.lp.dateFormatDay);
  1232. var beginTime = this.getString( beginDate.getHours() ) + ":" + this.getString( beginDate.getMinutes() );
  1233. var endTime = this.getString( endDate.getHours() ) + ":" + this.getString( endDate.getMinutes() );
  1234. var meetingTime = dateStr + " " + beginTime + "-" + endTime;
  1235. var description = (data.description || "")+(data.summary || "");
  1236. var html =
  1237. "<div style='overflow: hidden;padding:15px 20px 20px 10px;height:16px;line-height:16px;'>" +
  1238. " <div style='font-size: 12px;color:#666; float: right'>"+ this.lp.applyPerson +":" + data.applicant.split("@")[0] +"</div>" +
  1239. " <div style='font-size: 16px;color:#333;float: left'>"+ this.lp.meetingDetail +"</div>"+
  1240. "</div>"+
  1241. "<div style='font-size: 18px;color:#333;padding:0px 10px 15px 20px;'>"+ data.subject +"</div>"+
  1242. "<div style='height:1px;margin:0px 20px;border-bottom:1px solid #ccc;'></div>"+
  1243. "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' style='margin:13px 13px 13px 13px;'>" +
  1244. "<tr><td style='"+titleStyle+";' width='70'>"+this.lp.meetingTime+":</td>" +
  1245. " <td style='"+valueStyle+";color:"+ color +"'>" + meetingTime + "</td></tr>" +
  1246. //"<tr><td style='"+titleStyle+"' width='70'>"+this.lp.beginTime+":</td>" +
  1247. //" <td style='"+valueStyle+"'>" + data.startTime + "</td></tr>" +
  1248. //"<tr><td style='"+titleStyle+"'>"+this.lp.endTime+":</td>" +
  1249. //" <td style='"+valueStyle+"'>" + data.completedTime + "</td></tr>" +
  1250. "<tr><td style='"+titleStyle+"'>"+this.lp.selectRoom +":</td>" +
  1251. " <td style='"+valueStyle+"' item='meetingRoom'></td></tr>" +
  1252. "<tr><td style='"+titleStyle+"'>"+this.lp.invitePerson2+":</td>" +
  1253. " <td style='"+valueStyle+"' item='invitePerson'>"+persons.join(",")+"</td></tr>" +
  1254. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingDescription+":</td>" +
  1255. " <td style='"+valueStyle+"'>"+ description +"</td></tr>" +
  1256. ( this.options.isHideAttachment ? "" :
  1257. "<tr><td style='"+titleStyle+"'>"+this.lp.meetingAttachment+":</td>" +
  1258. " <td style='"+valueStyle+"' item='attachment'></td></tr>"
  1259. )+
  1260. "</table>";
  1261. return html;
  1262. },
  1263. getString : function( str ){
  1264. var s = "00" + str;
  1265. return s.substr(s.length - 2, 2 );
  1266. },
  1267. loadRoom: function( callback ){
  1268. var area = this.node.getElement("[item='meetingRoom']");
  1269. if (this.data.room){
  1270. this.app.actions.getRoom(this.data.room, function(json){
  1271. this.app.actions.getBuilding(json.data.building, function(bjson){
  1272. area.set("text", json.data.name+" ("+bjson.data.name+")");
  1273. if( callback )callback();
  1274. }.bind(this));
  1275. }.bind(this));
  1276. }
  1277. },
  1278. loadInvite : function(){
  1279. this.O2PersonList = [];
  1280. var area = this.node.getElement("[item='invitePerson']");
  1281. MWF.require("MWF.widget.O2Identity", function(){
  1282. area.empty();
  1283. this.data.invitePersonList.each(function( person ){
  1284. var O2person = new MWF.widget.O2Person({name : person}, area, {"style": "room", "onLoadedInfor": function(item){
  1285. this.loadAcceptAndReject( item );
  1286. }.bind(this) });
  1287. this.O2PersonList.push( O2person );
  1288. }.bind(this));
  1289. }.bind(this));
  1290. },
  1291. loadAcceptAndReject : function( item ){
  1292. var personName = item.data.distinguishedName;
  1293. if( this.data.acceptPersonList ){
  1294. if (this.data.acceptPersonList.indexOf(personName)!==-1){
  1295. var acceptNode = new Element("div", {"styles": {
  1296. "height": "20px",
  1297. "width": "14px",
  1298. "margin-right": "3px",
  1299. "float": "left",
  1300. "background": "url(/x_component_Template/$MPopupForm/meeting/icon/accept.png) no-repeat center center"
  1301. }}).inject(item.node, "top");
  1302. new Element("div", {
  1303. "styles" : {"color": "#1fbf04", "clear":"both","text-align":"center"},
  1304. "text": this.app.lp.accepted
  1305. }).inject(item.inforNode);
  1306. }
  1307. }
  1308. if(this.data.rejectPersonList){
  1309. if (this.data.rejectPersonList.indexOf(personName)!==-1){
  1310. var rejectNode = new Element("div", {"styles": {
  1311. "height": "20px",
  1312. "width": "14px",
  1313. "margin-right": "3px",
  1314. "float": "left",
  1315. "background": "url(/x_component_Template/$MPopupForm/meeting/icon/reject.png) no-repeat center center"
  1316. }}).inject(item.node, "top");
  1317. new Element("div", {
  1318. "styles" : {"color": "#FF0000", "clear":"both","text-align":"center"},
  1319. "text": this.app.lp.rejected
  1320. }).inject(item.inforNode);
  1321. }
  1322. }
  1323. },
  1324. destroy: function(){
  1325. if( this.O2PersonList ){
  1326. this.O2PersonList.each(function(p){
  1327. p.destroy();
  1328. })
  1329. }
  1330. if( this.node ){
  1331. this.node.destroy();
  1332. this.node = null;
  1333. }
  1334. },
  1335. loadAttachment: function(){
  1336. if( this.options.isHideAttachment )return;
  1337. if( typeOf(this.data.attachmentList)=="array" && this.data.attachmentList[0] ){
  1338. var area = this.node.getElement("[item='attachment']");
  1339. this.attachmentNode = new Element("div"
  1340. //{"styles": this.css.createMeetingAttachmentNode}
  1341. ).inject(area);
  1342. var attachmentContentNode = new Element("div", {
  1343. //"styles": this.css.createMeetingAttachmentContentNode
  1344. }).inject(this.attachmentNode);
  1345. this.attachmentController = new MWF.xApplication.Meeting.MeetingTooltip.AttachmentController(attachmentContentNode, this, {
  1346. "size": "min",
  1347. "isSizeChange": false,
  1348. "isReplace": false,
  1349. "isUpload": false,
  1350. "isDelete": false,
  1351. "isDownload": true,
  1352. "readonly": true
  1353. });
  1354. this.attachmentController.load();
  1355. this.data.attachmentList.each(function (att) {
  1356. att.person = att.lastUpdatePerson.split("@")[0];
  1357. var at = this.attachmentController.addAttachment(att);
  1358. }.bind(this));
  1359. }
  1360. },
  1361. downloadAttachment: function(e, node, attachments){
  1362. attachments.each(function(att){
  1363. this.app.actions.getFileDownload(att.data.id);
  1364. }.bind(this));
  1365. },
  1366. openAttachment: function(e, node, attachments){
  1367. attachments.each(function(att){
  1368. this.app.actions.getFile(att.data.id);
  1369. }.bind(this));
  1370. },
  1371. getAttachmentUrl: function(attachment, callback){
  1372. this.app.actions.getFileUrl(attachment.data.id, callback);
  1373. }
  1374. });
  1375. MWF.xApplication.Meeting.MeetingTooltip.AttachmentController = new Class({
  1376. Extends : MWF.widget.AttachmentController,
  1377. loadMin: function(){
  1378. if (!this.node) this.node = new Element("div", {"styles": this.css.container_min});
  1379. if (!this.minActionAreaNode){
  1380. //this.minActionAreaNode = new Element("div", {"styles": this.css.minActionAreaNode}).inject(this.node);
  1381. this.minContent = new Element("div", {"styles": this.css.minContentNode}).inject(this.node);
  1382. this.minContent.setStyles({
  1383. "margin-right" : "0px"
  1384. });
  1385. //this.min_downloadAction = this.createAction(this.minActionAreaNode, "download", MWF.LP.widget.download, function(e, node){
  1386. // this.downloadAttachment(e, node);
  1387. //}.bind(this));
  1388. this.node.inject(this.container);
  1389. //if (this.options.readonly) this.setReadonly();
  1390. this.checkActions();
  1391. this.setEvent();
  1392. }else{
  1393. //this.minActionAreaNode.setStyle("display", "block");
  1394. this.minContent.setStyle("display", "block");
  1395. this.minContent.empty();
  1396. }
  1397. var atts = [];
  1398. while (this.attachments.length){
  1399. var att = this.attachments.shift();
  1400. atts.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(att.data, this));
  1401. }
  1402. this.attachments = atts;
  1403. },
  1404. addAttachment: function(data){
  1405. if (this.options.size=="min"){
  1406. this.attachments.push(new MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin(data, this));
  1407. }else{
  1408. this.attachments.push(new MWF.widget.AttachmentController.Attachment(data, this));
  1409. }
  1410. }
  1411. });
  1412. MWF.xApplication.Meeting.MeetingTooltip.AttachmentMin = new Class({
  1413. Extends : MWF.widget.AttachmentController.AttachmentMin,
  1414. setEvent: function(){
  1415. this.node.addEvents({
  1416. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list_over"])}.bind(this),
  1417. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css["minAttachmentNode_list"])}.bind(this),
  1418. "mousedown": function(e){this.selected(e);}.bind(this),
  1419. "click": function(e){this.downloadAttachment(e);}.bind(this)
  1420. });
  1421. },
  1422. downloadAttachment: function(e){
  1423. if (this.controller.module) this.controller.module.downloadAttachment(e, null, [this]);
  1424. }
  1425. });
  1426. MWF.xApplication.Meeting.MeetingArea = new Class({
  1427. initialize: function(container, view, data){
  1428. this.container = container;
  1429. this.view = view;
  1430. this.css = this.view.css;
  1431. this.app = this.view.app;
  1432. this.data = data;
  1433. this.beginDate = Date.parse(this.data.startTime);
  1434. this.endDate = Date.parse(this.data.completedTime);
  1435. this.userName = layout.desktop.session.user.distinguishedName;
  1436. this.userId = layout.desktop.session.user.id;
  1437. this.parseData();
  1438. this.path = "/x_component_Meeting/$Common/default/meetingarea/";
  1439. this.cssPath = "/x_component_Meeting/$Common/default/meetingarea/css.wcss";
  1440. this._loadCss();
  1441. this.load();
  1442. },
  1443. load: function(){
  1444. this.node = new Element("div", {"styles": this.css.meetingNode}).inject( this.container );
  1445. this.node.addEvents({
  1446. mouseenter : function(){
  1447. this.node.setStyles( this.css.meetingNode_over );
  1448. this.subjectNode.setStyles( this.css.meetingSubjectNode_over );
  1449. }.bind(this),
  1450. mouseleave : function(){
  1451. this.node.setStyles( this.css.meetingNode );
  1452. this.subjectNode.setStyles( this.css.meetingSubjectNode );
  1453. }.bind(this),
  1454. click : function(){
  1455. this.openMeeting()
  1456. }.bind(this)
  1457. });
  1458. this.colorNode = new Element("div", {"styles": this.css.meetingColorNode}).inject(this.node);
  1459. this.contentNode = new Element("div", {"styles": this.css.meetingContentNode}).inject(this.node);
  1460. var beginTime = (this.beginDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  1461. var endTime = (this.endDate.getHours() < 12 ? this.app.lp.am : this.app.lp.pm) + " " + this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  1462. this.timeNode = new Element("div", {
  1463. "styles": this.css.meetingTimeNode,
  1464. "text" : beginTime + "-" + endTime
  1465. }).inject(this.contentNode);
  1466. this.subjectNode = new Element("div", {
  1467. "styles": this.css.meetingSubjectNode,
  1468. "text": this.data.subject
  1469. }).inject(this.contentNode);
  1470. var description = (this.data.description || "")+(this.data.summary || "");
  1471. this.descriptionNode = new Element("div", {
  1472. "styles": this.css.meetingDescriptionNode,
  1473. "text" : description
  1474. }).inject(this.contentNode);
  1475. this.loadActionBar();
  1476. switch (this.data.status){
  1477. case "wait":
  1478. this.colorNode.setStyles({"background-color": "#4990E2"});
  1479. this.timeNode.setStyles({"color": "#4990E2"});
  1480. break;
  1481. case "processing":
  1482. this.colorNode.setStyles({"background-color": "#66CC7F"});
  1483. this.timeNode.setStyles({"color": "#66CC7F"});
  1484. break;
  1485. case "completed":
  1486. //add attachment
  1487. this.colorNode.setStyles({"background-color": "#ccc"});
  1488. this.timeNode.setStyles({"color": "#ccc"});
  1489. break;
  1490. }
  1491. if (this.data.myWaitAccept){
  1492. this.colorNode.setStyles({"background-color": "#F6A623"});
  1493. this.timeNode.setStyles({"color": "#F6A623"});
  1494. }
  1495. this.resetNodeSize();
  1496. this.loadTooltip();
  1497. },
  1498. parseData : function(){
  1499. if( !this.data.status ){
  1500. var now = new Date();
  1501. var status;
  1502. if( this.beginDate > now ){
  1503. status = "wait";
  1504. }else if( this.endDate < now ){
  1505. status = "completed";
  1506. }else{
  1507. status = "processing";
  1508. }
  1509. this.data.status = status;
  1510. }
  1511. if( typeOf( this.data.myWaitAccept ) != "boolean" ){
  1512. if( this.data.invitePersonList.contains( this.userName ) || this.data.invitePersonList.contains( this.userId ) ){
  1513. this.data.myWaitAccept = ( !this.data.acceptPersonList.contains( this.userName ) || this.data.acceptPersonList.contains( this.userId ) ) &&
  1514. ( !this.data.rejectPersonList.contains( this.userName ) || !this.data.rejectPersonList.contains( this.userId ) )
  1515. }
  1516. }
  1517. },
  1518. loadActionBar : function(){
  1519. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() || this.data.myWaitAccept ){
  1520. }else{
  1521. return;
  1522. }
  1523. this.actionBar = new Element("div", {
  1524. "styles": this.css.actionBar
  1525. }).inject(this.contentNode);
  1526. //this.viewAction = new Element("div", {
  1527. // styles: this.css.action_view,
  1528. // events : {
  1529. // mouseenter : function(){
  1530. // this.viewAction.setStyles( this.css.action_view_over );
  1531. // }.bind(this),
  1532. // mouseleave : function(){
  1533. // this.viewAction.setStyles( this.css.action_view );
  1534. // }.bind(this),
  1535. // click : function(){
  1536. // this.openMeeting()
  1537. // }.bind(this)
  1538. // }
  1539. //}).inject(this.actionBar);
  1540. if( this.userName == this.data.applicant || this.userId == this.data.applicant || MWF.AC.isMeetingAdministrator() ){
  1541. if( this.data.status=="wait" ){
  1542. this.editAction = new Element("div", {
  1543. styles: this.css.action_edit,
  1544. events : {
  1545. mouseover : function(){
  1546. this.editAction.setStyles( this.css.action_edit_over );
  1547. }.bind(this),
  1548. mouseout : function(){
  1549. this.editAction.setStyles( this.css.action_edit );
  1550. }.bind(this),
  1551. click : function(e){
  1552. this.editMeeting();
  1553. e.stopPropagation();
  1554. }.bind(this)
  1555. }
  1556. }).inject(this.actionBar);
  1557. //if (this.data.myWaitConfirm) this.createConfirmActions();
  1558. //if (this.data.myWaitAccept) this.createAcceptActions();
  1559. //if (this.data.status=="wait" && this.isEdit) this.createCancelActions();
  1560. this.removeAction = new Element("div", {
  1561. styles: this.css.action_remove,
  1562. events : {
  1563. mouseover : function(){
  1564. this.removeAction.setStyles( this.css.action_remove_over );
  1565. }.bind(this),
  1566. mouseout : function(){
  1567. this.removeAction.setStyles( this.css.action_remove );
  1568. }.bind(this),
  1569. click : function( e ){
  1570. this.cancel(e);
  1571. e.stopPropagation();
  1572. }.bind(this)
  1573. }
  1574. }).inject(this.actionBar);
  1575. }
  1576. }
  1577. if (this.data.myWaitAccept){
  1578. this.acceptAction = new Element("div", {
  1579. styles: this.css.action_accept,
  1580. title : this.app.lp.accept,
  1581. events : {
  1582. mouseover : function(){
  1583. this.acceptAction.setStyles( this.css.action_accept_over );
  1584. }.bind(this),
  1585. mouseout : function(){
  1586. this.acceptAction.setStyles( this.css.action_accept );
  1587. }.bind(this),
  1588. click : function( e ){
  1589. this.accept(e);
  1590. e.stopPropagation();
  1591. }.bind(this)
  1592. }
  1593. }).inject(this.actionBar);
  1594. this.rejectAction = new Element("div", {
  1595. styles: this.css.action_reject,
  1596. title : this.app.lp.reject,
  1597. events : {
  1598. mouseover : function(){
  1599. this.rejectAction.setStyles( this.css.action_reject_over );
  1600. }.bind(this),
  1601. mouseout : function(){
  1602. this.rejectAction.setStyles( this.css.action_reject );
  1603. }.bind(this),
  1604. click : function( e ){
  1605. this.reject(e);
  1606. e.stopPropagation();
  1607. }.bind(this)
  1608. }
  1609. }).inject(this.actionBar);
  1610. }
  1611. },
  1612. getString : function( str ){
  1613. var s = "00" + str;
  1614. return s.substr(s.length - 2, 2 );
  1615. },
  1616. _loadCss: function(){
  1617. var key = encodeURIComponent(this.cssPath);
  1618. if (MWF.widget.css[key]){
  1619. this.css = MWF.widget.css[key];
  1620. }else{
  1621. var r = new Request.JSON({
  1622. url: this.cssPath,
  1623. secure: false,
  1624. async: false,
  1625. method: "get",
  1626. noCache: false,
  1627. onSuccess: function(responseJSON, responseText){
  1628. this.css = responseJSON;
  1629. MWF.widget.css[key] = responseJSON;
  1630. }.bind(this),
  1631. onError: function(text, error){
  1632. alert(error + text);
  1633. }
  1634. });
  1635. r.send();
  1636. }
  1637. },
  1638. loadTooltip : function( isHideAttachment ){
  1639. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.node, this.app, this.data, {
  1640. axis : "x",
  1641. hiddenDelay : 300,
  1642. displayDelay : 300,
  1643. isHideAttachment : isHideAttachment
  1644. });
  1645. },
  1646. showTooltip: function( ){
  1647. if( this.tooltip ){
  1648. this.tooltip.load();
  1649. }else{
  1650. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.viewAction, this.app, this.data);
  1651. this.tooltip.load();
  1652. }
  1653. },
  1654. openMeeting: function(){
  1655. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  1656. form.view = this.view;
  1657. form.open();
  1658. },
  1659. resetNodeSize: function(){
  1660. var contentSize = this.contentNode.getSize();
  1661. this.colorNode.setStyle("height", contentSize.y );
  1662. },
  1663. destroy: function(){
  1664. if(this.tooltip)this.tooltip.destroy();
  1665. this.node.destroy();
  1666. MWF.release(this);
  1667. },
  1668. editMeeting : function(){
  1669. var form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  1670. form.view = this.view;
  1671. form.edit();
  1672. },
  1673. cancel: function(e){
  1674. var _self = this;
  1675. var text = this.app.lp.cancel_confirm.replace(/{name}/g, this.data.subject);
  1676. this.app.confirm("infor", e, this.app.lp.cancel_confirm_title, text, 380, 150, function(){
  1677. _self.cancelMeeting();
  1678. this.close();
  1679. }, function(){
  1680. this.close();
  1681. });
  1682. },
  1683. cancelMeeting: function(){
  1684. var view = this.view;
  1685. this.app.actions.deleteMeeting(this.data.id, function(){
  1686. view.reload();
  1687. }.bind(this))
  1688. },
  1689. reject: function(e){
  1690. var _self = this;
  1691. var text = this.app.lp.reject_confirm.replace(/{name}/g, this.data.subject);
  1692. this.app.confirm("infor", e, this.app.lp.reject_confirm_title, text, 300, 120, function(){
  1693. _self.rejectMeeting();
  1694. this.close();
  1695. }, function(){
  1696. this.close();
  1697. });
  1698. },
  1699. rejectMeeting: function(){
  1700. var view = this.view;
  1701. this.app.actions.rejectMeeting(this.data.id, function(){
  1702. view.reload();
  1703. }.bind(this))
  1704. },
  1705. accept: function(e){
  1706. var _self = this;
  1707. var text = this.app.lp.accept_confirm.replace(/{name}/g, this.data.subject);
  1708. this.app.confirm("infor", e, this.app.lp.accept_confirm_title, text, 300, 120, function(){
  1709. _self.acceptMeeting();
  1710. this.close();
  1711. }, function(){
  1712. this.close();
  1713. });
  1714. },
  1715. acceptMeeting: function(){
  1716. var view = this.view;
  1717. this.app.actions.acceptMeeting(this.data.id, function(){
  1718. view.reload();
  1719. }.bind(this))
  1720. },
  1721. disagree: function(e){
  1722. var _self = this;
  1723. var text = this.app.lp.disagree_confirm.replace(/{name}/g, this.data.subject);
  1724. this.app.confirm("infor", e, this.app.lp.disagree_confirm_title, text, 300, 120, function(){
  1725. _self.disagreeMeeting();
  1726. this.close();
  1727. }, function(){
  1728. this.close();
  1729. });
  1730. },
  1731. disagreeMeeting: function(){
  1732. var view = this.view;
  1733. this.app.actions.denyMeeting(this.data.id, function(){
  1734. view.reload();
  1735. }.bind(this))
  1736. },
  1737. agree: function(e){
  1738. var _self = this;
  1739. var text = this.app.lp.agree_confirm.replace(/{name}/g, this.data.subject);
  1740. this.app.confirm("infor", e, this.app.lp.agree_confirm_title, text, 300, 120, function(){
  1741. _self.agreeMeeting();
  1742. this.close();
  1743. }, function(){
  1744. this.close();
  1745. });
  1746. },
  1747. agreeMeeting: function(){
  1748. var view = this.view;
  1749. this.app.actions.allowMeeting(this.data.id, function(){
  1750. view.reload();
  1751. }.bind(this))
  1752. }
  1753. });
  1754. MWF.xApplication.Meeting.SideBar = new Class({
  1755. Extends: MWF.widget.Common,
  1756. Implements: [Options, Events],
  1757. options: {
  1758. "style": "default"
  1759. },
  1760. initialize : function( container, app, options){
  1761. this.setOptions( options );
  1762. this.container = container;
  1763. this.app = app;
  1764. //this.css = this.app.css;
  1765. this.lp = this.app.lp;
  1766. this.isHidden = false;
  1767. this.cssPath = "/x_component_Meeting/$Common/"+this.options.style+"/sidebar/css.wcss";
  1768. this._loadCss();
  1769. this.load();
  1770. },
  1771. load : function(){
  1772. this.node = new Element("div.sideBar", {
  1773. "styles": this.css.node,
  1774. events : {
  1775. mousedown : function( ev ){
  1776. ev.stopPropagation();
  1777. }
  1778. }
  1779. }).inject(this.container);
  1780. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.node);
  1781. this.loadStatusArea();
  1782. new Element("div.contentLine", {
  1783. "styles" : this.css.contentLine
  1784. }).inject( this.contentNode );
  1785. this.loadTodayMeetingNode();
  1786. this.trapezoid = new Element("div.trapezoid",{
  1787. "styles":this.css.trapezoid_toRight,
  1788. events : {
  1789. click : function(){
  1790. this.trigger();
  1791. }.bind(this)
  1792. }
  1793. }).inject(this.node);
  1794. //this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  1795. this.loadTodayMeeting( function(){
  1796. var x = this.node.getSize().x - 8;
  1797. this.node.setStyle( "right", "-"+x+"px" );
  1798. this.resetNodeSize();
  1799. this.resetNodeSizeFun = this.resetNodeSize.bind(this);
  1800. this.app.addEvent("resize", this.resetNodeSizeFun );
  1801. this.hideFun = this.hide.bind(this);
  1802. this.app.node.addEvent("mousedown", this.hideFun);
  1803. }.bind(this));
  1804. },
  1805. loadStatusArea : function(){
  1806. var area = new Element("div", {
  1807. "styles" : this.css.statusArea
  1808. }).inject( this.contentNode );
  1809. var html = "<div class='titleDiv'>"+this.lp.config.meetingStatus+"</div>" +
  1810. "<div class = 'statusStyle'>"+
  1811. " <div class='statusIconStyle' style='background-color:#4990E2'></div>" +
  1812. " <div class = 'statusTextStyle'>"+this.lp.config.wait+"</div></div>" +
  1813. "</div>"+
  1814. "<div class = 'statusStyle'>"+
  1815. " <div class='statusIconStyle' style='background-color:#66CC7F'></div>" +
  1816. " <div class = 'statusTextStyle'>"+this.lp.config.progress+"</div></div>" +
  1817. "</div>"+
  1818. "<div class = 'statusStyle'>"+
  1819. " <div class='statusIconStyle' style='background-color:#F6A623'></div>" +
  1820. " <div class = 'statusTextStyle'>"+this.lp.config.invite+"</div></div>" +
  1821. "</div>"+
  1822. "<div class = 'statusStyle'>"+
  1823. " <div class='statusIconStyle' style='background-color:#ccc'></div>" +
  1824. " <div class = 'statusTextStyle'>"+this.lp.config.completed+"</div></div>" +
  1825. "</div>"+
  1826. "<div class = 'statusStyle'>"+
  1827. " <div class='statusIconStyle2' style='border:2px solid #FF7F7F;'></div>" +
  1828. " <div class = 'statusTextStyle'>"+this.lp.config.conflict+"</div></div>" +
  1829. "</div>";
  1830. area.set("html", html);
  1831. area.getElements("div.titleDiv").setStyles( this.css.titleDiv );
  1832. area.getElements("div.statusStyle").setStyles( this.css.statusStyle );
  1833. area.getElements("div.statusIconStyle").setStyles( this.css.statusIconStyle );
  1834. area.getElements("div.statusIconStyle2").setStyles( this.css.statusIconStyle2 );
  1835. area.getElements("div.statusTextStyle").setStyles( this.css.statusTextStyle );
  1836. },
  1837. loadTodayMeetingNode: function(){
  1838. var area = new Element("div.meetingArea", {
  1839. "styles" : this.css.meetingArea
  1840. }).inject( this.contentNode );
  1841. new Element("div.titleDiv", {
  1842. "styles" : this.css.titleDiv,
  1843. "text" : this.lp.meetingNotice
  1844. }).inject( area );
  1845. this.meetingNode = Element("div", {
  1846. "styles" : this.css.meetingNode
  1847. }).inject( area );
  1848. },
  1849. loadTodayMeeting : function( callback ){
  1850. var today = new Date();
  1851. var user = layout.desktop.session.user;
  1852. var dn = user.distinguishedName;
  1853. var y = today.getFullYear();
  1854. var m = today.getMonth()+1;
  1855. var d = today.getDate();
  1856. this.app.actions.listMeetingDay(y, m, d, function(json) {
  1857. var data = [];
  1858. json.data.each( function( d ){
  1859. if( d.invitePersonList.contains( dn ) || d.applicant == dn ){
  1860. if( !d.rejectPersonList.contains( dn ) ){
  1861. data.push( d );
  1862. }
  1863. }
  1864. }.bind(this));
  1865. if( user.distinguishedName ){
  1866. var userName = user.distinguishedName.split("@")[0]
  1867. }else{
  1868. var userName = user.name
  1869. }
  1870. var lp = data.length ? this.lp.meetingTopInfor : this.lp.noMeetingTopInfor ;
  1871. this.meetingTopNode = new Element("div", {
  1872. "styles" : this.css.meetingTopNode,
  1873. "html" : lp.replace("{userName}",userName).replace("{count}",data.length )
  1874. }).inject( this.meetingNode );
  1875. this.scrollNode = new Element("div.scrollNode", {
  1876. "styles" : this.css.scrollNode
  1877. }).inject( this.meetingNode );
  1878. this.meetingItemContainer = new Element("div.meetingItemContainer", {
  1879. "styles" : this.css.meetingItemContainer
  1880. }).inject( this.scrollNode );
  1881. data.each( function( d, i ){
  1882. var itemNode = new Element("div.meetingItemNode", {
  1883. "styles" : this.css.meetingItemNode,
  1884. "events" : {
  1885. click : function(){
  1886. this.obj.openMeeting( this.data );
  1887. }.bind({ obj : this, data : d })
  1888. }
  1889. }).inject( this.meetingItemContainer );
  1890. this.tooltipList = this.tooltipList || [];
  1891. this.tooltipList.push( new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, itemNode, this.app, d, {
  1892. axis : "x",
  1893. hiddenDelay : 300,
  1894. displayDelay : 300
  1895. })
  1896. );
  1897. var colorNode = new Element("div.meetingItemColorNode", {
  1898. "styles" : this.css.meetingItemColorNode,
  1899. "text" : i+1
  1900. }).inject( itemNode );
  1901. var textNode = new Element("div.meetingItemTextNode", {
  1902. "styles" : this.css.meetingItemTextNode,
  1903. "text" : d.subject
  1904. }).inject( itemNode );
  1905. switch (d.status){
  1906. case "wait":
  1907. colorNode.setStyles({"background-color": "#4990E2"});
  1908. break;
  1909. case "processing":
  1910. colorNode.setStyles({"background-color": "#66CC7F"});
  1911. break;
  1912. case "completed":
  1913. //add attachment
  1914. colorNode.setStyles({"background-color": "#ccc"});
  1915. break;
  1916. }
  1917. if (d.myWaitAccept){
  1918. colorNode.setStyles({"background-color": "#F6A623"});
  1919. }
  1920. var y = itemNode.getSize().y ;
  1921. colorNode.setStyle("margin-top", ( y - 20)/2 );
  1922. }.bind(this));
  1923. this.setScrollBar( this.scrollNode );
  1924. if( callback )callback();
  1925. }.bind(this));
  1926. },
  1927. trigger : function(){
  1928. this.isHidden ? this.show( true ) : this.hide( true )
  1929. },
  1930. hide: function( isFireEvent ){
  1931. var x = this.node.getSize().x - 9;
  1932. var fx = new Fx.Morph(this.node, {
  1933. "duration": "300",
  1934. "transition": Fx.Transitions.Expo.easeOut
  1935. });
  1936. fx.start({
  1937. //"opacity": 0
  1938. }).chain(function(){
  1939. this.isHidden = true;
  1940. //this.node.setStyle("display", "none");
  1941. this.node.setStyles({
  1942. "right": "-"+x+"px"
  1943. });
  1944. this.trapezoid.setStyles( this.css.trapezoid_toLeft );
  1945. //if(isFireEvent)this.app.fireEvent("resize");
  1946. }.bind(this));
  1947. },
  1948. show: function( isFireEvent ){
  1949. this.node.setStyles(this.css.node);
  1950. this.trapezoid.setStyles( this.css.trapezoid_toRight );
  1951. //var x = this.node.getSize().x - 8;
  1952. //this.node.setStyles( "right", "-"+x+"px" );
  1953. var fx = new Fx.Morph(this.node, {
  1954. "duration": "500",
  1955. "transition": Fx.Transitions.Expo.easeOut
  1956. });
  1957. this.app.fireAppEvent("resize");
  1958. fx.start({
  1959. "opacity": 1
  1960. }).chain(function(){
  1961. this.node.setStyles({
  1962. //"position": "static",
  1963. //"width": "auto"
  1964. "right": "0px"
  1965. });
  1966. this.isHidden = false;
  1967. //if(isFireEvent)this.app.fireEvent("resize");
  1968. }.bind(this))
  1969. },
  1970. //show: function(){
  1971. // this.node.setStyles(this.css.configNode);
  1972. // var fx = new Fx.Morph(this.node, {
  1973. // "duration": "500",
  1974. // "transition": Fx.Transitions.Expo.easeOut
  1975. // });
  1976. // fx.start({
  1977. // "opacity": 1
  1978. // }).chain(function(){
  1979. // this.hideFun = this.hide.bind(this);
  1980. // this.app.content.addEvent("mousedown", this.hideFun);
  1981. // }.bind(this));
  1982. //},
  1983. //hide: function(){
  1984. // this.node.destroy();
  1985. // this.app.content.removeEvent("mousedown", this.hideFun);
  1986. // MWF.release(this);
  1987. //},
  1988. resetNodeSize: function(){
  1989. var size = this.container.getSize();
  1990. this.node.setStyle("height", size.y - 50 );
  1991. this.trapezoid.setStyle("top", ( (size.y - 50)/2 - this.trapezoid.getSize().y/2 ));
  1992. var y = size.y - 395;
  1993. var meetContainerY = this.meetingItemContainer.getSize().y + 12;
  1994. this.scrollNode.setStyle("height", Math.min( y, meetContainerY ) );
  1995. },
  1996. getSize : function(){
  1997. //var size = this.node.getSize();
  1998. //return {
  1999. // x : this.isHidden ? 9 : size.x,
  2000. // y : size.y
  2001. //}
  2002. return { x : 9, y : 0 }
  2003. },
  2004. showByType : function( type ){
  2005. },
  2006. reload : function(){
  2007. this.destory();
  2008. this.app.reload();
  2009. },
  2010. openMeeting : function( data ){
  2011. var form = new MWF.xApplication.Meeting.MeetingForm(this, data, {}, {app:this.app});
  2012. form.view = this.app;
  2013. form.open();
  2014. },
  2015. destory : function(){
  2016. this.tooltipList.each( function( t ){
  2017. t.destory();
  2018. });
  2019. this.app.removeEvent("resize", this.resetNodeSizeFun );
  2020. this.app.node.removeEvent("mousedown", this.hideFun);
  2021. this.node.destory();
  2022. }
  2023. });