Tab.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.require("MWF.widget.Tab", null, false);
  3. MWF.xApplication.process.Xform.Tab = MWF.APPTab = new Class({
  4. Extends: MWF.APP$Module,
  5. _loadUserInterface: function(){
  6. this.elements = [];
  7. this.containers = [];
  8. var style = "form";
  9. if (layout.mobile) style = "mobileForm";
  10. this.tab = new MWF.widget.Tab(this.node, {"style": style});
  11. this._setTabWidgetStyles();
  12. this.tab.tabNodeContainer = this.node.getFirst("div");
  13. this.tab.contentNodeContainer = this.tab.tabNodeContainer.getNext("div");
  14. var lastNode = this.tab.tabNodeContainer.getLast();
  15. var tabs;
  16. if (lastNode && lastNode.hasClass("tabNodeContainerLeft")){
  17. this.tab.tabNodeContainerRight = this.tab.tabNodeContainer.getFirst();
  18. this.tab.tabNodeContainerLeft = lastNode;
  19. this.tab.tabNodeContainerArea = lastNode.getFirst();
  20. var menuNode = this.node.getElement(".MWFMenu");
  21. if (menuNode) menuNode.destroy();
  22. this.tab.load();
  23. tabs = this.tab.tabNodeContainerArea.getChildren("div");
  24. }else{
  25. tabs = this.tab.tabNodeContainer.getChildren("div");
  26. this.tab.load();
  27. }
  28. var contents = this.tab.contentNodeContainer.getChildren("div");
  29. tabs.each(function(tab, idx){
  30. this.tab.rebuildTab(contents[idx], contents[idx].getFirst(), tab);
  31. }.bind(this));
  32. this.tab.pages[0]._showTab();
  33. this.loadSubModule();
  34. },
  35. loadSubModule: function(){
  36. this.tab.pages.each(function(page){
  37. var node = page.tabNode;
  38. var json = this.form._getDomjson(node);
  39. var tab = this;
  40. var module = this.form._loadModule(json, node, function(){
  41. this.tab = tab;
  42. });
  43. this.elements.push(module);
  44. this.form.modules.push(module);
  45. node = page.contentNode;
  46. json = this.form._getDomjson(node);
  47. tab = this;
  48. module = this.form._loadModule(json, node, function(){
  49. this.tab = tab;
  50. });
  51. this.containers.push(module);
  52. this.form.modules.push(module);
  53. }.bind(this));
  54. },
  55. _setTabWidgetStyles: function(){
  56. if (this.json.tabNodeContainer) this.tab.css.tabNodeContainer = Object.clone(this.json.tabNodeContainer);
  57. if (this.json.contentNodeContainer) this.tab.css.contentNodeContainer = Object.clone(this.json.contentNodeContainer);
  58. this.tab.css.tabNode = Object.clone(this.json.tabStyles);
  59. this.tab.css.tabTextNode = Object.clone(this.json.tabTextStyles);
  60. this.tab.css.tabNodeCurrent = Object.clone(this.json.tabCurrentStyles);
  61. this.tab.css.tabTextNodeCurrent = Object.clone(this.json.tabTextCurrentStyles);
  62. }
  63. });
  64. MWF.xApplication.process.Xform.tab$Page = MWF.APPTab$Page = new Class({
  65. Extends: MWF.APP$Module
  66. });
  67. MWF.xApplication.process.Xform.tab$Content = MWF.APPTab$Content = new Class({
  68. Extends: MWF.APP$Module
  69. });