Table.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. tds.each(function(td){
  8. var json = this.form._getDomjson(td);
  9. var table = this;
  10. var module = this.form._loadModule(json, td, function(){
  11. this.table = table;
  12. });
  13. this.form.modules.push(module);
  14. }.bind(this));
  15. },
  16. _loadBorderStyle: function(){
  17. if (this.json.styles.border){
  18. if (!this.table) this.table = this.node.getElement("table");
  19. this.table.set("cellspacing", "0");
  20. this.table.setStyles({
  21. "border-top": this.json.styles.border,
  22. "border-left": this.json.styles.border
  23. });
  24. var ths = this.table.getElements("th");
  25. ths.setStyles({
  26. "border-bottom": this.json.styles.border,
  27. "border-right": this.json.styles.border
  28. });
  29. var tds = this.table.getElements("td");
  30. tds.setStyles({
  31. "border-bottom": this.json.styles.border,
  32. "border-right": this.json.styles.border,
  33. "background": "transparent"
  34. });
  35. }
  36. },
  37. _loadStyles: function(){
  38. Object.each(this.json.styles, function(value, key){
  39. var reg = /^border\w*/ig;
  40. if (!key.test(reg)){
  41. this.node.setStyle(key, value);
  42. }
  43. }.bind(this));
  44. this._loadBorderStyle();
  45. },
  46. });
  47. MWF.xApplication.process.Xform.Table$Td = MWF.APPTable$Td = new Class({
  48. Extends: MWF.APP$Module,
  49. _queryLoaded: function(){
  50. },
  51. _afterLoaded: function(){
  52. //this.form._loadModules(this.node);
  53. },
  54. _loadStyles: function(){
  55. var addStyles = {};
  56. if (this.json.cellType=="title"){
  57. addStyles = this.table.json.titleTdStyles
  58. }
  59. if (this.json.cellType=="content"){
  60. addStyles = this.table.json.contentTdStyles
  61. }
  62. if (this.json.cellType=="layout"){
  63. addStyles = this.table.json.layoutTdStyles
  64. }
  65. this.node.setStyles(addStyles);
  66. this.node.setStyles(this.json.styles);
  67. if (this.json.cellType=="content"){
  68. this.form.addEvent("postLoad", function(){
  69. var inputs = this.node.getElements("input");
  70. inputs.each(function(input){
  71. var inputType = input.get("type").toLowerCase();
  72. if (inputType!="radio" && inputType!="checkbox" && inputType!="submit" && inputType!="buttom" && inputType!="image"){
  73. input.setStyle("width", "100%");
  74. }
  75. }.bind(this));
  76. var textareas = this.node.getElements("textarea");
  77. textareas.each(function(textarea){
  78. textarea.setStyle("width", "100%");
  79. }.bind(this));
  80. }.bind(this))
  81. }
  82. }
  83. });