98fb0eb0cd3ee66bf0514223184de1df8bc757de.svn-base 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
  7. monitorResize : false,
  8. setContainer : function(A) {
  9. Ext.layout.TableLayout.superclass.setContainer.call(this, A);
  10. this.currentRow = 0;
  11. this.currentColumn = 0;
  12. this.spanCells = []
  13. },
  14. onLayout : function(C, E) {
  15. var D = C.items.items, A = D.length, F, B;
  16. if (!this.table) {
  17. E.addClass("x-table-layout-ct");
  18. this.table = E.createChild({
  19. tag : "table",
  20. cls : "x-table-layout",
  21. cellspacing : 0,
  22. cn : {
  23. tag : "tbody"
  24. }
  25. }, null, true);
  26. this.renderAll(C, E)
  27. }
  28. },
  29. getRow : function(A) {
  30. var B = this.table.tBodies[0].childNodes[A];
  31. if (!B) {
  32. B = document.createElement("tr");
  33. this.table.tBodies[0].appendChild(B)
  34. }
  35. return B
  36. },
  37. getNextCell : function(E) {
  38. var D = document.createElement("td"), I, G;
  39. if (!this.columns) {
  40. I = this.getRow(0)
  41. } else {
  42. G = this.currentColumn;
  43. if (G !== 0 && (G % this.columns === 0)) {
  44. this.currentRow++;
  45. G = (E.colspan || 1)
  46. } else {
  47. G += (E.colspan || 1)
  48. }
  49. var H = this.getNextNonSpan(G, this.currentRow);
  50. this.currentColumn = H[0];
  51. if (H[1] != this.currentRow) {
  52. this.currentRow = H[1];
  53. if (E.colspan) {
  54. this.currentColumn += E.colspan - 1
  55. }
  56. }
  57. I = this.getRow(this.currentRow)
  58. }
  59. if (E.colspan) {
  60. D.colSpan = E.colspan
  61. }
  62. D.className = "x-table-layout-cell";
  63. if (E.rowspan) {
  64. D.rowSpan = E.rowspan;
  65. var F = this.currentRow, C = E.colspan || 1;
  66. for (var A = F + 1; A < F + E.rowspan; A++) {
  67. for (var B = this.currentColumn - C + 1; B <= this.currentColumn; B++) {
  68. if (!this.spanCells[B]) {
  69. this.spanCells[B] = []
  70. }
  71. this.spanCells[B][A] = 1
  72. }
  73. }
  74. }
  75. I.appendChild(D);
  76. return D
  77. },
  78. getNextNonSpan : function(A, E) {
  79. var D = (A <= this.columns ? A : this.columns), C = E;
  80. for (var B = D; B <= this.columns; B++) {
  81. if (this.spanCells[B] && this.spanCells[B][C]) {
  82. if (++D > this.columns) {
  83. return this.getNextNonSpan(1, ++C)
  84. }
  85. } else {
  86. break
  87. }
  88. }
  89. return [D, C]
  90. },
  91. renderItem : function(C, A, B) {
  92. if (C && !C.rendered) {
  93. C.render(this.getNextCell(C))
  94. }
  95. },
  96. isValidParent : function(B, A) {
  97. return true
  98. }
  99. });
  100. Ext.Container.LAYOUTS["table"] = Ext.layout.TableLayout;