Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / toolbar / Toolbar-legacy.js
1 /**
2  * @ignore
3  */
4 // backwards compat
5 Ext.toolbar.Toolbar.Button = Ext.extend(Ext.button.Button, {});
6 Ext.toolbar.Toolbar.SplitButton = Ext.extend(Ext.button.Split, {});
7 Ext.reg('tbbutton', Ext.toolbar.Toolbar.Button);
8 Ext.reg('tbsplit', Ext.toolbar.Toolbar.SplitButton);
9
10 /**
11  * @ignore
12  */
13 Ext.toolbar.Toolbar.override({
14     /**
15      * Adds text to the toolbar
16      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
17      * @param {String} text The text to add
18      * @return {Ext.Toolbar.Item} The element's item
19      */
20     addText : function(text){
21         return this.addItem(new Ext.Toolbar.TextItem(text));
22     },
23
24     /**
25      * Adds a new element to the toolbar from the passed {@link Ext.core.DomHelper} config
26      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
27      * @param {Object} config
28      * @return {Ext.Toolbar.Item} The element's item
29      */
30     addDom : function(config){
31         return this.add(new Ext.Toolbar.Item({autoEl: config}));
32     },
33
34     /**
35      * Adds a dynamically rendered Ext.form field (Text, ComboBox, etc). Note: the field should not have
36      * been rendered yet. For a field that has already been rendered, use {@link #addElement}.
37      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
38      * @param {Ext.form.field.Field} field
39      * @return {Ext.Toolbar.Item}
40      */
41     addField : function(field){
42         return this.add(field);
43     },
44
45     /**
46      * Inserts any {@link Ext.toolbar.Item}/{@link Ext.button.Button} at the specified index.
47      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
48      * @param {Number} index The index where the item is to be inserted
49      * @param {Object/Ext.Toolbar.Item/Ext.button.Button/Array} item The button, or button config object to be
50      * inserted, or an array of buttons/configs.
51      * @return {Ext.button.Button/Item}
52      */
53     insertButton : function(index, item){
54         if(Ext.isArray(item)){
55             var buttons = [];
56             for(var i = 0, len = item.length; i < len; i++) {
57                buttons.push(this.insertButton(index + i, item[i]));
58             }
59             return buttons;
60         }
61         return Ext.toolbar.Toolbar.superclass.insert.call(this, index, item);
62     },
63
64     /**
65      * Adds a separator
66      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
67      * @return {Ext.toolbar.Item} The separator {@link Ext.toolbar.Item item}
68      */
69     addSeparator : function(){
70         return this.add(new Ext.toolbar.Separator());
71     },
72
73     /**
74      * Adds a spacer element
75      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
76      * @return {Ext.Toolbar.Spacer} The spacer item
77      */
78     addSpacer : function(){
79         return this.add(new Ext.Toolbar.Spacer());
80     },
81
82     /**
83      * Forces subsequent additions into the float:right toolbar
84      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
85      */
86     addFill : function(){
87         this.add(new Ext.Toolbar.Fill());
88     },
89
90     /**
91      * Adds any standard HTML element to the toolbar
92      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
93      * @param {Mixed} el The element or id of the element to add
94      * @return {Ext.Toolbar.Item} The element's item
95      */
96     addElement : function(el){
97         return this.addItem(new Ext.Toolbar.Item({el:el}));
98     },
99
100     /**
101      * Adds any Toolbar.Item or subclass
102      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
103      * @param {Ext.Toolbar.Item} item
104      * @return {Ext.Toolbar.Item} The item
105      */
106     addItem : function(item){
107         return this.add.apply(this, arguments);
108     },
109
110     /**
111      * Adds a button (or buttons). See {@link Ext.button.Button} for more info on the config.
112      * <br><p><b>Note</b>: See the notes within {@link Ext.container.Container#add}.</p>
113      * @param {Object/Array} config A button config or array of configs
114      * @return {Ext.button.Button/Array}
115      */
116     addButton : function(config){
117         if(Ext.isArray(config)){
118             var buttons = [];
119             for(var i = 0, len = config.length; i < len; i++) {
120                 buttons.push(this.addButton(config[i]));
121             }
122             return buttons;
123         }
124         return this.add(this.constructButton(config));
125     }
126 });