3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
19 Ext.toolbar.Toolbar.Button = Ext.extend(Ext.button.Button, {});
20 Ext.toolbar.Toolbar.SplitButton = Ext.extend(Ext.button.Split, {});
21 Ext.reg('tbbutton', Ext.toolbar.Toolbar.Button);
22 Ext.reg('tbsplit', Ext.toolbar.Toolbar.SplitButton);
27 Ext.toolbar.Toolbar.override({
29 * Adds text to the toolbar
30 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
31 * @param {String} text The text to add
32 * @return {Ext.Toolbar.Item} The element's item
34 addText : function(text){
35 return this.addItem(new Ext.Toolbar.TextItem(text));
39 * Adds a new element to the toolbar from the passed {@link Ext.core.DomHelper} config
40 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
41 * @param {Object} config
42 * @return {Ext.Toolbar.Item} The element's item
44 addDom : function(config){
45 return this.add(new Ext.Toolbar.Item({autoEl: config}));
49 * Adds a dynamically rendered Ext.form field (Text, ComboBox, etc). Note: the field should not have
50 * been rendered yet. For a field that has already been rendered, use {@link #addElement}.
51 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
52 * @param {Ext.form.field.Field} field
53 * @return {Ext.Toolbar.Item}
55 addField : function(field){
56 return this.add(field);
60 * Inserts any {@link Ext.toolbar.Item}/{@link Ext.button.Button} at the specified index.
61 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
62 * @param {Number} index The index where the item is to be inserted
63 * @param {Object/Ext.Toolbar.Item/Ext.button.Button/Array} item The button, or button config object to be
64 * inserted, or an array of buttons/configs.
65 * @return {Ext.button.Button/Item}
67 insertButton : function(index, item){
68 if(Ext.isArray(item)){
70 for(var i = 0, len = item.length; i < len; i++) {
71 buttons.push(this.insertButton(index + i, item[i]));
75 return Ext.toolbar.Toolbar.superclass.insert.call(this, index, item);
80 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
81 * @return {Ext.toolbar.Item} The separator {@link Ext.toolbar.Item item}
83 addSeparator : function(){
84 return this.add(new Ext.toolbar.Separator());
88 * Adds a spacer element
89 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
90 * @return {Ext.Toolbar.Spacer} The spacer item
92 addSpacer : function(){
93 return this.add(new Ext.Toolbar.Spacer());
97 * Forces subsequent additions into the float:right toolbar
98 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
100 addFill : function(){
101 this.add(new Ext.Toolbar.Fill());
105 * Adds any standard HTML element to the toolbar
106 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
107 * @param {Mixed} el The element or id of the element to add
108 * @return {Ext.Toolbar.Item} The element's item
110 addElement : function(el){
111 return this.addItem(new Ext.Toolbar.Item({el:el}));
115 * Adds any Toolbar.Item or subclass
116 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
117 * @param {Ext.Toolbar.Item} item
118 * @return {Ext.Toolbar.Item} The item
120 addItem : function(item){
121 return this.add.apply(this, arguments);
125 * Adds a button (or buttons). See {@link Ext.button.Button} for more info on the config.
126 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
127 * @param {Object/Array} config A button config or array of configs
128 * @return {Ext.button.Button/Array}
130 addButton : function(config){
131 if(Ext.isArray(config)){
133 for(var i = 0, len = config.length; i < len; i++) {
134 buttons.push(this.addButton(config[i]));
138 return this.add(this.constructButton(config));