Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / src / toolbar / Toolbar-legacy.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
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.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * @ignore
17  */
18 // backwards compat
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);
23
24 /**
25  * @ignore
26  */
27 Ext.toolbar.Toolbar.override({
28     /**
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
33      */
34     addText : function(text){
35         return this.addItem(new Ext.Toolbar.TextItem(text));
36     },
37
38     /**
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
43      */
44     addDom : function(config){
45         return this.add(new Ext.Toolbar.Item({autoEl: config}));
46     },
47
48     /**
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}
54      */
55     addField : function(field){
56         return this.add(field);
57     },
58
59     /**
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}
66      */
67     insertButton : function(index, item){
68         if(Ext.isArray(item)){
69             var buttons = [];
70             for(var i = 0, len = item.length; i < len; i++) {
71                buttons.push(this.insertButton(index + i, item[i]));
72             }
73             return buttons;
74         }
75         return Ext.toolbar.Toolbar.superclass.insert.call(this, index, item);
76     },
77
78     /**
79      * Adds a separator
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}
82      */
83     addSeparator : function(){
84         return this.add(new Ext.toolbar.Separator());
85     },
86
87     /**
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
91      */
92     addSpacer : function(){
93         return this.add(new Ext.Toolbar.Spacer());
94     },
95
96     /**
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>
99      */
100     addFill : function(){
101         this.add(new Ext.Toolbar.Fill());
102     },
103
104     /**
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
109      */
110     addElement : function(el){
111         return this.addItem(new Ext.Toolbar.Item({el:el}));
112     },
113
114     /**
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
119      */
120     addItem : function(item){
121         return this.add.apply(this, arguments);
122     },
123
124     /**
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}
129      */
130     addButton : function(config){
131         if(Ext.isArray(config)){
132             var buttons = [];
133             for(var i = 0, len = config.length; i < len; i++) {
134                 buttons.push(this.addButton(config[i]));
135             }
136             return buttons;
137         }
138         return this.add(this.constructButton(config));
139     }
140 });