SettingModuleMenu.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. o2.require("o2.xDesktop.Default", null, false);
  2. o2.xApplication.Setting.ModuleMenuDocument = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default"
  7. },
  8. initialize: function(explorer, content, options){
  9. this.setOptions(options);
  10. this.content = content;
  11. this.explorer = explorer;
  12. this.app = this.explorer.app;
  13. this.css = this.app.css;
  14. this.lp = this.app.lp.module;
  15. this.load();
  16. },
  17. "destroy": function(){
  18. // this.appDeploymentContent.destroy();
  19. // this.content.empty();
  20. // if (this.setContentHeightFun) this.app.removeEvent("resize", this.setContentHeightFun);
  21. MWF.release(this);
  22. },
  23. load: function(){
  24. this.menuShowArea = new Element("div", {
  25. styles: {
  26. "height": "100%",
  27. "overflow": "hidden",
  28. "width": "400px",
  29. "float": "left"
  30. }
  31. }).inject(this.content);
  32. this.actionsArea = new Element("div", {
  33. styles: {
  34. "height": "calc( 100% - 40px )",
  35. "overflow": "hidden",
  36. "margin-left": "420px",
  37. "padding": "20px 20px"
  38. }
  39. }).inject(this.content);
  40. this.startMenu = new o2.xApplication.Setting.ModuleMenuDocument.StartMenu(this);
  41. this.startMenu.addEvents({
  42. // "onHide": function(){
  43. // this.startMenuNode.removeClass("overColor_bg");
  44. // }.bind(this),
  45. "onLoad": function(){
  46. if (!this.startMenu.isShow){
  47. this.startMenu.show();
  48. }
  49. this.createDefaultMenuDataActions();
  50. this.createForceMenuDataActions();
  51. this.createCustomMenuDataActions();
  52. }.bind(this)
  53. });
  54. this.startMenu.load();
  55. },
  56. createDefaultMenuDataActions: function(){
  57. var node = new Element("div", {"styles": {"margin-bottom": "40px", "overflow": "hidden"}}).inject(this.actionsArea);
  58. new Element("div", {"styles": this.css.menuDataInfor,"text": this.app.lp.saveDefaultMenuDataInfor}).inject(node);
  59. this.createButton(this.app.lp.saveDefaultMenuData, this.saveDefaultMenuData.bind(this)).inject(node);
  60. this.createButton(this.app.lp.clearDefaultMenuData, this.clearDefaultMenuData.bind(this), "grayColor_bg", "grayColor_bg", "grayColor_bg").inject(node)
  61. if (this.startMenu.defaultData){
  62. this.createButton(this.app.lp.loadDefaultMenuData, this.loadDefaultMenuData.bind(this), "grayColor_bg", "grayColor_bg", "grayColor_bg").inject(node)
  63. }
  64. },
  65. createForceMenuDataActions: function(){
  66. var node = new Element("div", {"styles": {"margin-bottom": "40px", "overflow": "hidden"}}).inject(this.actionsArea);
  67. new Element("div", {"styles": this.css.menuDataInfor,"text": this.app.lp.saveForceMenuDataInfor}).inject(node);
  68. this.createButton(this.app.lp.saveForceMenuData, this.saveForceMenuData.bind(this)).inject(node);
  69. this.createButton(this.app.lp.clearForceMenuData, this.clearForceMenuData.bind(this), "grayColor_bg", "grayColor_bg", "grayColor_bg").inject(node)
  70. if (this.startMenu.forceData){
  71. this.createButton(this.app.lp.loadForceMenuData, this.loadForceMenuData.bind(this), "grayColor_bg", "grayColor_bg", "grayColor_bg").inject(node)
  72. }
  73. },
  74. createCustomMenuDataActions: function(){
  75. var node = new Element("div", {"styles": {"margin-bottom": "40px", "overflow": "hidden"}}).inject(this.actionsArea);
  76. new Element("div", {"styles": this.css.menuDataInfor,"text": this.app.lp.clearCustomMenuDataInfor}).inject(node);
  77. this.createButton(this.app.lp.clearCustomMenuData, this.clearCustomMenuData.bind(this), "grayColor_bg", "grayColor_bg", "grayColor_bg").inject(node)
  78. },
  79. createButton: function(text, action, main, over, down){
  80. var mainClass = main || "mainColor_bg";
  81. var overClass = over || "overColor_bg";
  82. var downClass = down || "deepColor_bg";
  83. var button = new Element("div."+mainClass, {"type": "button", "styles": this.css.buttonNode, "text": text});
  84. button.addEvents({
  85. "click": function(){
  86. if (action) action(button);
  87. }.bind(this),
  88. "mouseover": function(){this.removeClass(mainClass); this.removeClass(downClass); this.addClass(overClass);},
  89. "mouseout": function(){this.removeClass(overClass); this.removeClass(downClass); this.addClass(mainClass);},
  90. "mousedown": function(){this.removeClass(mainClass); this.removeClass(overClass); this.addClass(downClass);},
  91. "mouseup": function(){this.removeClass(mainClass); this.removeClass(downClass); this.addClass(overClass);}
  92. });
  93. return button
  94. },
  95. saveDefaultMenuData: function(){
  96. if (this.startMenu){
  97. this.startMenu.resetMenuData();
  98. if (this.startMenu.menuData){
  99. o2.UD.putPublicData("defaultMainMenuData", this.startMenu.menuData, function(){
  100. this.app.notice(this.app.lp.saveDefaultMenuDataSuccess, "success");
  101. }.bind(this));
  102. }
  103. }
  104. },
  105. clearDefaultMenuData: function(bt){
  106. var _self = this;
  107. this.app.confirm("warn", bt, this.app.lp.clearDefaultMenuData, this.app.lp.clearDefaultMenuDataConfirm, 380, 120, function(){
  108. o2.UD.deletePublicData("defaultMainMenuData", function(){
  109. _self.app.notice(_self.app.lp.clearDefaultMenuDataSuccess, "success");
  110. });
  111. this.close();
  112. }, function(){
  113. this.close();
  114. });
  115. },
  116. saveForceMenuData: function(){
  117. if (this.startMenu){
  118. this.startMenu.resetMenuData();
  119. if (this.startMenu.menuData){
  120. o2.UD.putPublicData("forceMainMenuData", this.startMenu.menuData, function(){
  121. this.app.notice(this.app.lp.saveForceMenuDataSuccess, "success");
  122. }.bind(this));
  123. }
  124. }
  125. },
  126. clearForceMenuData: function(bt){
  127. var _self = this;
  128. this.app.confirm("warn", bt, this.app.lp.clearForceMenuData, this.app.lp.clearForceMenuDataConfirm, 380, 120, function(){
  129. o2.UD.deletePublicData("forceMainMenuData", function(){
  130. _self.app.notice(_self.app.lp.clearForceMenuDataSuccess, "success");
  131. });
  132. this.close();
  133. }, function(){
  134. this.close();
  135. });
  136. },
  137. clearCustomMenuData: function(bt){
  138. var _self = this;
  139. this.app.confirm("warn", bt, this.app.lp.clearForceMenuData, this.app.lp.clearCustomMenuDataConfirm, 380, 120, function(){
  140. o2.require("o2.widget.UUID", function(){
  141. var id = new o2.widget.UUID();
  142. o2.UD.putPublicData("clearCustomMenuDataFlag", {"id": id.toString()}, function(){
  143. _self.app.notice(_self.app.lp.clearForceMenuDataSuccess, "success");
  144. });
  145. this.close();
  146. }.bind(this));
  147. }, function(){
  148. this.close();
  149. });
  150. },
  151. loadForceMenuData: function(){
  152. if (this.startMenu){
  153. this.startMenu.reload(this.startMenu.forceData);
  154. }
  155. },
  156. loadDefaultMenuData: function(){
  157. if (this.startMenu){
  158. this.startMenu.reload(this.startMenu.defaultData);
  159. }
  160. }
  161. });
  162. o2.xApplication.Setting.ModuleMenuDocument.StartMenu = new Class({
  163. Extends: o2.xDesktop.Default.StartMenu,
  164. Implements: [Events],
  165. initialize: function (setting) {
  166. this.layout = layout.desktop;
  167. this.setting = setting;
  168. this.container = this.setting.menuShowArea;
  169. //this.actionNode = this.setting.startMenuNode;
  170. this.isLoaded = false;
  171. this.isShow = false;
  172. this.isMorph = false;
  173. this.items = [];
  174. // this.menuData = (this.layout.status && this.layout.status.menuData) ? Object.clone(this.layout.status.menuData) : {
  175. // "appList": [],
  176. // "processList": [],
  177. // "inforList": [],
  178. // "queryList": []
  179. // };
  180. this.itemTempletedHtml = "" +
  181. " <div class='layout_start_item_iconArea'>" +
  182. " <div class='layout_start_item_icon'></div>" +
  183. " </div>" +
  184. " <div class='layout_start_item_text'></div>" +
  185. " <div class='layout_start_item_badge'></div>";
  186. this.checkLayout();
  187. },
  188. loadMenuData: function(callback){
  189. debugger;
  190. this.menuData = (this.layout.status && this.layout.status.menuData) ? Object.clone(this.layout.status.menuData) : {
  191. "appList": [],
  192. "processList": [],
  193. "inforList": [],
  194. "queryList": []
  195. };
  196. var forceData = null, defaultData = null;
  197. var forceLoaded = false, defaultLoaded = false;
  198. var check = function(){
  199. if (forceLoaded && defaultLoaded){
  200. this.forceData = forceData;
  201. this.defaultData = defaultData;
  202. if (forceData){
  203. this.menuData=forceData;
  204. }else if (defaultData){
  205. this.menuData=defaultData;
  206. }
  207. if (callback) callback();
  208. }
  209. }.bind(this)
  210. o2.UD.getPublicData("forceMainMenuData", function(fData){
  211. forceData = fData;
  212. forceLoaded = true;
  213. check();
  214. }.bind(this));
  215. o2.UD.getPublicData("defaultMainMenuData", function(dData){
  216. defaultData = dData;
  217. defaultLoaded = true;
  218. check();
  219. }.bind(this));
  220. },
  221. load: function(){
  222. this.loadMenuData(function(){
  223. //var view = this.layout.path+this.layout.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-menu-mobile.html" : "/layout-menu-pc.html");
  224. var view = this.layout.path+this.layout.options.style+"/layout-menu-pc.html";
  225. this.container.loadHtml(view, {"module": this}, function(){
  226. this.maskNode.destroy();
  227. this.node.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  228. //this.layout.menuNode.setStyle("z-index", o2.xDesktop.zIndexPool.applyZindex());
  229. this.node.addEvent("mousedown", function(e){
  230. e.stopPropagation();
  231. e.preventDefault();
  232. });
  233. // this.triangleNode = new Element("div.layout_menu_start_triangle").inject(this.layout.menuNode, "after");
  234. // this.hideMessage = function(){ this.hide(); }.bind(this);
  235. //this.fireEvent("load");
  236. this.layout.addEvent("resize", this.setSize.bind(this));
  237. this.loadTitle();
  238. this.loadLnks();
  239. this.setSize();
  240. this.isLoaded = true;
  241. this.fireEvent("load");
  242. }.bind(this));
  243. }.bind(this));
  244. },
  245. setSize: function(){
  246. if (this.appScrollBar && this.appScrollBar.scrollVNode) this.appScrollBar.scrollVNode.setStyle("margin-top", "0px");
  247. var isLnk = false;
  248. if (false && this.layout.lnks && this.layout.lnks.length){
  249. this.lnkAreaNode.show();
  250. this.lineNode.show();
  251. var h = 100*3;
  252. this.lnkScrollNode.setStyle("height", ""+h+"px");
  253. isLnk = true;
  254. }else{
  255. this.lnkAreaNode.hide();
  256. this.lineNode.hide();
  257. }
  258. debugger;
  259. if( !this.node.offsetParent )this.node.show();
  260. var size = this.node.getSize();
  261. var lnkSizeY = (isLnk) ? this.lnkAreaNode.getSize().y : 0;
  262. var lineSizeY = (isLnk) ? this.lineNode.getSize().y : 0;
  263. var mt = (isLnk) ? (this.lineNode.getStyle("margin-top").toInt() || 0) : 0;
  264. var mb = (isLnk) ? (this.lineNode.getStyle("margin-bottom").toInt() || 0) : 0;
  265. var titleSize = this.appTitleNode.getSize();
  266. var y = size.y-lnkSizeY-lineSizeY-mt-mb-titleSize.y - 40;
  267. this.appScrollNode.setStyle("height", ""+y+"px");
  268. },
  269. checkLayout: function(){
  270. if( !this.layout.path )this.layout.path = o2.session.path+"/xDesktop/$Default/";
  271. if( !this.layout.options )this.layout.options = {};
  272. if( !this.layout.options.style )this.layout.options.style = "blue";
  273. },
  274. reload: function(menuData){
  275. this.menuData = menuData || {
  276. "appList": [],
  277. "processList": [],
  278. "inforList": [],
  279. "queryList": []
  280. };
  281. this.container.empty();
  282. //var view = this.layout.path+this.layout.options.style+((o2.session.isMobile || layout.mobile) ? "/layout-menu-mobile.html" : "/layout-menu-pc.html");
  283. var view = this.layout.path+this.layout.options.style+"/layout-menu-pc.html";
  284. this.container.loadHtml(view, {"module": this}, function(){
  285. if (this.maskNode) this.maskNode.destroy();
  286. this.node.addEvent("mousedown", function(e){
  287. e.stopPropagation();
  288. e.preventDefault();
  289. });
  290. this.loadTitle();
  291. this.loadLnks();
  292. this.node.setStyles({
  293. "display": "block",
  294. "position": "relative",
  295. "left": "0",
  296. "top": "0"
  297. });
  298. this.loadJsons(function(){
  299. (this.currentTab || this.appCategoryTab).click();
  300. }.bind(this));
  301. this.isShow = true;
  302. this.setScroll();
  303. this.isLoaded = true;
  304. }.bind(this));
  305. },
  306. show: function(){
  307. this.node.setStyles({
  308. "display": "block",
  309. "position": "relative",
  310. "left": "0",
  311. "top": "0"
  312. });
  313. this.appAreaNode.setStyles({ "filter": "" });
  314. this.loadJsons(function(){
  315. (this.currentTab || this.appCategoryTab).click();
  316. }.bind(this));
  317. this.isShow = true;
  318. this.isMorph = false;
  319. this.setScroll();
  320. },
  321. hide: function(){
  322. },
  323. createApplicationMenuItem: function(value){
  324. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.Item(this, this.appContentNode, value));
  325. },
  326. createPortalMenuItem: function(value){
  327. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.PortalItem(this, this.appContentNode, value));
  328. },
  329. createProcessMenuItem: function(value){
  330. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.ProcessItem(this, this.appContentNode, value));
  331. },
  332. createInforMenuItem: function(value){
  333. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.InforItem(this, this.appContentNode, value));
  334. },
  335. createQueryMenuItem: function(value){
  336. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.QueryItem(this, this.appContentNode, value));
  337. },
  338. createGroupMenuItem: function(value){
  339. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.GroupItem(this, this.appContentNode, value));
  340. },
  341. resetMenuData: function(){
  342. if (!this.menuData) this.menuData = {
  343. "appList": [],
  344. "processList": [],
  345. "inforList": [],
  346. "queryList": []
  347. }
  348. var nodes = this.appContentNode.getChildren();
  349. var data = [];
  350. nodes.each(function(node){
  351. var item = node.retrieve("item");
  352. if (item){
  353. if (item.data.type==="group"){
  354. var d = {
  355. "id": item.data.id,
  356. "name": item.data.name,
  357. "type": item.data.type,
  358. "itemDataList": []
  359. }
  360. if (item.data.itemDataList) item.data.itemDataList.each(function(i){
  361. d.itemDataList.push(i);
  362. });
  363. data.push(d);
  364. }else{
  365. data.push({
  366. "id": item.data.id,
  367. "name": item.data.name,
  368. "type": item.data.type,
  369. });
  370. }
  371. }
  372. }.bind(this));
  373. if (this.currentTab === this.appCategoryTab){
  374. this.menuData.appList = data;
  375. }else if (this.currentTab === this.processCategoryTab){
  376. this.menuData.processList = data;
  377. }else if (this.currentTab === this.inforCategoryTab){
  378. this.menuData.inforList = data;
  379. }else if (this.currentTab === this.queryCategoryTab){
  380. this.menuData.queryList = data;
  381. }
  382. //this.layout.menuData = this.menuData;
  383. },
  384. defaultMenu: function(){
  385. this.menuData = null;
  386. this.reload();
  387. }
  388. });
  389. o2.xApplication.Setting.ModuleMenuDocument.StartMenu.Item = new Class({
  390. Extends: o2.xDesktop.Default.StartMenu.Item,
  391. loadBadge: function(){
  392. this.badgeNode.hide();
  393. },
  394. _drag_drag: function(dragging, e){
  395. if (this.dragStatus == "group"){
  396. if (!this.onGroup) this.checkDargOver(dragging);
  397. if (!this.overItem){
  398. this.checkDargPosition(dragging);
  399. }
  400. }
  401. }
  402. });
  403. o2.xApplication.Setting.ModuleMenuDocument.StartMenu.GroupItem = new Class({
  404. Extends: o2.xDesktop.Default.StartMenu.GroupItem,
  405. loadBadge: function(){
  406. this.badgeNode.hide();
  407. },
  408. _drag_drag: function(dragging, e){
  409. if (this.dragStatus == "group"){
  410. if (!this.onGroup) this.checkDargOver(dragging);
  411. if (!this.overItem){
  412. this.checkDargPosition(dragging);
  413. }
  414. }
  415. },
  416. loadItems: function(){
  417. if (!this.items) this.items = [];
  418. this.data.itemDataList.each(function(data){
  419. var item = this.items.find(function(i){
  420. return i.data.id == data.id;
  421. });
  422. if (!item){
  423. switch (data.type){
  424. case "portal":
  425. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.PortalItem(this, this.menuContentNode, data));
  426. break;
  427. case "process":
  428. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.ProcessItem(this, this.menuContentNode, data));
  429. break;
  430. case "cms":
  431. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.InforItem(this, this.menuContentNode, data));
  432. break;
  433. case "query":
  434. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.QueryItem(this, this.menuContentNode, data));
  435. break;
  436. default:
  437. this.items.push(new o2.xApplication.Setting.ModuleMenuDocument.StartMenu.Item(this, this.menuContentNode, data));
  438. }
  439. }
  440. }.bind(this));
  441. },
  442. });
  443. o2.xApplication.Setting.ModuleMenuDocument.StartMenu.PortalItem = new Class({
  444. Extends: o2.xDesktop.Default.StartMenu.PortalItem,
  445. loadBadge: function(){
  446. this.badgeNode.hide();
  447. },
  448. _drag_drag: function(dragging, e){
  449. if (this.dragStatus == "group"){
  450. if (!this.onGroup) this.checkDargOver(dragging);
  451. if (!this.overItem){
  452. this.checkDargPosition(dragging);
  453. }
  454. }
  455. }
  456. });
  457. o2.xApplication.Setting.ModuleMenuDocument.StartMenu.ProcessItem = new Class({
  458. Extends: o2.xDesktop.Default.StartMenu.ProcessItem,
  459. loadBadge: function(){
  460. this.badgeNode.hide();
  461. },
  462. _drag_drag: function(dragging, e){
  463. if (this.dragStatus == "group"){
  464. if (!this.onGroup) this.checkDargOver(dragging);
  465. if (!this.overItem){
  466. this.checkDargPosition(dragging);
  467. }
  468. }
  469. }
  470. });
  471. o2.xApplication.Setting.ModuleMenuDocument.StartMenu.InforItem = new Class({
  472. Extends: o2.xDesktop.Default.StartMenu.InforItem,
  473. loadBadge: function(){
  474. this.badgeNode.hide();
  475. },
  476. _drag_drag: function(dragging, e){
  477. if (this.dragStatus == "group"){
  478. if (!this.onGroup) this.checkDargOver(dragging);
  479. if (!this.overItem){
  480. this.checkDargPosition(dragging);
  481. }
  482. }
  483. }
  484. });
  485. o2.xApplication.Setting.ModuleMenuDocument.StartMenu.QueryItem = new Class({
  486. Extends: o2.xDesktop.Default.StartMenu.QueryItem,
  487. loadBadge: function(){
  488. this.badgeNode.hide();
  489. },
  490. _drag_drag: function(dragging, e){
  491. if (this.dragStatus == "group"){
  492. if (!this.onGroup) this.checkDargOver(dragging);
  493. if (!this.overItem){
  494. this.checkDargPosition(dragging);
  495. }
  496. }
  497. }
  498. });