Main.js 60 KB

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