Common.js 98 KB

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