Table.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xApplication.process.Xform.Table = MWF.APPTable = new Class({
  3. Extends: MWF.APP$Module,
  4. _afterLoaded: function(){
  5. if (!this.table) this.table = this.node.getElement("table");
  6. //var tds = this.node.getElements("td");
  7. var rows = this.table.rows;
  8. for (var i=0; i<rows.length; i++){
  9. var row = rows[i];
  10. for (var j=0; j<row.cells.length; j++){
  11. var td = row.cells[j];
  12. var json = this.form._getDomjson(td);
  13. var table = this;
  14. var module = this.form._loadModule(json, td, function(){
  15. this.table = table;
  16. });
  17. this.form.modules.push(module);
  18. }
  19. }
  20. // this.table.rows.each(function(row){
  21. // row.cells.each(function(td){
  22. // var json = this.form._getDomjson(td);
  23. // var table = this;
  24. // var module = this.form._loadModule(json, td, function(){
  25. // this.table = table;
  26. // });
  27. //
  28. // this.form.modules.push(module);
  29. // }.bind(this));
  30. // }.bind(this));
  31. // tds.each(function(td){
  32. // var json = this.form._getDomjson(td);
  33. // var table = this;
  34. // var module = this.form._loadModule(json, td, function(){
  35. // this.table = table;
  36. // });
  37. //
  38. // this.form.modules.push(module);
  39. // }.bind(this));
  40. },
  41. _loadBorderStyle: function(){
  42. if (this.json.styles.border){
  43. if (!this.table) this.table = this.node.getElement("table");
  44. this.table.set("cellspacing", "0");
  45. this.table.setStyles({
  46. "border-top": this.json.styles.border,
  47. "border-left": this.json.styles.border
  48. });
  49. var ths = this.table.getElements("th");
  50. ths.setStyles({
  51. "border-bottom": this.json.styles.border,
  52. "border-right": this.json.styles.border
  53. });
  54. var tds = this.table.getElements("td");
  55. tds.setStyles({
  56. "border-bottom": this.json.styles.border,
  57. "border-right": this.json.styles.border,
  58. "background": "transparent"
  59. });
  60. }
  61. },
  62. _loadStyles: function(){
  63. Object.each(this.json.styles, function(value, key){
  64. var reg = /^border\w*/ig;
  65. if (!key.test(reg)){
  66. this.node.setStyle(key, value);
  67. }
  68. }.bind(this));
  69. this._loadBorderStyle();
  70. }
  71. });
  72. MWF.xApplication.process.Xform.Table$Td = MWF.APPTable$Td = new Class({
  73. Extends: MWF.APP$Module,
  74. _queryLoaded: function(){
  75. },
  76. _afterLoaded: function(){
  77. //this.form._loadModules(this.node);
  78. },
  79. _loadStyles: function(){
  80. var addStyles = {};
  81. if (this.json.cellType=="title"){
  82. addStyles = this.table.json.titleTdStyles
  83. }
  84. if (this.json.cellType=="content"){
  85. addStyles = this.table.json.contentTdStyles
  86. }
  87. if (this.json.cellType=="layout"){
  88. addStyles = this.table.json.layoutTdStyles
  89. }
  90. this.node.setStyles(addStyles);
  91. this.node.setStyles(this.json.styles);
  92. if (this.json.cellType=="content"){
  93. this.form.addEvent("postLoad", function(){
  94. var inputs = this.node.getElements("input");
  95. inputs.each(function(input){
  96. var inputType = input.get("type").toLowerCase();
  97. if (inputType!="radio" && inputType!="checkbox" && inputType!="submit" && inputType!="buttom" && inputType!="image"){
  98. input.setStyle("width", "100%");
  99. }
  100. }.bind(this));
  101. var textareas = this.node.getElements("textarea");
  102. textareas.each(function(textarea){
  103. textarea.setStyle("width", "100%");
  104. }.bind(this));
  105. }.bind(this))
  106. }
  107. }
  108. });