Main.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528
  1. var MWFCalendar = MWF.xApplication.Calendar = MWF.xApplication.Calendar || {};
  2. MWF.require("MWF.xDesktop.UserData", null, false);
  3. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  4. //MWF.xDesktop.requireApp("Calendar", "Actions.RestActions", null, false);
  5. MWF.xDesktop.requireApp("Calendar", "Common", null, false);
  6. MWF.xDesktop.requireApp("Template", "MDomItem", null, false);
  7. MWF.xApplication.Calendar.options.multitask = false;
  8. MWFCalendar.LeftNaviWidth = 200;
  9. MWF.xApplication.Calendar.Main = new Class({
  10. Extends: MWF.xApplication.Common.Main,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "name": "Calendar",
  15. "icon": "icon.png",
  16. "width": "1000",
  17. "height": "600",
  18. "isResize": true,
  19. "isMax": true,
  20. "eventId" : "",
  21. "title": MWF.xApplication.Calendar.LP.title
  22. },
  23. onQueryLoad: function(){
  24. this.lp = MWF.xApplication.Calendar.LP;
  25. this.menuMode="show";
  26. this.isManager = MWF.AC.isAdministrator();
  27. this.userName = ( layout.desktop.session.user || layout.user ).distinguishedName;
  28. if (!this.actions) this.actions = MWF.Actions.get("x_calendar_assemble_control"); //new MWF.xApplication.Calendar.Actions.RestActions();
  29. //if (!this.personActions) this.personActions = MWF.Actions.get("x_organization_assemble_express");
  30. },
  31. loadApplication: function(callback) {
  32. this.canlendarData = null;
  33. MWF.UD.getDataJson("calendarConfig", function(json){
  34. this.calendarConfig = json || {};
  35. MWF.UD.getPublicData("calendarConfig", function(json){
  36. var jsonData = json || {};
  37. if (jsonData.process){
  38. this.calendarConfig.process = jsonData.process;
  39. }else{
  40. this.calendarConfig.process = null;
  41. }
  42. if( jsonData.weekBegin ){
  43. this.calendarConfig.weekBegin = jsonData.weekBegin;
  44. }
  45. for( var key in jsonData ){
  46. if( key != "process" && key != "weekBegin" ){
  47. this.calendarConfig[ key ] = jsonData[key];
  48. }
  49. }
  50. if( !this.calendarConfig.disableViewList ) this.calendarConfig.disableViewList = [];
  51. this.createNode();
  52. if (!this.options.isRefresh) {
  53. this.maxSize(function () {
  54. this.listCalendar( function(){
  55. this.loadLayout();
  56. }.bind(this));
  57. }.bind(this));
  58. } else {
  59. this.listCalendar( function(){
  60. this.loadLayout();
  61. }.bind(this))
  62. }
  63. if (callback) callback();
  64. }.bind(this));
  65. }.bind(this));
  66. },
  67. listCalendar : function( callback ){
  68. if( this.canlendarData ){
  69. if(callback)callback( this.canlendarData )
  70. }else{
  71. this.actions.listMyCalendar( function( json ){
  72. if( ( json.data.myCalendars || [] ).length == 0 ){
  73. this.createDefaultCalendar(function(){
  74. if(callback)callback( json.data )
  75. });
  76. }else{
  77. this.canlendarData = json.data;
  78. this.calendarDataList = json.data.myCalendars;
  79. this.currentCalendarData = json.data.myCalendars[0];
  80. if(callback)callback( json.data )
  81. }
  82. }.bind(this))
  83. }
  84. },
  85. getSelectedCalendarId : function(){
  86. if( this.leftNavi ){
  87. return this.leftNavi.getSelectedCalendarId();
  88. }else{
  89. return null;
  90. }
  91. },
  92. createDefaultCalendar : function( callback ){
  93. // this.actions.saveCalendar({
  94. // name : "我的日历",
  95. // type : "person",
  96. // color : "",
  97. // description : "",
  98. // source : "PERSON",
  99. // isPublic : false//,
  100. // //manageablePersonList : [this.userName]
  101. // }, function(){
  102. this.actions.listMyCalendar( function( json ){
  103. if( ( json.data.myCalendars || [] ).length == 0 ){
  104. }else{
  105. this.canlendarData = json.data;
  106. this.calendarDataList = json.data.myCalendars;
  107. this.currentCalendarData = json.data.myCalendars[0];
  108. if(callback)callback()
  109. }
  110. }.bind(this))
  111. // }.bind(this))
  112. },
  113. createNode: function(){
  114. this.content.setStyle("overflow", "hidden");
  115. this.node = new Element("div", {
  116. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  117. }).inject(this.content);
  118. this.naviContainerNode = new Element("div.naviContainerNode", {
  119. "styles": this.css.naviContainerNode
  120. }).inject(this.node);
  121. this.leftTitleNode = new Element("div.leftTitleNode", {
  122. "styles": this.css.leftTitleNode
  123. }).inject(this.naviContainerNode);
  124. this.rightContentNode = new Element("div", {
  125. "styles":this.css.rightContentNode
  126. }).inject(this.node);
  127. },
  128. loadLayout: function(){
  129. if( this.status && this.status.action ) {
  130. this.defaultAction = this.status.action;
  131. }else if( this.options.defaultAction ){
  132. this.defaultAction = this.options.defaultAction;
  133. }else if (this.calendarConfig.defaultView){
  134. this.defaultAction = this.calendarConfig.defaultView;
  135. }else{
  136. this.defaultAction = "toMonth";
  137. }
  138. if( this.calendarConfig.disableViewList.contains( this.defaultAction ) ){
  139. this.defaultAction = "";
  140. }
  141. this.loadNaviTitleNode();
  142. this.loadLeftNavi();
  143. this.topMenu = new Element("div", {"styles": this.css.topMenu}).inject(this.rightContentNode);
  144. this.contentNode = new Element("div", {"styles": this.css.contentNode}).inject(this.rightContentNode);
  145. this.loadTopMenus();
  146. //this.loadSideBar();
  147. this.resizeNodes();
  148. this.resizeNodesFun = this.resizeNodes.bind(this);
  149. this.addEvent("resize", this.resizeNodesFun )
  150. },
  151. loadNaviTitleNode: function(){
  152. this.titleContentNode = new Element("div.titleContentNode", {
  153. "styles": this.css.titleContentNode
  154. }).inject(this.leftTitleNode);
  155. this.newCalendarNode = new Element("div", {
  156. styles : this.css.newCalendarNode,
  157. text : "创建新日历",
  158. events : {
  159. mouseover : function( ev ){ ev.target.setStyles( this.css.newCalendarNode_over ); }.bind(this),
  160. mouseout : function( ev ){ ev.target.setStyles( this.css.newCalendarNode ); }.bind(this),
  161. click : function(){ this.addCalendar() }.bind(this)
  162. }
  163. }).inject( this.titleContentNode );
  164. //var iconAreaNode = this.iconAreaNode = new Element("div",{
  165. // "styles" : this.css.titleIconAreaNode
  166. //}).inject(this.titleContentNode);
  167. //
  168. //var iconNode = this.iconNode = new Element("img",{
  169. // "styles" : this.css.titleIconNode,
  170. // "src" : "../x_component_Calendar/$Main/appicon.png"
  171. //}).inject(iconAreaNode);
  172. //
  173. //this.titleTextNode = new Element("div.titleTextNode", {
  174. // "styles": this.css.titleTextNode,
  175. // "text": this.lp.title
  176. //}).inject(this.titleContentNode);
  177. //this.titleDescriptionNode = new Element("div.titleDescriptionNode", {
  178. // "styles": this.css.titleDescriptionNode
  179. //}).inject(this.titleContentNode);
  180. },
  181. loadLeftNavi : function(){
  182. this.naviNode = new Element("div.naviNode", {
  183. "styles": this.css.naviNode
  184. }).inject(this.naviContainerNode);
  185. this.leftNavi = new MWF.xApplication.Calendar.Navi(this, this.naviNode, {});
  186. },
  187. loadTopMenus_middle : function(){
  188. },
  189. loadTopMenus_right: function(){
  190. this.topMenuRight = new Element("div", {"styles": this.css.topMenuRight }).inject(this.topMenu);
  191. this.createTopMenu_right(this.lp.addEvent, "icon_newapply", "addCalendarEvent");
  192. //this.createTopMenu_right("新建日历", "icon_newapply", "addCalendar");
  193. //var refreshNode = this.createTopMenu_right(this.lp.refresh, "refresh", "refresh");
  194. //refreshNode.setStyle("float", "right");
  195. var configNode = this.createTopMenu_right(this.lp.setting, "icon_shezhi", "config");
  196. configNode.setStyle("float", "right");
  197. },
  198. createTopMenu_right : function(text, icon, action){
  199. var actionNode = new Element("div", {"styles": this.css.topMenuNode_right, "title" : text}).inject(this.topMenuRight);
  200. var actionIconNode = new Element("div", {"styles": this.css.topMenuIconNode}).inject(actionNode);
  201. var actionTextNode = new Element("div",{styles: this.css.topMenuTextNode, "text":text}).inject(actionNode);
  202. actionIconNode.setStyle("background", "url(../x_component_Calendar/$Main/default/icon/"+icon+".png) no-repeat center center");
  203. actionNode.store("icon",icon);
  204. actionNode.store("iconNode",actionIconNode);
  205. var _self = this;
  206. actionNode.addEvents({
  207. "mouseover": function(){
  208. this.node.setStyles(_self.css.topMenuNode_over);
  209. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Calendar/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  210. }.bind( { node : actionNode } ),
  211. "mouseout": function(){
  212. this.node.setStyles(_self.css.topMenuNode_right);
  213. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Calendar/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" );
  214. }.bind({ node:actionNode }),
  215. "click": function(){
  216. this.node.setStyles(_self.css.topMenuNode_down);
  217. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Calendar/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  218. if (_self[action]) _self[action].apply(_self);
  219. }.bind({ node : actionNode })
  220. });
  221. return actionNode;
  222. },
  223. loadTopMenus: function(){
  224. //this.createTopMenu(this.lp.myCalendar, "icon_huiyi", "toMyCalendar");
  225. this.createTopMenu(this.lp.month, "icon_yue", "toMonth");
  226. this.createTopMenu(this.lp.week, "icon_zhou", "toWeek");
  227. this.createTopMenu(this.lp.day, "icon_ri", "toDay");
  228. this.createTopMenu(this.lp.list, "icon_liebiao", "toList");
  229. this.loadTopMenus_middle();
  230. this.loadTopMenus_right();
  231. },
  232. isViewAvailable : function( action ){
  233. return !this.calendarConfig.disableViewList.contains( action );
  234. },
  235. createTopMenu: function(text, icon, action){
  236. if( this.calendarConfig.disableViewList.contains( action ) )return;
  237. if( this.calendarConfig[ action + "ViewName" ] ){
  238. text = this.calendarConfig[ action + "ViewName" ];
  239. }
  240. var actionNode = new Element("div", {"styles": this.css.topMenuNode}).inject(this.topMenu);
  241. var actionIconNode = new Element("div", {"styles": this.css.topMenuIconNode}).inject(actionNode);
  242. actionIconNode.setStyle("background", "url(../x_component_Calendar/$Main/default/icon/"+icon+".png) no-repeat center center");
  243. var actionTextNode = new Element("div", {"styles": this.css.topMenuTextNode, "text": text}).inject(actionNode);
  244. actionNode.store("icon",icon);
  245. actionNode.store("iconNode",actionIconNode);
  246. actionNode.store("action",action);
  247. var _self = this;
  248. actionNode.addEvents({
  249. "mouseover": function(){
  250. if( this.node != _self.currentTopMenuNode ){
  251. this.node.setStyles(_self.css.topMenuNode_over);
  252. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Calendar/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  253. }
  254. }.bind( { node : actionNode } ),
  255. "mouseout": function(){
  256. if(this.node != _self.currentTopMenuNode){
  257. this.node.setStyles(_self.css.topMenuNode);
  258. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Calendar/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" );
  259. }
  260. }.bind({ node:actionNode }),
  261. //"mousedown": function(){this.setStyles(_self.css.topMenuNode_down);},
  262. //"mouseup": function(){this.setStyles(_self.css.topMenuNode_over);},
  263. "click": function(){
  264. if( this.node != _self.currentTopMenuNode ){
  265. this.node.setStyles( _self.css.topMenuNode_down );
  266. this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Calendar/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" );
  267. }
  268. if( _self.currentTopMenuNode && this.node != _self.currentTopMenuNode){
  269. _self.currentTopMenuNode.setStyles( _self.css.topMenuNode );
  270. _self.currentTopMenuNode.retrieve("iconNode").setStyle( "background","url(../x_component_Calendar/$Main/default/icon/"+_self.currentTopMenuNode.retrieve("icon")+".png) no-repeat center center" );
  271. }
  272. _self.currentTopMenuNode = this.node;
  273. if (_self[action]) _self[action].apply(_self);
  274. }.bind({ node : actionNode })
  275. });
  276. if( this.defaultAction ){
  277. if( this.defaultAction == action ){
  278. actionNode.click();
  279. }
  280. }else if( !this.loaded ){
  281. actionNode.click();
  282. this.loaded = true;
  283. }
  284. this.resizeNodes();
  285. return actionNode;
  286. },
  287. hideCurrentView: function(){
  288. if (this.currentView){
  289. this.currentView.hide();
  290. this.currentView = null;
  291. }
  292. },
  293. toList: function(){
  294. if(this.contentNode)this.contentNode.setStyle("background", "#EEE");
  295. if( this.currentView ){
  296. this.currentView.destroy();
  297. this.currentView = null;
  298. }
  299. this.listView = null;
  300. this.getListView(function(){
  301. this.listView.show();
  302. this.currentView = this.listView;
  303. if( this.options.eventId ){
  304. this.openEvent( this.options.eventId );
  305. this.options.eventId = "";
  306. }
  307. }.bind(this));
  308. },
  309. getListView: function(callback){
  310. if (!this.listView){
  311. MWF.xDesktop.requireApp("Calendar", "ListView", function(){
  312. var options;
  313. if( this.status && this.status.options ){
  314. options = this.status.options
  315. }else if( this.currentDate ){
  316. //options = { date : this.currentDate };
  317. }
  318. this.listView = new MWF.xApplication.Calendar.ListView(this.contentNode, this, options);
  319. if( options && this.status)this.status.options = null;
  320. if (callback) callback();
  321. }.bind(this));
  322. }else{
  323. if (callback) callback();
  324. }
  325. },
  326. toMonth: function(){
  327. if(this.contentNode)this.contentNode.setStyle("background", "#EEE");
  328. if( this.currentView ){
  329. this.currentView.destroy();
  330. this.currentView = null;
  331. }
  332. this.monthView = null;
  333. this.getMonthView(function(){
  334. this.monthView.show();
  335. this.currentView = this.monthView;
  336. debugger;
  337. if( this.options.eventId ){
  338. this.openEvent( this.options.eventId );
  339. this.options.eventId = "";
  340. }
  341. }.bind(this));
  342. },
  343. getMonthView: function(callback){
  344. if (!this.monthView){
  345. MWF.xDesktop.requireApp("Calendar", "MonthView", function(){
  346. var options;
  347. if( this.status && this.status.options ){
  348. options = this.status.options
  349. }else if( this.currentDate ){
  350. //options = { date : this.currentDate.format("%Y-%m-%d") };
  351. }
  352. this.monthView = new MWF.xApplication.Calendar.MonthView(this.contentNode, this, options);
  353. if( options && this.status)this.status.options = null;
  354. if (callback) callback();
  355. }.bind(this));
  356. }else{
  357. if (callback) callback();
  358. }
  359. },
  360. toWeek: function(){
  361. if(this.contentNode)this.contentNode.setStyle("background", "#EEE");
  362. if( this.currentView ){
  363. this.currentView.destroy();
  364. this.currentView = null;
  365. }
  366. this.weekView = null;
  367. this.getWeekView(function(){
  368. this.weekView.show();
  369. this.currentView = this.weekView;
  370. if( this.options.eventId ){
  371. this.openEvent( this.options.eventId );
  372. this.options.eventId = "";
  373. }
  374. }.bind(this));
  375. },
  376. getWeekView: function(callback){
  377. if (!this.weekView){
  378. MWF.xDesktop.requireApp("Calendar", "WeekView", function(){
  379. var options;
  380. if( this.status && this.status.options ){
  381. options = this.status.options
  382. }else if( this.currentDate ){
  383. //options = { date : this.currentDate.format("%Y-%m-%d") };
  384. }
  385. this.weekView = new MWF.xApplication.Calendar.WeekView(this.contentNode, this, options);
  386. if( options && this.status)this.status.options = null;
  387. if (callback) callback();
  388. }.bind(this));
  389. }else{
  390. if (callback) callback();
  391. }
  392. },
  393. toDay: function(d){
  394. if(this.contentNode)this.contentNode.setStyle("background", "#EEE");
  395. if( this.currentView ){
  396. this.currentView.destroy();
  397. this.currentView = null;
  398. }
  399. this.dayView = null;
  400. this.getDayView(function(){
  401. this.dayView.show();
  402. this.currentView = this.dayView;
  403. if( this.options.eventId ){
  404. this.openEvent( this.options.eventId );
  405. this.options.eventId = "";
  406. }
  407. }.bind(this), d);
  408. },
  409. getDayView: function(callback, d){
  410. if (!this.dayView){
  411. MWF.xDesktop.requireApp("Calendar", "DayView", function(){
  412. var options;
  413. if( this.status && this.status.options ){
  414. options = this.status.options
  415. }else if( d ){
  416. options = {"date": d};
  417. }else if( this.currentDate ){
  418. //options = { date : this.currentDate.format("%Y-%m-%d") };
  419. }
  420. this.dayView = new MWF.xApplication.Calendar.DayView(this.contentNode, this, options);
  421. if(this.status && this.status)this.status.options = null;
  422. if (callback) callback();
  423. }.bind(this));
  424. }else{
  425. this.dayView.toDay(d);
  426. if (callback) callback();
  427. }
  428. },
  429. addCalendarEvent: function(date, hour, minute, calendarId){
  430. MWF.UD.getPublicData("calendarConfig", function(json){
  431. var process = (json) ? json.process : null;
  432. if (process){
  433. this.loadCalendarProcess(process);
  434. }else{
  435. //new MWF.xApplication.Calendar.Creator(this, date, hour, room);
  436. var form = new MWF.xApplication.Calendar.EventForm(this,{}, {
  437. date : date,
  438. hour : hour,
  439. minute : minute,
  440. defaultCalendarId : calendarId
  441. }, {app:this});
  442. form.view = this;
  443. form.create();
  444. //this.hideMenu();
  445. }
  446. }.bind(this));
  447. },
  448. addCalendar: function(){
  449. var form = new MWF.xApplication.Calendar.CalendarForm(this,{}, {
  450. }, {app:this});
  451. form.view = this.leftNavi;
  452. form.create();
  453. },
  454. editCalendar: function( data ){
  455. var form = new MWF.xApplication.Calendar.CalendarForm(this,data, {
  456. }, {app:this});
  457. form.view = this.leftNavi;
  458. form.edit();
  459. },
  460. openCalendar: function( data ){
  461. var form = new MWF.xApplication.Calendar.CalendarForm(this,data, {
  462. }, {app:this});
  463. form.view = this.leftNavi;
  464. form.open();
  465. },
  466. loadCalendarProcess: function(id){
  467. this.getProcess(id, function(process){
  468. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  469. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(process, this, {
  470. "onStarted": function(data, title, processName){
  471. this.afterStartProcess(data, title, processName);
  472. }.bind(this)
  473. });
  474. starter.load();
  475. }.bind(this));
  476. }.bind(this));
  477. },
  478. afterStartProcess: function(data, title, processName){
  479. var workInfors = [];
  480. var currentTask = [];
  481. data.each(function(work){
  482. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  483. workInfors.push(this.getStartWorkInforObj(work));
  484. }.bind(this));
  485. if (currentTask.length===1){
  486. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  487. this.desktop.openApplication(null, "process.Work", options);
  488. this.createStartWorkResault(workInfors, title, processName, false);
  489. }else{
  490. this.createStartWorkResault(workInfors, title, processName, true);
  491. }
  492. },
  493. createStartWorkResault: function(workInfors, title, processName, isopen){
  494. var content = "";
  495. workInfors.each(function(infor){
  496. var users = [];
  497. infor.users.each(function(uname){
  498. users.push(MWF.name.cn(uname));
  499. });
  500. content += "<div><b>"+this.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  501. if (infor.currentTask && isopen){
  502. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.lp.deal+"</span></div>";
  503. }else{
  504. content += "</div>";
  505. }
  506. }.bind(this));
  507. var msg = {
  508. "subject": this.lp.processStarted,
  509. "content": "<div>"+this.lp.processStartedMessage+"“["+processName+"]"+title+"”</div>"+content
  510. };
  511. var tooltip = layout.desktop.message.addTooltip(msg);
  512. var item = layout.desktop.message.addMessage(msg);
  513. this.setStartWorkResaultAction(tooltip);
  514. this.setStartWorkResaultAction(item);
  515. },
  516. getStartWorkInforObj: function(work){
  517. var users = [];
  518. var currentTask = "";
  519. work.taskList.each(function(task, idx){
  520. users.push(task.person+"("+task.department + ")");
  521. if (work.currentTaskIndex===idx) currentTask = task.id;
  522. }.bind(this));
  523. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask};
  524. },
  525. setStartWorkResaultAction: function(item){
  526. var node = item.node.getElements("span");
  527. node.setStyles(this.app.css.dealStartedWorkAction);
  528. var _self = this;
  529. node.addEvent("click", function(e){
  530. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  531. _self.desktop.openApplication(e, "process.Work", options);
  532. });
  533. },
  534. getProcess: function(id, callback){
  535. // MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", function(){
  536. // var action = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  537. // action.getProcess(id, function(json){
  538. if (callback) callback(id);
  539. // }.bind(this));
  540. // }.bind(this));
  541. },
  542. config: function(){
  543. new MWF.xApplication.Calendar.Config(this, this.calendarConfig);
  544. //this.hideMenu();
  545. },
  546. recordStatus: function(){
  547. //alert( JSON.stringify(
  548. // {
  549. // action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyCalendar",
  550. // options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  551. // }
  552. //) )
  553. return {
  554. action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyCalendar",
  555. options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
  556. };
  557. },
  558. reloadView : function(){
  559. if( this.currentView ){
  560. this.currentView.reload();
  561. }
  562. },
  563. reload: function( ){
  564. this.refresh()
  565. },
  566. loadSideBar : function(){
  567. //this.sideBar = new MWF.xApplication.Calendar.SideBar(this.node, this);
  568. //this.sideBar.show();
  569. },
  570. resizeNodes : function(){
  571. this.showLeftNavi = true;
  572. if( this.inContainer ){
  573. var size = this.container.getSize();
  574. }else{
  575. var size = this.node.getSize();
  576. }
  577. this.naviContainerNode.setStyle("height", ""+size.y+"px");
  578. if( this.showLeftNavi ){
  579. this.rightContentNode.setStyle("width",size.x - MWFCalendar.LeftNaviWidth );
  580. //this.topMenu.setStyle("width",size.x - leftNaviSize.x);
  581. //this.contentNode.setStyle("width",size.x - leftNaviSize.x);
  582. }
  583. if( this.currentView ){
  584. this.currentView.resetNodeSize();
  585. }
  586. if( this.leftNavi )this.leftNavi.resizeNode();
  587. },
  588. openEvent : function (id) {
  589. debugger;
  590. this.actions.getEvent( id, function (json) {
  591. var form = new MWF.xApplication.Calendar.EventForm(this, json.data, {
  592. isFull : true
  593. }, {app:this});
  594. form.view = this.currentView;
  595. form.open();
  596. }.bind(this))
  597. }
  598. });
  599. MWF.xApplication.Calendar.Navi = new Class({
  600. Implements: [Options, Events],
  601. options : {
  602. },
  603. initialize: function(app, node, options){
  604. this.setOptions(options);
  605. this.app = app;
  606. this.node = $(node);
  607. this.css = this.app.css;
  608. this.load();
  609. },
  610. load : function(){
  611. this.naviContainer = new Element("div", {
  612. styles : {
  613. overflow : "hidden"
  614. }
  615. }).inject(this.node);
  616. this.naviNode = new Element("div").inject(this.naviContainer);
  617. this.myCalendarNaviItem = [];
  618. this.unitCalendarNaviItem = [];
  619. this.followCalendarNaviItem = [];
  620. this.app.listCalendar( function( data ){
  621. this.myCalendars = data.myCalendars;
  622. this.unitCalendars = data.unitCalendars;
  623. this.followCalendars = data.followCalendars;
  624. this.app.canlendarData = null;
  625. this.loadNode();
  626. }.bind(this));
  627. o2.require("MWF.widget.ScrollBar", function(){
  628. this.scrollBar = new MWF.widget.ScrollBar(this.naviContainer, {
  629. "indent": false,
  630. "style": "default",
  631. "where": "before",
  632. "distance": 60,
  633. "friction": 4,
  634. "axis": {"x": false, "y": true},
  635. "onScroll": function (y) {
  636. }.bind(this)
  637. });
  638. }.bind(this));
  639. },
  640. loadNode: function(){
  641. this.loadMyCalendar();
  642. this.loadUnitCalendar();
  643. this.loadFollowCalendar();
  644. this.loadMoreCalendarNode();
  645. //this.resizeNode();
  646. },
  647. reload : function(){
  648. this.node.empty();
  649. this.load();
  650. },
  651. loadMoreCalendarNode : function(){
  652. //this.newCalendarNode = new Element("div", {
  653. // styles : this.css.newCalendarNode,
  654. // text : "创建新日历",
  655. // events : {
  656. // mouseover : function( ev ){ ev.target.setStyles( this.css.newCalendarNode_over ); }.bind(this),
  657. // mouseout : function( ev ){ ev.target.setStyles( this.css.newCalendarNode ); }.bind(this),
  658. // click : function(){ this.app.addCalendar() }.bind(this)
  659. // }
  660. //}).inject( this.node );
  661. this.seeMore = new Element("div.seeMore", {
  662. styles : this.css.seeMoreNode,
  663. "text" : "日历广场",
  664. "events" : {
  665. mouseover : function(ev){ ev.target.setStyles( this.css.seeMoreNode_over ) }.bind(this),
  666. mouseout : function(ev){ ev.target.setStyles( this.css.seeMoreNode ) }.bind(this),
  667. click : function(ev){
  668. var form = new MWF.xApplication.Calendar.CalendarMarket(this.app,{}, {
  669. }, {app:this.app});
  670. form.view = this.leftNavi;
  671. form.create();
  672. }.bind(this)
  673. }
  674. }).inject( this.node );
  675. },
  676. selectSingleCalendar : function( id ){
  677. this.myCalendarNaviItem.each( function( item ){
  678. if( item.isSelected && item.data.id !== id ){
  679. item.cancelSelect()
  680. }
  681. if( !item.isSelected && item.data.id == id ){
  682. item.select()
  683. }
  684. });
  685. this.unitCalendarNaviItem.each( function( item ){
  686. if( item.isSelected && item.data.id !== id ){
  687. item.cancelSelect()
  688. }
  689. if( !item.isSelected && item.data.id == id ){
  690. item.select()
  691. }
  692. });
  693. this.followCalendarNaviItem.each( function( item ){
  694. if( item.isSelected && item.data.id !== id ){
  695. item.cancelSelect()
  696. }
  697. if( !item.isSelected && item.data.id == id ){
  698. item.select()
  699. }
  700. });
  701. this.app.reloadView();
  702. },
  703. getSelectedCalendarId : function(){
  704. var ids = [];
  705. this.myCalendarNaviItem.each( function( navi ){
  706. if( navi.isSelected )ids.push( navi.data.id );
  707. });
  708. this.unitCalendarNaviItem.each( function( navi ){
  709. if( navi.isSelected )ids.push( navi.data.id );
  710. });
  711. this.followCalendarNaviItem.each( function( navi ){
  712. if( navi.isSelected )ids.push( navi.data.id );
  713. });
  714. return ids;
  715. },
  716. loadMyCalendar : function(){
  717. var listNode = this.createCategoryNode("我的日历");
  718. this.myCalendars.each( function( d ){
  719. this.myCalendarNaviItem.push( new MWF.xApplication.Calendar.NaviItem( this, listNode, d, {
  720. isSelected : true
  721. } ) );
  722. }.bind(this))
  723. },
  724. loadUnitCalendar : function(){
  725. var listNode = this.createCategoryNode("组织日历");
  726. this.unitCalendars.each( function( d ){
  727. this.unitCalendarNaviItem.push( new MWF.xApplication.Calendar.NaviItem( this, listNode, d, {
  728. isSelected : true
  729. } ));
  730. }.bind(this))
  731. },
  732. loadFollowCalendar : function(){
  733. var listNode = this.createCategoryNode("关注的日历");
  734. this.followCalendars.each( function( d ){
  735. this.followCalendarNaviItem.push( new MWF.xApplication.Calendar.NaviItem( this, listNode, d, {
  736. isSelected : true
  737. } ));
  738. }.bind(this));
  739. //var seeMore = new Element("div", {
  740. // styles : this.css.seeMoreNode,
  741. // "text" : "查看日历广场",
  742. // "events" : {
  743. // mouseover : function(ev){ ev.target.setStyles( this.css.seeMoreNode_over ) }.bind(this),
  744. // mouseout : function(ev){ ev.target.setStyles( this.css.seeMoreNode ) }.bind(this),
  745. // click : function(ev){
  746. // var form = new MWF.xApplication.Calendar.CalendarMarket(this.app,{}, {
  747. // }, {app:this.app});
  748. // form.view = this.leftNavi;
  749. // form.create();
  750. // }.bind(this)
  751. // }
  752. //}).inject( this.naviNode );
  753. },
  754. createCategoryNode : function( text ){
  755. var _self = this;
  756. var categoryNaviNode = new Element("div.categoryNaviNode", {
  757. "styles": this.css.categoryNaviNode
  758. }).inject(this.naviNode);
  759. var expendNode = new Element("div.categoryExpendNode", {
  760. styles : this.css.categoryExpendNode
  761. }).inject(categoryNaviNode);
  762. categoryNaviNode.addEvent( "click" , function(ev){
  763. var target = this.categoryNaviNode;
  764. if( target.retrieve("isExpended") ){
  765. target.store("isExpended" , false);
  766. target.retrieve("expendNode").setStyles( _self.css.categoryCollapseNode );
  767. target.retrieve("listNode").setStyle("display","none")
  768. }else{
  769. target.store("isExpended" , true);
  770. target.retrieve("expendNode").setStyles( _self.css.categoryExpendNode );
  771. target.retrieve("listNode").setStyle("display","")
  772. }
  773. }.bind( { categoryNaviNode : categoryNaviNode } ));
  774. var textNode = new Element("div.categoryNaviTextNode",{
  775. "styles": this.css.categoryNaviTextNode,
  776. "text": text //this.defaultRevealData.id == "defaultList" ? this.data.name : this.defaultRevealData.showName
  777. }).inject( categoryNaviNode);
  778. var listNode = new Element("div.viewNaviListNode",{
  779. "styles" : this.css.viewNaviListNode
  780. }).inject(this.naviNode);
  781. categoryNaviNode.store("isExpended" , true);
  782. categoryNaviNode.store("expendNode" , expendNode);
  783. categoryNaviNode.store("textNode" , textNode);
  784. categoryNaviNode.store("listNode" , listNode);
  785. return listNode;
  786. },
  787. resizeNode : function(){
  788. if( this.app.inContainer ){
  789. var size = this.app.container.getSize();
  790. }else{
  791. var size = this.app.node.getSize();
  792. }
  793. //var titleSize = this.app.leftTitleNode ? this.app.leftTitleNode.getSize() : {x:0,y:0};
  794. this.node.setStyle("height",size.y - 80 );
  795. this.naviContainer.setStyle("height",size.y - 122 );
  796. }
  797. });
  798. MWF.xApplication.Calendar.NaviItem = new Class({
  799. Implements: [Options, Events],
  800. options: {
  801. "style": "default",
  802. "index" : 0,
  803. "isSelected" : true
  804. },
  805. initialize: function ( navi, container, data, options) {
  806. this.setOptions(options);
  807. this.navi = navi;
  808. this.app = navi.app;
  809. this.data = data;
  810. this.container = $(container);
  811. this.css = this.app.css;
  812. this.load();
  813. },
  814. load: function(){
  815. this.isSelected = this.options.isSelected;
  816. var _self = this;
  817. this.node = new Element("div.naviItemNode", {
  818. "styles": this.css.naviItemNode
  819. }).inject(this.container);
  820. this.node.addEvents({
  821. "mouseover": function(){
  822. this.setStyles(_self.css.naviItemNode_over);
  823. _self.actionNode.fade("in");
  824. },
  825. "mouseout": function(){
  826. this.setStyles( _self.css.naviItemNode );
  827. _self.actionNode.fade("out");
  828. },
  829. "click": function (el) {
  830. if( _self.isSelected ){
  831. _self.cancelSelect( true );
  832. }else{
  833. _self.select( true );
  834. }
  835. }
  836. });
  837. this.actionNode = new Element("div.naviItemActionNode",{
  838. styles : this.css.naviItemActionNode,
  839. events : {
  840. click : function( ev ){
  841. ev.stopPropagation();
  842. }.bind(this)
  843. }
  844. }).inject( this.node );
  845. this.colorNode = new Element("div", {
  846. styles : this.css.naviColorNode
  847. }).inject( this.node );
  848. this.colorNode.setStyle("border-color", this.data.color);
  849. this.textNode = new Element("div.naviItemTextNode", {
  850. styles : this.css.naviItemTextNode,
  851. "text" : this.data.name,
  852. "title" : this.data.name
  853. }).inject( this.node );
  854. if( this.isSelected ){
  855. this.select()
  856. }
  857. this.loadActionsMenu();
  858. },
  859. select : function( reload ){
  860. //this.node.setStyles( this.css.naviItemNode_selected );
  861. this.isSelected = true;
  862. this.colorNode.setStyle("background-color", this.data.color);
  863. this.colorNode.setStyles(this.css.naviColorNode_selected);
  864. if(reload)this.app.reloadView();
  865. //this.loadView();
  866. },
  867. cancelSelect : function(reload){
  868. this.isSelected = false;
  869. this.colorNode.setStyle("background-color", "transparent");
  870. this.colorNode.setStyles(this.css.naviColorNode);
  871. this.colorNode.setStyle("border-color", this.data.color);
  872. if(reload)this.app.reloadView();
  873. },
  874. loadActionsMenu : function(){
  875. this.menu = new MWF.xApplication.Calendar.CalendarMenu(this.actionNode, {} , this.app, {}, this.app.node);
  876. this.menu.calendarData = this.data;
  877. this.menu.load();
  878. }
  879. //loadView : function( searchKey ){
  880. // this.app.openView( this, this.category.data, this.data, searchKey || "", this );
  881. //}
  882. });
  883. MWF.xDesktop.requireApp("Template", "MSelector", null, false);
  884. MWF.xApplication.Calendar.CalendarMenu = new Class({
  885. Extends: MSelector,
  886. options : {
  887. "style": "arrow",
  888. "width": "150px",
  889. "height": "36px",
  890. "defaultOptionLp" : "字体",
  891. "textField" : "name",
  892. "valueField" : "val",
  893. "event" : "mouseenter",
  894. "isSetSelectedValue" : false,
  895. "isChangeOptionStyle" : false,
  896. "emptyOptionEnable" : false,
  897. "containerIsTarget" : true,
  898. "tooltipsOptions" : {
  899. axis : "x",
  900. hasArrow : true
  901. }
  902. },
  903. _selectItem : function( itemNode, itemData, ev ){
  904. if( this[itemData.val] ){
  905. this[itemData.val](ev);
  906. }
  907. },
  908. showThis : function(){
  909. this.app.leftNavi.selectSingleCalendar( this.calendarData.id );
  910. },
  911. createEvent : function(){
  912. this.app.addCalendarEvent(null,null,null, this.calendarData.id);
  913. },
  914. openCalendar : function(){
  915. this.app.actions.getCalendar( this.calendarData.id, function( json ){
  916. this.app.openCalendar( json.data );
  917. }.bind(this))
  918. },
  919. editCalendar : function(){
  920. this.app.actions.getCalendar( this.calendarData.id, function( json ){
  921. this.app.editCalendar( json.data );
  922. }.bind(this))
  923. },
  924. deleteCalendar : function( e ){
  925. var _self = this;
  926. _self.app.confirm("warn", e, "删除确认", "删除后无法恢复,确定要删除“"+ _self.calendarData.name +"”?", 300, 120, function(){
  927. _self.app.actions.deleteCalendar( _self.calendarData.id, function( json ){
  928. _self.app.notice("删除成功");
  929. _self.app.leftNavi.reload();
  930. }.bind(this));
  931. this.close();
  932. }, function(){
  933. this.close();
  934. }, null);
  935. },
  936. _loadData : function( callback ){
  937. var actionList = [{
  938. name: '只显示当前日历',
  939. val: 'showThis'
  940. }];
  941. if( this.calendarData.publishable || this.calendarData.manageable){
  942. actionList.push( {
  943. name: '新建日程',
  944. val: 'createEvent'
  945. });
  946. }
  947. if( this.calendarData.manageable ){
  948. actionList.push( {
  949. name: '编辑日历',
  950. val: 'editCalendar'
  951. }, {
  952. name: '删除日历',
  953. val: 'deleteCalendar'
  954. });
  955. }else{
  956. actionList.push( {
  957. name: '日历详情',
  958. val: 'openCalendar'
  959. });
  960. }
  961. if(callback)callback( actionList );
  962. },
  963. _postCreateItem: function( itemNode, data ){
  964. itemNode.setStyles( {
  965. "cursor" : "pointer",
  966. "font-size" : "14px",
  967. "min-height" : "36px",
  968. "line-height" : "36px"
  969. } );
  970. }
  971. });
  972. MWF.xApplication.Calendar.CalendarMarket = new Class({
  973. Extends: MPopupForm,
  974. Implements: [Options, Events],
  975. options: {
  976. "style": "meeting",
  977. "width": "1100",
  978. "height": "80%",
  979. "hasTop": true,
  980. "hasIcon": false,
  981. "hasBottom": false,
  982. "hasTopIcon" : false,
  983. "hasTopContent" : false,
  984. "draggable": true,
  985. "maxAction" : true,
  986. "closeAction": true,
  987. "title" : "日历广场"
  988. },
  989. _createTableContent : function(){
  990. var _self = this;
  991. this.formTableContainer.setStyles({
  992. "width" : "auto",
  993. "padding-top" : "20px",
  994. "padding-left" : "20px"
  995. });
  996. this.formTableArea.setStyle("overflow","hidden");
  997. this.app.actions.listPublicCalendar( function( json ){
  998. if( !json.data || json.data.length == 0 ){
  999. this.noCalendarNode = new Element("div",{
  1000. "styles" : this.css.noCalendarNode,
  1001. "text" : "系统内还没有公开日历!"
  1002. }).inject( this.formTableArea );
  1003. }else{
  1004. ( json.data || [] ).each( function(d){
  1005. var node = new Element("div", { styles : this.css.marketNode }).inject( this.formTableArea );
  1006. node.setStyle("border-left","5px solid "+ d.color);
  1007. var itemNode = new Element("div", { styles : this.css.marketItemNode }).inject( node );
  1008. var topNode = new Element("div", { styles : this.css.marketItemTopNode }).inject( itemNode );
  1009. var titleNode = new Element("div", {
  1010. styles : this.css.marketItemTitleNode,
  1011. text : d.name
  1012. }).inject( topNode );
  1013. titleNode.setStyle("color", d.color);
  1014. var middleNode = new Element("div", { styles : this.css.marketItemMiddleNode }).inject( itemNode );
  1015. new Element("div", {
  1016. styles : this.css.marketItemTopLable,
  1017. text : "创建:"
  1018. }).inject( middleNode );
  1019. new Element("div", {
  1020. styles : this.css.marketItemTopInfor,
  1021. text : d.createor.split("@")[0] + ","
  1022. }).inject( middleNode );
  1023. new Element("div", {
  1024. styles : this.css.marketItemTopLable,
  1025. text : "时间:"
  1026. }).inject( middleNode );
  1027. new Element("div", {
  1028. styles : this.css.marketItemTopInfor,
  1029. text : d.createTime.split(" ")[0]
  1030. }).inject( middleNode );
  1031. var middleNode = new Element("div", { styles : this.css.marketItemMiddleNode }).inject( itemNode );
  1032. new Element("div", {
  1033. styles : this.css.marketItemTopLable,
  1034. text : "类型:"
  1035. }).inject( middleNode );
  1036. new Element("div", {
  1037. styles : this.css.marketItemTopInfor,
  1038. text : d.type == "PERSON" ? "个人" : "组织,"
  1039. }).inject( middleNode );
  1040. if( d.type == "UNIT" ){
  1041. new Element("div", {
  1042. styles : this.css.marketItemTopLable,
  1043. text : "所属:"
  1044. }).inject( middleNode );
  1045. new Element("div", {
  1046. styles : this.css.marketItemTopInfor,
  1047. text : d.target.split("@")[0],
  1048. title : d.target.split("@")[0]
  1049. }).inject( middleNode );
  1050. }
  1051. var middleNode = new Element("div", { styles : this.css.marketItemMiddleNode }).inject( itemNode );
  1052. new Element("div", {
  1053. styles : this.css.marketItemTopLable,
  1054. text : "备注:"
  1055. }).inject( middleNode );
  1056. new Element("div", {
  1057. styles : this.css.marketItemDescriptiontInfor,
  1058. text : d.description || "",
  1059. title : d.description || ""
  1060. }).inject( middleNode );
  1061. var followedAction, followAction;
  1062. var followedAction = new Element("div",{
  1063. styles : this.css.marketItemFollowedAction,
  1064. text : "已关注",
  1065. title : "点击取消关注",
  1066. events : {
  1067. click : function(){
  1068. _self.app.actions.followCalendarCancel(d.id, function(){
  1069. _self.app.notice("取消关注成功");
  1070. _self.needReload = true;
  1071. this.followedAction.setStyle("display","none");
  1072. this.followAction.setStyle("display","");
  1073. }.bind({ followedAction : followedAction, followAction: followAction }))
  1074. }.bind(this)
  1075. }
  1076. }).inject(node);
  1077. if( !d.followed )followedAction.setStyle("display","none");
  1078. var followAction = new Element("div",{
  1079. styles : this.css.marketItemFollowAction,
  1080. text : "关注",
  1081. events : {
  1082. click: function () {
  1083. _self.app.actions.followCalendar(d.id, function () {
  1084. _self.app.notice("关注成功");
  1085. _self.needReload = true;
  1086. this.followedAction.setStyle("display","");
  1087. this.followAction.setStyle("display","none");
  1088. }.bind({ followedAction : followedAction, followAction: followAction }))
  1089. }.bind(this)
  1090. }
  1091. }).inject(node);
  1092. if( d.followed )followAction.setStyle("display","none");
  1093. //var typeNode = new Element("div", {
  1094. // styles : this.css.marketTypleLabel,
  1095. // text : d.type == "PERSON" ? "个人日历" : "组织日历"
  1096. //}).inject( topNode );
  1097. //typeNode.setStyle( "background-color" , MWFCalendar.ColorOptions.getLightColor(d.color ) );
  1098. }.bind(this))
  1099. }
  1100. }.bind(this))
  1101. },
  1102. _close : function(){
  1103. if( this.needReload )this.app.reload();
  1104. }
  1105. });
  1106. MWF.xApplication.Calendar.Config = new Class({
  1107. Implements: [Events],
  1108. initialize: function(app){
  1109. this.app = app;
  1110. this.css = this.app.css;
  1111. this.lp = this.app.lp;
  1112. this.configData = this.app.calendarConfig || {};
  1113. this.process = null;
  1114. MWF.UD.getPublicData("calendarConfig", function(json){
  1115. var jsonData = json || {};
  1116. //if (jsonData.process){
  1117. // this.configData.process = jsonData.process;
  1118. //}else{
  1119. // this.configData.process = null;
  1120. //}
  1121. if( jsonData.weekBegin ){
  1122. this.configData.weekBegin = jsonData.weekBegin;
  1123. }
  1124. //if( jsonData.mobileCreateEnable ){
  1125. // this.configData.mobileCreateEnable = jsonData.mobileCreateEnable;
  1126. //}
  1127. for( var key in jsonData ){
  1128. if( key != "process" && key != "weekBegin" && key !="mobileCreateEnable"){
  1129. this.configData[ key ] = jsonData[key];
  1130. }
  1131. }
  1132. this.load();
  1133. }.bind(this));
  1134. },
  1135. load: function(){
  1136. this.node = new Element("div", {"styles": this.css.configNode}).inject(this.app.node);
  1137. this.contentNode = new Element("div", {"styles": this.css.configContentNode}).inject(this.node);
  1138. var statusStyle = "overflow: hidden;margin-top:6px;margin-left:10px;";
  1139. var statusIconStyle = "float: left; width: 16px; height: 16px; border-radius: 100px; ";
  1140. var statusIconStyle2 = "float: left; width: 14px; height: 14px; border-radius: 100px; ";
  1141. var statusTextStyle = "margin-left:35px; line-height:16px; height:16px;font-size:14px;color:#666;";
  1142. var viewStyle = "font-size:14px;color:#666;heigh:16px;margin-top:6px;margin-left:10px;";
  1143. var inputTextStyle = "float:right; width:120px; border:1px solid #ccc";
  1144. var d = this.configData;
  1145. var configLp = this.lp.config;
  1146. var html =
  1147. //"<div class='configTitle'>"+this.lp.config.calendarStatus+"</div>" +
  1148. //
  1149. //"<div style='"+ statusStyle +"'>"+
  1150. //" <div style='"+ statusIconStyle + "background-color:#4990E2'></div>" +
  1151. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.wait+"</div></div>" +
  1152. //"</div>"+
  1153. //
  1154. //"<div style='"+ statusStyle +"'>"+
  1155. //" <div style='"+ statusIconStyle + "background-color:#66CC7F'></div>" +
  1156. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.progress+"</div></div>" +
  1157. //"</div>"+
  1158. //
  1159. //"<div style='"+ statusStyle +"'>"+
  1160. //" <div style='"+ statusIconStyle + "background-color:#F6A623'></div>" +
  1161. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.invite+"</div></div>" +
  1162. //"</div>"+
  1163. //
  1164. //"<div style='"+ statusStyle +"'>"+
  1165. //" <div style='"+ statusIconStyle + "background-color:#ccc'></div>" +
  1166. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.completed+"</div></div>" +
  1167. //"</div>"+
  1168. //
  1169. //"<div style='"+ statusStyle +"'>"+
  1170. //" <div style='"+ statusIconStyle2 + "border:2px solid #FF7F7F;'></div>" +
  1171. //" <div style='"+ statusTextStyle +"'>"+this.lp.config.conflict+"</div></div>" +
  1172. //"</div>"+
  1173. //
  1174. //"<div class='line'></div>" +
  1175. "<div class='configTitle'>"+this.lp.config["default"]+"</div>" +
  1176. "<div>";
  1177. if( !d.disableViewList.contains( "toMonth" ) ){
  1178. html +=
  1179. " <div style='"+ viewStyle +"'>" +
  1180. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toMonth") ? "checked" : "")+" value='toMonth'>"+ ( d.toMonthViewName || this.lp.month )+
  1181. " </div>";
  1182. }
  1183. if( !d.disableViewList.contains( "toWeek" ) ){
  1184. html +=
  1185. " <div style='"+ viewStyle +"'>" +
  1186. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toWeek") ? "checked" : "")+" value='toWeek'>"+( d.toWeekViewName || this.lp.week )+
  1187. " </div>";
  1188. }
  1189. if( !d.disableViewList.contains( "toDay" ) ){
  1190. html +=
  1191. " <div style='"+ viewStyle +"'>" +
  1192. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toDay") ? "checked" : "")+" value='toDay'>"+(d.toDayViewName || this.lp.day)+
  1193. " </div>";
  1194. }
  1195. if( !d.disableViewList.contains( "toList" ) ){
  1196. html +=
  1197. " <div style='"+ viewStyle +"'>" +
  1198. "<input type='radio' name='configSelectDefaultView' "+((d.defaultView=="toList") ? "checked" : "")+" value='toList'>"+(d.toListViewName || this.lp.list)+
  1199. " </div>";
  1200. }
  1201. html +="</div>";
  1202. if( MWF.AC.isAdministrator() ){
  1203. d.disableViewList = d.disableViewList || [];
  1204. html += "<div class='line'></div>"+
  1205. "<div class='configTitle'>"+this.lp.config.viewSetting +"</div>" +
  1206. "<div>"+
  1207. " <div style='"+ viewStyle +"'>" +
  1208. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toMonth" ) ? "checked" : "")+" value='toMonth'>"+this.lp.month+
  1209. "<input type='text' name='toMonthViewName' value='" + (d.toMonthViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  1210. " </div>" +
  1211. " <div style='"+ viewStyle +"'>" +
  1212. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toWeek" ) ? "checked" : "")+" value='toWeek'>"+this.lp.week+
  1213. "<input type='text' name='toWeekViewName' value='" + (d.toWeekViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  1214. " </div>" +
  1215. " <div style='"+ viewStyle +"'>" +
  1216. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toDay" ) ? "checked" : "")+" value='toDay'>"+this.lp.day+
  1217. "<input type='text' name='toDayViewName' value='" + (d.toDayViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  1218. " </div>" +
  1219. " <div style='"+ viewStyle +"'>" +
  1220. "<input type='checkbox' name='configAvailableView' "+( !d.disableViewList.contains( "toList" ) ? "checked" : "")+" value='toList'>"+this.lp.list+
  1221. "<input type='text' name='toListViewName' value='" + (d.toListViewName || "") + "' style='"+ inputTextStyle +"' placeholder='"+ this.lp.config.viewCustomName +"' >"+
  1222. " </div>" +
  1223. "</div>" +
  1224. "<div class='line'></div>"+
  1225. "<div class='configTitle'>"+this.lp.config.weekBegin +"</div>" +
  1226. "<div><select name='configSelectWeekBeign'>"+
  1227. "<option value='0' "+((d.weekBegin=="0") ? "selected" : "")+">"+this.lp.weeks.Sun+"</option>"+
  1228. "<option value='1' "+((d.weekBegin=="1") ? "selected" : "")+">"+this.lp.weeks.Mon+"</option>"+
  1229. //"<option value='2'"+((d.weekBegin=="2") ? "selected" : "")+">"+this.lp.weeks.Tues+"</option>"+
  1230. //"<option value='3'"+((d.weekBegin=="3") ? "selected" : "")+">"+this.lp.weeks.Wed+"</option>"+
  1231. //"<option value='4'"+((d.weekBegin=="4") ? "selected" : "")+">"+this.lp.weeks.Thur+"</option>"+
  1232. //"<option value='5'"+((d.weekBegin=="5") ? "selected" : "")+">"+this.lp.weeks.Fri+"</option>"+
  1233. //"<option value='6'"+((d.weekBegin=="6") ? "selected" : "")+">"+this.lp.weeks.Sat+"</option>"+
  1234. "</select></div>"; //+
  1235. //"<div class='line'></div>"+
  1236. //"<div class='configTitle'>"+this.lp.config.applyProcess+"</div>" +
  1237. //"<div item='processArea'></div>" +
  1238. //
  1239. //
  1240. //"<div class='configTitle'>"+this.lp.config.mobileCreateEnable +"</div>" +
  1241. //"<div item='mobileCreateEnable'></div>";
  1242. }
  1243. this.contentNode.set("html", html);
  1244. this.contentNode.getElements("div.line").setStyles(this.css.configContentLine);
  1245. this.contentNode.getElements("div.configTitle").setStyles(this.css.configTitleDiv);
  1246. if( MWF.AC.isAdministrator() ){
  1247. //this.processNode = this.contentNode.getElement("[item='processArea']");
  1248. //this.processNode.setStyles(this.css.configProcessNode);
  1249. //this.createApplicationSelect();
  1250. //
  1251. //this.mobileCreateEnableNode = this.contentNode.getElement("[item='mobileCreateEnable']");
  1252. //this.mobileCreateEnable = new MDomItem(this.mobileCreateEnableNode, {
  1253. // name : "mobileCreateEnable", type : "select", selectValue : ["true","false"], selectText : this.lp.config.mobileCreateEnableOptions,
  1254. // value : d.mobileCreateEnable || "true"
  1255. //} , null, this.app );
  1256. //this.mobileCreateEnable.load();
  1257. }
  1258. this.actionNode = new Element("div", {"styles": this.css.configActionNode}).inject(this.node);
  1259. this.cancelNode = new Element("div", {"styles": this.css.configActionCancelNode, "text": this.app.lp.cancel}).inject(this.actionNode);
  1260. this.saveNode = new Element("div", {"styles": this.css.configActionSaveNode, "text": this.app.lp.save}).inject(this.actionNode);
  1261. this.cancelNode.addEvent("click", this.hide.bind(this));
  1262. this.saveNode.addEvent("click", this.save.bind(this));
  1263. this.node.addEvent("mousedown", function(e){e.stopPropagation();}.bind(this));
  1264. this.setSize();
  1265. this.show();
  1266. },
  1267. setSize : function(){
  1268. var sizeY = this.node.getSize().y;
  1269. if( this.app.inContainer ){
  1270. var y = this.app.container.getSize().y;
  1271. }else{
  1272. var y = this.app.content.getSize().y;
  1273. }
  1274. if( sizeY > y-50 ){
  1275. this.node.setStyle("height", y-50 );
  1276. }
  1277. },
  1278. createApplicationSelect: function(){
  1279. if (this.configData.process){
  1280. MWF.require("MWF.widget.O2Identity", function(){
  1281. var p = new MWF.widget.O2Process(this.configData.process, this.processNode);
  1282. }.bind(this));
  1283. }
  1284. this.processNode.addEvent("click", function(){
  1285. MWF.xDesktop.requireApp("Selector", "package", function(){
  1286. var options = {
  1287. "type": "Process",
  1288. "values": [this.process || this.configData.process],
  1289. "count": 1,
  1290. "onComplete": function (items) {
  1291. this.processNode.empty();
  1292. this.process = null;
  1293. this.configData.process = null;
  1294. if (items.length){
  1295. MWF.require("MWF.widget.O2Identity", function(){
  1296. var p = new MWF.widget.O2Process(items[0].data, this.processNode);
  1297. this.process = {
  1298. "name": items[0].data.name,
  1299. "id": items[0].data.id,
  1300. "application": items[0].data.application,
  1301. "applicationName": items[0].data.applicationName,
  1302. "alias": items[0].data.alias
  1303. };
  1304. this.configData.process = this.process;
  1305. }.bind(this));
  1306. }
  1307. }.bind(this)
  1308. };
  1309. var selector = new MWF.O2Selector(this.app.content, options);
  1310. }.bind(this));
  1311. }.bind(this));
  1312. },
  1313. save: function(){
  1314. //var hideMenu = "auto";
  1315. var defaultView = "toMyCalendar";
  1316. var process = null;
  1317. //var node = this.contentNode.getFirst("div");
  1318. //var hideMenuNode = node.getElement("input");
  1319. //if (hideMenuNode) if (!hideMenuNode.checked) hideMenu = "static";
  1320. //node = node.getNext();
  1321. var viewNodes = this.contentNode.getElements("input[name='configSelectDefaultView']");
  1322. for (var i=0; i<viewNodes.length; i++){
  1323. if (viewNodes[i].checked){
  1324. defaultView = viewNodes[i].get("value");
  1325. break;
  1326. }
  1327. }
  1328. MWF.UD.putData("calendarConfig", {
  1329. //"hideMenu": hideMenu,
  1330. "defaultView": defaultView
  1331. }, null, false);
  1332. if( MWF.AC.isAdministrator() ){
  1333. //if (this.processSelect){
  1334. //process = this.processSelect.options[this.processSelect.selectedIndex].get("value");
  1335. //MWF.UD.putPublicData("calendarConfig", {"process": process});
  1336. //}
  1337. var disableViewList = [];
  1338. var viewAvailableNodes = this.contentNode.getElements("input[name='configAvailableView']");
  1339. for (var i=0; i<viewAvailableNodes.length; i++){
  1340. if ( !viewAvailableNodes[i].checked){
  1341. disableViewList.push( viewAvailableNodes[i].get("value") ) ;
  1342. }
  1343. }
  1344. var weekBeginSelect = this.contentNode.getElement("select[name='configSelectWeekBeign']");
  1345. var weekBeginValue = "0";
  1346. if( weekBeginSelect ){
  1347. weekBeginValue = weekBeginSelect.options[weekBeginSelect.selectedIndex].get("value");
  1348. }
  1349. MWF.UD.putPublicData("calendarConfig", {
  1350. //"process": this.process || this.configData.process,
  1351. "weekBegin" : weekBeginValue,
  1352. //"mobileCreateEnable" : this.mobileCreateEnable.getValue(),
  1353. "disableViewList" : disableViewList,
  1354. "toMonthViewName" : this.contentNode.getElement("input[name='toMonthViewName']").get("value"),
  1355. "toWeekViewName" : this.contentNode.getElement("input[name='toWeekViewName']").get("value"),
  1356. "toDayViewName" : this.contentNode.getElement("input[name='toDayViewName']").get("value"),
  1357. "toListViewName" : this.contentNode.getElement("input[name='toListViewName']").get("value")
  1358. }, null, false);
  1359. }
  1360. this.app.notice( this.app.lp.config_saveSuccess, "success" );
  1361. this.hide();
  1362. },
  1363. show: function(){
  1364. this.node.setStyles(this.css.configNode);
  1365. var fx = new Fx.Morph(this.node, {
  1366. "duration": "500",
  1367. "transition": Fx.Transitions.Expo.easeOut
  1368. });
  1369. fx.start({
  1370. "opacity": 1
  1371. }).chain(function(){
  1372. this.hideFun = this.hide.bind(this);
  1373. this.app.node.addEvent("mousedown", this.hideFun);
  1374. }.bind(this));
  1375. },
  1376. hide: function(){
  1377. this.node.destroy();
  1378. this.app.node.removeEvent("mousedown", this.hideFun);
  1379. MWF.release(this);
  1380. }
  1381. });