Tab.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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(ev, historyCallback){
  69. var tabNode = new Element("div");
  70. var page = this.tabWidget.addTab(tabNode, "page", false);
  71. var tabPage, tabContent;
  72. this.form.getTemplateData("Tab$Page", function(data){
  73. var moduleData = Object.clone(data);
  74. moduleData.name = page.tabNode.get("text");
  75. tabPage = new MWF.PCTab$Page(this, page);
  76. tabPage.load(moduleData, page.tabNode, this);
  77. this.elements.push(tabPage);
  78. }.bind(this), false);
  79. this.form.getTemplateData("Tab$Content", function(data){
  80. var moduleData = Object.clone(data);
  81. tabContent = new MWF.PCTab$Content(this, page);
  82. tabContent.load(moduleData, page.contentNode, this);
  83. this.containers.push(tabContent);
  84. }.bind(this), false);
  85. page.showTabIm();
  86. if( historyCallback ){
  87. historyCallback( tabPage );
  88. }else{
  89. tabPage.addHistoryLog("add")
  90. }
  91. return page;
  92. }
  93. });