RoomView.js 33 KB

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