Editor.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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-container-Editor'>/**
  19. </span> * Component layout for editors
  20. * @private
  21. */
  22. Ext.define('Ext.layout.container.Editor', {
  23. /* Begin Definitions */
  24. alias: 'layout.editor',
  25. extend: 'Ext.layout.container.Container',
  26. /* End Definitions */
  27. autoSizeDefault: {
  28. width: 'field',
  29. height: 'field'
  30. },
  31. getItemSizePolicy: function (item) {
  32. var me = this,
  33. autoSize = me.owner.autoSize;
  34. return me.sizePolicy || (me.sizePolicy = {
  35. setsWidth: autoSize &amp;&amp; autoSize.width === 'boundEl' ? 1 : 0,
  36. setsHeight: autoSize &amp;&amp; autoSize.height === 'boundEl' ? 1 : 0
  37. });
  38. },
  39. calculate: function(ownerContext) {
  40. var me = this,
  41. owner = me.owner,
  42. autoSize = owner.autoSize,
  43. fieldWidth,
  44. fieldHeight;
  45. if (autoSize === true) {
  46. autoSize = me.autoSizeDefault;
  47. }
  48. // Calculate size of both Editor, and its owned Field
  49. if (autoSize) {
  50. fieldWidth = me.getDimension(owner, autoSize.width, 'getWidth', owner.width);
  51. fieldHeight = me.getDimension(owner, autoSize.height, 'getHeight', owner.height);
  52. }
  53. // Set Field size
  54. ownerContext.childItems[0].setSize(fieldWidth, fieldHeight);
  55. // Bypass validity checking. Container layouts should not usually set their owner's size.
  56. ownerContext.setWidth(fieldWidth);
  57. ownerContext.setHeight(fieldHeight);
  58. // This is a Container layout, so publish content size
  59. ownerContext.setContentSize(fieldWidth || owner.field.getWidth(),
  60. fieldHeight || owner.field.getHeight());
  61. },
  62. getDimension: function(owner, type, getMethod, ownerSize){
  63. switch (type) {
  64. // Size to boundEl's dimension
  65. case 'boundEl':
  66. return owner.boundEl[getMethod]();
  67. // Auto size (shrink wrap the Field's size
  68. case 'field':
  69. return undefined;
  70. // Size to the Editor's configured size
  71. default:
  72. return ownerSize;
  73. }
  74. }
  75. });</pre>
  76. </body>
  77. </html>