Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
7.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.layout.TableLayout"></div>/**
  16. * @class Ext.layout.TableLayout
  17. * @extends Ext.layout.ContainerLayout
  18. * <p>This layout allows you to easily render content into an HTML table. The total number of columns can be
  19. * specified, and rowspan and colspan can be used to create complex layouts within the table.
  20. * This class is intended to be extended or created via the layout:'table' {@link Ext.Container#layout} config,
  21. * and should generally not need to be created directly via the new keyword.</p>
  22. * <p>Note that when creating a layout via config, the layout-specific config properties must be passed in via
  23. * the {@link Ext.Container#layoutConfig} object which will then be applied internally to the layout. In the
  24. * case of TableLayout, the only valid layout config property is {@link #columns}. However, the items added to a
  25. * TableLayout can supply the following table-specific config properties:</p>
  26. * <ul>
  27. * <li><b>rowspan</b> Applied to the table cell containing the item.</li>
  28. * <li><b>colspan</b> Applied to the table cell containing the item.</li>
  29. * <li><b>cellId</b> An id applied to the table cell containing the item.</li>
  30. * <li><b>cellCls</b> A CSS class name added to the table cell containing the item.</li>
  31. * </ul>
  32. * <p>The basic concept of building up a TableLayout is conceptually very similar to building up a standard
  33. * HTML table. You simply add each panel (or "cell") that you want to include along with any span attributes
  34. * specified as the special config properties of rowspan and colspan which work exactly like their HTML counterparts.
  35. * Rather than explicitly creating and nesting rows and columns as you would in HTML, you simply specify the
  36. * total column count in the layoutConfig and start adding panels in their natural order from left to right,
  37. * top to bottom. The layout will automatically figure out, based on the column count, rowspans and colspans,
  38. * how to position each panel within the table. Just like with HTML tables, your rowspans and colspans must add
  39. * up correctly in your overall layout or you'll end up with missing and/or extra cells! Example usage:</p>
  40. * <pre><code>
  41. // This code will generate a layout table that is 3 columns by 2 rows
  42. // with some spanning included. The basic layout will be:
  43. // +--------+-----------------+
  44. // | A | B |
  45. // | |--------+--------|
  46. // | | C | D |
  47. // +--------+--------+--------+
  48. var table = new Ext.Panel({
  49. title: 'Table Layout',
  50. layout:'table',
  51. defaults: {
  52. // applied to each contained panel
  53. bodyStyle:'padding:20px'
  54. },
  55. layoutConfig: {
  56. // The total column count must be specified here
  57. columns: 3
  58. },
  59. items: [{
  60. html: '&lt;p&gt;Cell A content&lt;/p&gt;',
  61. rowspan: 2
  62. },{
  63. html: '&lt;p&gt;Cell B content&lt;/p&gt;',
  64. colspan: 2
  65. },{
  66. html: '&lt;p&gt;Cell C content&lt;/p&gt;',
  67. cellCls: 'highlight'
  68. },{
  69. html: '&lt;p&gt;Cell D content&lt;/p&gt;'
  70. }]
  71. });
  72. </code></pre>
  73. */
  74. Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
  75. <div id="cfg-Ext.layout.TableLayout-columns"></div>/**
  76. * @cfg {Number} columns
  77. * The total number of columns to create in the table for this layout. If not specified, all Components added to
  78. * this layout will be rendered into a single row using one column per Component.
  79. */
  80. // private
  81. monitorResize:false,
  82. type: 'table',
  83. targetCls: 'x-table-layout-ct',
  84. <div id="cfg-Ext.layout.TableLayout-tableAttrs"></div>/**
  85. * @cfg {Object} tableAttrs
  86. * <p>An object containing properties which are added to the {@link Ext.DomHelper DomHelper} specification
  87. * used to create the layout's <tt>&lt;table&gt;</tt> element. Example:</p><pre><code>
  88. {
  89. xtype: 'panel',
  90. layout: 'table',
  91. layoutConfig: {
  92. tableAttrs: {
  93. style: {
  94. width: '100%'
  95. }
  96. },
  97. columns: 3
  98. }
  99. }</code></pre>
  100. */
  101. tableAttrs:null,
  102. // private
  103. setContainer : function(ct){
  104. Ext.layout.TableLayout.superclass.setContainer.call(this, ct);
  105. this.currentRow = 0;
  106. this.currentColumn = 0;
  107. this.cells = [];
  108. },
  109. // private
  110. onLayout : function(ct, target){
  111. var cs = ct.items.items, len = cs.length, c, i;
  112. if(!this.table){
  113. target.addClass('x-table-layout-ct');
  114. this.table = target.createChild(
  115. Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
  116. }
  117. this.renderAll(ct, target);
  118. },
  119. // private
  120. getRow : function(index){
  121. var row = this.table.tBodies[0].childNodes[index];
  122. if(!row){
  123. row = document.createElement('tr');
  124. this.table.tBodies[0].appendChild(row);
  125. }
  126. return row;
  127. },
  128. // private
  129. getNextCell : function(c){
  130. var cell = this.getNextNonSpan(this.currentColumn, this.currentRow);
  131. var curCol = this.currentColumn = cell[0], curRow = this.currentRow = cell[1];
  132. for(var rowIndex = curRow; rowIndex < curRow + (c.rowspan || 1); rowIndex++){
  133. if(!this.cells[rowIndex]){
  134. this.cells[rowIndex] = [];
  135. }
  136. for(var colIndex = curCol; colIndex < curCol + (c.colspan || 1); colIndex++){
  137. this.cells[rowIndex][colIndex] = true;
  138. }
  139. }
  140. var td = document.createElement('td');
  141. if(c.cellId){
  142. td.id = c.cellId;
  143. }
  144. var cls = 'x-table-layout-cell';
  145. if(c.cellCls){
  146. cls += ' ' + c.cellCls;
  147. }
  148. td.className = cls;
  149. if(c.colspan){
  150. td.colSpan = c.colspan;
  151. }
  152. if(c.rowspan){
  153. td.rowSpan = c.rowspan;
  154. }
  155. this.getRow(curRow).appendChild(td);
  156. return td;
  157. },
  158. // private
  159. getNextNonSpan: function(colIndex, rowIndex){
  160. var cols = this.columns;
  161. while((cols && colIndex >= cols) || (this.cells[rowIndex] && this.cells[rowIndex][colIndex])) {
  162. if(cols && colIndex >= cols){
  163. rowIndex++;
  164. colIndex = 0;
  165. }else{
  166. colIndex++;
  167. }
  168. }
  169. return [colIndex, rowIndex];
  170. },
  171. // private
  172. renderItem : function(c, position, target){
  173. // Ensure we have our inner table to get cells to render into.
  174. if(!this.table){
  175. this.table = target.createChild(
  176. Ext.apply({tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, this.tableAttrs), null, true);
  177. }
  178. if(c && !c.rendered){
  179. c.render(this.getNextCell(c));
  180. this.configureItem(c);
  181. }else if(c && !this.isValidParent(c, target)){
  182. var container = this.getNextCell(c);
  183. container.insertBefore(c.getPositionEl().dom, null);
  184. c.container = Ext.get(container);
  185. this.configureItem(c);
  186. }
  187. },
  188. // private
  189. isValidParent : function(c, target){
  190. return c.getPositionEl().up('table', 5).dom.parentNode === (target.dom || target);
  191. },
  192. destroy: function(){
  193. delete this.table;
  194. Ext.layout.TableLayout.superclass.destroy.call(this);
  195. }
  196. <div id="prop-Ext.layout.TableLayout-activeItem"></div>/**
  197. * @property activeItem
  198. * @hide
  199. */
  200. });
  201. Ext.Container.LAYOUTS['table'] = Ext.layout.TableLayout;</pre>
  202. </body>
  203. </html>