RoomView.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  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.app.inContainer ? this.css.scrollNode_inContainer : 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. //if( this.app.inContainer )return;
  264. var size = this.container.getSize();
  265. if( !this.app.inContainer ){
  266. var y = size.y-50;
  267. this.node.setStyle("height", ""+y+"px");
  268. this.node.setStyle("margin-top", "50px");
  269. }
  270. var dateSize = this.roomDateArea.getSize();
  271. var topSize = this.roomTopArea.getSize();
  272. var y = size.y-dateSize.y-topSize.y-60;
  273. this.roomNodeHeight = y-60;
  274. this.scrollNode.setStyle("height", ""+y+"px");
  275. var sideBarSize = this.app.sideBar ? this.app.sideBar.getSize() : { x :0 , y:0 };
  276. this.scrollNode.setStyle("width", ""+ ( size.x - sideBarSize.x ) +"px");
  277. var roomsWidth = this.rooms.length * 330 + 30;
  278. var x = size.x - sideBarSize.x - 50;
  279. if (this.contentWarpNode){
  280. this.contentWarpNode.setStyles({
  281. "width": Math.max( x, roomsWidth) +"px"
  282. });
  283. }
  284. this.rooms.each( function( m ){
  285. m.resetHeight();
  286. });
  287. },
  288. loadAllRooms : function(){
  289. this.bulidingData.each( function( b ){
  290. b.roomList.each(function(room){
  291. this.rooms.push(new MWF.xApplication.Meeting.RoomView.Room(this, this.roomBuildingsArea ,room, b.name ));
  292. }.bind(this));
  293. }.bind(this));
  294. this.resetNodeSize();
  295. },
  296. loadRooms: function( node ){
  297. var data = node.retrieve("data");
  298. data.roomList.each(function(room){
  299. this.rooms.push(new MWF.xApplication.Meeting.RoomView.Room(this, this.roomBuildingsArea ,room ));
  300. }.bind(this));
  301. this.resetNodeSize();
  302. },
  303. emptyRooms : function(){
  304. this.rooms.each( function(room){
  305. room.destroy();
  306. });
  307. this.rooms = [];
  308. },
  309. reload: function(date, hours, minutes){
  310. if( hours == 0 && minutes==0 )return;
  311. if (date) this.date = date;
  312. if (hours) this.hours = hours;
  313. if (minutes) this.minutes = minutes;
  314. this.rooms.each(function(r){
  315. r.destroy();
  316. }.bind(this));
  317. this.bulidingTooltips = {};
  318. this.rooms = [];
  319. this.bulidings = [];
  320. this.node.destroy();
  321. this.load();
  322. this.show();
  323. },
  324. hide: function(){
  325. var fx = new Fx.Morph(this.node, {
  326. "duration": "300",
  327. "transition": Fx.Transitions.Expo.easeOut
  328. });
  329. fx.start({
  330. "opacity": 0
  331. }).chain(function(){
  332. this.node.setStyle("display", "none");
  333. }.bind(this));
  334. },
  335. show: function(){
  336. this.node.setStyles(this.css.node);
  337. if( this.app.inContainer ){
  338. this.node.setStyles({
  339. "opacity": 1,
  340. "position": "static",
  341. "width": "auto"
  342. });
  343. }else{
  344. var fx = new Fx.Morph(this.node, {
  345. "duration": "800",
  346. "transition": Fx.Transitions.Expo.easeOut
  347. });
  348. this.app.fireAppEvent("resize");
  349. fx.start({
  350. "opacity": 1,
  351. "left": "0px"
  352. }).chain(function(){
  353. this.node.setStyles({
  354. "position": "static",
  355. "width": "auto"
  356. });
  357. }.bind(this));
  358. }
  359. },
  360. recordStatus : function(){
  361. var id = "";
  362. if( this.currentBuliding )id = this.currentBuliding.retrieve("data").id;
  363. return {
  364. buildingId : id,
  365. date : this.selectedDate ? this.date.toString() : null,
  366. hours : this.hours,
  367. minutes : this.minutes
  368. };
  369. },
  370. destroy: function(){
  371. this.rooms.each(function(r){
  372. r.destroy();
  373. }.bind(this));
  374. this.rooms = [];
  375. this.bulidings = [];
  376. this.node.destroy();
  377. }
  378. });
  379. MWF.xApplication.Meeting.RoomView.Room = new Class({
  380. Implements: [Events],
  381. initialize: function(view, node, data, buildingName ){
  382. this.data = data;
  383. this.view = view;
  384. this.css = this.view.css;
  385. this.container = node;
  386. this.app = this.view.app;
  387. this.meetings = [];
  388. this.buildingName = buildingName;
  389. this.enable = this.data.available && this.data.idle;
  390. this.load();
  391. },
  392. load : function(){
  393. this.node = new Element("div.roomItemNode", {"styles": this.css.roomItemNode}).inject(this.container);
  394. this.node.setStyle("min-height",""+this.view.roomNodeHeight+"px");
  395. this.node.addEvents( {
  396. mouseover : function(){
  397. this.node.setStyles( this.css.roomItemNode_over );
  398. }.bind(this),
  399. mouseout : function(){
  400. this.node.setStyles( this.css.roomItemNode );
  401. }.bind(this)
  402. });
  403. this.titleNode = new Element("div.titleNode", { "styles": this.css.roomItemTitleNode }).inject(this.node);
  404. this.titleNode.addEvents({
  405. click : function(){
  406. this.openRoom()
  407. }.bind(this)
  408. });
  409. if( this.enable ){
  410. this.titleNode.addEvents({
  411. mouseenter : function(){
  412. this.titleTextNode.setStyles( this.css.roomItemTitleTextNode_over );
  413. }.bind(this),
  414. mouseleave : function(){
  415. this.titleTextNode.setStyles( this.css.roomItemTitleTextNode );
  416. }.bind(this)
  417. });
  418. }
  419. this.topNode = new Element("div.topNode", { styles : this.css.roomItemTitleTopNode }).inject( this.titleNode );
  420. if( this.data.capacity ){
  421. this.titleCountNode = new Element("div.titleCountNode", {
  422. "styles": this.enable ? this.css.roomItemTitleCountNode : this.css.roomItemTitleCountNode_disable,
  423. "text" : "("+this.data.capacity+ this.app.lp.person +")"
  424. }).inject(this.topNode);
  425. }
  426. this.titleTextNode = new Element("div.roomItemTitleTextNode", {
  427. "styles": this.enable ? this.css.roomItemTitleTextNode : this.css.roomItemTitleTextNode_disable ,
  428. "text" : this.data.name
  429. }).inject(this.topNode);
  430. if( this.buildingName ){
  431. this.buildingTextNode = new Element("div.buildingTextNode", {
  432. "styles": this.enable ? this.css.roomItemBuildingTextNode : this.css.roomItemBuildingTextNode_disable,
  433. "text" : this.buildingName
  434. }).inject(this.titleNode);
  435. }
  436. this.middleNode = new Element("div.middleNode", {
  437. "styles": this.css.roomItemTitleMiddleNode
  438. }).inject(this.titleNode);
  439. this.iconsNode = new Element("div.iconsNode", {
  440. "styles": this.css.roomItemTitleIconsNode
  441. }).inject(this.middleNode);
  442. var deviceList = this.data.device.split("#");
  443. deviceList.each(function(name){
  444. var node = new Element("div", {"styles": this.css.roomItemIconNode, "title": this.app.lp.device[name]}).inject(this.iconsNode);
  445. node.setStyle("background-image", "url(/x_component_Meeting/$RoomView/default/icon/device/"+ name + ( this.enable ? "" : "_disable" ) +".png)");
  446. }.bind(this));
  447. this.actionsNode = new Element("div.actionsNode", {
  448. "styles": this.css.roomItemTitleActionsNode
  449. }).inject(this.middleNode);
  450. this.loadActions();
  451. this.contentNode = new Element("div.roomItemContentNode", {"styles": this.css.roomItemContentNode}).inject(this.node);
  452. this.loadMeetings();
  453. this.loadTooltip();
  454. },
  455. loadTooltip : function(){
  456. this.tooltip = new MWF.xApplication.Meeting.RoomTooltip(this.app.content, this.titleNode, this.app, this.data, {
  457. axis : "x",
  458. hiddenDelay : 300,
  459. displayDelay : 300
  460. });
  461. },
  462. loadActions: function(){
  463. if( MWF.AC.isMeetingAdministrator() ){
  464. this.editAction = new Element("div", {
  465. styles: this.css.roomAction_edit,
  466. events : {
  467. mouseover : function(){
  468. this.editAction.setStyles( this.css.roomAction_edit_over );
  469. }.bind(this),
  470. mouseout : function(){
  471. this.editAction.setStyles( this.css.roomAction_edit );
  472. }.bind(this),
  473. click : function(e){
  474. this.editRoom();
  475. e.stopPropagation();
  476. }.bind(this)
  477. }
  478. }).inject(this.actionsNode);
  479. this.removeAction = new Element("div", {
  480. styles: this.css.roomAction_remove,
  481. events : {
  482. mouseover : function(){
  483. this.removeAction.setStyles( this.css.roomAction_remove_over );
  484. }.bind(this),
  485. mouseout : function(){
  486. this.removeAction.setStyles( this.css.roomAction_remove );
  487. }.bind(this),
  488. click : function( e ){
  489. this.removeRoom(e);
  490. e.stopPropagation();
  491. }.bind(this)
  492. }
  493. }).inject(this.actionsNode);
  494. }
  495. if( this.enable ){
  496. this.createMeetingAction = new Element("div", {
  497. tltile : this.app.lp.addMeeting,
  498. styles: this.css.createMeetingAction,
  499. events : {
  500. mouseover : function(){
  501. this.createMeetingAction.setStyles( this.css.createMeetingAction_over );
  502. }.bind(this),
  503. mouseout : function(){
  504. this.createMeetingAction.setStyles( this.css.createMeetingAction );
  505. }.bind(this),
  506. click : function(e){
  507. this.app.addMeeting( this.view.date, this.view.hours, this.view.minutes, this.data.id);
  508. e.stopPropagation();
  509. }.bind(this)
  510. }
  511. }).inject(this.actionsNode);
  512. }
  513. },
  514. editRoom : function(){
  515. var form = new MWF.xApplication.Meeting.RoomForm(this.app,this.data, {}, {app:this.app});
  516. form.view = this;
  517. form.edit();
  518. },
  519. openRoom : function(){
  520. var form = new MWF.xApplication.Meeting.RoomForm(this.app,this.data, {}, {app:this.app});
  521. form.view = this;
  522. form.open();
  523. },
  524. reload : function(){
  525. this.view.reload( this.view.date, this.view.hours, this.view.minutes );
  526. },
  527. removeRoom: function(e) {
  528. var info = this.app.lp.delete_room;
  529. info = info.replace(/{name}/g, this.data.name);
  530. var _self = this;
  531. this.app.confirm("warn", e, this.app.lp.delete_building_title, info, 300, 120, function(){
  532. _self.remove();
  533. this.close();
  534. }, function(){
  535. this.close();
  536. });
  537. },
  538. remove: function(){
  539. var view = this.view;
  540. this.app.actions.deleteRoom(this.data.id, function(){
  541. view.reload();
  542. }.bind(this));
  543. },
  544. resetHeight: function(){
  545. this.node.setStyle("min-height",""+this.view.roomNodeHeight+"px");
  546. if( this.noMeetingNode ){
  547. this.noMeetingNode.setStyle("min-height",""+(this.view.roomNodeHeight - 170)+"px");
  548. this.noMeetingNode.setStyle("line-height",""+(this.view.roomNodeHeight - 170)+"px");
  549. }
  550. },
  551. destroy: function(){
  552. if( this.calendar ){
  553. this.calendar.container.destroy();
  554. }
  555. if( this.tooltip ){
  556. this.tooltip.destroy();
  557. }
  558. this.meetings.each( function(m){
  559. m.destroy();
  560. });
  561. this.node.destroy();
  562. MWF.release(this);
  563. },
  564. loadMeetings: function(){
  565. this.app.isMeetingViewer( function( isAll ){
  566. this.isMeetingViewer = isAll;
  567. this._loadMeetings();
  568. }.bind(this))
  569. },
  570. _loadMeetings: function(){
  571. if( this.data.meetingList.length > 0 ){
  572. this.data.meetingList.each(function(meeting, i){
  573. var m = new MWF.xApplication.Meeting.RoomView.Meeting( this.contentNode, this, meeting);
  574. this.meetings.push( m );
  575. }.bind(this));
  576. }else{
  577. this.noMeetingNode = new Element("div.noMeetingNode", {
  578. "styles": this.data.available ? this.css.noMeetingNode : this.css.noMeetingNode_disable,
  579. "text" : this.data.available ? this.app.lp.noMeeting : this.app.lp.roomDisable
  580. }).inject(this.contentNode);
  581. this.noMeetingNode.setStyle("min-height",""+(this.view.roomNodeHeight - 160)+"px");
  582. this.noMeetingNode.setStyle("line-height",""+(this.view.roomNodeHeight - 160)+"px");
  583. }
  584. }
  585. });
  586. MWF.xApplication.Meeting.RoomView.Meeting = new Class({
  587. Extends : MWF.xApplication.Meeting.MeetingArea,
  588. load: function(){
  589. var userName = layout.desktop.session.user.distinguishedName;
  590. var isAdmin = MWF.AC.isMeetingAdministrator();
  591. var available = false;
  592. var rejected = false;
  593. var confilct = false;
  594. if( isAdmin || this.view.isMeetingViewer || this.data.invitePersonList.contains( userName ) || this.data.applicant == userName ){
  595. available = true
  596. }
  597. if( this.data.rejectPersonList.contains( userName ) ){
  598. rejected = true;
  599. }
  600. var rBeginDate = this.view.view.date;
  601. var rEndDate = this.view.view.endDate;
  602. if( (this.beginDate >= rBeginDate && this.beginDate <= rEndDate) || (this.endDate >= rBeginDate && this.endDate <= rEndDate) ){
  603. confilct = true;
  604. this.data.confilct = true;
  605. }
  606. //if( !confilct && ( !available || rejected )){
  607. // return;
  608. //}
  609. this.node = new Element("div", {"styles": this.css.meetingNode}).inject( this.container );
  610. if( available ){
  611. this.node.addEvents({
  612. click : function(){
  613. this.openMeeting()
  614. }.bind(this)
  615. });
  616. if( !rejected ){
  617. this.node.addEvents({
  618. mouseenter : function(){
  619. this.node.setStyles( this.css.meetingNode_over );
  620. this.subjectNode.setStyles( this.css.meetingSubjectNode_over );
  621. }.bind(this),
  622. mouseleave : function(){
  623. this.node.setStyles( this.css.meetingNode );
  624. this.subjectNode.setStyles( this.css.meetingSubjectNode );
  625. }.bind(this)
  626. })
  627. }
  628. }
  629. this.colorNode = new Element("div", {"styles": this.css.meetingColorNode}).inject(this.node);
  630. this.contentNode = new Element("div", {"styles": this.css.meetingContentNode}).inject(this.node);
  631. var dateStr = this.beginDate.format(this.app.lp.dateFormatMonthDay);
  632. var beginTime = this.getString( this.beginDate.getHours() ) + ":" + this.getString( this.beginDate.getMinutes() );
  633. var endTime = this.getString( this.endDate.getHours() ) + ":" + this.getString( this.endDate.getMinutes() );
  634. this.timeNode = new Element("div", {
  635. "styles": this.css.meetingTimeNode,
  636. "text" : dateStr + " " + beginTime + "-" + endTime
  637. }).inject(this.contentNode);
  638. if( !available || rejected )this.timeNode.setStyle("color" , "#ccc");
  639. if( available ){
  640. this.subjectNode = new Element("div", {
  641. "styles": this.css.meetingSubjectNode,
  642. "text": this.data.subject
  643. }).inject(this.contentNode);
  644. if( rejected )this.subjectNode.setStyle("color" , "#ccc");
  645. }
  646. this.descriptionNode = new Element("div", {
  647. "styles": this.css.meetingDescriptionNode,
  648. "text" : available ? (this.data.summary || "") : this.app.lp.noPermission
  649. }).inject(this.contentNode);
  650. if( !available || rejected )this.descriptionNode.setStyle("color" , "#ccc");
  651. this.loadActionBar();
  652. switch (this.data.status){
  653. case "wait":
  654. this.colorNode.setStyles({"background-color": "#4990E2"});
  655. this.timeNode.setStyles({"color": "#4990E2"});
  656. break;
  657. case "processing":
  658. this.colorNode.setStyles({"background-color": "#66CC7F"});
  659. this.timeNode.setStyles({"color": "#66CC7F"});
  660. break;
  661. case "completed":
  662. this.colorNode.setStyles({"background-color": "#ccc"});
  663. this.timeNode.setStyles({"color": "#ccc"});
  664. break;
  665. }
  666. if (this.data.myWaitAccept){
  667. this.colorNode.setStyles({"background-color": "#F6A623"});
  668. this.timeNode.setStyles({"color": "#F6A623"});
  669. }
  670. if (!available || rejected){
  671. this.colorNode.setStyles({"background-color": "#eee"});
  672. this.timeNode.setStyles({"color": "#ccc"});
  673. }
  674. if (confilct){
  675. this.colorNode.setStyles({"background-color": "#FF7F7F"});
  676. this.timeNode.setStyles({"color": "#FF7F7F"});
  677. }
  678. this.resetNodeSize();
  679. if( available ){
  680. this.loadTooltip( true );
  681. }
  682. }
  683. });
  684. MWF.xApplication.Meeting.RoomView.HelpTooltip = new Class({
  685. Extends: MTooltips,
  686. _getHtml : function(){
  687. var html =
  688. "<div item='containr' style='line-height:24px;'><div style='font-size: 14px;color:#666;float:left; '>"+ this.lp.roomViewHelp +"</div></div>";
  689. return html;
  690. }
  691. });