RoomView.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. MWF.xDesktop.requireApp("Meeting", "MeetingView", null, false);
  2. MWF.xApplication.Meeting.RoomView = new Class({
  3. Extends: MWF.widget.Common,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "buildingId" : "",
  8. "date" : "",
  9. "hours" : 1,
  10. "minutes" : 0
  11. },
  12. initialize: function(node, app, options){
  13. this.setOptions(options);
  14. this.path = "/x_component_Meeting/$RoomView/";
  15. this.cssPath = "/x_component_Meeting/$RoomView/"+this.options.style+"/css.wcss";
  16. this._loadCss();
  17. this.app = app;
  18. this.container = $(node);
  19. this.bulidings = [];
  20. this.rooms = [];
  21. if( this.options.date ){
  22. this.date = Date.parse( this.options.date);
  23. }else{
  24. this.date = new Date();
  25. this.date.increment("hour",1);
  26. this.date.setMinutes(0);
  27. }
  28. this.hours = parseInt( this.options.hours );
  29. this.minutes = parseInt( this.options.minutes );
  30. this.load();
  31. },
  32. load: function(){
  33. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  34. this.roomArea = new Element("div.roomArea", {"styles": this.css.roomArea}).inject(this.node);
  35. //this.infoArea = new Element("div.infoArea", {"styles": this.css.infoArea}).inject(this.node);
  36. this.roomDateArea = new Element("div.roomDateArea", {"styles": this.css.roomDateArea}).inject(this.roomArea);
  37. this.roomTopArea = new Element("div.roomTopArea", {"styles": this.css.roomTopArea}).inject(this.roomArea);
  38. this.scrollNode = new Element("div", {
  39. "styles": this.css.scrollNode
  40. }).inject(this.roomArea);
  41. this.contentWarpNode = new Element("div", {
  42. "styles": this.css.contentWarpNode
  43. }).inject(this.scrollNode);
  44. this.contentContainerNode = new Element("div",{
  45. "styles" : this.css.contentContainerNode
  46. }).inject(this.contentWarpNode);
  47. this.bodyNode = new Element("div", {
  48. "styles": this.css.contentNode
  49. }).inject(this.contentContainerNode);
  50. this.roomBuildingsArea = new Element("div.roomBuildingsArea", {"styles": this.css.roomBuildingsArea}).inject(this.bodyNode);
  51. this.app.addEvent("resize", this.resetNodeSize.bind(this));
  52. // this.loadSideBar();
  53. this.loadDate();
  54. this.loadTop( function(){
  55. this.resetNodeSize();
  56. }.bind(this));
  57. },
  58. loadDate: function(){
  59. var dateText = this.date.format(this.app.lp.dateFormatAll);
  60. this.roomDateNode = new Element("div", {
  61. "styles": this.css.roomDateNode,
  62. "text" : dateText
  63. }).inject(this.roomDateArea);
  64. this.roomHourRangeNode = new Element("div", {"styles": this.css.roomHourRangeNode}).inject(this.roomDateArea);
  65. var html = this.app.lp.persist+" <select data-id='hour'>" +
  66. "<option "+((this.hours==0) ? "selected" : "")+" value=0>0</option>" +
  67. "<option "+((this.hours==1) ? "selected" : "")+" value=1>1</option>" +
  68. "<option "+((this.hours==2) ? "selected" : "")+" value=2>2</option>" +
  69. "<option "+((this.hours==3) ? "selected" : "")+" value=3>3</option>" +
  70. "<option "+((this.hours==4) ? "selected" : "")+" value=4>4</option>" +
  71. "<option "+((this.hours==5) ? "selected" : "")+" value=5>5</option>" +
  72. "<option "+((this.hours==6) ? "selected" : "")+" value=6>6</option>" +
  73. "<option "+((this.hours==7) ? "selected" : "")+" value=7>7</option>" +
  74. "<option "+((this.hours==8) ? "selected" : "")+" value=8>8</option>" +
  75. "<option "+((this.hours==9) ? "selected" : "")+" value=9>9</option>" +
  76. "<option "+((this.hours==10) ? "selected" : "")+" value=10>10</option>" +
  77. "<option "+((this.hours==11) ? "selected" : "")+" value=11>11</option>" +
  78. "<option "+((this.hours==12) ? "selected" : "")+" value=12>12</option>" +
  79. "<option "+((this.hours==13) ? "selected" : "")+" value=13>13</option>" +
  80. "<option "+((this.hours==14) ? "selected" : "")+" value=14>14</option>" +
  81. "<option "+((this.hours==15) ? "selected" : "")+" value=15>15</option>" +
  82. "<option "+((this.hours==16) ? "selected" : "")+" value=16>16</option>" +
  83. "<option "+((this.hours==17) ? "selected" : "")+" value=17>17</option>" +
  84. "<option "+((this.hours==18) ? "selected" : "")+" value=18>18</option>" +
  85. "<option "+((this.hours==19) ? "selected" : "")+" value=19>19</option>" +
  86. "<option "+((this.hours==20) ? "selected" : "")+" value=20>20</option>" +
  87. "<option "+((this.hours==21) ? "selected" : "")+" value=21>21</option>" +
  88. "<option "+((this.hours==22) ? "selected" : "")+" value=22>22</option>" +
  89. "<option "+((this.hours==23) ? "selected" : "")+" value=23>23</option>" +
  90. "<option "+((this.hours==24) ? "selected" : "")+" value=24>24</option>" +
  91. "</select> "+
  92. this.app.lp.hour+
  93. " <select data-id='minute'>" +
  94. "<option "+((this.minutes==0) ? "selected" : "")+" value=0>0</option>" +
  95. "<option "+((this.minutes==5) ? "selected" : "")+" value=5>5</option>" +
  96. "<option "+((this.minutes==10) ? "selected" : "")+" value=10>10</option>" +
  97. "<option "+((this.minutes==15) ? "selected" : "")+" value=15>15</option>" +
  98. "<option "+((this.minutes==20) ? "selected" : "")+" value=20>20</option>" +
  99. "<option "+((this.minutes==25) ? "selected" : "")+" value=25>25</option>" +
  100. "<option "+((this.minutes==30) ? "selected" : "")+" value=30>30</option>" +
  101. "<option "+((this.minutes==35) ? "selected" : "")+" value=35>35</option>" +
  102. "<option "+((this.minutes==40) ? "selected" : "")+" value=40>40</option>" +
  103. "<option "+((this.minutes==45) ? "selected" : "")+" value=45>45</option>" +
  104. "<option "+((this.minutes==50) ? "selected" : "")+" value=50>50</option>" +
  105. "<option "+((this.minutes==55) ? "selected" : "")+" value=55>55</option>" +
  106. "</select> "+this.app.lp.minute;
  107. this.roomHourRangeNode.set("html", html);
  108. this.roomHourRangeSelect = this.roomHourRangeNode.getElement("select[data-id='hour']");
  109. this.roomHourRangeSelect.setStyles(this.css.roomHourRangeSelectNode);
  110. this.roomMinuteRangeSelect = this.roomHourRangeNode.getElement("select[data-id='minute']");
  111. this.roomMinuteRangeSelect.setStyles(this.css.roomHourRangeSelectNode);
  112. this.roomHourRangeSelect.addEvent("change", function(){
  113. var h = this.roomHourRangeSelect.options[this.roomHourRangeSelect.selectedIndex].get("value");
  114. var m = this.roomMinuteRangeSelect.options[this.roomMinuteRangeSelect.selectedIndex].get("value");
  115. this.reload(this.date, h, m);
  116. }.bind(this));
  117. this.roomMinuteRangeSelect.addEvent("change", function(){
  118. var h = this.roomHourRangeSelect.options[this.roomHourRangeSelect.selectedIndex].get("value");
  119. var m = this.roomMinuteRangeSelect.options[this.roomMinuteRangeSelect.selectedIndex].get("value");
  120. this.reload(this.date, h, m);
  121. }.bind(this));
  122. this.roomDateNode.addEvents({
  123. "mouseover": function(){
  124. this.roomDateNode.setStyles(this.css.roomDateNode_over);
  125. }.bind(this),
  126. "mouseout": function(){
  127. this.roomDateNode.setStyles(this.css.roomDateNode);
  128. }.bind(this),
  129. "mousedown": function(){
  130. this.roomDateNode.setStyles(this.css.roomDateNode_down);
  131. }.bind(this),
  132. "mouseup": function(){
  133. this.roomDateNode.setStyles(this.css.roomDateNode_over);
  134. }.bind(this)
  135. });
  136. MWF.require("MWF.widget.Calendar", function(){
  137. new MWF.widget.Calendar(this.roomDateNode, {
  138. "style":"meeting_blue",
  139. "isTime": true,
  140. "target": this.node,
  141. "onQueryComplate": function(e, dv, date){
  142. this.selectedDate = true;
  143. var selectedDate = new Date.parse(dv);
  144. var h = this.roomHourRangeSelect.options[this.roomHourRangeSelect.selectedIndex].get("value");
  145. var m = this.roomMinuteRangeSelect.options[this.roomMinuteRangeSelect.selectedIndex].get("value");
  146. this.reload(selectedDate, h, m);
  147. }.bind(this)
  148. });
  149. }.bind(this));
  150. this.helpNode = new Element("div", {
  151. "styles": this.css.roomHelpNode,
  152. "events" : {
  153. mouseover : function(){
  154. this.helpNode.setStyles( this.css.roomHelpNode_over );
  155. }.bind(this),
  156. mouseout : function(){
  157. this.helpNode.setStyles( this.css.roomHelpNode );
  158. }.bind(this)
  159. }
  160. }).inject(this.roomDateArea);
  161. new MWF.xApplication.Meeting.RoomView.HelpTooltip( this.app.content, this.helpNode, this.app, {}, {
  162. hiddenDelay : 300,
  163. displayDelay : 0,
  164. nodeStyles : {
  165. "min-width" : "260px",
  166. "border-radius" : "4px"
  167. }
  168. });
  169. },
  170. loadTop : function( callback ){
  171. var startTime = this.date.clone();
  172. startTime.set("sec", 0);
  173. var start = startTime.format("%Y-%m-%d %H:%M");
  174. if(this.hours)startTime.increment("hour", this.hours);
  175. if(this.minutes)startTime.increment("minute", this.minutes);
  176. var complete = startTime.format("%Y-%m-%d %H:%M");
  177. this.endDate = startTime;
  178. var _self = this;
  179. var buliding = new Element( "div", {
  180. text : this.app.lp.all,
  181. styles : this.css.roomTopItemNode,
  182. events : {
  183. mouseover : function( ev ){
  184. var node = ev.target;
  185. if( _self.currentBuliding != node )node.setStyles( _self.css.roomTopItemNode_over );
  186. },
  187. mouseout : function( ev ){
  188. var node = ev.target;
  189. if( _self.currentBuliding != node )node.setStyles( _self.css.roomTopItemNode )
  190. },
  191. click : function(ev){
  192. var node = ev.target;
  193. if(_self.currentBuliding)_self.currentBuliding.setStyles( _self.css.roomTopItemNode );
  194. _self.currentBuliding = node;
  195. node.setStyles( _self.css.roomTopItemNode_current );
  196. _self.emptyRooms();
  197. _self.loadAllRooms();
  198. }
  199. }
  200. }).inject( this.roomTopArea );
  201. buliding.store( "data", {"id":"all"} );
  202. this.bulidings.push( buliding );
  203. this.app.actions.listBuildingByRange((start), (complete), function( json ){
  204. this.bulidingData = json.data;
  205. //buliding.click();
  206. json.data.each( function( b, i ){
  207. //if( !b.roomList || !b.roomList.length )return;
  208. var buliding = new Element( "div", {
  209. text : b.name,
  210. styles : this.css.roomTopItemNode,
  211. events : {
  212. mouseover : function( ev ){
  213. var node = ev.target;
  214. if( _self.currentBuliding != node )node.setStyles( _self.css.roomTopItemNode_over );
  215. _self.showBulidingTooltip( ev.target );
  216. },
  217. mouseout : function( ev ){
  218. var node = ev.target;
  219. if( _self.currentBuliding != node )node.setStyles( _self.css.roomTopItemNode )
  220. },
  221. click : function(ev){
  222. var node = ev.target;
  223. if(_self.currentBuliding)_self.currentBuliding.setStyles( _self.css.roomTopItemNode );
  224. _self.currentBuliding = node;
  225. node.setStyles( _self.css.roomTopItemNode_current );
  226. _self.emptyRooms();
  227. _self.loadRooms( node );
  228. }
  229. }
  230. }).inject( this.roomTopArea );
  231. buliding.store( "data", b );
  232. this.bulidings.push( buliding );
  233. if( this.options.buildingId == b.id )buliding.click();
  234. }.bind(this));
  235. if( !this.options.buildingId || this.options.buildingId == "all" ){
  236. this.bulidings[0].click();
  237. }
  238. if( callback )callback();
  239. }.bind(this))
  240. },
  241. showBulidingTooltip : function( node ){
  242. var data = node.retrieve("data");
  243. if( !this.bulidingTooltips )this.bulidingTooltips = {};
  244. var tooltip = this.bulidingTooltips[ data.id ];
  245. if( tooltip ){
  246. tooltip.load();
  247. }else{
  248. tooltip = new MWF.xApplication.Meeting.BuildingTooltip( this.app.content, node, this.app, data, {
  249. hiddenDelay : 300,
  250. displayDelay : 0,
  251. nodeStyles : {
  252. "min-width" : "100px",
  253. "border-radius" : "4px"
  254. }
  255. });
  256. tooltip.view = this;
  257. tooltip.css = this.css;
  258. this.bulidingTooltips[data.id] = tooltip;
  259. tooltip.load();
  260. }
  261. },
  262. resetNodeSize: function(){
  263. var size = this.container.getSize();
  264. var dateSize = this.roomDateArea.getSize();
  265. var topSize = this.roomTopArea.getSize();
  266. var y = size.y-dateSize.y-topSize.y-60;
  267. this.roomNodeHeight = y-60;
  268. this.scrollNode.setStyle("height", ""+y+"px");
  269. var sideBarSize = this.app.sideBar ? this.app.sideBar.getSize() : { x :0 , y:0 };
  270. this.scrollNode.setStyle("width", ""+ ( size.x - sideBarSize.x ) +"px");
  271. var roomsWidth = this.rooms.length * 330 + 30;
  272. var x = size.x - sideBarSize.x - 50;
  273. if (this.contentWarpNode){
  274. this.contentWarpNode.setStyles({
  275. "width": Math.max( x, roomsWidth) +"px"
  276. });
  277. }
  278. this.rooms.each( function( m ){
  279. m.resetHeight();
  280. });
  281. },
  282. loadAllRooms : function(){
  283. this.bulidingData.each( function( b ){
  284. b.roomList.each(function(room){
  285. this.rooms.push(new MWF.xApplication.Meeting.RoomView.Room(this, this.roomBuildingsArea ,room, b.name ));
  286. }.bind(this));
  287. }.bind(this));
  288. this.resetNodeSize();
  289. },
  290. loadRooms: function( node ){
  291. var data = node.retrieve("data");
  292. data.roomList.each(function(room){
  293. this.rooms.push(new MWF.xApplication.Meeting.RoomView.Room(this, this.roomBuildingsArea ,room ));
  294. }.bind(this));
  295. this.resetNodeSize();
  296. },
  297. emptyRooms : function(){
  298. this.rooms.each( function(room){
  299. room.destroy();
  300. });
  301. this.rooms = [];
  302. },
  303. reload: function(date, hours, minutes){
  304. if( hours == 0 && minutes==0 )return;
  305. if (date) this.date = date;
  306. if (hours) this.hours = hours;
  307. if (minutes) this.minutes = minutes;
  308. this.rooms.each(function(r){
  309. r.destroy();
  310. }.bind(this));
  311. this.bulidingTooltips = {};
  312. this.rooms = [];
  313. this.bulidings = [];
  314. this.node.destroy();
  315. this.load();
  316. this.show();
  317. },
  318. hide: function(){
  319. var fx = new Fx.Morph(this.node, {
  320. "duration": "300",
  321. "transition": Fx.Transitions.Expo.easeOut
  322. });
  323. fx.start({
  324. "opacity": 0
  325. }).chain(function(){
  326. this.node.setStyle("display", "none");
  327. }.bind(this));
  328. },
  329. show: function(){
  330. this.node.setStyles(this.css.node);
  331. var fx = new Fx.Morph(this.node, {
  332. "duration": "800",
  333. "transition": Fx.Transitions.Expo.easeOut
  334. });
  335. this.app.fireAppEvent("resize");
  336. fx.start({
  337. "opacity": 1,
  338. "left": "0px"
  339. }).chain(function(){
  340. this.node.setStyles({
  341. "position": "static",
  342. "width": "auto"
  343. });
  344. }.bind(this));
  345. },
  346. recordStatus : function(){
  347. var id = "";
  348. if( this.currentBuliding )id = this.currentBuliding.retrieve("data").id;
  349. return {
  350. buildingId : id,
  351. date : this.selectedDate ? this.date.toString() : null,
  352. hours : this.hours,
  353. minutes : this.minutes
  354. };
  355. },
  356. destroy: function(){
  357. this.rooms.each(function(r){
  358. r.destroy();
  359. }.bind(this));
  360. this.rooms = [];
  361. this.bulidings = [];
  362. this.node.destroy();
  363. }
  364. });
  365. MWF.xApplication.Meeting.RoomView.Room = new Class({
  366. Implements: [Events],
  367. initialize: function(view, node, data, buildingName ){
  368. this.data = data;
  369. this.view = view;
  370. this.css = this.view.css;
  371. this.container = node;
  372. this.app = this.view.app;
  373. this.meetings = [];
  374. this.buildingName = buildingName;
  375. this.enable = this.data.available && this.data.idle;
  376. this.load();
  377. },
  378. load : function(){
  379. this.node = new Element("div.roomItemNode", {"styles": this.css.roomItemNode}).inject(this.container);
  380. this.node.setStyle("min-height",""+this.view.roomNodeHeight+"px");
  381. this.node.addEvents( {
  382. mouseover : function(){
  383. this.node.setStyles( this.css.roomItemNode_over );
  384. }.bind(this),
  385. mouseout : function(){
  386. this.node.setStyles( this.css.roomItemNode );
  387. }.bind(this)
  388. });
  389. this.titleNode = new Element("div.titleNode", { "styles": this.css.roomItemTitleNode }).inject(this.node);
  390. this.titleNode.addEvents({
  391. click : function(){
  392. this.openRoom()
  393. }.bind(this)
  394. });
  395. if( this.enable ){
  396. this.titleNode.addEvents({
  397. mouseenter : function(){
  398. this.titleTextNode.setStyles( this.css.roomItemTitleTextNode_over );
  399. }.bind(this),
  400. mouseleave : function(){
  401. this.titleTextNode.setStyles( this.css.roomItemTitleTextNode );
  402. }.bind(this)
  403. });
  404. }
  405. this.topNode = new Element("div.topNode", { styles : this.css.roomItemTitleTopNode }).inject( this.titleNode );
  406. if( this.data.capacity ){
  407. this.titleCountNode = new Element("div.titleCountNode", {
  408. "styles": this.enable ? this.css.roomItemTitleCountNode : this.css.roomItemTitleCountNode_disable,
  409. "text" : "("+this.data.capacity+ this.app.lp.person +")"
  410. }).inject(this.topNode);
  411. }
  412. this.titleTextNode = new Element("div.roomItemTitleTextNode", {
  413. "styles": this.enable ? this.css.roomItemTitleTextNode : this.css.roomItemTitleTextNode_disable ,
  414. "text" : this.data.name
  415. }).inject(this.topNode);
  416. if( this.buildingName ){
  417. this.buildingTextNode = new Element("div.buildingTextNode", {
  418. "styles": this.enable ? this.css.roomItemBuildingTextNode : this.css.roomItemBuildingTextNode_disable,
  419. "text" : this.buildingName
  420. }).inject(this.titleNode);
  421. }
  422. this.middleNode = new Element("div.middleNode", {
  423. "styles": this.css.roomItemTitleMiddleNode
  424. }).inject(this.titleNode);
  425. this.iconsNode = new Element("div.iconsNode", {
  426. "styles": this.css.roomItemTitleIconsNode
  427. }).inject(this.middleNode);
  428. var deviceList = this.data.device.split("#");
  429. deviceList.each(function(name){
  430. var node = new Element("div", {"styles": this.css.roomItemIconNode, "title": this.app.lp.device[name]}).inject(this.iconsNode);
  431. node.setStyle("background-image", "url(/x_component_Meeting/$RoomView/default/icon/device/"+ name + ( this.enable ? "" : "_disable" ) +".png)");
  432. }.bind(this));
  433. this.actionsNode = new Element("div.actionsNode", {
  434. "styles": this.css.roomItemTitleActionsNode
  435. }).inject(this.middleNode);
  436. this.loadActions();
  437. this.contentNode = new Element("div.roomItemContentNode", {"styles": this.css.roomItemContentNode}).inject(this.node);
  438. this.loadMeetings();
  439. this.loadTooltip();
  440. },
  441. loadTooltip : function(){
  442. this.tooltip = new MWF.xApplication.Meeting.RoomTooltip(this.app.content, this.titleNode, this.app, this.data, {
  443. axis : "x",
  444. hiddenDelay : 300,
  445. displayDelay : 300
  446. });
  447. },
  448. loadActions: function(){
  449. if( MWF.AC.isMeetingAdministrator() ){
  450. this.editAction = new Element("div", {
  451. styles: this.css.roomAction_edit,
  452. events : {
  453. mouseover : function(){
  454. this.editAction.setStyles( this.css.roomAction_edit_over );
  455. }.bind(this),
  456. mouseout : function(){
  457. this.editAction.setStyles( this.css.roomAction_edit );
  458. }.bind(this),
  459. click : function(e){
  460. this.editRoom();
  461. e.stopPropagation();
  462. }.bind(this)
  463. }
  464. }).inject(this.actionsNode);
  465. this.removeAction = new Element("div", {
  466. styles: this.css.roomAction_remove,
  467. events : {
  468. mouseover : function(){
  469. this.removeAction.setStyles( this.css.roomAction_remove_over );
  470. }.bind(this),
  471. mouseout : function(){
  472. this.removeAction.setStyles( this.css.roomAction_remove );
  473. }.bind(this),
  474. click : function( e ){
  475. this.removeRoom(e);
  476. e.stopPropagation();
  477. }.bind(this)
  478. }
  479. }).inject(this.actionsNode);
  480. }
  481. if( this.enable ){
  482. this.createMeetingAction = new Element("div", {
  483. tltile : this.app.lp.addMeeting,
  484. styles: this.css.createMeetingAction,
  485. events : {
  486. mouseover : function(){
  487. this.createMeetingAction.setStyles( this.css.createMeetingAction_over );
  488. }.bind(this),
  489. mouseout : function(){
  490. this.createMeetingAction.setStyles( this.css.createMeetingAction );
  491. }.bind(this),
  492. click : function(e){
  493. this.app.addMeeting( this.view.date, this.view.hours, this.view.minutes, this.data.id);
  494. e.stopPropagation();
  495. }.bind(this)
  496. }
  497. }).inject(this.actionsNode);
  498. }
  499. },
  500. editRoom : function(){
  501. var form = new MWF.xApplication.Meeting.RoomForm(this.app,this.data, {}, {app:this.app});
  502. form.view = this;
  503. form.edit();
  504. },
  505. openRoom : function(){
  506. var form = new MWF.xApplication.Meeting.RoomForm(this.app,this.data, {}, {app:this.app});
  507. form.view = this;
  508. form.open();
  509. },
  510. reload : function(){
  511. this.view.reload( this.view.date, this.view.hours, this.view.minutes );
  512. },
  513. removeRoom: function(e) {
  514. var info = this.app.lp.delete_room;
  515. info = info.replace(/{name}/g, this.data.name);
  516. var _self = this;
  517. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  518. _self.remove();
  519. this.close();
  520. }, function(){
  521. this.close();
  522. });
  523. },
  524. remove: function(){
  525. var view = this.view;
  526. this.app.actions.deleteRoom(this.data.id, function(){
  527. view.reload();
  528. }.bind(this));
  529. },
  530. resetHeight: function(){
  531. this.node.setStyle("min-height",""+this.view.roomNodeHeight+"px");
  532. if( this.noMeetingNode ){
  533. this.noMeetingNode.setStyle("min-height",""+(this.view.roomNodeHeight - 170)+"px");
  534. this.noMeetingNode.setStyle("line-height",""+(this.view.roomNodeHeight - 170)+"px");
  535. }
  536. },
  537. destroy: function(){
  538. if( this.calendar ){
  539. this.calendar.container.destroy();
  540. }
  541. if( this.tooltip ){
  542. this.tooltip.destroy();
  543. }
  544. this.meetings.each( function(m){
  545. m.destroy();
  546. });
  547. this.node.destroy();
  548. MWF.release(this);
  549. },
  550. loadMeetings: function(){
  551. this.app.isMeetingViewer( function( isAll ){
  552. this.isMeetingViewer = isAll;
  553. this._loadMeetings();
  554. }.bind(this))
  555. },
  556. _loadMeetings: function(){
  557. if( this.data.meetingList.length > 0 ){
  558. this.data.meetingList.each(function(meeting, i){
  559. var m = new MWF.xApplication.Meeting.RoomView.Meeting( this.contentNode, this, meeting);
  560. this.meetings.push( m );
  561. }.bind(this));
  562. }else{
  563. this.noMeetingNode = new Element("div.noMeetingNode", {
  564. "styles": this.data.available ? this.css.noMeetingNode : this.css.noMeetingNode_disable,
  565. "text" : this.data.available ? this.app.lp.noMeeting : this.app.lp.roomDisable
  566. }).inject(this.contentNode);
  567. this.noMeetingNode.setStyle("min-height",""+(this.view.roomNodeHeight - 160)+"px");
  568. this.noMeetingNode.setStyle("line-height",""+(this.view.roomNodeHeight - 160)+"px");
  569. }
  570. }
  571. });
  572. MWF.xApplication.Meeting.RoomView.Meeting = new Class({
  573. Extends : MWF.xApplication.Meeting.MeetingArea,
  574. load: function(){
  575. var userName = layout.desktop.session.user.distinguishedName;
  576. var isAdmin = MWF.AC.isMeetingAdministrator();
  577. var available = false;
  578. var rejected = false;
  579. var confilct = false;
  580. if( isAdmin || this.view.isMeetingViewer || this.data.invitePersonList.contains( userName ) || this.data.applicant == userName ){
  581. available = true
  582. }
  583. if( this.data.rejectPersonList.contains( userName ) ){
  584. rejected = true;
  585. }
  586. var rBeginDate = this.view.view.date;
  587. var rEndDate = this.view.view.endDate;
  588. if( (this.beginDate >= rBeginDate && this.beginDate <= rEndDate) || (this.endDate >= rBeginDate && this.endDate <= rEndDate) ){
  589. confilct = true;
  590. this.data.confilct = true;
  591. }
  592. //if( !confilct && ( !available || rejected )){
  593. // return;
  594. //}
  595. this.node = new Element("div", {"styles": this.css.meetingNode}).inject( this.container );
  596. if( available ){
  597. this.node.addEvents({
  598. click : function(){
  599. this.openMeeting()
  600. }.bind(this)
  601. });
  602. if( !rejected ){
  603. this.node.addEvents({
  604. mouseenter : function(){
  605. this.node.setStyles( this.css.meetingNode_over );
  606. this.subjectNode.setStyles( this.css.meetingSubjectNode_over );
  607. }.bind(this),
  608. mouseleave : function(){
  609. this.node.setStyles( this.css.meetingNode );
  610. this.subjectNode.setStyles( this.css.meetingSubjectNode );
  611. }.bind(this)
  612. })
  613. }
  614. }
  615. this.colorNode = new Element("div", {"styles": this.css.meetingColorNode}).inject(this.node);
  616. this.contentNode = new Element("div", {"styles": this.css.meetingContentNode}).inject(this.node);
  617. var dateStr = this.beginDate.format(this.app.lp.dateFormatMonthDay);
  618. var beginTime = this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  619. var endTime = this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  620. this.timeNode = new Element("div", {
  621. "styles": this.css.meetingTimeNode,
  622. "text" : dateStr + " " + beginTime + "-" + endTime
  623. }).inject(this.contentNode);
  624. if( !available || rejected )this.timeNode.setStyle("color" , "#ccc");
  625. if( available ){
  626. this.subjectNode = new Element("div", {
  627. "styles": this.css.meetingSubjectNode,
  628. "text": this.data.subject
  629. }).inject(this.contentNode);
  630. if( rejected )this.subjectNode.setStyle("color" , "#ccc");
  631. }
  632. this.descriptionNode = new Element("div", {
  633. "styles": this.css.meetingDescriptionNode,
  634. "text" : available ? this.data.description : this.app.lp.noPermission
  635. }).inject(this.contentNode);
  636. if( !available || rejected )this.descriptionNode.setStyle("color" , "#ccc");
  637. this.loadActionBar();
  638. switch (this.data.status){
  639. case "wait":
  640. this.colorNode.setStyles({"background-color": "#4990E2"});
  641. this.timeNode.setStyles({"color": "#4990E2"});
  642. break;
  643. case "processing":
  644. this.colorNode.setStyles({"background-color": "#66CC7F"});
  645. this.timeNode.setStyles({"color": "#66CC7F"});
  646. break;
  647. case "completed":
  648. this.colorNode.setStyles({"background-color": "#ccc"});
  649. this.timeNode.setStyles({"color": "#ccc"});
  650. break;
  651. }
  652. if (this.data.myWaitAccept){
  653. this.colorNode.setStyles({"background-color": "#F6A623"});
  654. this.timeNode.setStyles({"color": "#F6A623"});
  655. }
  656. if (!available || rejected){
  657. this.colorNode.setStyles({"background-color": "#eee"});
  658. this.timeNode.setStyles({"color": "#ccc"});
  659. }
  660. if (confilct){
  661. this.colorNode.setStyles({"background-color": "#FF7F7F"});
  662. this.timeNode.setStyles({"color": "#FF7F7F"});
  663. }
  664. this.resetNodeSize();
  665. if( available ){
  666. this.loadTooltip( true );
  667. }
  668. }
  669. });
  670. MWF.xApplication.Meeting.RoomView.HelpTooltip = new Class({
  671. Extends: MTooltips,
  672. _getHtml : function(){
  673. var html =
  674. "<div item='containr' style='line-height:24px;'><div style='font-size: 14px;color:#666;float:left; '>"+ this.lp.roomViewHelp +"</div></div>";
  675. return html;
  676. }
  677. });