Main.js 60 KB

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