FieldSet.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-layout-component-FieldSet'>/**
  19. </span> * Component layout for Ext.form.FieldSet components
  20. * @private
  21. */
  22. Ext.define('Ext.layout.component.FieldSet', {
  23. extend: 'Ext.layout.component.Body',
  24. alias: ['layout.fieldset'],
  25. type: 'fieldset',
  26. beforeLayoutCycle: function (ownerContext) {
  27. if (ownerContext.target.collapsed) {
  28. ownerContext.heightModel = this.sizeModels.shrinkWrap;
  29. }
  30. },
  31. beginLayoutCycle: function (ownerContext) {
  32. var target = ownerContext.target,
  33. lastSize;
  34. this.callParent(arguments);
  35. // Each time we begin (2nd+ would be due to invalidate) we need to publish the
  36. // known contentHeight if we are collapsed:
  37. //
  38. if (target.collapsed) {
  39. ownerContext.setContentHeight(0);
  40. // If we are also shrinkWrap width, we must provide a contentWidth (since the
  41. // container layout is not going to run).
  42. //
  43. if (ownerContext.widthModel.shrinkWrap) {
  44. lastSize = target.lastComponentSize;
  45. ownerContext.setContentWidth((lastSize &amp;&amp; lastSize.contentWidth) || 100);
  46. }
  47. }
  48. },
  49. calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {
  50. var border = ownerContext.getBorderInfo(),
  51. legend = ownerContext.target.legend;
  52. // Height of fieldset is content height plus top border width (which is either the legend height or top border width) plus bottom border width
  53. return ownerContext.getProp('contentHeight') + ownerContext.getPaddingInfo().height + (legend ? legend.getHeight() : border.top) + border.bottom;
  54. },
  55. publishInnerHeight: function (ownerContext, height) {
  56. // Subtract the legend off here and pass it up to the body
  57. // We do this because we don't want to set an incorrect body height
  58. // and then setting it again with the correct value
  59. var legend = ownerContext.target.legend;
  60. if (legend) {
  61. height -= legend.getHeight();
  62. }
  63. this.callParent([ownerContext, height]);
  64. },
  65. getLayoutItems : function() {
  66. var legend = this.owner.legend;
  67. if (legend) {
  68. return [legend];
  69. }
  70. return [];
  71. }
  72. });</pre>
  73. </body>
  74. </html>