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.

77 lines
3.4 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-Label-method-constructor'><span id='Ext-form-Label'>/**
  19. </span></span> * @class Ext.form.Label
  20. * @extends Ext.BoxComponent
  21. * Basic Label field.
  22. * @constructor
  23. * Creates a new Label
  24. * @param {Ext.Element/String/Object} config The configuration options. If an element is passed, it is set as the internal
  25. * element and its id used as the component id. If a string is passed, it is assumed to be the id of an existing element
  26. * and is used as the component id. Otherwise, it is assumed to be a standard config object and is applied to the component.
  27. * @xtype label
  28. */
  29. Ext.form.Label = Ext.extend(Ext.BoxComponent, {
  30. <span id='Ext-form-Label-cfg-text'> /**
  31. </span> * @cfg {String} text The plain text to display within the label (defaults to ''). If you need to include HTML
  32. * tags within the label's innerHTML, use the {@link #html} config instead.
  33. */
  34. <span id='Ext-form-Label-cfg-forId'> /**
  35. </span> * @cfg {String} forId The id of the input element to which this label will be bound via the standard HTML 'for'
  36. * attribute. If not specified, the attribute will not be added to the label.
  37. */
  38. <span id='Ext-form-Label-cfg-html'> /**
  39. </span> * @cfg {String} html An HTML fragment that will be used as the label's innerHTML (defaults to '').
  40. * Note that if {@link #text} is specified it will take precedence and this value will be ignored.
  41. */
  42. <span id='Ext-form-Label-method-onRender'> // private
  43. </span> onRender : function(ct, position){
  44. if(!this.el){
  45. this.el = document.createElement('label');
  46. this.el.id = this.getId();
  47. this.el.innerHTML = this.text ? Ext.util.Format.htmlEncode(this.text) : (this.html || '');
  48. if(this.forId){
  49. this.el.setAttribute('for', this.forId);
  50. }
  51. }
  52. Ext.form.Label.superclass.onRender.call(this, ct, position);
  53. },
  54. <span id='Ext-form-Label-method-setText'> /**
  55. </span> * Updates the label's innerHTML with the specified string.
  56. * @param {String} text The new label text
  57. * @param {Boolean} encode (optional) False to skip HTML-encoding the text when rendering it
  58. * to the label (defaults to true which encodes the value). This might be useful if you want to include
  59. * tags in the label's innerHTML rather than rendering them as string literals per the default logic.
  60. * @return {Label} this
  61. */
  62. setText : function(t, encode){
  63. var e = encode === false;
  64. this[!e ? 'text' : 'html'] = t;
  65. delete this[e ? 'text' : 'html'];
  66. if(this.rendered){
  67. this.el.dom.innerHTML = encode !== false ? Ext.util.Format.htmlEncode(t) : t;
  68. }
  69. return this;
  70. }
  71. });
  72. Ext.reg('label', Ext.form.Label);</pre>
  73. </body>
  74. </html>