Upgrade to ExtJS 4.0.7 - Released 10/19/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 // backwards compat
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);
20
21 /*
22  * @ignore
23  */
24 Ext.toolbar.Toolbar.override({
25     /*
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
30      */
31     addText : function(text){
32         return this.addItem(new Ext.Toolbar.TextItem(text));
33     },
34
35     /*
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
40      */
41     addDom : function(config){
42         return this.add(new Ext.Toolbar.Item({autoEl: config}));
43     },
44
45     /*
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}
51      */
52     addField : function(field){
53         return this.add(field);
54     },
55
56     /*
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}
63      */
64     insertButton : function(index, item){
65         if(Ext.isArray(item)){
66             var buttons = [];
67             for(var i = 0, len = item.length; i < len; i++) {
68                buttons.push(this.insertButton(index + i, item[i]));
69             }
70             return buttons;
71         }
72         return Ext.toolbar.Toolbar.superclass.insert.call(this, index, item);
73     },
74
75     /*
76      * Adds a separator
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}
79      */
80     addSeparator : function(){
81         return this.add(new Ext.toolbar.Separator());
82     },
83
84     /*
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
88      */
89     addSpacer : function(){
90         return this.add(new Ext.Toolbar.Spacer());
91     },
92
93     /*
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>
96      */
97     addFill : function(){
98         this.add(new Ext.Toolbar.Fill());
99     },
100
101     /*
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
106      */
107     addElement : function(el){
108         return this.addItem(new Ext.Toolbar.Item({el:el}));
109     },
110
111     /*
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
116      */
117     addItem : function(item){
118         return this.add.apply(this, arguments);
119     },
120
121     /*
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[]}
126      */
127     addButton : function(config){
128         if(Ext.isArray(config)){
129             var buttons = [];
130             for(var i = 0, len = config.length; i < len; i++) {
131                 buttons.push(this.addButton(config[i]));
132             }
133             return buttons;
134         }
135         return this.add(this.constructButton(config));
136     }
137 });