Text2.html 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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-field-Text'>/**
  19. </span> * Layout class for {@link Ext.form.field.Text} fields. Handles sizing the input field.
  20. * @private
  21. */
  22. Ext.define('Ext.layout.component.field.Text', {
  23. extend: 'Ext.layout.component.field.Field',
  24. alias: 'layout.textfield',
  25. requires: ['Ext.util.TextMetrics'],
  26. type: 'textfield',
  27. canGrowWidth: true,
  28. beginLayoutCycle: function(ownerContext) {
  29. var me = this;
  30. me.callParent(arguments);
  31. // Clear height, in case a previous layout cycle stretched it.
  32. if (ownerContext.shrinkWrap) {
  33. ownerContext.inputContext.el.setStyle('height', '');
  34. }
  35. },
  36. measureContentWidth: function (ownerContext) {
  37. var me = this,
  38. owner = me.owner,
  39. width = me.callParent(arguments),
  40. inputContext = ownerContext.inputContext,
  41. inputEl, value, calcWidth, max, min;
  42. if (owner.grow &amp;&amp; me.canGrowWidth &amp;&amp; !ownerContext.state.growHandled) {
  43. inputEl = owner.inputEl;
  44. // Find the width that contains the whole text value
  45. value = Ext.util.Format.htmlEncode(inputEl.dom.value || (owner.hasFocus ? '' : owner.emptyText) || '');
  46. value += owner.growAppend;
  47. calcWidth = inputEl.getTextWidth(value) + inputContext.getFrameInfo().width;
  48. max = owner.growMax;
  49. min = Math.min(max, width);
  50. max = Math.max(owner.growMin, max, min);
  51. // Constrain
  52. calcWidth = Ext.Number.constrain(calcWidth, owner.growMin, max);
  53. inputContext.setWidth(calcWidth);
  54. ownerContext.state.growHandled = true;
  55. // Now that we've set the inputContext, we need to recalculate the width
  56. inputContext.domBlock(me, 'width');
  57. width = NaN;
  58. }
  59. return width;
  60. },
  61. publishInnerHeight: function(ownerContext, height) {
  62. ownerContext.inputContext.setHeight(height - this.measureLabelErrorHeight(ownerContext));
  63. },
  64. beginLayoutFixed: function(ownerContext, width, suffix) {
  65. var me = this,
  66. ieInputWidthAdjustment = me.ieInputWidthAdjustment;
  67. if (ieInputWidthAdjustment) {
  68. // adjust for IE 6/7 strict content-box model
  69. // RTL: This might have to be padding-left unless the senses of the padding styles switch when in RTL mode.
  70. me.owner.bodyEl.setStyle('padding-right', ieInputWidthAdjustment + 'px');
  71. if(suffix === 'px') {
  72. width -= ieInputWidthAdjustment;
  73. }
  74. }
  75. me.callParent(arguments);
  76. }
  77. });
  78. </pre>
  79. </body>
  80. </html>