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.

599 lines
21 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-Toolbar-method-constructor'><span id='Ext-Toolbar'>/**
  19. </span></span> * @class Ext.Toolbar
  20. * @extends Ext.Container
  21. * &lt;p&gt;Basic Toolbar class. Although the &lt;tt&gt;{@link Ext.Container#defaultType defaultType}&lt;/tt&gt; for Toolbar
  22. * is &lt;tt&gt;{@link Ext.Button button}&lt;/tt&gt;, Toolbar elements (child items for the Toolbar container) may
  23. * be virtually any type of Component. Toolbar elements can be created explicitly via their constructors,
  24. * or implicitly via their xtypes, and can be &lt;tt&gt;{@link #add}&lt;/tt&gt;ed dynamically.&lt;/p&gt;
  25. * &lt;p&gt;Some items have shortcut strings for creation:&lt;/p&gt;
  26. * &lt;pre&gt;
  27. &lt;u&gt;Shortcut&lt;/u&gt; &lt;u&gt;xtype&lt;/u&gt; &lt;u&gt;Class&lt;/u&gt; &lt;u&gt;Description&lt;/u&gt;
  28. '-&gt;' 'tbfill' {@link Ext.Toolbar.Fill} begin using the right-justified button container
  29. '-' 'tbseparator' {@link Ext.Toolbar.Separator} add a vertical separator bar between toolbar items
  30. ' ' 'tbspacer' {@link Ext.Toolbar.Spacer} add horiztonal space between elements
  31. * &lt;/pre&gt;
  32. *
  33. * Example usage of various elements:
  34. * &lt;pre&gt;&lt;code&gt;
  35. var tb = new Ext.Toolbar({
  36. renderTo: document.body,
  37. width: 600,
  38. height: 100,
  39. items: [
  40. {
  41. // xtype: 'button', // default for Toolbars, same as 'tbbutton'
  42. text: 'Button'
  43. },
  44. {
  45. xtype: 'splitbutton', // same as 'tbsplitbutton'
  46. text: 'Split Button'
  47. },
  48. // begin using the right-justified button container
  49. '-&gt;', // same as {xtype: 'tbfill'}, // Ext.Toolbar.Fill
  50. {
  51. xtype: 'textfield',
  52. name: 'field1',
  53. emptyText: 'enter search term'
  54. },
  55. // add a vertical separator bar between toolbar items
  56. '-', // same as {xtype: 'tbseparator'} to create Ext.Toolbar.Separator
  57. 'text 1', // same as {xtype: 'tbtext', text: 'text1'} to create Ext.Toolbar.TextItem
  58. {xtype: 'tbspacer'},// same as ' ' to create Ext.Toolbar.Spacer
  59. 'text 2',
  60. {xtype: 'tbspacer', width: 50}, // add a 50px space
  61. 'text 3'
  62. ]
  63. });
  64. * &lt;/code&gt;&lt;/pre&gt;
  65. * Example adding a ComboBox within a menu of a button:
  66. * &lt;pre&gt;&lt;code&gt;
  67. // ComboBox creation
  68. var combo = new Ext.form.ComboBox({
  69. store: new Ext.data.ArrayStore({
  70. autoDestroy: true,
  71. fields: ['initials', 'fullname'],
  72. data : [
  73. ['FF', 'Fred Flintstone'],
  74. ['BR', 'Barney Rubble']
  75. ]
  76. }),
  77. displayField: 'fullname',
  78. typeAhead: true,
  79. mode: 'local',
  80. forceSelection: true,
  81. triggerAction: 'all',
  82. emptyText: 'Select a name...',
  83. selectOnFocus: true,
  84. width: 135,
  85. getListParent: function() {
  86. return this.el.up('.x-menu');
  87. },
  88. iconCls: 'no-icon' //use iconCls if placing within menu to shift to right side of menu
  89. });
  90. // put ComboBox in a Menu
  91. var menu = new Ext.menu.Menu({
  92. id: 'mainMenu',
  93. items: [
  94. combo // A Field in a Menu
  95. ]
  96. });
  97. // add a Button with the menu
  98. tb.add({
  99. text:'Button w/ Menu',
  100. menu: menu // assign menu by instance
  101. });
  102. tb.doLayout();
  103. * &lt;/code&gt;&lt;/pre&gt;
  104. * @constructor
  105. * Creates a new Toolbar
  106. * @param {Object/Array} config A config object or an array of buttons to &lt;tt&gt;{@link #add}&lt;/tt&gt;
  107. * @xtype toolbar
  108. */
  109. Ext.Toolbar = function(config){
  110. if(Ext.isArray(config)){
  111. config = {items: config, layout: 'toolbar'};
  112. } else {
  113. config = Ext.apply({
  114. layout: 'toolbar'
  115. }, config);
  116. if(config.buttons) {
  117. config.items = config.buttons;
  118. }
  119. }
  120. Ext.Toolbar.superclass.constructor.call(this, config);
  121. };
  122. (function(){
  123. var T = Ext.Toolbar;
  124. Ext.extend(T, Ext.Container, {
  125. defaultType: 'button',
  126. <span id='Ext-Toolbar-cfg-layout'> /**
  127. </span> * @cfg {String/Object} layout
  128. * This class assigns a default layout (&lt;code&gt;layout:'&lt;b&gt;toolbar&lt;/b&gt;'&lt;/code&gt;).
  129. * Developers &lt;i&gt;may&lt;/i&gt; override this configuration option if another layout
  130. * is required (the constructor must be passed a configuration object in this
  131. * case instead of an array).
  132. * See {@link Ext.Container#layout} for additional information.
  133. */
  134. enableOverflow : false,
  135. <span id='Ext-Toolbar-cfg-enableOverflow'> /**
  136. </span> * @cfg {Boolean} enableOverflow
  137. * Defaults to false. Configure &lt;tt&gt;true&lt;/tt&gt; to make the toolbar provide a button
  138. * which activates a dropdown Menu to show items which overflow the Toolbar's width.
  139. */
  140. <span id='Ext-Toolbar-cfg-buttonAlign'> /**
  141. </span> * @cfg {String} buttonAlign
  142. * &lt;p&gt;The default position at which to align child items. Defaults to &lt;code&gt;&quot;left&quot;&lt;/code&gt;&lt;/p&gt;
  143. * &lt;p&gt;May be specified as &lt;code&gt;&quot;center&quot;&lt;/code&gt; to cause items added before a Fill (A &lt;code&gt;&quot;-&gt;&quot;&lt;/code&gt;) item
  144. * to be centered in the Toolbar. Items added after a Fill are still right-aligned.&lt;/p&gt;
  145. * &lt;p&gt;Specify as &lt;code&gt;&quot;right&quot;&lt;/code&gt; to right align all child items.&lt;/p&gt;
  146. */
  147. trackMenus : true,
  148. internalDefaults: {removeMode: 'container', hideParent: true},
  149. toolbarCls: 'x-toolbar',
  150. initComponent : function(){
  151. T.superclass.initComponent.call(this);
  152. <span id='Ext-Toolbar-event-overflowchange'> /**
  153. </span> * @event overflowchange
  154. * Fires after the overflow state has changed.
  155. * @param {Object} c The Container
  156. * @param {Boolean} lastOverflow overflow state
  157. */
  158. this.addEvents('overflowchange');
  159. },
  160. // private
  161. onRender : function(ct, position){
  162. if(!this.el){
  163. if(!this.autoCreate){
  164. this.autoCreate = {
  165. cls: this.toolbarCls + ' x-small-editor'
  166. };
  167. }
  168. this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);
  169. Ext.Toolbar.superclass.onRender.apply(this, arguments);
  170. }
  171. },
  172. <span id='Ext-Toolbar-method-add'> /**
  173. </span> * &lt;p&gt;Adds element(s) to the toolbar -- this function takes a variable number of
  174. * arguments of mixed type and adds them to the toolbar.&lt;/p&gt;
  175. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  176. * @param {Mixed} arg1 The following types of arguments are all valid:&lt;br /&gt;
  177. * &lt;ul&gt;
  178. * &lt;li&gt;{@link Ext.Button} config: A valid button config object (equivalent to {@link #addButton})&lt;/li&gt;
  179. * &lt;li&gt;HtmlElement: Any standard HTML element (equivalent to {@link #addElement})&lt;/li&gt;
  180. * &lt;li&gt;Field: Any form field (equivalent to {@link #addField})&lt;/li&gt;
  181. * &lt;li&gt;Item: Any subclass of {@link Ext.Toolbar.Item} (equivalent to {@link #addItem})&lt;/li&gt;
  182. * &lt;li&gt;String: Any generic string (gets wrapped in a {@link Ext.Toolbar.TextItem}, equivalent to {@link #addText}).
  183. * Note that there are a few special strings that are treated differently as explained next.&lt;/li&gt;
  184. * &lt;li&gt;'-': Creates a separator element (equivalent to {@link #addSeparator})&lt;/li&gt;
  185. * &lt;li&gt;' ': Creates a spacer element (equivalent to {@link #addSpacer})&lt;/li&gt;
  186. * &lt;li&gt;'-&gt;': Creates a fill element (equivalent to {@link #addFill})&lt;/li&gt;
  187. * &lt;/ul&gt;
  188. * @param {Mixed} arg2
  189. * @param {Mixed} etc.
  190. * @method add
  191. */
  192. // private
  193. lookupComponent : function(c){
  194. if(Ext.isString(c)){
  195. if(c == '-'){
  196. c = new T.Separator();
  197. }else if(c == ' '){
  198. c = new T.Spacer();
  199. }else if(c == '-&gt;'){
  200. c = new T.Fill();
  201. }else{
  202. c = new T.TextItem(c);
  203. }
  204. this.applyDefaults(c);
  205. }else{
  206. if(c.isFormField || c.render){ // some kind of form field, some kind of Toolbar.Item
  207. c = this.createComponent(c);
  208. }else if(c.tag){ // DomHelper spec
  209. c = new T.Item({autoEl: c});
  210. }else if(c.tagName){ // element
  211. c = new T.Item({el:c});
  212. }else if(Ext.isObject(c)){ // must be button config?
  213. c = c.xtype ? this.createComponent(c) : this.constructButton(c);
  214. }
  215. }
  216. return c;
  217. },
  218. // private
  219. applyDefaults : function(c){
  220. if(!Ext.isString(c)){
  221. c = Ext.Toolbar.superclass.applyDefaults.call(this, c);
  222. var d = this.internalDefaults;
  223. if(c.events){
  224. Ext.applyIf(c.initialConfig, d);
  225. Ext.apply(c, d);
  226. }else{
  227. Ext.applyIf(c, d);
  228. }
  229. }
  230. return c;
  231. },
  232. <span id='Ext-Toolbar-method-addSeparator'> /**
  233. </span> * Adds a separator
  234. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  235. * @return {Ext.Toolbar.Item} The separator {@link Ext.Toolbar.Item item}
  236. */
  237. addSeparator : function(){
  238. return this.add(new T.Separator());
  239. },
  240. <span id='Ext-Toolbar-method-addSpacer'> /**
  241. </span> * Adds a spacer element
  242. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  243. * @return {Ext.Toolbar.Spacer} The spacer item
  244. */
  245. addSpacer : function(){
  246. return this.add(new T.Spacer());
  247. },
  248. <span id='Ext-Toolbar-method-addFill'> /**
  249. </span> * Forces subsequent additions into the float:right toolbar
  250. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  251. */
  252. addFill : function(){
  253. this.add(new T.Fill());
  254. },
  255. <span id='Ext-Toolbar-method-addElement'> /**
  256. </span> * Adds any standard HTML element to the toolbar
  257. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  258. * @param {Mixed} el The element or id of the element to add
  259. * @return {Ext.Toolbar.Item} The element's item
  260. */
  261. addElement : function(el){
  262. return this.addItem(new T.Item({el:el}));
  263. },
  264. <span id='Ext-Toolbar-method-addItem'> /**
  265. </span> * Adds any Toolbar.Item or subclass
  266. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  267. * @param {Ext.Toolbar.Item} item
  268. * @return {Ext.Toolbar.Item} The item
  269. */
  270. addItem : function(item){
  271. return this.add.apply(this, arguments);
  272. },
  273. <span id='Ext-Toolbar-method-addButton'> /**
  274. </span> * Adds a button (or buttons). See {@link Ext.Button} for more info on the config.
  275. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  276. * @param {Object/Array} config A button config or array of configs
  277. * @return {Ext.Button/Array}
  278. */
  279. addButton : function(config){
  280. if(Ext.isArray(config)){
  281. var buttons = [];
  282. for(var i = 0, len = config.length; i &lt; len; i++) {
  283. buttons.push(this.addButton(config[i]));
  284. }
  285. return buttons;
  286. }
  287. return this.add(this.constructButton(config));
  288. },
  289. <span id='Ext-Toolbar-method-addText'> /**
  290. </span> * Adds text to the toolbar
  291. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  292. * @param {String} text The text to add
  293. * @return {Ext.Toolbar.Item} The element's item
  294. */
  295. addText : function(text){
  296. return this.addItem(new T.TextItem(text));
  297. },
  298. <span id='Ext-Toolbar-method-addDom'> /**
  299. </span> * Adds a new element to the toolbar from the passed {@link Ext.DomHelper} config
  300. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  301. * @param {Object} config
  302. * @return {Ext.Toolbar.Item} The element's item
  303. */
  304. addDom : function(config){
  305. return this.add(new T.Item({autoEl: config}));
  306. },
  307. <span id='Ext-Toolbar-method-addField'> /**
  308. </span> * Adds a dynamically rendered Ext.form field (TextField, ComboBox, etc). Note: the field should not have
  309. * been rendered yet. For a field that has already been rendered, use {@link #addElement}.
  310. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  311. * @param {Ext.form.Field} field
  312. * @return {Ext.Toolbar.Item}
  313. */
  314. addField : function(field){
  315. return this.add(field);
  316. },
  317. <span id='Ext-Toolbar-method-insertButton'> /**
  318. </span> * Inserts any {@link Ext.Toolbar.Item}/{@link Ext.Button} at the specified index.
  319. * &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
  320. * @param {Number} index The index where the item is to be inserted
  321. * @param {Object/Ext.Toolbar.Item/Ext.Button/Array} item The button, or button config object to be
  322. * inserted, or an array of buttons/configs.
  323. * @return {Ext.Button/Item}
  324. */
  325. insertButton : function(index, item){
  326. if(Ext.isArray(item)){
  327. var buttons = [];
  328. for(var i = 0, len = item.length; i &lt; len; i++) {
  329. buttons.push(this.insertButton(index + i, item[i]));
  330. }
  331. return buttons;
  332. }
  333. return Ext.Toolbar.superclass.insert.call(this, index, item);
  334. },
  335. // private
  336. trackMenu : function(item, remove){
  337. if(this.trackMenus &amp;&amp; item.menu){
  338. var method = remove ? 'mun' : 'mon';
  339. this[method](item, 'menutriggerover', this.onButtonTriggerOver, this);
  340. this[method](item, 'menushow', this.onButtonMenuShow, this);
  341. this[method](item, 'menuhide', this.onButtonMenuHide, this);
  342. }
  343. },
  344. // private
  345. constructButton : function(item){
  346. var b = item.events ? item : this.createComponent(item, item.split ? 'splitbutton' : this.defaultType);
  347. return b;
  348. },
  349. // private
  350. onAdd : function(c){
  351. Ext.Toolbar.superclass.onAdd.call(this);
  352. this.trackMenu(c);
  353. if(this.disabled){
  354. c.disable();
  355. }
  356. },
  357. // private
  358. onRemove : function(c){
  359. Ext.Toolbar.superclass.onRemove.call(this);
  360. if (c == this.activeMenuBtn) {
  361. delete this.activeMenuBtn;
  362. }
  363. this.trackMenu(c, true);
  364. },
  365. // private
  366. onDisable : function(){
  367. this.items.each(function(item){
  368. if(item.disable){
  369. item.disable();
  370. }
  371. });
  372. },
  373. // private
  374. onEnable : function(){
  375. this.items.each(function(item){
  376. if(item.enable){
  377. item.enable();
  378. }
  379. });
  380. },
  381. // private
  382. onButtonTriggerOver : function(btn){
  383. if(this.activeMenuBtn &amp;&amp; this.activeMenuBtn != btn){
  384. this.activeMenuBtn.hideMenu();
  385. btn.showMenu();
  386. this.activeMenuBtn = btn;
  387. }
  388. },
  389. // private
  390. onButtonMenuShow : function(btn){
  391. this.activeMenuBtn = btn;
  392. },
  393. // private
  394. onButtonMenuHide : function(btn){
  395. delete this.activeMenuBtn;
  396. }
  397. });
  398. Ext.reg('toolbar', Ext.Toolbar);
  399. <span id='Ext-Toolbar-Item-method-constructor'><span id='Ext-Toolbar-Item'>/**
  400. </span></span> * @class Ext.Toolbar.Item
  401. * @extends Ext.BoxComponent
  402. * The base class that other non-interacting Toolbar Item classes should extend in order to
  403. * get some basic common toolbar item functionality.
  404. * @constructor
  405. * Creates a new Item
  406. * @param {HTMLElement} el
  407. * @xtype tbitem
  408. */
  409. T.Item = Ext.extend(Ext.BoxComponent, {
  410. <span id='Ext-Toolbar-Item-method-enable'><span id='Ext-Toolbar-Item-cfg-hideParent'> hideParent: true, // Hiding a Toolbar.Item hides its containing TD
  411. </span></span> enable:Ext.emptyFn,
  412. <span id='Ext-Toolbar-Item-method-disable'> disable:Ext.emptyFn,
  413. </span><span id='Ext-Toolbar-Item-method-focus'> focus:Ext.emptyFn
  414. </span><span id='Ext-Toolbar-Item-cfg-overflowText'> /**
  415. </span> * @cfg {String} overflowText Text to be used for the menu if the item is overflowed.
  416. */
  417. });
  418. Ext.reg('tbitem', T.Item);
  419. <span id='Ext-Toolbar-Separator-method-constructor'><span id='Ext-Toolbar-Separator'>/**
  420. </span></span> * @class Ext.Toolbar.Separator
  421. * @extends Ext.Toolbar.Item
  422. * A simple class that adds a vertical separator bar between toolbar items
  423. * (css class:&lt;tt&gt;'xtb-sep'&lt;/tt&gt;). Example usage:
  424. * &lt;pre&gt;&lt;code&gt;
  425. new Ext.Panel({
  426. tbar : [
  427. 'Item 1',
  428. {xtype: 'tbseparator'}, // or '-'
  429. 'Item 2'
  430. ]
  431. });
  432. &lt;/code&gt;&lt;/pre&gt;
  433. * @constructor
  434. * Creates a new Separator
  435. * @xtype tbseparator
  436. */
  437. T.Separator = Ext.extend(T.Item, {
  438. <span id='Ext-Toolbar-Separator-method-onRender'> onRender : function(ct, position){
  439. </span> this.el = ct.createChild({tag:'span', cls:'xtb-sep'}, position);
  440. }
  441. });
  442. Ext.reg('tbseparator', T.Separator);
  443. <span id='Ext-Toolbar-Spacer-method-constructor'><span id='Ext-Toolbar-Spacer'>/**
  444. </span></span> * @class Ext.Toolbar.Spacer
  445. * @extends Ext.Toolbar.Item
  446. * A simple element that adds extra horizontal space between items in a toolbar.
  447. * By default a 2px wide space is added via css specification:&lt;pre&gt;&lt;code&gt;
  448. .x-toolbar .xtb-spacer {
  449. width:2px;
  450. }
  451. * &lt;/code&gt;&lt;/pre&gt;
  452. * &lt;p&gt;Example usage:&lt;/p&gt;
  453. * &lt;pre&gt;&lt;code&gt;
  454. new Ext.Panel({
  455. tbar : [
  456. 'Item 1',
  457. {xtype: 'tbspacer'}, // or ' '
  458. 'Item 2',
  459. // space width is also configurable via javascript
  460. {xtype: 'tbspacer', width: 50}, // add a 50px space
  461. 'Item 3'
  462. ]
  463. });
  464. &lt;/code&gt;&lt;/pre&gt;
  465. * @constructor
  466. * Creates a new Spacer
  467. * @xtype tbspacer
  468. */
  469. T.Spacer = Ext.extend(T.Item, {
  470. <span id='Ext-Toolbar-Spacer-cfg-width'> /**
  471. </span> * @cfg {Number} width
  472. * The width of the spacer in pixels (defaults to 2px via css style &lt;tt&gt;.x-toolbar .xtb-spacer&lt;/tt&gt;).
  473. */
  474. onRender : function(ct, position){
  475. this.el = ct.createChild({tag:'div', cls:'xtb-spacer', style: this.width?'width:'+this.width+'px':''}, position);
  476. }
  477. });
  478. Ext.reg('tbspacer', T.Spacer);
  479. <span id='Ext-Toolbar-Fill-method-constructor'><span id='Ext-Toolbar-Fill'>/**
  480. </span></span> * @class Ext.Toolbar.Fill
  481. * @extends Ext.Toolbar.Spacer
  482. * A non-rendering placeholder item which instructs the Toolbar's Layout to begin using
  483. * the right-justified button container.
  484. * &lt;pre&gt;&lt;code&gt;
  485. new Ext.Panel({
  486. tbar : [
  487. 'Item 1',
  488. {xtype: 'tbfill'}, // or '-&gt;'
  489. 'Item 2'
  490. ]
  491. });
  492. &lt;/code&gt;&lt;/pre&gt;
  493. * @constructor
  494. * Creates a new Fill
  495. * @xtype tbfill
  496. */
  497. T.Fill = Ext.extend(T.Item, {
  498. <span id='Ext-Toolbar-Fill-method-render'> // private
  499. </span> render : Ext.emptyFn,
  500. <span id='Ext-Toolbar-Fill-property-isFill'> isFill : true
  501. </span>});
  502. Ext.reg('tbfill', T.Fill);
  503. <span id='Ext-Toolbar-TextItem-method-constructor'><span id='Ext-Toolbar-TextItem'>/**
  504. </span></span> * @class Ext.Toolbar.TextItem
  505. * @extends Ext.Toolbar.Item
  506. * A simple class that renders text directly into a toolbar
  507. * (with css class:&lt;tt&gt;'xtb-text'&lt;/tt&gt;). Example usage:
  508. * &lt;pre&gt;&lt;code&gt;
  509. new Ext.Panel({
  510. tbar : [
  511. {xtype: 'tbtext', text: 'Item 1'} // or simply 'Item 1'
  512. ]
  513. });
  514. &lt;/code&gt;&lt;/pre&gt;
  515. * @constructor
  516. * Creates a new TextItem
  517. * @param {String/Object} text A text string, or a config object containing a &lt;tt&gt;text&lt;/tt&gt; property
  518. * @xtype tbtext
  519. */
  520. T.TextItem = Ext.extend(T.Item, {
  521. <span id='Ext-Toolbar-TextItem-cfg-text'> /**
  522. </span> * @cfg {String} text The text to be used as innerHTML (html tags are accepted)
  523. */
  524. constructor: function(config){
  525. T.TextItem.superclass.constructor.call(this, Ext.isString(config) ? {text: config} : config);
  526. },
  527. <span id='Ext-Toolbar-TextItem-method-onRender'> // private
  528. </span> onRender : function(ct, position) {
  529. this.autoEl = {cls: 'xtb-text', html: this.text || ''};
  530. T.TextItem.superclass.onRender.call(this, ct, position);
  531. },
  532. <span id='Ext-Toolbar-TextItem-method-setText'> /**
  533. </span> * Updates this item's text, setting the text to be used as innerHTML.
  534. * @param {String} t The text to display (html accepted).
  535. */
  536. setText : function(t) {
  537. if(this.rendered){
  538. this.el.update(t);
  539. }else{
  540. this.text = t;
  541. }
  542. }
  543. });
  544. Ext.reg('tbtext', T.TextItem);
  545. // backwards compat
  546. T.Button = Ext.extend(Ext.Button, {});
  547. T.SplitButton = Ext.extend(Ext.SplitButton, {});
  548. Ext.reg('tbbutton', T.Button);
  549. Ext.reg('tbsplit', T.SplitButton);
  550. })();
  551. </pre>
  552. </body>
  553. </html>