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.
16 Ext.toolbar.Toolbar.Button = Ext.extend(Ext.button.Button, {});
17 Ext.toolbar.Toolbar.SplitButton = Ext.extend(Ext.button.Split, {});
18 Ext.reg('tbbutton', Ext.toolbar.Toolbar.Button);
19 Ext.reg('tbsplit', Ext.toolbar.Toolbar.SplitButton);
24 Ext.toolbar.Toolbar.override({
26 * Adds text to the toolbar
27 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
28 * @param {String} text The text to add
29 * @return {Ext.toolbar.Item} The element's item
31 addText : function(text){
32 return this.addItem(new Ext.Toolbar.TextItem(text));
36 * Adds a new element to the toolbar from the passed {@link Ext.DomHelper} config
37 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
38 * @param {Object} config
39 * @return {Ext.toolbar.Item} The element's item
41 addDom : function(config){
42 return this.add(new Ext.Toolbar.Item({autoEl: config}));
46 * Adds a dynamically rendered Ext.form field (Text, ComboBox, etc). Note: the field should not have
47 * been rendered yet. For a field that has already been rendered, use {@link #addElement}.
48 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
49 * @param {Ext.form.field.Field} field
50 * @return {Ext.toolbar.Item}
52 addField : function(field){
53 return this.add(field);
57 * Inserts any {@link Ext.toolbar.Item}/{@link Ext.button.Button} at the specified index.
58 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
59 * @param {Number} index The index where the item is to be inserted
60 * @param {Object/Ext.toolbar.Item/Ext.button.Button/Object[]} item The button, or button config object to be
61 * inserted, or an array of buttons/configs.
62 * @return {Ext.button.Button/Ext.toolbar.Item}
64 insertButton : function(index, item){
65 if(Ext.isArray(item)){
67 for(var i = 0, len = item.length; i < len; i++) {
68 buttons.push(this.insertButton(index + i, item[i]));
72 return Ext.toolbar.Toolbar.superclass.insert.call(this, index, item);
77 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
78 * @return {Ext.toolbar.Item} The separator {@link Ext.toolbar.Item item}
80 addSeparator : function(){
81 return this.add(new Ext.toolbar.Separator());
85 * Adds a spacer element
86 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
87 * @return {Ext.toolbar.Spacer} The spacer item
89 addSpacer : function(){
90 return this.add(new Ext.Toolbar.Spacer());
94 * Forces subsequent additions into the float:right toolbar
95 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
98 this.add(new Ext.Toolbar.Fill());
102 * Adds any standard HTML element to the toolbar
103 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
104 * @param {String/HTMLElement/Ext.Element} el The element or id of the element to add
105 * @return {Ext.toolbar.Item} The element's item
107 addElement : function(el){
108 return this.addItem(new Ext.Toolbar.Item({el:el}));
112 * Adds any Toolbar.Item or subclass
113 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
114 * @param {Ext.toolbar.Item} item
115 * @return {Ext.toolbar.Item} The item
117 addItem : function(item){
118 return this.add.apply(this, arguments);
122 * Adds a button (or buttons). See {@link Ext.button.Button} for more info on the config.
123 * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
124 * @param {Object/Object[]} config A button config or array of configs
125 * @return {Ext.button.Button/Ext.button.Button[]}
127 addButton : function(config){
128 if(Ext.isArray(config)){
130 for(var i = 0, len = config.length; i < len; i++) {
131 buttons.push(this.addButton(config[i]));
135 return this.add(this.constructButton(config));