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.

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