You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
5.5 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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-form-TextArea-method-constructor'><span id='Ext-form-TextArea'>/**
  19. </span></span> * @class Ext.form.TextArea
  20. * @extends Ext.form.TextField
  21. * Multiline text field. Can be used as a direct replacement for traditional textarea fields, plus adds
  22. * support for auto-sizing.
  23. * @constructor
  24. * Creates a new TextArea
  25. * @param {Object} config Configuration options
  26. * @xtype textarea
  27. */
  28. Ext.form.TextArea = Ext.extend(Ext.form.TextField, {
  29. <span id='Ext-form-TextArea-cfg-growMin'> /**
  30. </span> * @cfg {Number} growMin The minimum height to allow when &lt;tt&gt;{@link Ext.form.TextField#grow grow}=true&lt;/tt&gt;
  31. * (defaults to &lt;tt&gt;60&lt;/tt&gt;)
  32. */
  33. growMin : 60,
  34. <span id='Ext-form-TextArea-cfg-growMax'> /**
  35. </span> * @cfg {Number} growMax The maximum height to allow when &lt;tt&gt;{@link Ext.form.TextField#grow grow}=true&lt;/tt&gt;
  36. * (defaults to &lt;tt&gt;1000&lt;/tt&gt;)
  37. */
  38. growMax: 1000,
  39. <span id='Ext-form-TextArea-property-growAppend'> growAppend : '&amp;#160;\n&amp;#160;',
  40. </span>
  41. <span id='Ext-form-TextArea-property-enterIsSpecial'> enterIsSpecial : false,
  42. </span>
  43. <span id='Ext-form-TextArea-cfg-preventScrollbars'> /**
  44. </span> * @cfg {Boolean} preventScrollbars &lt;tt&gt;true&lt;/tt&gt; to prevent scrollbars from appearing regardless of how much text is
  45. * in the field. This option is only relevant when {@link #grow} is &lt;tt&gt;true&lt;/tt&gt;. Equivalent to setting overflow: hidden, defaults to
  46. * &lt;tt&gt;false&lt;/tt&gt;.
  47. */
  48. preventScrollbars: false,
  49. <span id='Ext-form-TextArea-cfg-autoCreate'> /**
  50. </span> * @cfg {String/Object} autoCreate &lt;p&gt;A {@link Ext.DomHelper DomHelper} element spec, or true for a default
  51. * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.
  52. * See &lt;tt&gt;{@link Ext.Component#autoEl autoEl}&lt;/tt&gt; for details. Defaults to:&lt;/p&gt;
  53. * &lt;pre&gt;&lt;code&gt;{tag: &quot;textarea&quot;, style: &quot;width:100px;height:60px;&quot;, autocomplete: &quot;off&quot;}&lt;/code&gt;&lt;/pre&gt;
  54. */
  55. <span id='Ext-form-TextArea-method-onRender'> // private
  56. </span> onRender : function(ct, position){
  57. if(!this.el){
  58. this.defaultAutoCreate = {
  59. tag: &quot;textarea&quot;,
  60. style:&quot;width:100px;height:60px;&quot;,
  61. autocomplete: &quot;off&quot;
  62. };
  63. }
  64. Ext.form.TextArea.superclass.onRender.call(this, ct, position);
  65. if(this.grow){
  66. this.textSizeEl = Ext.DomHelper.append(document.body, {
  67. tag: &quot;pre&quot;, cls: &quot;x-form-grow-sizer&quot;
  68. });
  69. if(this.preventScrollbars){
  70. this.el.setStyle(&quot;overflow&quot;, &quot;hidden&quot;);
  71. }
  72. this.el.setHeight(this.growMin);
  73. }
  74. },
  75. <span id='Ext-form-TextArea-method-onDestroy'> onDestroy : function(){
  76. </span> Ext.removeNode(this.textSizeEl);
  77. Ext.form.TextArea.superclass.onDestroy.call(this);
  78. },
  79. <span id='Ext-form-TextArea-method-fireKey'> fireKey : function(e){
  80. </span> if(e.isSpecialKey() &amp;&amp; (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){
  81. this.fireEvent(&quot;specialkey&quot;, this, e);
  82. }
  83. },
  84. <span id='Ext-form-TextArea-method-doAutoSize'> // private
  85. </span> doAutoSize : function(e){
  86. return !e.isNavKeyPress() || e.getKey() == e.ENTER;
  87. },
  88. <span id='Ext-form-TextArea-method-filterValidation'> // inherit docs
  89. </span> filterValidation: function(e) {
  90. if(!e.isNavKeyPress() || (!this.enterIsSpecial &amp;&amp; e.keyCode == e.ENTER)){
  91. this.validationTask.delay(this.validationDelay);
  92. }
  93. },
  94. <span id='Ext-form-TextArea-method-autoSize'> /**
  95. </span> * Automatically grows the field to accomodate the height of the text up to the maximum field height allowed.
  96. * This only takes effect if grow = true, and fires the {@link #autosize} event if the height changes.
  97. */
  98. autoSize: function(){
  99. if(!this.grow || !this.textSizeEl){
  100. return;
  101. }
  102. var el = this.el,
  103. v = Ext.util.Format.htmlEncode(el.dom.value),
  104. ts = this.textSizeEl,
  105. h;
  106. Ext.fly(ts).setWidth(this.el.getWidth());
  107. if(v.length &lt; 1){
  108. v = &quot;&amp;#160;&amp;#160;&quot;;
  109. }else{
  110. v += this.growAppend;
  111. if(Ext.isIE){
  112. v = v.replace(/\n/g, '&amp;#160;&lt;br /&gt;');
  113. }
  114. }
  115. ts.innerHTML = v;
  116. h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin));
  117. if(h != this.lastHeight){
  118. this.lastHeight = h;
  119. this.el.setHeight(h);
  120. this.fireEvent(&quot;autosize&quot;, this, h);
  121. }
  122. }
  123. });
  124. Ext.reg('textarea', Ext.form.TextArea);</pre>
  125. </body>
  126. </html>