Web UI for ARGUS server
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.

186 lines
6.6 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.ColumnLayout"></div>/**
  16. * @class Ext.layout.ColumnLayout
  17. * @extends Ext.layout.ContainerLayout
  18. * <p>This is the layout style of choice for creating structural layouts in a multi-column format where the width of
  19. * each column can be specified as a percentage or fixed width, but the height is allowed to vary based on the content.
  20. * This class is intended to be extended or created via the layout:'column' {@link Ext.Container#layout} config,
  21. * and should generally not need to be created directly via the new keyword.</p>
  22. * <p>ColumnLayout does not have any direct config options (other than inherited ones), but it does support a
  23. * specific config property of <b><tt>columnWidth</tt></b> that can be included in the config of any panel added to it. The
  24. * layout will use the columnWidth (if present) or width of each panel during layout to determine how to size each panel.
  25. * If width or columnWidth is not specified for a given panel, its width will default to the panel's width (or auto).</p>
  26. * <p>The width property is always evaluated as pixels, and must be a number greater than or equal to 1.
  27. * The columnWidth property is always evaluated as a percentage, and must be a decimal value greater than 0 and
  28. * less than 1 (e.g., .25).</p>
  29. * <p>The basic rules for specifying column widths are pretty simple. The logic makes two passes through the
  30. * set of contained panels. During the first layout pass, all panels that either have a fixed width or none
  31. * specified (auto) are skipped, but their widths are subtracted from the overall container width. During the second
  32. * pass, all panels with columnWidths are assigned pixel widths in proportion to their percentages based on
  33. * the total <b>remaining</b> container width. In other words, percentage width panels are designed to fill the space
  34. * left over by all the fixed-width and/or auto-width panels. Because of this, while you can specify any number of columns
  35. * with different percentages, the columnWidths must always add up to 1 (or 100%) when added together, otherwise your
  36. * layout may not render as expected. Example usage:</p>
  37. * <pre><code>
  38. // All columns are percentages -- they must add up to 1
  39. var p = new Ext.Panel({
  40. title: 'Column Layout - Percentage Only',
  41. layout:'column',
  42. items: [{
  43. title: 'Column 1',
  44. columnWidth: .25
  45. },{
  46. title: 'Column 2',
  47. columnWidth: .6
  48. },{
  49. title: 'Column 3',
  50. columnWidth: .15
  51. }]
  52. });
  53. // Mix of width and columnWidth -- all columnWidth values must add up
  54. // to 1. The first column will take up exactly 120px, and the last two
  55. // columns will fill the remaining container width.
  56. var p = new Ext.Panel({
  57. title: 'Column Layout - Mixed',
  58. layout:'column',
  59. items: [{
  60. title: 'Column 1',
  61. width: 120
  62. },{
  63. title: 'Column 2',
  64. columnWidth: .8
  65. },{
  66. title: 'Column 3',
  67. columnWidth: .2
  68. }]
  69. });
  70. </code></pre>
  71. */
  72. Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {
  73. // private
  74. monitorResize:true,
  75. type: 'column',
  76. extraCls: 'x-column',
  77. scrollOffset : 0,
  78. // private
  79. targetCls: 'x-column-layout-ct',
  80. isValidParent : function(c, target){
  81. return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;
  82. },
  83. getLayoutTargetSize : function() {
  84. var target = this.container.getLayoutTarget(), ret;
  85. if (target) {
  86. ret = target.getViewSize();
  87. // IE in strict mode will return a width of 0 on the 1st pass of getViewSize.
  88. // Use getStyleSize to verify the 0 width, the adjustment pass will then work properly
  89. // with getViewSize
  90. if (Ext.isIE && Ext.isStrict && ret.width == 0){
  91. ret = target.getStyleSize();
  92. }
  93. ret.width -= target.getPadding('lr');
  94. ret.height -= target.getPadding('tb');
  95. }
  96. return ret;
  97. },
  98. renderAll : function(ct, target) {
  99. if(!this.innerCt){
  100. // the innerCt prevents wrapping and shuffling while
  101. // the container is resizing
  102. this.innerCt = target.createChild({cls:'x-column-inner'});
  103. this.innerCt.createChild({cls:'x-clear'});
  104. }
  105. Ext.layout.ColumnLayout.superclass.renderAll.call(this, ct, this.innerCt);
  106. },
  107. // private
  108. onLayout : function(ct, target){
  109. var cs = ct.items.items,
  110. len = cs.length,
  111. c,
  112. i,
  113. m,
  114. margins = [];
  115. this.renderAll(ct, target);
  116. var size = this.getLayoutTargetSize();
  117. if(size.width < 1 && size.height < 1){ // display none?
  118. return;
  119. }
  120. var w = size.width - this.scrollOffset,
  121. h = size.height,
  122. pw = w;
  123. this.innerCt.setWidth(w);
  124. // some columns can be percentages while others are fixed
  125. // so we need to make 2 passes
  126. for(i = 0; i < len; i++){
  127. c = cs[i];
  128. m = c.getPositionEl().getMargins('lr');
  129. margins[i] = m;
  130. if(!c.columnWidth){
  131. pw -= (c.getWidth() + m);
  132. }
  133. }
  134. pw = pw < 0 ? 0 : pw;
  135. for(i = 0; i < len; i++){
  136. c = cs[i];
  137. m = margins[i];
  138. if(c.columnWidth){
  139. c.setSize(Math.floor(c.columnWidth * pw) - m);
  140. }
  141. }
  142. // Browsers differ as to when they account for scrollbars. We need to re-measure to see if the scrollbar
  143. // spaces were accounted for properly. If not, re-layout.
  144. if (Ext.isIE) {
  145. if (i = target.getStyle('overflow') && i != 'hidden' && !this.adjustmentPass) {
  146. var ts = this.getLayoutTargetSize();
  147. if (ts.width != size.width){
  148. this.adjustmentPass = true;
  149. this.onLayout(ct, target);
  150. }
  151. }
  152. }
  153. delete this.adjustmentPass;
  154. }
  155. <div id="prop-Ext.layout.ColumnLayout-activeItem"></div>/**
  156. * @property activeItem
  157. * @hide
  158. */
  159. });
  160. Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;
  161. </pre>
  162. </body>
  163. </html>