Common.js 90 KB

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