Tab.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. if (page.isShow){
  46. this.showContentModule.call(page, this);
  47. }else{
  48. if (this.json.isDelay){
  49. var _self = this;
  50. page.showContentModuleFun = function(){_self.showContentModule.call(page, _self)};
  51. page.addEvent("show", page.showContentModuleFun);
  52. }else{
  53. this.showContentModule.call(page, this);
  54. }
  55. }
  56. }.bind(this));
  57. },
  58. showContentModule: function(_self){
  59. var node = this.contentNode;
  60. node.isLoadModule = true;
  61. json = _self.form._getDomjson(node);
  62. tab = _self;
  63. module = _self.form._loadModule(json, node, function(){
  64. this.tab = tab;
  65. });
  66. _self.containers.push(module);
  67. _self.form.modules.push(module);
  68. if (this.showContentModuleFun) this.removeEvent("show", this.showContentModuleFun);
  69. },
  70. _setTabWidgetStyles: function(){
  71. if (this.json.tabNodeContainer) this.tab.css.tabNodeContainer = Object.clone(this.json.tabNodeContainer);
  72. if (this.json.contentNodeContainer) this.tab.css.contentNodeContainer = Object.clone(this.json.contentNodeContainer);
  73. this.tab.css.tabNode = Object.clone(this.json.tabStyles);
  74. this.tab.css.tabTextNode = Object.clone(this.json.tabTextStyles);
  75. this.tab.css.tabNodeCurrent = Object.clone(this.json.tabCurrentStyles);
  76. this.tab.css.tabTextNodeCurrent = Object.clone(this.json.tabTextCurrentStyles);
  77. }
  78. });
  79. MWF.xApplication.process.Xform.tab$Page = MWF.APPTab$Page = new Class({
  80. Extends: MWF.APP$Module
  81. });
  82. MWF.xApplication.process.Xform.tab$Content = MWF.APPTab$Content = new Class({
  83. Extends: MWF.APP$Module,
  84. _loadUserInterface: function(){
  85. this.form._loadModules(this.node);
  86. }
  87. });