Common.js 90 KB

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