MonthView.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. MWF.xApplication.Meeting.MonthView = new Class({
  2. Extends: MWF.widget.Common,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "date" : ""
  7. },
  8. initialize: function(node, app, options){
  9. this.setOptions(options);
  10. this.path = "/x_component_Meeting/$MonthView/";
  11. this.cssPath = "/x_component_Meeting/$MonthView/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.app = app;
  14. this.container = $(node);
  15. this.load();
  16. },
  17. load: function(){
  18. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  19. //this.loadSideBar();
  20. this.resetNodeSize();
  21. this.app.addEvent("resize", this.resetNodeSize.bind(this));
  22. this.loadCalendar();
  23. },
  24. resetNodeSize: function(){
  25. var size = this.container.getSize();
  26. var y = size.y-60;
  27. this.node.setStyle("height", ""+y+"px");
  28. this.node.setStyle("margin-top", "60px");
  29. var sideBarSize = this.app.sideBar ? this.app.sideBar.getSize() : { x : 0, y:0 };
  30. this.node.setStyle("width", ""+(size.x - sideBarSize.x)+"px");
  31. this.node.setStyle("margin-right", ""+sideBarSize.x+"px");
  32. //var size = this.container.getSize();
  33. //
  34. //this.scrollNode.setStyle("height", ""+(size.y-60)+"px");
  35. //this.scrollNode.setStyle("margin-top", "60px");
  36. //
  37. //if (this.contentWarpNode){
  38. // this.contentWarpNode.setStyles({
  39. // "width": (size.x - 50) +"px"
  40. // });
  41. //}
  42. },
  43. loadCalendar: function(){
  44. var date = "";
  45. if( this.options.date ){
  46. date = Date.parse( this.options.date )
  47. }
  48. this.calendar = new MWF.xApplication.Meeting.MonthView.Calendar(this, date );
  49. },
  50. hide: function(){
  51. var fx = new Fx.Morph(this.node, {
  52. "duration": "300",
  53. "transition": Fx.Transitions.Expo.easeOut
  54. });
  55. fx.start({
  56. "opacity": 0
  57. }).chain(function(){
  58. this.node.setStyle("display", "none");
  59. }.bind(this));
  60. },
  61. show: function(){
  62. this.node.setStyles(this.css.node);
  63. var fx = new Fx.Morph(this.node, {
  64. "duration": "800",
  65. "transition": Fx.Transitions.Expo.easeOut
  66. });
  67. this.app.fireAppEvent("resize");
  68. fx.start({
  69. "opacity": 1,
  70. "left": "0px"
  71. }).chain(function(){
  72. this.node.setStyles({
  73. "position": "static",
  74. "width": "auto"
  75. });
  76. }.bind(this));
  77. },
  78. reload: function(){
  79. if (this.calendar) this.calendar.reLoadCalendar();
  80. },
  81. recordStatus : function(){
  82. var date = "";
  83. if (this.calendar) date = this.calendar.date;
  84. return {
  85. date : date.toString()
  86. };
  87. },
  88. destroy: function(){
  89. if (this.calendar){
  90. this.calendar.destroy();
  91. }
  92. this.node.destroy();
  93. //MWF.release( this );
  94. }
  95. });
  96. MWF.xApplication.Meeting.MonthView.Calendar = new Class({
  97. Implements: [Events],
  98. initialize: function(view, date){
  99. this.view = view;
  100. this.css = this.view.css;
  101. this.container = this.view.node;
  102. this.app = this.view.app;
  103. this.date = date || new Date();
  104. this.today = new Date();
  105. this.days = {};
  106. this.weekBegin = this.app.meetingConfig.weekBegin || 0;
  107. this.load();
  108. },
  109. load: function(){
  110. this.titleNode = new Element("div", {"styles": this.css.calendarTitleNode}).inject(this.container);
  111. this.scrollNode = new Element("div", {
  112. "styles": this.css.scrollNode
  113. }).inject(this.container);
  114. this.contentWarpNode = new Element("div", {
  115. "styles": this.css.contentWarpNode
  116. }).inject(this.scrollNode);
  117. this.contentContainerNode = new Element("div",{
  118. "styles" : this.css.contentContainerNode
  119. }).inject(this.contentWarpNode);
  120. this.bodyNode = new Element("div", {
  121. "styles": this.css.contentNode
  122. }).inject(this.contentContainerNode);
  123. //this.bodyNode = new Element("div", {"styles": this.css.calendarBodyNode}).inject(this.container);
  124. this.setTitleNode();
  125. this.setBodyNode();
  126. this.resetBodySize();
  127. this.app.addEvent("resize", this.resetBodySize.bind(this));
  128. },
  129. resetBodySize: function(){
  130. var size = this.container.getSize();
  131. var titleSize = this.titleNode.getSize();
  132. var y = size.y-titleSize.y;
  133. //this.bodyNode.setStyle("height", ""+y+"px");
  134. //var size = this.container.getSize();
  135. this.scrollNode.setStyle("height", ""+y+"px");
  136. //this.scrollNode.setStyle("margin-top", "60px");
  137. if (this.contentWarpNode){
  138. this.contentWarpNode.setStyles({
  139. "width": (size.x - 40) +"px"
  140. });
  141. }
  142. //var tdy = (y-30)/6;
  143. //tdy = tdy-34;
  144. //var tds = this.calendarTable.getElements("td");
  145. //tds.each(function(td){
  146. // var yy = tdy;
  147. // var node = td.getLast("div");
  148. // if (node.childNodes.length>=4){
  149. // if (yy<92) yy = 69;
  150. // }
  151. // node.setStyle("height", ""+yy+"px");
  152. //}.bind(this));
  153. },
  154. setTitleNode: function(){
  155. this.prevMonthNode = new Element("div", {"styles": this.css.calendarPrevMonthNode}).inject(this.titleNode);
  156. var text = this.date.format(this.app.lp.dateFormatMonth);
  157. this.titleTextNode = new Element("div", {"styles": this.css.calendarTitleTextNode, "text": text}).inject(this.titleNode);
  158. this.nextMonthNode = new Element("div", {"styles": this.css.calendarNextMonthNode}).inject(this.titleNode);
  159. this.prevMonthNode.addEvents({
  160. "mouseover": function(){this.prevMonthNode.setStyles(this.css.calendarPrevMonthNode_over);}.bind(this),
  161. "mouseout": function(){this.prevMonthNode.setStyles(this.css.calendarPrevMonthNode);}.bind(this),
  162. "mousedown": function(){this.prevMonthNode.setStyles(this.css.calendarPrevMonthNode_down);}.bind(this),
  163. "mouseup": function(){this.prevMonthNode.setStyles(this.css.calendarPrevMonthNode_over);}.bind(this),
  164. "click": function(){this.changeMonthPrev();}.bind(this)
  165. });
  166. this.nextMonthNode.addEvents({
  167. "mouseover": function(){this.nextMonthNode.setStyles(this.css.calendarNextMonthNode_over);}.bind(this),
  168. "mouseout": function(){this.nextMonthNode.setStyles(this.css.calendarNextMonthNode);}.bind(this),
  169. "mousedown": function(){this.nextMonthNode.setStyles(this.css.calendarNextMonthNode_down);}.bind(this),
  170. "mouseup": function(){this.nextMonthNode.setStyles(this.css.calendarNextMonthNode_over);}.bind(this),
  171. "click": function(){this.changeMonthNext();}.bind(this)
  172. });
  173. this.titleTextNode.addEvents({
  174. "mouseover": function(){this.titleTextNode.setStyles(this.css.calendarTitleTextNode_over);}.bind(this),
  175. "mouseout": function(){this.titleTextNode.setStyles(this.css.calendarTitleTextNode);}.bind(this),
  176. "mousedown": function(){this.titleTextNode.setStyles(this.css.calendarTitleTextNode_down);}.bind(this),
  177. "mouseup": function(){this.titleTextNode.setStyles(this.css.calendarTitleTextNode_over);}.bind(this),
  178. "click": function(){this.changeMonthSelect();}.bind(this)
  179. });
  180. },
  181. changeMonthPrev: function(){
  182. this.date.decrement("month", 1);
  183. var text = this.date.format(this.app.lp.dateFormatMonth);
  184. this.titleTextNode.set("text", text);
  185. this.reLoadCalendar();
  186. },
  187. changeMonthNext: function(){
  188. this.date.increment("month", 1);
  189. var text = this.date.format(this.app.lp.dateFormatMonth);
  190. this.titleTextNode.set("text", text);
  191. this.reLoadCalendar();
  192. },
  193. changeMonthSelect: function(){
  194. if (!this.monthSelector) this.createMonthSelector();
  195. this.monthSelector.show();
  196. },
  197. createMonthSelector: function(){
  198. this.monthSelector = new MWF.xApplication.Meeting.MonthView.Calendar.MonthSelector(this.date, this);
  199. },
  200. changeMonthTo: function(d){
  201. this.date = d;
  202. var text = this.date.format(this.app.lp.dateFormatMonth);
  203. this.titleTextNode.set("text", text);
  204. this.reLoadCalendar();
  205. },
  206. setBodyNode: function(){
  207. if( this.weekBegin == "1" ){
  208. var html = "<tr><th>"+this.app.lp.weeks.Mon+"</th><th>"+this.app.lp.weeks.Tues+"</th><th>"+this.app.lp.weeks.Wed+"</th>" +
  209. "<th>"+this.app.lp.weeks.Thur+"</th><th>"+this.app.lp.weeks.Fri+"</th><th>"+this.app.lp.weeks.Sat+"</th><th>"+this.app.lp.weeks.Sun+"</th></tr>";
  210. }else{
  211. var html = "<tr><th>"+this.app.lp.weeks.Sun+"</th><th>"+this.app.lp.weeks.Mon+"</th><th>"+this.app.lp.weeks.Tues+"</th><th>"+this.app.lp.weeks.Wed+"</th>" +
  212. "<th>"+this.app.lp.weeks.Thur+"</th><th>"+this.app.lp.weeks.Fri+"</th><th>"+this.app.lp.weeks.Sat+"</th></tr>";
  213. }
  214. html += "<tr><td valign='top'></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  215. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  216. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  217. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  218. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  219. html += "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
  220. this.calendarTable = new Element("table", {
  221. "styles": this.css.calendarTable,
  222. "height": "100%",
  223. "border": "0",
  224. "cellPadding": "0",
  225. "cellSpacing": "0",
  226. "html": html
  227. }).inject(this.bodyNode);
  228. this.calendarTableTitleTr = this.calendarTable.getElement("tr");
  229. this.calendarTableTitleTr.setStyles(this.css.calendarTableTitleTr);
  230. var ths = this.calendarTableTitleTr.getElements("th");
  231. ths.setStyles(this.css.calendarTableTh);
  232. //var tds = this.calendarTable.getElements("td");
  233. //tds.setStyles(this.css.calendarTableCell);
  234. this.loadCalendar();
  235. },
  236. reLoadCalendar: function(){
  237. Object.each(this.days, function(day){
  238. day.destroy();
  239. }.bind(this));
  240. this.loadCalendar();
  241. },
  242. loadCalendar: function(){
  243. var date = this.date.clone();
  244. date.set("date", 1);
  245. var week = date.getDay();
  246. if( this.weekBegin == "1" ){
  247. var decrementDay = ((week-1)<0) ? 6 : week-1;
  248. }else{
  249. var decrementDay = week;
  250. }
  251. date.decrement("day", decrementDay);
  252. var tds = this.calendarTable.getElements("td");
  253. tds.each(function(td){
  254. this.loadDay(td, date);
  255. date.increment();
  256. }.bind(this));
  257. },
  258. loadDay: function(td, date){
  259. var type = "thisMonth";
  260. var m = date.get("month");
  261. var y = date.get("year");
  262. var d = date.get("date");
  263. var mm = this.date.get("month");
  264. var yy = this.date.get("year");
  265. var mmm = this.today.get("month");
  266. var yyy = this.today.get("year");
  267. var ddd = this.today.get("date");
  268. if ((m==mmm) && (y==yyy) && (d==ddd)){
  269. type = "today";
  270. }else if ((m==mm) && (y==yy)){
  271. type = "thisMonth";
  272. }else{
  273. type = "otherMonth";
  274. }
  275. var key = date.format(this.app.lp.dateFormat);
  276. this.days[key] = new MWF.xApplication.Meeting.MonthView.Calendar.Day(td, date, this, type);
  277. },
  278. reload : function(){
  279. this.view.reload();
  280. },
  281. destroy: function(){
  282. Object.each(this.days, function(day){
  283. day.destroy();
  284. }.bind(this));
  285. this.container.empty();
  286. }
  287. });
  288. MWF.xApplication.Meeting.MonthView.Calendar.Day = new Class({
  289. Implements: [Events],
  290. initialize: function(td, date, calendar, type){
  291. this.container = td;
  292. this.calendar = calendar;
  293. this.view = this.calendar.view;
  294. this.css = this.calendar.css;
  295. this.app = this.calendar.app;
  296. this.date = date.clone();
  297. this.key = this.date.format(this.app.lp.dateFormat);
  298. this.type = type; //today, otherMonth, thisMonth
  299. this.meetings = [];
  300. this.load();
  301. },
  302. load: function(){
  303. this.color = "#666";
  304. if( this.type == "thisMonth" ){
  305. }else if( this.type == "otherMonth" ){
  306. this.color = "#ccc";
  307. }
  308. this.day = this.date.getDate();
  309. this.month = this.date.getMonth();
  310. this.year = this.date.getYear();
  311. this.node = new Element("div", {
  312. "styles" : this.css["calendarTableCell_"+this.type]
  313. }).inject( this.container );
  314. this.titleNode = new Element("div", {"styles": this.css["dayTitle_"+this.type]}).inject(this.node);
  315. this.titleDayNode = new Element("div", {"styles": this.css["dayTitleDay_"+this.type], "text": this.day}).inject(this.titleNode);
  316. if ((new Date()).diff(this.date)>=0){
  317. this.titleNode.set("title", this.app.lp.titleNode);
  318. this.titleNode.addEvent("click", function(){
  319. this.app.addMeeting(this.date);
  320. }.bind(this));
  321. }
  322. this.contentNode = new Element("div", {"styles": this.css.dayContentNode}).inject(this.node);
  323. this.loadMeetings();
  324. },
  325. loadMeetings: function(){
  326. this.app.isMeetingViewer( function( isAll ){
  327. this._loadMeetings( isAll );
  328. }.bind(this))
  329. },
  330. _loadMeetings: function( isAll ){
  331. var y = this.date.getFullYear();
  332. var m = this.date.getMonth()+1;
  333. var d = this.date.getDate();
  334. var meetingCount = 0;
  335. var myRejectCount = 0;
  336. this.firstStatus = "";
  337. this.lastStatus = "";
  338. this.app.actions[ isAll ? "listMeetingDayAll" : "listMeetingDay" ](y, m, d, function(json){
  339. var length = json.data.length;
  340. json.data.each(function(meeting, i){
  341. if (!meeting.myReject){
  342. meetingCount++;
  343. if (meetingCount==3){
  344. //this.contentNode.setStyle("height", "100px");
  345. }
  346. if( meetingCount == 1 ){
  347. this.firstStatus = meeting.status;
  348. if( meeting.myWaitAccept )this.firstStatus = "myWaitAccept"
  349. }
  350. if( meetingCount + myRejectCount == length ){
  351. this.lastStatus = meeting.status;
  352. if( meeting.myWaitAccept )this.lastStatus = "myWaitAccept"
  353. }
  354. //if (meetingCount<4)
  355. this.meetings.push(new MWF.xApplication.Meeting.MonthView.Calendar.Day.Meeting(this, meeting, meetingCount));
  356. }else{
  357. myRejectCount++;
  358. }
  359. }.bind(this));
  360. if (meetingCount==0){
  361. var node = new Element("div", {
  362. "styles": {
  363. "line-height": "40px",
  364. "font-size": "14px",
  365. "text-align" : "center",
  366. "color" : this.color,
  367. "padding": "0px 10px"
  368. }
  369. }).inject(this.contentNode);
  370. node.set("text", this.app.lp.noMeeting);
  371. }else{
  372. this.titleInforNode = new Element("div", {"styles": this.css["dayTitleInfor_"+this.type]}).inject(this.titleNode);
  373. if( this.app.isViewAvailable( "toDay" ) ) {
  374. this.titleInforNode.addEvent("click", function (e) {
  375. this.app.toDay(this.date);
  376. e.stopPropagation();
  377. }.bind(this));
  378. }else{
  379. this.titleInforNode.setStyle("cursor","default");
  380. }
  381. this.titleInforNode.set("text", ""+meetingCount+this.app.lp.countMeetings+"");
  382. if (meetingCount>3){
  383. this.node.addEvents( {
  384. "mouseenter" : function(){
  385. this.expend();
  386. }.bind(this),
  387. "mouseleave" : function(){
  388. this.collapseReady = true;
  389. this.collapse();
  390. }.bind(this)
  391. } )
  392. }else{
  393. this.titleInforNode.setStyle("color", this.type == "otherMonth" ? "#ccc" : "#999");
  394. }
  395. }
  396. if(this.firstStatus){
  397. switch (this.firstStatus){
  398. case "wait":
  399. this.titleNode.setStyles({ "border-left": "6px solid #4990E2" });
  400. break;
  401. case "processing":
  402. this.titleNode.setStyles({ "border-left": "6px solid #66CC7F" });
  403. break;
  404. case "completed":
  405. this.titleNode.setStyles({ "border-left": "6px solid #ccc" });
  406. break;
  407. case "myWaitAccept":
  408. this.titleNode.setStyles({ "border-left": "6px solid #F6A623" });
  409. break
  410. }
  411. }
  412. if( this.lastStatus ){
  413. var heigth=0;
  414. if( meetingCount >= 3 ){
  415. heigth = 10;
  416. }else{
  417. heigth = 100 - meetingCount*30;
  418. }
  419. var bottomEmptyNode = new Element("div", {
  420. styles : {
  421. "height" : ""+heigth+"px"
  422. }
  423. }).inject( this.node );
  424. switch (this.lastStatus){
  425. case "wait":
  426. bottomEmptyNode.setStyles({ "border-left": "6px solid #4990E2" });
  427. break;
  428. case "processing":
  429. bottomEmptyNode.setStyles({ "border-left": "6px solid #66CC7F" });
  430. break;
  431. case "completed":
  432. bottomEmptyNode.setStyles({ "border-left": "6px solid #ccc" });
  433. break;
  434. case "myWaitAccept":
  435. bottomEmptyNode.setStyles({ "border-left": "6px solid #F6A623" });
  436. break
  437. }
  438. }
  439. }.bind(this));
  440. },
  441. expend : function(){
  442. this.oSize = this.node.getSize();
  443. this.container.setStyles({
  444. "position" : "relative"
  445. });
  446. this.tempNode = new Element("div",{
  447. styles : {
  448. width : (this.node.getSize().x ) + "px",
  449. height : "1px",
  450. margin : "7px"
  451. }
  452. }).inject(this.container);
  453. this.node.setStyles({
  454. "height" : this.node.getScrollSize().y + "px",
  455. "width" : (this.node.getSize().x ) + "px",
  456. "position" : "absolute",
  457. "top" : "0px",
  458. "left" : "0px",
  459. "box-shadow": "0 0 8px 0 rgba(0,0,0,0.25)"
  460. });
  461. var nodeCoordinate = this.node.getCoordinates();
  462. var contentNode = this.calendar.contentWarpNode;
  463. var contentCoordinate = contentNode.getCoordinates();
  464. if( nodeCoordinate.bottom > contentCoordinate.bottom ){
  465. this.contentHeight = contentCoordinate.height;
  466. contentNode.setStyle("height", ( nodeCoordinate.bottom - contentCoordinate.top )+"px" );
  467. }
  468. this.isCollapse = false;
  469. },
  470. collapse : function(){
  471. if( !this.collapseDisable && this.collapseReady){
  472. this.container.setStyles({
  473. "position" : "static"
  474. });
  475. if( this.tempNode )this.tempNode.destroy();
  476. this.node.setStyles({
  477. "height" : "140px",
  478. "width" : "auto",
  479. "position" : "static",
  480. "box-shadow": "none"
  481. });
  482. if( this.contentHeight ){
  483. var contentNode = this.calendar.contentWarpNode;
  484. contentNode .setStyle("height", ( this.contentHeight )+"px" );
  485. this.contentHeight = null;
  486. }
  487. this.isCollapse = true;
  488. }
  489. },
  490. destroy: function(){
  491. this.meetings.each(function(meeting){
  492. meeting.destroy();
  493. }.bind(this));
  494. this.meetings = [];
  495. this.titleNode.destroy();
  496. this.titleNode = null;
  497. this.titleDayNode = null;
  498. this.titleInforNode = null;
  499. delete this.calendar.days[this.key];
  500. this.container.empty();
  501. MWF.release(this);
  502. },
  503. reload: function(){
  504. this.view.reload();
  505. }
  506. });
  507. MWF.xApplication.Meeting.MonthView.Calendar.Day.Meeting = new Class({
  508. initialize: function(day, data, index){
  509. this.day = day;
  510. this.css = this.day.css;
  511. this.view = this.day.view;
  512. this.app = this.day.app;
  513. this.container = this.day.contentNode;
  514. this.data = data;
  515. this.index = index;
  516. this.load();
  517. },
  518. load: function(){
  519. this.nodeStyles = (this.day.type == "today") ? this.css.meetingNode_today : this.css.meetingNode;
  520. this.node = new Element("div", {
  521. "styles": this.nodeStyles
  522. }).inject(this.container);
  523. this.iconNode = new Element("div", {"styles": this.css.meetingIconNode}).inject(this.node);
  524. this.timeNode = new Element("div", {"styles": this.css.meetingTimeNode}).inject(this.node);
  525. this.textNode = new Element("div", {"styles": this.css.meetingTextNode}).inject(this.node);
  526. var timeStr = Date.parse(this.data.startTime).format("%H:%M");
  527. this.timeNode.set("text", timeStr);
  528. this.textNode.set("text", this.data.subject);
  529. //this.node.set("title", this.data.subject);
  530. //
  531. //if (this.data.myWaitAccept){
  532. // this.iconNode.setStyle("background", "url(/x_component_Meeting/$MonthView/"+this.app.options.style+"/icon/invite.png) no-repeat center center");
  533. //}
  534. switch (this.data.status){
  535. case "wait":
  536. this.node.setStyles({
  537. "border-left": "6px solid #4990E2"
  538. });
  539. break;
  540. case "processing":
  541. this.node.setStyles({
  542. "border-left": "6px solid #66CC7F"
  543. });
  544. break;
  545. case "completed":
  546. //add attachment
  547. this.node.setStyles({
  548. "border-left": "6px solid #ccc"
  549. });
  550. //this.textNode.setStyle("color", "#666");
  551. break;
  552. }
  553. if (this.data.myWaitAccept){
  554. this.node.setStyles({
  555. "border-left": "6px solid #F6A623"
  556. });
  557. }
  558. this.node.addEvents({
  559. mouseenter : function(){
  560. this.day.collapseReady = false;
  561. this.node.setStyles( this.css.meetingNode_over );
  562. //this.showTooltip();
  563. }.bind(this),
  564. mouseleave : function(){
  565. this.node.setStyles( this.nodeStyles );
  566. }.bind(this),
  567. "click": function(){this.openMeeting();}.bind(this)
  568. });
  569. this.loadTooltip();
  570. },
  571. loadTooltip : function(){
  572. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.node, this.app, this.data, {
  573. axis : "x",
  574. hiddenDelay : 300,
  575. displayDelay : 300,
  576. onShow : function(){
  577. this.day.collapseDisable = true;
  578. }.bind(this),
  579. onQueryCreate : function(){
  580. this.day.collapseDisable = true;
  581. }.bind(this),
  582. onHide : function(){
  583. this.day.collapseDisable = false;
  584. this.day.collapse();
  585. }.bind(this)
  586. });
  587. },
  588. showTooltip: function( ){
  589. //if( this.index > 3 && this.day.isCollapse ){
  590. //}else{
  591. if( this.tooltip ){
  592. this.tooltip.load();
  593. }else{
  594. this.tooltip = new MWF.xApplication.Meeting.MeetingTooltip(this.app.content, this.node, this.app, this.data, {
  595. axis : "x", "delay" : 150
  596. //onShow : function(){
  597. // this.day.collapseDisable = true;
  598. //}.bind(this),
  599. //onQueryCreate : function(){
  600. // this.day.collapseDisable = true;
  601. //}.bind(this),
  602. //onHide : function(){
  603. // this.day.collapseDisable = false;
  604. //}.bind(this)
  605. });
  606. this.tooltip.load();
  607. }
  608. //}
  609. },
  610. openMeeting: function(){
  611. this.form = new MWF.xApplication.Meeting.MeetingForm(this,this.data, {}, {app:this.app});
  612. this.form.view = this;
  613. this.form.open();
  614. },
  615. destroy: function(){
  616. if(this.tooltip)this.tooltip.destroy();
  617. this.node.destroy();
  618. MWF.release(this);
  619. },
  620. reload: function(){
  621. this.view.reload();
  622. }
  623. });
  624. MWF.xApplication.Meeting.MonthView.Calendar.MonthSelector = new Class({
  625. Implements: [Events],
  626. initialize: function(date, calendar){
  627. this.calendar = calendar;
  628. this.css = this.calendar.css;
  629. this.app = this.calendar.app;
  630. this.date = date;
  631. this.year = this.date.get("year");
  632. this.load();
  633. },
  634. load: function(){
  635. this.monthSelectNode = new Element("div", {"styles": this.css.calendarMonthSelectNode}).inject(this.calendar.container);
  636. this.monthSelectNode.position({
  637. relativeTo: this.calendar.titleTextNode,
  638. position: 'bottomCenter',
  639. edge: 'upperCenter'
  640. });
  641. this.monthSelectNode.addEvent("mousedown", function(e){e.stopPropagation();});
  642. this.monthSelectTitleNode = new Element("div", {"styles": this.css.calendarMonthSelectTitleNode}).inject(this.monthSelectNode);
  643. this.monthSelectPrevYearNode = new Element("div", {"styles": this.css.calendarMonthSelectTitlePrevYearNode}).inject(this.monthSelectTitleNode);
  644. this.monthSelectNextYearNode = new Element("div", {"styles": this.css.calendarMonthSelectTitleNextYearNode}).inject(this.monthSelectTitleNode);
  645. this.monthSelectTextNode = new Element("div", {"styles": this.css.calendarMonthSelectTitleTextNode}).inject(this.monthSelectTitleNode);
  646. this.monthSelectTextNode.set("text", this.year);
  647. var html = "<tr><td></td><td></td><td></td></tr>";
  648. html += "<tr><td></td><td></td><td></td></tr>";
  649. html += "<tr><td></td><td></td><td></td></tr>";
  650. html += "<tr><td></td><td></td><td></td></tr>";
  651. this.monthSelectTable = new Element("table", {
  652. "styles": {"margin-top": "10px"},
  653. "height": "200px",
  654. "width": "90%",
  655. "align": "center",
  656. "border": "0",
  657. "cellPadding": "0",
  658. "cellSpacing": "0", //5
  659. "html": html
  660. }).inject(this.monthSelectNode);
  661. //this.loadMonth();
  662. this.monthSelectBottomNode = new Element("div", {"styles": this.css.calendarMonthSelectBottomNode, "text": this.app.lp.today}).inject(this.monthSelectNode);
  663. this.setEvent();
  664. },
  665. loadMonth: function(){
  666. this.monthSelectTextNode.set("text", this.year);
  667. var d = new Date();
  668. var todayY = d.get("year");
  669. var todayM = d.get("month");
  670. var thisY = this.date.get("year");
  671. var thisM = this.date.get("month");
  672. var _self = this;
  673. var tds = this.monthSelectTable.getElements("td");
  674. tds.each(function(td, idx){
  675. td.empty();
  676. td.removeEvents("mouseover");
  677. td.removeEvents("mouseout");
  678. td.removeEvents("mousedown");
  679. td.removeEvents("mouseup");
  680. td.removeEvents("click");
  681. var m = idx+1;
  682. td.store("month", m);
  683. td.setStyles(this.css.calendarMonthSelectTdNode);
  684. td.setStyle("background-color", "#FFF");
  685. if ((this.year == todayY) && (idx == todayM)){
  686. new Element("div", {
  687. styles : _self.css.calendarMonthSelectTodayNode,
  688. text : ""+m+this.app.lp.month
  689. }).inject( td );
  690. }else if ((this.year == thisY) && (idx == thisM)){
  691. //td.setStyle("background-color", "#EEE");
  692. new Element("div", {
  693. styles : _self.css.calendarMonthSelectCurrentNode,
  694. text : ""+m+this.app.lp.month
  695. }).inject( td );
  696. }else{
  697. td.set("text", ""+m+this.app.lp.month);
  698. }
  699. td.addEvents({
  700. "mouseover": function(){this.setStyles(_self.css.calendarMonthSelectTdNode_over);},
  701. "mouseout": function(){this.setStyles(_self.css.calendarMonthSelectTdNode);},
  702. "mousedown": function(){this.setStyles(_self.css.calendarMonthSelectTdNode_down);},
  703. "mouseup": function(){this.setStyles(_self.css.calendarMonthSelectTdNode_over);},
  704. "click": function(){
  705. _self.selectedMonth(this);
  706. }
  707. });
  708. }.bind(this));
  709. },
  710. setEvent: function(){
  711. this.monthSelectPrevYearNode.addEvent("click", function(){
  712. this.prevYear();
  713. }.bind(this));
  714. this.monthSelectNextYearNode.addEvent("click", function(){
  715. this.nextYear();
  716. }.bind(this));
  717. this.monthSelectBottomNode.addEvents({
  718. "mouuseover" : function(){ this.monthSelectBottomNode.setStyles( this.css.calendarMonthSelectBottomNode_over ); }.bind(this),
  719. "mouuseout" : function(){ this.monthSelectBottomNode.setStyles( this.css.calendarMonthSelectBottomNode ); }.bind(this),
  720. "click" : function(){ this.todayMonth(); }.bind(this)
  721. });
  722. },
  723. prevYear: function(){
  724. this.year--;
  725. if (this.year<1900) this.year=1900;
  726. this.monthSelectTextNode.set("text", this.year);
  727. this.loadMonth();
  728. },
  729. nextYear: function(){
  730. this.year++;
  731. //if (this.year<1900) this.year=1900;
  732. this.monthSelectTextNode.set("text", this.year);
  733. this.loadMonth();
  734. },
  735. todayMonth: function(){
  736. var d = new Date();
  737. this.calendar.changeMonthTo(d);
  738. this.hide();
  739. },
  740. selectedMonth: function(td){
  741. var m = td.retrieve("month");
  742. var d = Date.parse(this.year+"/"+m+"/1");
  743. this.calendar.changeMonthTo(d);
  744. this.hide();
  745. },
  746. show: function(){
  747. this.date = this.calendar.date;
  748. this.year = this.date.get("year");
  749. this.loadMonth();
  750. this.monthSelectNode.setStyle("display", "block");
  751. this.hideFun = this.hide.bind(this);
  752. document.body.addEvent("mousedown", this.hideFun);
  753. },
  754. hide: function(){
  755. this.monthSelectNode.setStyle("display", "none");
  756. document.body.removeEvent("mousedown", this.hideFun);
  757. },
  758. destroy: function(){
  759. //this.titleNode.destroy();
  760. //this.titleNode = null;
  761. //this.titleDayNode = null;
  762. //this.titleInforNode = null;
  763. //
  764. //delete this.calendar.days[this.key];
  765. //
  766. //this.node.empty();
  767. //MWF.release(this);
  768. }
  769. });