TextItem.html 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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-toolbar-TextItem-method-constructor'><span id='Ext-toolbar-TextItem'>/**
  19. </span></span> * A simple class that renders text directly into a toolbar.
  20. *
  21. * @example
  22. * Ext.create('Ext.panel.Panel', {
  23. * title: 'Panel with TextItem',
  24. * width: 300,
  25. * height: 200,
  26. * tbar: [
  27. * { xtype: 'tbtext', text: 'Sample Text Item' }
  28. * ],
  29. * renderTo: Ext.getBody()
  30. * });
  31. *
  32. * @constructor
  33. * Creates a new TextItem
  34. * @param {Object} text A text string, or a config object containing a #text property
  35. */
  36. Ext.define('Ext.toolbar.TextItem', {
  37. extend: 'Ext.toolbar.Item',
  38. requires: ['Ext.XTemplate'],
  39. alias: 'widget.tbtext',
  40. alternateClassName: 'Ext.Toolbar.TextItem',
  41. <span id='Ext-toolbar-TextItem-cfg-text'> /**
  42. </span> * @cfg {String} text
  43. * The text to be used as innerHTML (html tags are accepted).
  44. */
  45. text: '',
  46. renderTpl: '{text}',
  47. //
  48. baseCls: Ext.baseCSSPrefix + 'toolbar-text',
  49. beforeRender : function() {
  50. var me = this;
  51. me.callParent();
  52. Ext.apply(me.renderData, {
  53. text: me.text
  54. });
  55. },
  56. <span id='Ext-toolbar-TextItem-method-setText'> /**
  57. </span> * Updates this item's text, setting the text to be used as innerHTML.
  58. * @param {String} text The text to display (html accepted).
  59. */
  60. setText : function(text) {
  61. var me = this;
  62. if (me.rendered) {
  63. me.el.update(text);
  64. me.updateLayout();
  65. } else {
  66. this.text = text;
  67. }
  68. }
  69. });</pre>
  70. </body>
  71. </html>