TextArea.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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-TextArea'>/**
  19. </span> * Layout class for {@link Ext.form.field.TextArea} fields. Handles sizing the textarea field.
  20. * @private
  21. */
  22. Ext.define('Ext.layout.component.field.TextArea', {
  23. extend: 'Ext.layout.component.field.Text',
  24. alias: 'layout.textareafield',
  25. type: 'textareafield',
  26. canGrowWidth: false,
  27. naturalSizingProp: 'cols',
  28. beginLayout: function(ownerContext){
  29. this.callParent(arguments);
  30. ownerContext.target.inputEl.setStyle('height', '');
  31. },
  32. measureContentHeight: function (ownerContext) {
  33. var me = this,
  34. owner = me.owner,
  35. height = me.callParent(arguments),
  36. inputContext, inputEl, value, max, curWidth, calcHeight;
  37. if (owner.grow &amp;&amp; !ownerContext.state.growHandled) {
  38. inputContext = ownerContext.inputContext;
  39. inputEl = owner.inputEl;
  40. curWidth = inputEl.getWidth(true); //subtract border/padding to get the available width for the text
  41. // Get and normalize the field value for measurement
  42. value = Ext.util.Format.htmlEncode(inputEl.dom.value) || '&amp;#160;';
  43. value += owner.growAppend;
  44. // Translate newlines to &lt;br&gt; tags
  45. value = value.replace(/\n/g, '&lt;br/&gt;');
  46. // Find the height that contains the whole text value
  47. calcHeight = Ext.util.TextMetrics.measure(inputEl, value, curWidth).height +
  48. inputContext.getBorderInfo().height + inputContext.getPaddingInfo().height;
  49. // Constrain
  50. calcHeight = Ext.Number.constrain(calcHeight, owner.growMin, owner.growMax);
  51. inputContext.setHeight(calcHeight);
  52. ownerContext.state.growHandled = true;
  53. // Now that we've set the inputContext, we need to recalculate the width
  54. inputContext.domBlock(me, 'height');
  55. height = NaN;
  56. }
  57. return height;
  58. }
  59. });
  60. </pre>
  61. </body>
  62. </html>