Tab.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("portal.PageDesigner", "Module.Tab$Page", null, false);
  3. MWF.xDesktop.requireApp("portal.PageDesigner", "Module.Tab$Content", null, false);
  4. MWF.require("MWF.widget.Tab", null, false);
  5. MWF.xApplication.portal.PageDesigner.Module.Tab = MWF.PCTab = new Class({
  6. Extends: MWF.FCTab,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "propertyPath": "../x_component_portal_PageDesigner/Module/Tab/tab.html"
  11. },
  12. initialize: function(form, options){
  13. this.setOptions(options);
  14. this.path = "../x_component_portal_PageDesigner/Module/Tab/";
  15. this.cssPath = "../x_component_portal_PageDesigner/Module/Tab/"+this.options.style+"/css.wcss";
  16. this._loadCss();
  17. this.moduleType = "component";
  18. this.moduleName = "tab";
  19. this.form = form;
  20. this.container = null;
  21. this.containerNode = null;
  22. this.containers = [];
  23. this.elements = [];
  24. },
  25. _getElements: function(){
  26. //this.elements.push(this);
  27. if (!this.tabWidget) this._createTabWidget();
  28. this.form.getTemplateData("Tab$Page", function(data){
  29. this.tabWidget.pages.each(function(page){
  30. var tabPage = null;
  31. var json = this.form.getDomjson(page.tabNode);
  32. if (!json){
  33. var moduleData = Object.clone(data);
  34. moduleData.name = page.tabNode.get("text");
  35. tabPage = new MWF.PCTab$Page(this, page);
  36. tabPage.page = page;
  37. tabPage.load(moduleData, page.tabNode, this);
  38. }else{
  39. tabPage = new MWF.PCTab$Page(this, page);
  40. tabPage.page = page;
  41. tabPage.load(json, page.tabNode, this);
  42. }
  43. if (tabPage) this.elements.push(tabPage);
  44. }.bind(this));
  45. }.bind(this));
  46. if (!this.tabWidget.showPage) this.tabWidget.pages[0].showTabIm();
  47. },
  48. _getContainers: function(){
  49. if (!this.tabWidget) this._createTabWidget();
  50. this.form.getTemplateData("Tab$Content", function(data){
  51. this.tabWidget.pages.each(function(page){
  52. var tabContent = null;
  53. var json = this.form.getDomjson(page.contentNode);
  54. if (!json){
  55. var moduleData = Object.clone(data);
  56. tabContent = new MWF.PCTab$Content(this, page);
  57. tabContent.page = page;
  58. tabContent.load(moduleData, page.contentNode, this);
  59. }else{
  60. tabContent = new MWF.PCTab$Content(this, page);
  61. tabContent.page = page;
  62. tabContent.load(json, page.contentNode, this);
  63. }
  64. if (tabContent) this.containers.push(tabContent);
  65. }.bind(this));
  66. }.bind(this));
  67. },
  68. addPage: function(){
  69. tabNode = new Element("div");
  70. var page = this.tabWidget.addTab(tabNode, "page", false);
  71. this.form.getTemplateData("Tab$Page", function(data){
  72. var moduleData = Object.clone(data);
  73. moduleData.name = page.tabNode.get("text");
  74. var tabPage = new MWF.PCTab$Page(this, page);
  75. tabPage.load(moduleData, page.tabNode, this);
  76. this.elements.push(tabPage);
  77. }.bind(this));
  78. this.form.getTemplateData("Tab$Content", function(data){
  79. var moduleData = Object.clone(data);
  80. var tabContent = new MWF.PCTab$Content(this, page);
  81. tabContent.load(moduleData, page.contentNode, this);
  82. this.containers.push(tabContent);
  83. }.bind(this));
  84. page.showTabIm();
  85. return page;
  86. }
  87. });