MonthView.js 32 KB

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