MonthView.js 33 KB

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