Main.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. MWF.xApplication.Attendance = MWF.xApplication.Attendance || {};
  2. MWF.require("MWF.widget.O2Identity", null, false);
  3. //MWF.xDesktop.requireApp("Attendance", "Actions.RestActions", null, false);
  4. MWF.xDesktop.requireApp("Attendance", "Common", null, false);
  5. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  6. MWF.xDesktop.requireApp("Template", "MDomItem", null, false);
  7. MWF.xApplication.Attendance.options = {
  8. multitask: false,
  9. executable: true
  10. };
  11. MWF.xApplication.Attendance.Main = new Class({
  12. Extends: MWF.xApplication.Common.Main,
  13. Implements: [Options, Events],
  14. options: {
  15. "curNaviId": null,
  16. "style": "default",
  17. "name": "Attendance",
  18. "icon": "icon.png",
  19. "width": "1400",
  20. "height": "700",
  21. "isResize": true,
  22. "isMax": true,
  23. "title": MWF.xApplication.Attendance.LP.title
  24. },
  25. onQueryLoad: function () {
  26. this.lp = MWF.xApplication.Attendance.LP;
  27. },
  28. loadApplication: function (callback) {
  29. if (!this.options.isRefresh) {
  30. this.maxSize(function () {
  31. this.loadLayout();
  32. }.bind(this));
  33. } else {
  34. this.loadLayout();
  35. }
  36. },
  37. loadLayout: function () {
  38. this.manageUnits = [];
  39. this.manageTopUnits = [];
  40. this.enableType = "";
  41. this.restActions = MWF.Actions.get("x_attendance_assemble_control");
  42. this.personActions = MWF.Actions.get("x_organization_assemble_personal");
  43. this.orgActions = MWF.Actions.get("x_organization_assemble_express");
  44. this.content.loadCss("../x_component_Attendance/$Main/default/style.css");
  45. this.createNode();
  46. this.loadApplicationContent();
  47. },
  48. isAdmin: function () {
  49. return this.isTopUnitManager() || MWF.AC.isAttendanceManager() || MWF.AC.isAdministrator()
  50. },
  51. isUnitManager: function () {
  52. return this.manageUnits.length > 0;
  53. },
  54. isTopUnitManager: function () {
  55. return this.manageTopUnits.length > 0;
  56. },
  57. getNameFlag: function (name) {
  58. var t = typeOf(name);
  59. if (t === "array") {
  60. var v = [];
  61. name.each(function (id) {
  62. v.push((typeOf(id) === "object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
  63. });
  64. return v;
  65. } else {
  66. return [(t === "object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
  67. }
  68. },
  69. loadController: function (callback) {
  70. this.restActions.listPermission(function (json) {
  71. json.data = json.data || [];
  72. json.data.each(function (item) {
  73. if (item.adminLevel == "COMPANY" && item.adminName == layout.desktop.session.user.distinguishedName) {
  74. this.manageTopUnits.push(item.unitName)
  75. } else if (item.adminLevel == "DEPT" && item.adminName == layout.desktop.session.user.distinguishedName) {
  76. this.manageUnits.push(item.unitName)
  77. }
  78. }.bind(this));
  79. if (callback) callback(json);
  80. }.bind(this));
  81. },
  82. loadEnableType: function (callback) {
  83. var action = o2.Actions.load("x_attendance_assemble_control");
  84. action.AttendanceSettingAction.enableType(//平台封装好的方法
  85. function (json) { //服务调用成功的回调函数, json为服务传回的数据
  86. if (json.data && json.data.value) {
  87. debugger;
  88. this.enableType = json.data.value;
  89. }
  90. if (callback) callback(json);
  91. }.bind(this));
  92. },
  93. createNode: function () {
  94. this.content.setStyle("overflow", "hidden");
  95. this.node = new Element("div", {
  96. "styles": { "width": "100%", "height": "100%", "overflow": "hidden" }
  97. }).inject(this.content);
  98. },
  99. loadApplicationContent: function () {
  100. this.loadController(function () {
  101. this.loadEnableType(function () {
  102. this.loaNavi();
  103. }.bind(this));
  104. }.bind(this));
  105. //this.loadApplicationLayout();
  106. },
  107. loaNavi: function (callback) {
  108. this.naviNode = new Element("div.naviNode", {
  109. "styles": this.css.naviNode
  110. }).inject(this.node);
  111. var curNavi = { "id": "" };
  112. if (this.status) {
  113. curNavi.id = this.status.id
  114. }
  115. if (this.options.curNaviId) {
  116. curNavi.id = this.options.curNaviId;
  117. }
  118. this.navi = new MWF.xApplication.Attendance.Navi(this, this.naviNode, curNavi);
  119. },
  120. clearContent: function () {
  121. if (this.explorerContent) {
  122. if (this.explorer && this.explorer.destroy) {
  123. this.explorer.destroy();
  124. }
  125. this.explorerContent.destroy();
  126. this.explorerContent = null;
  127. }
  128. },
  129. openMyIndex: function () {
  130. MWF.xDesktop.requireApp("Attendance", "MyIndex", function () {
  131. this.clearContent();
  132. this.explorerContent = new Element("div", {
  133. "styles": this.css.rightContentNode
  134. }).inject(this.node);
  135. this.explorer = new MWF.xApplication.Attendance.MyIndex(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  136. this.explorer.load();
  137. }.bind(this));
  138. },
  139. openMyDetail: function () {
  140. MWF.xDesktop.requireApp("Attendance", "MyDetail", function () {
  141. this.clearContent();
  142. this.explorerContent = new Element("div", {
  143. "styles": this.css.rightContentNode
  144. }).inject(this.node);
  145. this.explorer = new MWF.xApplication.Attendance.MyDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  146. this.explorer.load();
  147. }.bind(this));
  148. },
  149. openUnitIndex: function () {
  150. MWF.xDesktop.requireApp("Attendance", "UnitIndex", function () {
  151. this.clearContent();
  152. this.explorerContent = new Element("div", {
  153. "styles": this.css.rightContentNode
  154. }).inject(this.node);
  155. this.explorer = new MWF.xApplication.Attendance.UnitIndex(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  156. this.explorer.load();
  157. }.bind(this));
  158. },
  159. openUnitDingdingIndex: function () {
  160. MWF.xDesktop.requireApp("Attendance", "UnitDingdingIndex", function () {
  161. this.clearContent();
  162. this.explorerContent = new Element("div", {
  163. "styles": this.css.rightContentNode
  164. }).inject(this.node);
  165. this.explorer = new MWF.xApplication.Attendance.UnitDingdingIndex(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  166. this.explorer.load();
  167. }.bind(this));
  168. },
  169. openUnitQywxIndex: function () {
  170. MWF.xDesktop.requireApp("Attendance", "UnitQywxIndex", function () {
  171. this.clearContent();
  172. this.explorerContent = new Element("div", {
  173. "styles": this.css.rightContentNode
  174. }).inject(this.node);
  175. this.explorer = new MWF.xApplication.Attendance.UnitQywxIndex(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  176. this.explorer.load();
  177. }.bind(this));
  178. },
  179. openUnitDetail: function () {
  180. MWF.xDesktop.requireApp("Attendance", "UnitDetail", function () {
  181. this.clearContent();
  182. this.explorerContent = new Element("div", {
  183. "styles": this.css.rightContentNode
  184. }).inject(this.node);
  185. this.explorer = new MWF.xApplication.Attendance.UnitDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  186. this.explorer.load();
  187. }.bind(this));
  188. },
  189. openDingdingUnitDetail: function () {
  190. MWF.xDesktop.requireApp("Attendance", "UnitDingdingDetail", function () {
  191. this.clearContent();
  192. this.explorerContent = new Element("div", {
  193. "styles": this.css.rightContentNode
  194. }).inject(this.node);
  195. this.explorer = new MWF.xApplication.Attendance.UnitDingdingDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  196. this.explorer.load();
  197. }.bind(this));
  198. },
  199. openQywxUnitDetail: function () {
  200. MWF.xDesktop.requireApp("Attendance", "UnitQywxDetail", function () {
  201. this.clearContent();
  202. this.explorerContent = new Element("div", {
  203. "styles": this.css.rightContentNode
  204. }).inject(this.node);
  205. this.explorer = new MWF.xApplication.Attendance.UnitQywxDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  206. this.explorer.load();
  207. }.bind(this));
  208. },
  209. openPeopleDetail: function () {
  210. MWF.xDesktop.requireApp("Attendance", "PeopleDetail", function () {
  211. this.clearContent();
  212. this.explorerContent = new Element("div", {
  213. "styles": this.css.rightContentNode
  214. }).inject(this.node);
  215. this.explorer = new MWF.xApplication.Attendance.PeopleDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  216. this.explorer.load();
  217. }.bind(this));
  218. },
  219. openDingdingPeopleDetail: function () {
  220. MWF.xDesktop.requireApp("Attendance", "PeopleDingdingDetail", function () {
  221. this.clearContent();
  222. this.explorerContent = new Element("div", {
  223. "styles": this.css.rightContentNode
  224. }).inject(this.node);
  225. this.explorer = new MWF.xApplication.Attendance.PeopleDingdingDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  226. this.explorer.load();
  227. }.bind(this));
  228. },
  229. openQywxPeopleDetail: function () {
  230. MWF.xDesktop.requireApp("Attendance", "PeopleQywxDetail", function () {
  231. this.clearContent();
  232. this.explorerContent = new Element("div", {
  233. "styles": this.css.rightContentNode
  234. }).inject(this.node);
  235. this.explorer = new MWF.xApplication.Attendance.PeopleQywxDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  236. this.explorer.load();
  237. }.bind(this));
  238. },
  239. openTopUnitDetail: function () {
  240. MWF.xDesktop.requireApp("Attendance", "TopUnitDetail", function () {
  241. this.clearContent();
  242. this.explorerContent = new Element("div", {
  243. "styles": this.css.rightContentNode
  244. }).inject(this.node);
  245. this.explorer = new MWF.xApplication.Attendance.TopUnitDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  246. this.explorer.load();
  247. }.bind(this));
  248. },
  249. openSelfHoliday: function () {
  250. MWF.xDesktop.requireApp("Attendance", "SelfHoliday", function () {
  251. this.clearContent();
  252. this.explorerContent = new Element("div", {
  253. "styles": this.css.rightContentNode
  254. }).inject(this.node);
  255. this.explorer = new MWF.xApplication.Attendance.SelfHoliday(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  256. this.explorer.load();
  257. }.bind(this));
  258. },
  259. openMyAppealDeal: function () {
  260. MWF.xDesktop.requireApp("Attendance", "MyAppeal", function () {
  261. this.clearContent();
  262. this.explorerContent = new Element("div", {
  263. "styles": this.css.rightContentNode
  264. }).inject(this.node);
  265. this.explorer = new MWF.xApplication.Attendance.MyAppeal(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  266. this.explorer.load();
  267. }.bind(this));
  268. },
  269. openAppealDeal: function () {
  270. MWF.xDesktop.requireApp("Attendance", "AppealExplorer", function () {
  271. this.clearContent();
  272. this.explorerContent = new Element("div", {
  273. "styles": this.css.rightContentNode
  274. }).inject(this.node);
  275. this.explorer = new MWF.xApplication.Attendance.AppealExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  276. this.explorer.load();
  277. }.bind(this));
  278. },
  279. openImporting: function () {
  280. MWF.xDesktop.requireApp("Attendance", "ImportExplorer", function () {
  281. this.clearContent();
  282. this.explorerContent = new Element("div", {
  283. "styles": this.css.rightContentNode
  284. }).inject(this.node);
  285. this.explorer = new MWF.xApplication.Attendance.ImportExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  286. this.explorer.load();
  287. }.bind(this));
  288. },
  289. openImportedInvalidInfor: function () {
  290. MWF.xDesktop.requireApp("Attendance", "InvalidInfor", function () {
  291. this.clearContent();
  292. this.explorerContent = new Element("div", {
  293. "styles": this.css.rightContentNode
  294. }).inject(this.node);
  295. this.explorer = new MWF.xApplication.Attendance.InvalidInfor(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  296. this.explorer.load();
  297. }.bind(this));
  298. },
  299. openAbnormalExport: function () {
  300. MWF.xDesktop.requireApp("Attendance", "AbnormalExport", function () {
  301. this.clearContent();
  302. this.explorerContent = new Element("div", {
  303. "styles": this.css.rightContentNode
  304. }).inject(this.node);
  305. this.explorer = new MWF.xApplication.Attendance.AbnormalExport(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  306. this.explorer.load();
  307. }.bind(this));
  308. },
  309. openScheduleSetting: function () {
  310. MWF.xDesktop.requireApp("Attendance", "ScheduleExplorer", function () {
  311. this.clearContent();
  312. this.explorerContent = new Element("div", {
  313. "styles": this.css.rightContentNode
  314. }).inject(this.node);
  315. this.explorer = new MWF.xApplication.Attendance.ScheduleExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  316. this.explorer.load();
  317. }.bind(this));
  318. },
  319. openPermissionSetting: function () {
  320. MWF.xDesktop.requireApp("Attendance", "PermissionExplorer", function () {
  321. this.clearContent();
  322. this.explorerContent = new Element("div", {
  323. "styles": this.css.rightContentNode
  324. }).inject(this.node);
  325. this.explorer = new MWF.xApplication.Attendance.PermissionExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  326. this.explorer.load();
  327. }.bind(this));
  328. },
  329. openHolidaySetting: function () {
  330. MWF.xDesktop.requireApp("Attendance", "HolidayExplorer", function () {
  331. this.clearContent();
  332. this.explorerContent = new Element("div", {
  333. "styles": this.css.rightContentNode
  334. }).inject(this.node);
  335. this.explorer = new MWF.xApplication.Attendance.HolidayExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  336. this.explorer.load();
  337. }.bind(this));
  338. },
  339. openStaticsCycleExplorer: function () {
  340. MWF.xDesktop.requireApp("Attendance", "StatisticsCycle", function () {
  341. this.clearContent();
  342. this.explorerContent = new Element("div", {
  343. "styles": this.css.rightContentNode
  344. }).inject(this.node);
  345. this.explorer = new MWF.xApplication.Attendance.StatisticsCycle(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  346. this.explorer.load();
  347. }.bind(this));
  348. },
  349. openAppSetting: function () {
  350. MWF.xDesktop.requireApp("Attendance", "AppSetting", function () {
  351. var setting = new MWF.xApplication.Attendance.AppSetting({app: this});
  352. setting.edit();
  353. }.bind(this));
  354. },
  355. openWeekendSetting : function(){
  356. MWF.xDesktop.requireApp("Attendance", "WeekendSetting", function(){
  357. var setting = new MWF.xApplication.Attendance.WeekendSetting({app: this});
  358. setting.edit();
  359. }.bind(this));
  360. },
  361. openAddressSetting: function () {
  362. MWF.xDesktop.requireApp("Attendance", "AddressExplorer", function () {
  363. this.clearContent();
  364. this.explorerContent = new Element("div", {
  365. "styles": this.css.rightContentNode
  366. }).inject(this.node);
  367. this.explorer = new MWF.xApplication.Attendance.AddressExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  368. this.explorer.load();
  369. }.bind(this));
  370. },
  371. openPersonSetting: function () {
  372. MWF.xDesktop.requireApp("Attendance", "PersonSetting", function () {
  373. this.clearContent();
  374. this.explorerContent = new Element("div", {
  375. "styles": this.css.rightContentNode
  376. }).inject(this.node);
  377. this.explorer = new MWF.xApplication.Attendance.PersonSetting(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
  378. this.explorer.load();
  379. }.bind(this));
  380. },
  381. recordStatus: function () {
  382. return this.navi && this.navi.currentItem ? this.navi.currentItem.retrieve("data") : {};
  383. }
  384. });
  385. MWF.xApplication.Attendance.Navi = new Class({
  386. Implements: [Options, Events],
  387. options: {
  388. "id": ""
  389. },
  390. initialize: function (app, node, options) {
  391. this.setOptions(options);
  392. this.app = app;
  393. this.node = $(node);
  394. this.css = this.app.css;
  395. this.currentMenu = null;
  396. this.currentItem = null;
  397. this.menus = {};
  398. this.items = {};
  399. this.elements = [];
  400. this.load();
  401. },
  402. load: function () {
  403. this.scrollNode = new Element("div.naviScrollNode", { "styles": this.css.naviScrollNode }).inject(this.node);
  404. this.areaNode = new Element("div.naviAreaNode", { "styles": this.css.naviAreaNode }).inject(this.scrollNode);
  405. // this.setNodeScroll();
  406. var naviUrl = this.app.path + "navi.json";
  407. MWF.getJSON(naviUrl, function (json) {
  408. json.each(function (navi) {
  409. if (navi.access && navi.access == "admin") {
  410. if (this.app.isAdmin()) this.createNaviNode(navi);
  411. } else if (navi.access && navi.access == "admin_dept") {
  412. if (this.app.isUnitManager() || this.app.isAdmin()) this.createNaviNode(navi);
  413. } else if (navi.access && navi.access == "dingding") { //启用钉钉考勤同步后
  414. debugger;
  415. if ((this.app.isUnitManager() || this.app.isAdmin()) && (this.app.enableType == "dingding")) this.createNaviNode(navi);
  416. } else if (navi.access && navi.access == "qywx") { // 启用企业微信考勤同步后
  417. debugger;
  418. if ((this.app.isUnitManager() || this.app.isAdmin()) && (this.app.enableType == "qywx")) this.createNaviNode(navi);
  419. } else {
  420. this.createNaviNode(navi);
  421. }
  422. }.bind(this));
  423. if (this.options.id == "") this.elements[1].click();
  424. this.setContentSize();
  425. this.app.addEvent("resize", this.setContentSize.bind(this));
  426. }.bind(this));
  427. },
  428. // setNodeScroll: function () {
  429. // MWF.require("MWF.widget.DragScroll", function () {
  430. // new MWF.widget.DragScroll(this.scrollNode);
  431. // }.bind(this));
  432. // MWF.require("MWF.widget.ScrollBar", function () {
  433. // new MWF.widget.ScrollBar(this.scrollNode, { "indent": false });
  434. // }.bind(this));
  435. // },
  436. createNaviNode: function (data) {
  437. if (data.type == "sep") {
  438. var flag = true;
  439. if (data.access == "admin") {
  440. if (!this.app.isAdmin()) flag = false;
  441. } else if (data.access && data.access == "admin_dept") {
  442. if (!this.app.isUnitManager() && !this.app.isAdmin()) flag = false;
  443. }
  444. if (flag) {
  445. new Element("div", { "styles": this.css.viewNaviSepartorNode }).inject(this.areaNode);
  446. }
  447. } else if (data.sub && data.sub.length > 0) {
  448. this.createNaviMenuNode(data);
  449. } else {
  450. this.menus[data.id] = {};
  451. this.createNaviItemNode(data, data.id);
  452. }
  453. },
  454. createNaviMenuNode: function (data) {
  455. if (data.access == "admin") {
  456. if (!this.app.isAdmin()) return;
  457. } else if (data.access == "admin_dept") {
  458. if (!this.app.isUnitManager() && !this.app.isAdmin()) return;
  459. }
  460. var _self = this;
  461. var menuNode = new Element("div", {
  462. "styles": this.css.naviMenuNode
  463. });
  464. menuNode.store("data", data);
  465. menuNode.store("type", "menu");
  466. var textNode = new Element("div", {
  467. "styles": this.css.naviMenuTextNode,
  468. "text": data.title
  469. });
  470. textNode.inject(menuNode);
  471. menuNode.inject(this.areaNode);
  472. this.menus[data.id] = {};
  473. this.menus[data.id].node = menuNode;
  474. this.elements.push(menuNode);
  475. menuNode.addEvents({
  476. "mouseover": function () { if (_self.currentMenu != this){
  477. this.setStyles(_self.app.css.naviMenuNode_over);
  478. this.addClass("mainColor_bg_opacity");
  479. }},
  480. "mouseout": function () { if (_self.currentMenu != this){
  481. this.setStyles(_self.app.css.naviMenuNode_normal);
  482. this.removeClass("mainColor_bg_opacity");
  483. }},
  484. // "mousedown": function () { if (_self.currentMenu != this) this.setStyles(_self.app.css.naviMenuNode_down); },
  485. // "mouseup": function () { if (_self.currentMenu != this) this.setStyles(_self.app.css.naviMenuNode_over); },
  486. "click": function () {
  487. //if (_self.currentNavi!=this) _self.doAction.apply(_self, [this]);
  488. _self.clickMenu.apply(_self, [this]);
  489. }
  490. });
  491. data.sub.each(function (d) {
  492. this.createNaviItemNode(d, data.id, menuNode)
  493. }.bind(this))
  494. },
  495. clickMenu: function (naviNode) {
  496. var navi = naviNode.retrieve("data");
  497. var action = navi.action;
  498. var collapse = naviNode.retrieve("collapse");
  499. // this.closeCurrentMenu();
  500. if (this.menus[navi.id].itemNodes) {
  501. this.menus[navi.id].itemNodes.each(function (itemNode) {
  502. itemNode.setStyle("display", collapse ? "block" : "none");
  503. })
  504. }
  505. // var type = naviNode.retrieve("type");
  506. if (!navi.target || navi.target != "_blank") {
  507. naviNode.setStyles(collapse ? this.css.naviMenuNode : this.css.naviMenuNode_collapse );
  508. // this.currentMenu = naviNode;
  509. }
  510. naviNode.store("collapse", !collapse);
  511. },
  512. // closeCurrentMenu: function () {
  513. // if (this.currentMenu) {
  514. // var data = this.currentMenu.retrieve("data");
  515. // if (this.menus[data.id].itemNodes) {
  516. // this.menus[data.id].itemNodes.each(function (itemNode) {
  517. // itemNode.setStyle("display", "none");
  518. // })
  519. // }
  520. // this.currentMenu.setStyles(this.css.naviMenuNode);
  521. // }
  522. // },
  523. createNaviItemNode: function (data, menuId) {
  524. if (data.access == "admin") {
  525. if (!this.app.isAdmin()) return;
  526. } else if (data.access && data.access == "admin_dept") {
  527. if (!this.app.isUnitManager() && !this.app.isAdmin()) return;
  528. }
  529. var _self = this;
  530. var items = this.menus[menuId].itemNodes = this.menus[menuId].itemNodes || [];
  531. var itemNode = new Element("div", {
  532. "styles": this.css.naviItemNode
  533. });
  534. itemNode.setStyle("display", "block");
  535. items.push(itemNode);
  536. itemNode.store("data", data);
  537. itemNode.store("type", "item");
  538. var textNode = new Element("div", {
  539. "styles": this.css.naviItemTextNode,
  540. "text": data.title
  541. });
  542. textNode.inject(itemNode);
  543. itemNode.inject(this.areaNode);
  544. this.elements.push(itemNode);
  545. this.items[data.id] = itemNode;
  546. itemNode.addEvents({
  547. "mouseover": function () { if (_self.currentItem != this) {
  548. this.setStyles(_self.app.css.naviItemNode_over);
  549. this.addClass("mainColor_bg_opacity");
  550. } },
  551. "mouseout": function () { if (_self.currentItem != this) {
  552. this.setStyles(_self.app.css.naviItemNode);
  553. this.removeClass("mainColor_bg_opacity");
  554. } },
  555. "mousedown": function () { if (_self.currentItem != this) {
  556. this.setStyles(_self.app.css.naviItemNode_down);
  557. this.addClass("mainColor_color");
  558. this.addClass("mainColor_bg_opacity");
  559. } },
  560. "mouseup": function () { if (_self.currentItem != this) {
  561. this.setStyles(_self.app.css.naviItemNode_over);
  562. this.removeClass("mainColor_color");
  563. this.removeClass("mainColor_bg_opacity");
  564. } },
  565. "click": function () {
  566. _self.clickItem.apply(_self, [this]);
  567. }
  568. });
  569. if (data.id == this.options.id) {
  570. itemNode.click();
  571. }
  572. },
  573. clickItem: function (naviNode) {
  574. var navi = naviNode.retrieve("data");
  575. var action = navi.action;
  576. var type = naviNode.retrieve("type");
  577. if (!navi.target || navi.target != "_blank") {
  578. if (this.currentItem) {
  579. this.currentItem.setStyles(this.css.naviItemNode);
  580. this.currentItem.removeClass("mainColor_color");
  581. this.currentItem.removeClass("mainColor_bg_opacity");
  582. }
  583. naviNode.setStyles(this.css.naviItemNode_current);
  584. naviNode.addClass("mainColor_color");
  585. naviNode.addClass("mainColor_bg_opacity");
  586. this.currentItem = naviNode;
  587. }
  588. if (navi.action && this.app[navi.action]) {
  589. this.app[navi.action].call(this.app, navi);
  590. }
  591. },
  592. setContentSize: function () {
  593. var size = this.app.content.getSize();
  594. this.scrollNode.setStyle("height", size.y - 5);
  595. }
  596. //loadCalendar: function () {
  597. // var calendarArea = new Element("div#calendarArea",{
  598. // "styles" : this.css.calendarArea
  599. // }).inject(this.node)
  600. // this.calendar = new MWF.xApplication.Attendance.Calendar( calendarArea, this.app, this.actions )
  601. // this.calendar.load();
  602. //}
  603. });