Body.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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-Body'>/**
  19. </span> * Component layout for components which maintain an inner body element which must be resized to synchronize with the
  20. * Component size.
  21. * @private
  22. */
  23. Ext.define('Ext.layout.component.Body', {
  24. /* Begin Definitions */
  25. alias: ['layout.body'],
  26. extend: 'Ext.layout.component.Auto',
  27. /* End Definitions */
  28. type: 'body',
  29. beginLayout: function (ownerContext) {
  30. this.callParent(arguments);
  31. ownerContext.bodyContext = ownerContext.getEl('body');
  32. },
  33. // Padding is exciting here because we have 2 el's: owner.el and owner.body. Content
  34. // size always includes the padding of the targetEl, which should be owner.body. But
  35. // it is common to have padding on owner.el also (such as a panel header), so we need
  36. // to do some more padding work if targetContext is not owner.el. The base class has
  37. // already handled the ownerContext's frameInfo (border+framing) so all that is left
  38. // is padding.
  39. calculateOwnerHeightFromContentHeight: function (ownerContext, contentHeight) {
  40. var height = this.callParent(arguments);
  41. if (ownerContext.targetContext != ownerContext) {
  42. height += ownerContext.getPaddingInfo().height;
  43. }
  44. return height;
  45. },
  46. calculateOwnerWidthFromContentWidth: function (ownerContext, contentWidth) {
  47. var width = this.callParent(arguments);
  48. if (ownerContext.targetContext != ownerContext) {
  49. width += ownerContext.getPaddingInfo().width;
  50. }
  51. return width;
  52. },
  53. measureContentWidth: function (ownerContext) {
  54. return ownerContext.bodyContext.setWidth(ownerContext.bodyContext.el.dom.offsetWidth, false);
  55. },
  56. measureContentHeight: function (ownerContext) {
  57. return ownerContext.bodyContext.setHeight(ownerContext.bodyContext.el.dom.offsetHeight, false);
  58. },
  59. publishInnerHeight: function (ownerContext, height) {
  60. var innerHeight = height - ownerContext.getFrameInfo().height,
  61. targetContext = ownerContext.targetContext;
  62. if (targetContext != ownerContext) {
  63. innerHeight -= ownerContext.getPaddingInfo().height;
  64. }
  65. // return the value here, it may get used in a subclass
  66. return ownerContext.bodyContext.setHeight(innerHeight, !ownerContext.heightModel.natural);
  67. },
  68. publishInnerWidth: function (ownerContext, width) {
  69. var innerWidth = width - ownerContext.getFrameInfo().width,
  70. targetContext = ownerContext.targetContext;
  71. if (targetContext != ownerContext) {
  72. innerWidth -= ownerContext.getPaddingInfo().width;
  73. }
  74. ownerContext.bodyContext.setWidth(innerWidth, !ownerContext.widthModel.natural);
  75. }
  76. });
  77. </pre>
  78. </body>
  79. </html>