-/**\r
- * @class Ext.layout.ToolbarLayout\r
- * @extends Ext.layout.ContainerLayout\r
- * Layout manager implicitly used by Ext.Toolbar.\r
- */\r
-Ext.layout.ToolbarLayout = Ext.extend(Ext.layout.ContainerLayout, {\r
- monitorResize : true,\r
- triggerWidth : 18,\r
- lastOverflow : false,\r
-\r
- noItemsMenuText : '<div class="x-toolbar-no-items">(None)</div>',\r
- // private\r
- onLayout : function(ct, target){\r
- if(!this.leftTr){\r
- target.addClass('x-toolbar-layout-ct');\r
- target.insertHtml('beforeEnd',\r
- '<table cellspacing="0" class="x-toolbar-ct"><tbody><tr><td class="x-toolbar-left" align="left"><table cellspacing="0"><tbody><tr class="x-toolbar-left-row"></tr></tbody></table></td><td class="x-toolbar-right" align="right"><table cellspacing="0" class="x-toolbar-right-ct"><tbody><tr><td><table cellspacing="0"><tbody><tr class="x-toolbar-right-row"></tr></tbody></table></td><td><table cellspacing="0"><tbody><tr class="x-toolbar-extras-row"></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>');\r
- this.leftTr = target.child('tr.x-toolbar-left-row', true);\r
- this.rightTr = target.child('tr.x-toolbar-right-row', true);\r
- this.extrasTr = target.child('tr.x-toolbar-extras-row', true);\r
- }\r
- var side = this.leftTr;\r
- var pos = 0;\r
-\r
- var items = ct.items.items;\r
- for(var i = 0, len = items.length, c; i < len; i++, pos++) {\r
- c = items[i];\r
- if(c.isFill){\r
- side = this.rightTr;\r
- pos = -1;\r
- }else if(!c.rendered){\r
- c.render(this.insertCell(c, side, pos));\r
- }else{\r
- if(!c.xtbHidden && !this.isValidParent(c, side.childNodes[pos])){\r
- var td = this.insertCell(c, side, pos);\r
- td.appendChild(c.getDomPositionEl().dom);\r
- c.container = Ext.get(td);\r
- }\r
- }\r
- }\r
- //strip extra empty cells\r
- this.cleanup(this.leftTr);\r
- this.cleanup(this.rightTr);\r
- this.cleanup(this.extrasTr);\r
- this.fitToSize(target);\r
- },\r
-\r
- cleanup : function(row){\r
- var cn = row.childNodes;\r
- for(var i = cn.length-1, c; i >= 0 && (c = cn[i]); i--){\r
- if(!c.firstChild){\r
- row.removeChild(c);\r
- }\r
- }\r
- },\r
-\r
- insertCell : function(c, side, pos){\r
- var td = document.createElement('td');\r
- td.className='x-toolbar-cell';\r
- side.insertBefore(td, side.childNodes[pos]||null);\r
- return td;\r
- },\r
-\r
- hideItem : function(item){\r
- var h = (this.hiddens = this.hiddens || []);\r
- h.push(item);\r
- item.xtbHidden = true;\r
- item.xtbWidth = item.getDomPositionEl().dom.parentNode.offsetWidth;\r
- item.hide();\r
- },\r
-\r
- unhideItem : function(item){\r
- item.show();\r
- item.xtbHidden = false;\r
- this.hiddens.remove(item);\r
- if(this.hiddens.length < 1){\r
- delete this.hiddens;\r
- }\r
- },\r
-\r
- getItemWidth : function(c){\r
- return c.hidden ? (c.xtbWidth || 0) : c.getDomPositionEl().dom.parentNode.offsetWidth;\r
- },\r
-\r
- fitToSize : function(t){\r
- if(this.container.enableOverflow === false){\r
- return;\r
- }\r
- var w = t.dom.clientWidth;\r
- var lw = this.lastWidth || 0;\r
- this.lastWidth = w;\r
- var iw = t.dom.firstChild.offsetWidth;\r
-\r
- var clipWidth = w - this.triggerWidth;\r
- var hideIndex = -1;\r
-\r
- if(iw > w || (this.hiddens && w >= lw)){\r
- var i, items = this.container.items.items, len = items.length, c;\r
- var loopWidth = 0;\r
- for(i = 0; i < len; i++) {\r
- c = items[i];\r
- if(!c.isFill){\r
- loopWidth += this.getItemWidth(c);\r
- if(loopWidth > clipWidth){\r
- if(!c.xtbHidden){\r
- this.hideItem(c);\r
- }\r
- }else{\r
- if(c.xtbHidden){\r
- this.unhideItem(c);\r
- }\r
- }\r
- }\r
- }\r
- }\r
- if(this.hiddens){\r
- this.initMore();\r
- if(!this.lastOverflow){\r
- this.container.fireEvent('overflowchange', this.container, true);\r
- this.lastOverflow = true;\r
- }\r
- }else if(this.more){\r
- this.clearMenu();\r
- this.more.destroy();\r
- delete this.more;\r
- if(this.lastOverflow){\r
- this.container.fireEvent('overflowchange', this.container, false);\r
- this.lastOverflow = false;\r
- }\r
- }\r
- },\r
-\r
- createMenuConfig : function(c, hideOnClick){\r
- var cfg = Ext.apply({}, c.initialConfig),\r
- group = c.toggleGroup;\r
-\r
- Ext.apply(cfg, {\r
- text: c.overflowText || c.text,\r
- iconCls: c.iconCls,\r
- icon: c.icon,\r
- itemId: c.itemId,\r
- disabled: c.disabled,\r
- handler: c.handler,\r
- scope: c.scope,\r
- menu: c.menu,\r
- hideOnClick: hideOnClick\r
- });\r
- if(group || c.enableToggle){\r
- Ext.apply(cfg, {\r
- group: group,\r
- checked: c.pressed,\r
- listeners: {\r
- checkchange: function(item, checked){\r
- c.toggle(checked);\r
- }\r
- }\r
- });\r
- }\r
- delete cfg.xtype;\r
- delete cfg.id;\r
- return cfg;\r
- },\r
-\r
- // private\r
- addComponentToMenu : function(m, c){\r
- if(c instanceof Ext.Toolbar.Separator){\r
- m.add('-');\r
- }else if(Ext.isFunction(c.isXType)){\r
- if(c.isXType('splitbutton')){\r
- m.add(this.createMenuConfig(c, true));\r
- }else if(c.isXType('button')){\r
- m.add(this.createMenuConfig(c, !c.menu));\r
- }else if(c.isXType('buttongroup')){\r
- c.items.each(function(item){\r
- this.addComponentToMenu(m, item);\r
- }, this);\r
- }\r
- }\r
- },\r
-\r
- clearMenu : function(){\r
- var m = this.moreMenu;\r
- if(m && m.items){\r
- this.moreMenu.items.each(function(item){\r
- delete item.menu;\r
- });\r
- }\r
- },\r
-\r
- // private\r
- beforeMoreShow : function(m){\r
- var h = this.container.items.items,\r
- len = h.length,\r
- c,\r
- prev,\r
- needsSep = function(group, item){\r
- return group.isXType('buttongroup') && !(item instanceof Ext.Toolbar.Separator);\r
- };\r
-\r
- this.clearMenu();\r
- m.removeAll();\r
- for(var i = 0; i < len; i++){\r
- c = h[i];\r
- if(c.xtbHidden){\r
- if(prev && (needsSep(c, prev) || needsSep(prev, c))){\r
- m.add('-');\r
- }\r
- this.addComponentToMenu(m, c);\r
- prev = c;\r
- }\r
- }\r
- // put something so the menu isn't empty\r
- // if no compatible items found\r
- if(m.items.length < 1){\r
- m.add(this.noItemsMenuText);\r
- }\r
- },\r
-\r
- initMore : function(){\r
- if(!this.more){\r
- this.moreMenu = new Ext.menu.Menu({\r
- listeners: {\r
- beforeshow: this.beforeMoreShow,\r
- scope: this\r
- }\r
- });\r
- this.more = new Ext.Button({\r
- iconCls: 'x-toolbar-more-icon',\r
- cls: 'x-toolbar-more',\r
- menu: this.moreMenu\r
- });\r
- var td = this.insertCell(this.more, this.extrasTr, 100);\r
- this.more.render(td);\r
- }\r
- },\r
-\r
- destroy : function(){\r
- Ext.destroy(this.more, this.moreMenu);\r
- Ext.layout.ToolbarLayout.superclass.destroy.call(this);\r
- }\r
- /**\r
- * @property activeItem\r
- * @hide\r
- */\r
-});\r
-\r
-Ext.Container.LAYOUTS.toolbar = Ext.layout.ToolbarLayout;\r
-\r
-/**\r
- * @class Ext.Toolbar\r
- * @extends Ext.Container\r
- * <p>Basic Toolbar class. Although the <tt>{@link Ext.Container#defaultType defaultType}</tt> for Toolbar\r
- * is <tt>{@link Ext.Button button}</tt>, Toolbar elements (child items for the Toolbar container) may\r
- * be virtually any type of Component. Toolbar elements can be created explicitly via their constructors,\r
- * or implicitly via their xtypes, and can be <tt>{@link #add}</tt>ed dynamically.</p>\r
- * <p>Some items have shortcut strings for creation:</p>\r
- * <pre>\r
-<u>Shortcut</u> <u>xtype</u> <u>Class</u> <u>Description</u>\r
-'->' 'tbfill' {@link Ext.Toolbar.Fill} begin using the right-justified button container\r
-'-' 'tbseparator' {@link Ext.Toolbar.Separator} add a vertical separator bar between toolbar items\r
-' ' 'tbspacer' {@link Ext.Toolbar.Spacer} add horiztonal space between elements\r
- * </pre>\r
- *\r
- * Example usage of various elements:\r
- * <pre><code>\r
-var tb = new Ext.Toolbar({\r
- renderTo: document.body,\r
- width: 600,\r
- height: 100,\r
- items: [\r
- {\r
- // xtype: 'button', // default for Toolbars, same as 'tbbutton'\r
- text: 'Button'\r
- },\r
- {\r
- xtype: 'splitbutton', // same as 'tbsplitbutton'\r
- text: 'Split Button'\r
- },\r
- // begin using the right-justified button container\r
- '->', // same as {xtype: 'tbfill'}, // Ext.Toolbar.Fill\r
- {\r
- xtype: 'textfield',\r
- name: 'field1',\r
- emptyText: 'enter search term'\r
- },\r
- // add a vertical separator bar between toolbar items\r
- '-', // same as {xtype: 'tbseparator'} to create Ext.Toolbar.Separator\r
- 'text 1', // same as {xtype: 'tbtext', text: 'text1'} to create Ext.Toolbar.TextItem\r
- {xtype: 'tbspacer'},// same as ' ' to create Ext.Toolbar.Spacer\r
- 'text 2',\r
- {xtype: 'tbspacer', width: 50}, // add a 50px space\r
- 'text 3'\r
- ]\r
-});\r
- * </code></pre>\r
- * Example adding a ComboBox within a menu of a button:\r
- * <pre><code>\r
-// ComboBox creation\r
-var combo = new Ext.form.ComboBox({\r
- store: new Ext.data.ArrayStore({\r
- autoDestroy: true,\r
- fields: ['initials', 'fullname'],\r
- data : [\r
- ['FF', 'Fred Flintstone'],\r
- ['BR', 'Barney Rubble']\r
- ]\r
- }),\r
- displayField: 'fullname',\r
- typeAhead: true,\r
- mode: 'local',\r
- forceSelection: true,\r
- triggerAction: 'all',\r
- emptyText: 'Select a name...',\r
- selectOnFocus: true,\r
- width: 135,\r
- getListParent: function() {\r
- return this.el.up('.x-menu');\r
- },\r
- iconCls: 'no-icon' //use iconCls if placing within menu to shift to right side of menu\r
-});\r
-\r
-// put ComboBox in a Menu\r
-var menu = new Ext.menu.Menu({\r
- id: 'mainMenu',\r
- items: [\r
- combo // A Field in a Menu\r
- ]\r
-});\r
-\r
-// add a Button with the menu\r
-tb.add({\r
- text:'Button w/ Menu',\r
- menu: menu // assign menu by instance\r
- });\r
-tb.doLayout();\r
- * </code></pre>\r
- * @constructor\r
- * Creates a new Toolbar\r
- * @param {Object/Array} config A config object or an array of buttons to <tt>{@link #add}</tt>\r
- * @xtype toolbar\r
- */\r
-Ext.Toolbar = function(config){\r
- if(Ext.isArray(config)){\r
- config = {items: config, layout: 'toolbar'};\r
- } else {\r
- config = Ext.apply({\r
- layout: 'toolbar'\r
- }, config);\r
- if(config.buttons) {\r
- config.items = config.buttons;\r
- }\r
- }\r
- Ext.Toolbar.superclass.constructor.call(this, config);\r
-};\r
-\r
-(function(){\r
-\r
-var T = Ext.Toolbar;\r
-\r
-Ext.extend(T, Ext.Container, {\r
-\r
- defaultType: 'button',\r
-\r
- trackMenus : true,\r
- internalDefaults: {removeMode: 'container', hideParent: true},\r
- toolbarCls: 'x-toolbar',\r
-\r
- initComponent : function(){\r
- T.superclass.initComponent.call(this);\r
-\r
- /**\r
- * @event overflowchange\r
- * Fires after the overflow state has changed.\r
- * @param {Object} c The Container\r
- * @param {Boolean} lastOverflow overflow state\r
- */\r
- this.addEvents('overflowchange');\r
- },\r
-\r
- // private\r
- onRender : function(ct, position){\r
- if(!this.el){\r
- if(!this.autoCreate){\r
- this.autoCreate = {\r
- cls: this.toolbarCls + ' x-small-editor'\r
- };\r
- }\r
- this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);\r
- }\r
- },\r
-\r
- /**\r
- * Adds element(s) to the toolbar -- this function takes a variable number of\r
- * arguments of mixed type and adds them to the toolbar.\r
- * @param {Mixed} arg1 The following types of arguments are all valid:<br />\r
- * <ul>\r
- * <li>{@link Ext.Button} config: A valid button config object (equivalent to {@link #addButton})</li>\r
- * <li>HtmlElement: Any standard HTML element (equivalent to {@link #addElement})</li>\r
- * <li>Field: Any form field (equivalent to {@link #addField})</li>\r
- * <li>Item: Any subclass of {@link Ext.Toolbar.Item} (equivalent to {@link #addItem})</li>\r
- * <li>String: Any generic string (gets wrapped in a {@link Ext.Toolbar.TextItem}, equivalent to {@link #addText}).\r
- * Note that there are a few special strings that are treated differently as explained next.</li>\r
- * <li>'-': Creates a separator element (equivalent to {@link #addSeparator})</li>\r
- * <li>' ': Creates a spacer element (equivalent to {@link #addSpacer})</li>\r
- * <li>'->': Creates a fill element (equivalent to {@link #addFill})</li>\r
- * </ul>\r
- * @param {Mixed} arg2\r
- * @param {Mixed} etc.\r
- * @method add\r
- */\r
-\r
- // private\r
- lookupComponent : function(c){\r
- if(Ext.isString(c)){\r
- if(c == '-'){\r
- c = new T.Separator();\r
- }else if(c == ' '){\r
- c = new T.Spacer();\r
- }else if(c == '->'){\r
- c = new T.Fill();\r
- }else{\r
- c = new T.TextItem(c);\r
- }\r
- this.applyDefaults(c);\r
- }else{\r
- if(c.isFormField || c.render){ // some kind of form field, some kind of Toolbar.Item\r
- c = this.constructItem(c);\r
- }else if(c.tag){ // DomHelper spec\r
- c = new T.Item({autoEl: c});\r
- }else if(c.tagName){ // element\r
- c = new T.Item({el:c});\r
- }else if(Ext.isObject(c)){ // must be button config?\r
- c = c.xtype ? this.constructItem(c) : this.constructButton(c);\r
- }\r
- }\r
- return c;\r
- },\r
-\r
- // private\r
- applyDefaults : function(c){\r
- if(!Ext.isString(c)){\r
- c = Ext.Toolbar.superclass.applyDefaults.call(this, c);\r
- var d = this.internalDefaults;\r
- if(c.events){\r
- Ext.applyIf(c.initialConfig, d);\r
- Ext.apply(c, d);\r
- }else{\r
- Ext.applyIf(c, d);\r
- }\r
- }\r
- return c;\r
- },\r
-\r
- // private\r
- constructItem : function(item, type){\r
- return Ext.create(item, type || this.defaultType);\r
- },\r
-\r
- /**\r
- * Adds a separator\r
- * @return {Ext.Toolbar.Item} The separator {@link Ext.Toolbar.Item item}\r
- */\r
- addSeparator : function(){\r
- return this.add(new T.Separator());\r
- },\r
-\r
- /**\r
- * Adds a spacer element\r
- * @return {Ext.Toolbar.Spacer} The spacer item\r
- */\r
- addSpacer : function(){\r
- return this.add(new T.Spacer());\r
- },\r
-\r
- /**\r
- * Forces subsequent additions into the float:right toolbar\r
- */\r
- addFill : function(){\r
- this.add(new T.Fill());\r
- },\r
-\r
- /**\r
- * Adds any standard HTML element to the toolbar\r
- * @param {Mixed} el The element or id of the element to add\r
- * @return {Ext.Toolbar.Item} The element's item\r
- */\r
- addElement : function(el){\r
- return this.addItem(new T.Item({el:el}));\r
- },\r
-\r
- /**\r
- * Adds any Toolbar.Item or subclass\r
- * @param {Ext.Toolbar.Item} item\r
- * @return {Ext.Toolbar.Item} The item\r
- */\r
- addItem : function(item){\r
- return Ext.Toolbar.superclass.add.apply(this, arguments);\r
- },\r
-\r
- /**\r
- * Adds a button (or buttons). See {@link Ext.Button} for more info on the config.\r
- * @param {Object/Array} config A button config or array of configs\r
- * @return {Ext.Button/Array}\r
- */\r
- addButton : function(config){\r
- if(Ext.isArray(config)){\r
- var buttons = [];\r
- for(var i = 0, len = config.length; i < len; i++) {\r
- buttons.push(this.addButton(config[i]));\r
- }\r
- return buttons;\r
- }\r
- return this.add(this.constructButton(config));\r
- },\r
-\r
- /**\r
- * Adds text to the toolbar\r
- * @param {String} text The text to add\r
- * @return {Ext.Toolbar.Item} The element's item\r
- */\r
- addText : function(text){\r
- return this.addItem(new T.TextItem(text));\r
- },\r
-\r
- /**\r
- * Adds a new element to the toolbar from the passed {@link Ext.DomHelper} config\r
- * @param {Object} config\r
- * @return {Ext.Toolbar.Item} The element's item\r
- */\r
- addDom : function(config){\r
- return this.add(new T.Item({autoEl: config}));\r
- },\r
-\r
- /**\r
- * Adds a dynamically rendered Ext.form field (TextField, ComboBox, etc). Note: the field should not have\r
- * been rendered yet. For a field that has already been rendered, use {@link #addElement}.\r
- * @param {Ext.form.Field} field\r
- * @return {Ext.Toolbar.Item}\r
- */\r
- addField : function(field){\r
- return this.add(field);\r
- },\r
-\r
- /**\r
- * Inserts any {@link Ext.Toolbar.Item}/{@link Ext.Button} at the specified index.\r
- * @param {Number} index The index where the item is to be inserted\r
- * @param {Object/Ext.Toolbar.Item/Ext.Button/Array} item The button, or button config object to be\r
- * inserted, or an array of buttons/configs.\r
- * @return {Ext.Button/Item}\r
- */\r
- insertButton : function(index, item){\r
- if(Ext.isArray(item)){\r
- var buttons = [];\r
- for(var i = 0, len = item.length; i < len; i++) {\r
- buttons.push(this.insertButton(index + i, item[i]));\r
- }\r
- return buttons;\r
- }\r
- return Ext.Toolbar.superclass.insert.call(this, index, item);\r
- },\r
-\r
- // private\r
- initMenuTracking : function(item){\r
- if(this.trackMenus && item.menu){\r
- this.mon(item, {\r
- 'menutriggerover' : this.onButtonTriggerOver,\r
- 'menushow' : this.onButtonMenuShow,\r
- 'menuhide' : this.onButtonMenuHide,\r
- scope: this\r
- });\r
- }\r
- },\r
-\r
- // private\r
- constructButton : function(item){\r
- var b = item.events ? item : this.constructItem(item, item.split ? 'splitbutton' : this.defaultType);\r
- this.initMenuTracking(b);\r
- return b;\r
- },\r
-\r
- // private\r
- onDisable : function(){\r
- this.items.each(function(item){\r
- if(item.disable){\r
- item.disable();\r
- }\r
- });\r
- },\r
-\r
- // private\r
- onEnable : function(){\r
- this.items.each(function(item){\r
- if(item.enable){\r
- item.enable();\r
- }\r
- });\r
- },\r
-\r
- // private\r
- onButtonTriggerOver : function(btn){\r
- if(this.activeMenuBtn && this.activeMenuBtn != btn){\r
- this.activeMenuBtn.hideMenu();\r
- btn.showMenu();\r
- this.activeMenuBtn = btn;\r
- }\r
- },\r
-\r
- // private\r
- onButtonMenuShow : function(btn){\r
- this.activeMenuBtn = btn;\r
- },\r
-\r
- // private\r
- onButtonMenuHide : function(btn){\r
- delete this.activeMenuBtn;\r
- }\r
-});\r
-Ext.reg('toolbar', Ext.Toolbar);\r
-\r
-/**\r
- * @class Ext.Toolbar.Item\r
- * @extends Ext.BoxComponent\r
- * The base class that other non-interacting Toolbar Item classes should extend in order to\r
- * get some basic common toolbar item functionality.\r
- * @constructor\r
- * Creates a new Item\r
- * @param {HTMLElement} el\r
- * @xtype tbitem\r
- */\r
-T.Item = Ext.extend(Ext.BoxComponent, {\r
- hideParent: true, // Hiding a Toolbar.Item hides its containing TD\r
- enable:Ext.emptyFn,\r
- disable:Ext.emptyFn,\r
- focus:Ext.emptyFn\r
- /**\r
- * @cfg {String} overflowText Text to be used for the menu if the item is overflowed.\r
- */\r
-});\r
-Ext.reg('tbitem', T.Item);\r
-\r
-/**\r
- * @class Ext.Toolbar.Separator\r
- * @extends Ext.Toolbar.Item\r
- * A simple class that adds a vertical separator bar between toolbar items\r
- * (css class:<tt>'xtb-sep'</tt>). Example usage:\r
- * <pre><code>\r
-new Ext.Panel({\r
- tbar : [\r
- 'Item 1',\r
- {xtype: 'tbseparator'}, // or '-'\r
- 'Item 2'\r
- ]\r
-});\r
-</code></pre>\r
- * @constructor\r
- * Creates a new Separator\r
- * @xtype tbseparator\r
- */\r
-T.Separator = Ext.extend(T.Item, {\r
- onRender : function(ct, position){\r
- this.el = ct.createChild({tag:'span', cls:'xtb-sep'}, position);\r
- }\r
-});\r
-Ext.reg('tbseparator', T.Separator);\r
-\r
-/**\r
- * @class Ext.Toolbar.Spacer\r
- * @extends Ext.Toolbar.Item\r
- * A simple element that adds extra horizontal space between items in a toolbar.\r
- * By default a 2px wide space is added via css specification:<pre><code>\r
-.x-toolbar .xtb-spacer {\r
- width:2px;\r
-}\r
- * </code></pre>\r
- * <p>Example usage:</p>\r
- * <pre><code>\r
-new Ext.Panel({\r
- tbar : [\r
- 'Item 1',\r
- {xtype: 'tbspacer'}, // or ' '\r
- 'Item 2',\r
- // space width is also configurable via javascript\r
- {xtype: 'tbspacer', width: 50}, // add a 50px space\r
- 'Item 3'\r
- ]\r
-});\r
-</code></pre>\r
- * @constructor\r
- * Creates a new Spacer\r
- * @xtype tbspacer\r
- */\r
-T.Spacer = Ext.extend(T.Item, {\r
- /**\r
- * @cfg {Number} width\r
- * The width of the spacer in pixels (defaults to 2px via css style <tt>.x-toolbar .xtb-spacer</tt>).\r
- */\r
-\r
- onRender : function(ct, position){\r
- this.el = ct.createChild({tag:'div', cls:'xtb-spacer', style: this.width?'width:'+this.width+'px':''}, position);\r
- }\r
-});\r
-Ext.reg('tbspacer', T.Spacer);\r
-\r
-/**\r
- * @class Ext.Toolbar.Fill\r
- * @extends Ext.Toolbar.Spacer\r
- * A non-rendering placeholder item which instructs the Toolbar's Layout to begin using\r
- * the right-justified button container.\r
- * <pre><code>\r
-new Ext.Panel({\r
- tbar : [\r
- 'Item 1',\r
- {xtype: 'tbfill'}, // or '->'\r
- 'Item 2'\r
- ]\r
-});\r
-</code></pre>\r
- * @constructor\r
- * Creates a new Fill\r
- * @xtype tbfill\r
- */\r
-T.Fill = Ext.extend(T.Item, {\r
- // private\r
- render : Ext.emptyFn,\r
- isFill : true\r
-});\r
-Ext.reg('tbfill', T.Fill);\r
-\r
-/**\r
- * @class Ext.Toolbar.TextItem\r
- * @extends Ext.Toolbar.Item\r
- * A simple class that renders text directly into a toolbar\r
- * (with css class:<tt>'xtb-text'</tt>). Example usage:\r
- * <pre><code>\r
-new Ext.Panel({\r
- tbar : [\r
- {xtype: 'tbtext', text: 'Item 1'} // or simply 'Item 1'\r
- ]\r
-});\r
-</code></pre>\r
- * @constructor\r
- * Creates a new TextItem\r
- * @param {String/Object} text A text string, or a config object containing a <tt>text</tt> property\r
- * @xtype tbtext\r
- */\r
-T.TextItem = Ext.extend(T.Item, {\r
- constructor: function(config){\r
- if (Ext.isString(config)) {\r
- config = { autoEl: {cls: 'xtb-text', html: config }};\r
- } else {\r
- config.autoEl = {cls: 'xtb-text', html: config.text || ''};\r
- }\r
- T.TextItem.superclass.constructor.call(this, config);\r
- },\r
- /**\r
- * Updates this item's text, setting the text to be used as innerHTML.\r
- * @param {String} t The text to display (html accepted).\r
- */\r
- setText : function(t) {\r
- if (this.rendered) {\r
- this.el.dom.innerHTML = t;\r
- } else {\r
- this.autoEl.html = t;\r
- }\r
- }\r
-});\r
-Ext.reg('tbtext', T.TextItem);\r
-\r
-// backwards compat\r
-T.Button = Ext.extend(Ext.Button, {});\r
-T.SplitButton = Ext.extend(Ext.SplitButton, {});\r
-Ext.reg('tbbutton', T.Button);\r
-Ext.reg('tbsplit', T.SplitButton);\r
-\r
-})();\r
-/**\r
- * @class Ext.ButtonGroup\r
- * @extends Ext.Panel\r
- * Container for a group of buttons. Example usage:\r
- * <pre><code>\r
-var p = new Ext.Panel({\r
- title: 'Panel with Button Group',\r
- width: 300,\r
- height:200,\r
- renderTo: document.body,\r
- html: 'whatever',\r
- tbar: [{\r
- xtype: 'buttongroup',\r
- {@link #columns}: 3,\r
- title: 'Clipboard',\r
- items: [{\r
- text: 'Paste',\r
- scale: 'large',\r
- rowspan: 3, iconCls: 'add',\r
- iconAlign: 'top',\r
- cls: 'x-btn-as-arrow'\r
- },{\r
- xtype:'splitbutton',\r
- text: 'Menu Button',\r
- scale: 'large',\r
- rowspan: 3,\r
- iconCls: 'add',\r
- iconAlign: 'top',\r
- arrowAlign:'bottom',\r
- menu: [{text: 'Menu Item 1'}]\r
- },{\r
- xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]\r
- },{\r
- text: 'Copy', iconCls: 'add16'\r
- },{\r
- text: 'Format', iconCls: 'add16'\r
- }]\r
- }]\r
-});\r
- * </code></pre>\r
- * @xtype buttongroup\r
- */\r
-Ext.ButtonGroup = Ext.extend(Ext.Panel, {\r
- /**\r
- * @cfg {Number} columns The <tt>columns</tt> configuration property passed to the\r
- * {@link #layout configured layout manager}. See {@link Ext.layout.TableLayout#columns}.\r
- */\r
- /**\r
- * @cfg {String} baseCls Defaults to <tt>'x-btn-group'</tt>. See {@link Ext.Panel#baseCls}.\r
- */\r
- baseCls: 'x-btn-group',\r
- /**\r
- * @cfg {String} layout Defaults to <tt>'table'</tt>. See {@link Ext.Container#layout}.\r
- */\r
- layout:'table',\r
- defaultType: 'button',\r
- /**\r
- * @cfg {Boolean} frame Defaults to <tt>true</tt>. See {@link Ext.Panel#frame}.\r
- */\r
- frame: true,\r
- internalDefaults: {removeMode: 'container', hideParent: true},\r
-\r
- initComponent : function(){\r
- this.layoutConfig = this.layoutConfig || {};\r
- Ext.applyIf(this.layoutConfig, {\r
- columns : this.columns\r
- });\r
- if(!this.title){\r
- this.addClass('x-btn-group-notitle');\r
- }\r
- this.on('afterlayout', this.onAfterLayout, this);\r
- Ext.ButtonGroup.superclass.initComponent.call(this);\r
- },\r
-\r
- applyDefaults : function(c){\r
- c = Ext.ButtonGroup.superclass.applyDefaults.call(this, c);\r
- var d = this.internalDefaults;\r
- if(c.events){\r
- Ext.applyIf(c.initialConfig, d);\r
- Ext.apply(c, d);\r
- }else{\r
- Ext.applyIf(c, d);\r
- }\r
- return c;\r
- },\r
-\r
- onAfterLayout : function(){\r
- var bodyWidth = this.body.getFrameWidth('lr') + this.body.dom.firstChild.offsetWidth;\r
- this.body.setWidth(bodyWidth);\r
- this.el.setWidth(bodyWidth + this.getFrameWidth());\r
- }\r
- /**\r
- * @cfg {Array} tools @hide\r
- */\r
-});\r
-\r
-Ext.reg('buttongroup', Ext.ButtonGroup);\r
+/**
+ * @class Ext.Toolbar
+ * @extends Ext.Container
+ * <p>Basic Toolbar class. Although the <tt>{@link Ext.Container#defaultType defaultType}</tt> for Toolbar
+ * is <tt>{@link Ext.Button button}</tt>, Toolbar elements (child items for the Toolbar container) may
+ * be virtually any type of Component. Toolbar elements can be created explicitly via their constructors,
+ * or implicitly via their xtypes, and can be <tt>{@link #add}</tt>ed dynamically.</p>
+ * <p>Some items have shortcut strings for creation:</p>
+ * <pre>
+<u>Shortcut</u> <u>xtype</u> <u>Class</u> <u>Description</u>
+'->' 'tbfill' {@link Ext.Toolbar.Fill} begin using the right-justified button container
+'-' 'tbseparator' {@link Ext.Toolbar.Separator} add a vertical separator bar between toolbar items
+' ' 'tbspacer' {@link Ext.Toolbar.Spacer} add horiztonal space between elements
+ * </pre>
+ *
+ * Example usage of various elements:
+ * <pre><code>
+var tb = new Ext.Toolbar({
+ renderTo: document.body,
+ width: 600,
+ height: 100,
+ items: [
+ {
+ // xtype: 'button', // default for Toolbars, same as 'tbbutton'
+ text: 'Button'
+ },
+ {
+ xtype: 'splitbutton', // same as 'tbsplitbutton'
+ text: 'Split Button'
+ },
+ // begin using the right-justified button container
+ '->', // same as {xtype: 'tbfill'}, // Ext.Toolbar.Fill
+ {
+ xtype: 'textfield',
+ name: 'field1',
+ emptyText: 'enter search term'
+ },
+ // add a vertical separator bar between toolbar items
+ '-', // same as {xtype: 'tbseparator'} to create Ext.Toolbar.Separator
+ 'text 1', // same as {xtype: 'tbtext', text: 'text1'} to create Ext.Toolbar.TextItem
+ {xtype: 'tbspacer'},// same as ' ' to create Ext.Toolbar.Spacer
+ 'text 2',
+ {xtype: 'tbspacer', width: 50}, // add a 50px space
+ 'text 3'
+ ]
+});
+ * </code></pre>
+ * Example adding a ComboBox within a menu of a button:
+ * <pre><code>
+// ComboBox creation
+var combo = new Ext.form.ComboBox({
+ store: new Ext.data.ArrayStore({
+ autoDestroy: true,
+ fields: ['initials', 'fullname'],
+ data : [
+ ['FF', 'Fred Flintstone'],
+ ['BR', 'Barney Rubble']
+ ]
+ }),
+ displayField: 'fullname',
+ typeAhead: true,
+ mode: 'local',
+ forceSelection: true,
+ triggerAction: 'all',
+ emptyText: 'Select a name...',
+ selectOnFocus: true,
+ width: 135,
+ getListParent: function() {
+ return this.el.up('.x-menu');
+ },
+ iconCls: 'no-icon' //use iconCls if placing within menu to shift to right side of menu
+});
+
+// put ComboBox in a Menu
+var menu = new Ext.menu.Menu({
+ id: 'mainMenu',
+ items: [
+ combo // A Field in a Menu
+ ]
+});
+
+// add a Button with the menu
+tb.add({
+ text:'Button w/ Menu',
+ menu: menu // assign menu by instance
+ });
+tb.doLayout();
+ * </code></pre>
+ * @constructor
+ * Creates a new Toolbar
+ * @param {Object/Array} config A config object or an array of buttons to <tt>{@link #add}</tt>
+ * @xtype toolbar
+ */
+Ext.Toolbar = function(config){
+ if(Ext.isArray(config)){
+ config = {items: config, layout: 'toolbar'};
+ } else {
+ config = Ext.apply({
+ layout: 'toolbar'
+ }, config);
+ if(config.buttons) {
+ config.items = config.buttons;
+ }
+ }
+ Ext.Toolbar.superclass.constructor.call(this, config);
+};
+
+(function(){
+
+var T = Ext.Toolbar;
+
+Ext.extend(T, Ext.Container, {
+
+ defaultType: 'button',
+
+ /**
+ * @cfg {String/Object} layout
+ * This class assigns a default layout (<code>layout:'<b>toolbar</b>'</code>).
+ * Developers <i>may</i> override this configuration option if another layout
+ * is required (the constructor must be passed a configuration object in this
+ * case instead of an array).
+ * See {@link Ext.Container#layout} for additional information.
+ */
+
+ enableOverflow : false,
+
+ /**
+ * @cfg {Boolean} enableOverflow
+ * Defaults to false. Configure <code>true<code> to make the toolbar provide a button
+ * which activates a dropdown Menu to show items which overflow the Toolbar's width.
+ */
+ /**
+ * @cfg {String} buttonAlign
+ * <p>The default position at which to align child items. Defaults to <code>"left"</code></p>
+ * <p>May be specified as <code>"center"</code> to cause items added before a Fill (A <code>"->"</code>) item
+ * to be centered in the Toolbar. Items added after a Fill are still right-aligned.</p>
+ * <p>Specify as <code>"right"</code> to right align all child items.</p>
+ */
+
+ trackMenus : true,
+ internalDefaults: {removeMode: 'container', hideParent: true},
+ toolbarCls: 'x-toolbar',
+
+ initComponent : function(){
+ T.superclass.initComponent.call(this);
+
+ /**
+ * @event overflowchange
+ * Fires after the overflow state has changed.
+ * @param {Object} c The Container
+ * @param {Boolean} lastOverflow overflow state
+ */
+ this.addEvents('overflowchange');
+ },
+
+ // private
+ onRender : function(ct, position){
+ if(!this.el){
+ if(!this.autoCreate){
+ this.autoCreate = {
+ cls: this.toolbarCls + ' x-small-editor'
+ };
+ }
+ this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);
+ Ext.Toolbar.superclass.onRender.apply(this, arguments);
+ }
+ },
+
+ /**
+ * <p>Adds element(s) to the toolbar -- this function takes a variable number of
+ * arguments of mixed type and adds them to the toolbar.</p>
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @param {Mixed} arg1 The following types of arguments are all valid:<br />
+ * <ul>
+ * <li>{@link Ext.Button} config: A valid button config object (equivalent to {@link #addButton})</li>
+ * <li>HtmlElement: Any standard HTML element (equivalent to {@link #addElement})</li>
+ * <li>Field: Any form field (equivalent to {@link #addField})</li>
+ * <li>Item: Any subclass of {@link Ext.Toolbar.Item} (equivalent to {@link #addItem})</li>
+ * <li>String: Any generic string (gets wrapped in a {@link Ext.Toolbar.TextItem}, equivalent to {@link #addText}).
+ * Note that there are a few special strings that are treated differently as explained next.</li>
+ * <li>'-': Creates a separator element (equivalent to {@link #addSeparator})</li>
+ * <li>' ': Creates a spacer element (equivalent to {@link #addSpacer})</li>
+ * <li>'->': Creates a fill element (equivalent to {@link #addFill})</li>
+ * </ul>
+ * @param {Mixed} arg2
+ * @param {Mixed} etc.
+ * @method add
+ */
+
+ // private
+ lookupComponent : function(c){
+ if(Ext.isString(c)){
+ if(c == '-'){
+ c = new T.Separator();
+ }else if(c == ' '){
+ c = new T.Spacer();
+ }else if(c == '->'){
+ c = new T.Fill();
+ }else{
+ c = new T.TextItem(c);
+ }
+ this.applyDefaults(c);
+ }else{
+ if(c.isFormField || c.render){ // some kind of form field, some kind of Toolbar.Item
+ c = this.createComponent(c);
+ }else if(c.tag){ // DomHelper spec
+ c = new T.Item({autoEl: c});
+ }else if(c.tagName){ // element
+ c = new T.Item({el:c});
+ }else if(Ext.isObject(c)){ // must be button config?
+ c = c.xtype ? this.createComponent(c) : this.constructButton(c);
+ }
+ }
+ return c;
+ },
+
+ // private
+ applyDefaults : function(c){
+ if(!Ext.isString(c)){
+ c = Ext.Toolbar.superclass.applyDefaults.call(this, c);
+ var d = this.internalDefaults;
+ if(c.events){
+ Ext.applyIf(c.initialConfig, d);
+ Ext.apply(c, d);
+ }else{
+ Ext.applyIf(c, d);
+ }
+ }
+ return c;
+ },
+
+ /**
+ * Adds a separator
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @return {Ext.Toolbar.Item} The separator {@link Ext.Toolbar.Item item}
+ */
+ addSeparator : function(){
+ return this.add(new T.Separator());
+ },
+
+ /**
+ * Adds a spacer element
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @return {Ext.Toolbar.Spacer} The spacer item
+ */
+ addSpacer : function(){
+ return this.add(new T.Spacer());
+ },
+
+ /**
+ * Forces subsequent additions into the float:right toolbar
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ */
+ addFill : function(){
+ this.add(new T.Fill());
+ },
+
+ /**
+ * Adds any standard HTML element to the toolbar
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @param {Mixed} el The element or id of the element to add
+ * @return {Ext.Toolbar.Item} The element's item
+ */
+ addElement : function(el){
+ return this.addItem(new T.Item({el:el}));
+ },
+
+ /**
+ * Adds any Toolbar.Item or subclass
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @param {Ext.Toolbar.Item} item
+ * @return {Ext.Toolbar.Item} The item
+ */
+ addItem : function(item){
+ return this.add.apply(this, arguments);
+ },
+
+ /**
+ * Adds a button (or buttons). See {@link Ext.Button} for more info on the config.
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @param {Object/Array} config A button config or array of configs
+ * @return {Ext.Button/Array}
+ */
+ addButton : function(config){
+ if(Ext.isArray(config)){
+ var buttons = [];
+ for(var i = 0, len = config.length; i < len; i++) {
+ buttons.push(this.addButton(config[i]));
+ }
+ return buttons;
+ }
+ return this.add(this.constructButton(config));
+ },
+
+ /**
+ * Adds text to the toolbar
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @param {String} text The text to add
+ * @return {Ext.Toolbar.Item} The element's item
+ */
+ addText : function(text){
+ return this.addItem(new T.TextItem(text));
+ },
+
+ /**
+ * Adds a new element to the toolbar from the passed {@link Ext.DomHelper} config
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @param {Object} config
+ * @return {Ext.Toolbar.Item} The element's item
+ */
+ addDom : function(config){
+ return this.add(new T.Item({autoEl: config}));
+ },
+
+ /**
+ * Adds a dynamically rendered Ext.form field (TextField, ComboBox, etc). Note: the field should not have
+ * been rendered yet. For a field that has already been rendered, use {@link #addElement}.
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @param {Ext.form.Field} field
+ * @return {Ext.Toolbar.Item}
+ */
+ addField : function(field){
+ return this.add(field);
+ },
+
+ /**
+ * Inserts any {@link Ext.Toolbar.Item}/{@link Ext.Button} at the specified index.
+ * <br><p><b>Note</b>: See the notes within {@link Ext.Container#add}.</p>
+ * @param {Number} index The index where the item is to be inserted
+ * @param {Object/Ext.Toolbar.Item/Ext.Button/Array} item The button, or button config object to be
+ * inserted, or an array of buttons/configs.
+ * @return {Ext.Button/Item}
+ */
+ insertButton : function(index, item){
+ if(Ext.isArray(item)){
+ var buttons = [];
+ for(var i = 0, len = item.length; i < len; i++) {
+ buttons.push(this.insertButton(index + i, item[i]));
+ }
+ return buttons;
+ }
+ return Ext.Toolbar.superclass.insert.call(this, index, item);
+ },
+
+ // private
+ trackMenu : function(item, remove){
+ if(this.trackMenus && item.menu){
+ var method = remove ? 'mun' : 'mon';
+ this[method](item, 'menutriggerover', this.onButtonTriggerOver, this);
+ this[method](item, 'menushow', this.onButtonMenuShow, this);
+ this[method](item, 'menuhide', this.onButtonMenuHide, this);
+ }
+ },
+
+ // private
+ constructButton : function(item){
+ var b = item.events ? item : this.createComponent(item, item.split ? 'splitbutton' : this.defaultType);
+ return b;
+ },
+
+ // private
+ onAdd : function(c){
+ Ext.Toolbar.superclass.onAdd.call(this);
+ this.trackMenu(c);
+ if(this.disabled){
+ c.disable();
+ }
+ },
+
+ // private
+ onRemove : function(c){
+ Ext.Toolbar.superclass.onRemove.call(this);
+ this.trackMenu(c, true);
+ },
+
+ // private
+ onDisable : function(){
+ this.items.each(function(item){
+ if(item.disable){
+ item.disable();
+ }
+ });
+ },
+
+ // private
+ onEnable : function(){
+ this.items.each(function(item){
+ if(item.enable){
+ item.enable();
+ }
+ });
+ },
+
+ // private
+ onButtonTriggerOver : function(btn){
+ if(this.activeMenuBtn && this.activeMenuBtn != btn){
+ this.activeMenuBtn.hideMenu();
+ btn.showMenu();
+ this.activeMenuBtn = btn;
+ }
+ },
+
+ // private
+ onButtonMenuShow : function(btn){
+ this.activeMenuBtn = btn;
+ },
+
+ // private
+ onButtonMenuHide : function(btn){
+ delete this.activeMenuBtn;
+ }
+});
+Ext.reg('toolbar', Ext.Toolbar);
+
+/**
+ * @class Ext.Toolbar.Item
+ * @extends Ext.BoxComponent
+ * The base class that other non-interacting Toolbar Item classes should extend in order to
+ * get some basic common toolbar item functionality.
+ * @constructor
+ * Creates a new Item
+ * @param {HTMLElement} el
+ * @xtype tbitem
+ */
+T.Item = Ext.extend(Ext.BoxComponent, {
+ hideParent: true, // Hiding a Toolbar.Item hides its containing TD
+ enable:Ext.emptyFn,
+ disable:Ext.emptyFn,
+ focus:Ext.emptyFn
+ /**
+ * @cfg {String} overflowText Text to be used for the menu if the item is overflowed.
+ */
+});
+Ext.reg('tbitem', T.Item);
+
+/**
+ * @class Ext.Toolbar.Separator
+ * @extends Ext.Toolbar.Item
+ * A simple class that adds a vertical separator bar between toolbar items
+ * (css class:<tt>'xtb-sep'</tt>). Example usage:
+ * <pre><code>
+new Ext.Panel({
+ tbar : [
+ 'Item 1',
+ {xtype: 'tbseparator'}, // or '-'
+ 'Item 2'
+ ]
+});
+</code></pre>
+ * @constructor
+ * Creates a new Separator
+ * @xtype tbseparator
+ */
+T.Separator = Ext.extend(T.Item, {
+ onRender : function(ct, position){
+ this.el = ct.createChild({tag:'span', cls:'xtb-sep'}, position);
+ }
+});
+Ext.reg('tbseparator', T.Separator);
+
+/**
+ * @class Ext.Toolbar.Spacer
+ * @extends Ext.Toolbar.Item
+ * A simple element that adds extra horizontal space between items in a toolbar.
+ * By default a 2px wide space is added via css specification:<pre><code>
+.x-toolbar .xtb-spacer {
+ width:2px;
+}
+ * </code></pre>
+ * <p>Example usage:</p>
+ * <pre><code>
+new Ext.Panel({
+ tbar : [
+ 'Item 1',
+ {xtype: 'tbspacer'}, // or ' '
+ 'Item 2',
+ // space width is also configurable via javascript
+ {xtype: 'tbspacer', width: 50}, // add a 50px space
+ 'Item 3'
+ ]
+});
+</code></pre>
+ * @constructor
+ * Creates a new Spacer
+ * @xtype tbspacer
+ */
+T.Spacer = Ext.extend(T.Item, {
+ /**
+ * @cfg {Number} width
+ * The width of the spacer in pixels (defaults to 2px via css style <tt>.x-toolbar .xtb-spacer</tt>).
+ */
+
+ onRender : function(ct, position){
+ this.el = ct.createChild({tag:'div', cls:'xtb-spacer', style: this.width?'width:'+this.width+'px':''}, position);
+ }
+});
+Ext.reg('tbspacer', T.Spacer);
+
+/**
+ * @class Ext.Toolbar.Fill
+ * @extends Ext.Toolbar.Spacer
+ * A non-rendering placeholder item which instructs the Toolbar's Layout to begin using
+ * the right-justified button container.
+ * <pre><code>
+new Ext.Panel({
+ tbar : [
+ 'Item 1',
+ {xtype: 'tbfill'}, // or '->'
+ 'Item 2'
+ ]
+});
+</code></pre>
+ * @constructor
+ * Creates a new Fill
+ * @xtype tbfill
+ */
+T.Fill = Ext.extend(T.Item, {
+ // private
+ render : Ext.emptyFn,
+ isFill : true
+});
+Ext.reg('tbfill', T.Fill);
+
+/**
+ * @class Ext.Toolbar.TextItem
+ * @extends Ext.Toolbar.Item
+ * A simple class that renders text directly into a toolbar
+ * (with css class:<tt>'xtb-text'</tt>). Example usage:
+ * <pre><code>
+new Ext.Panel({
+ tbar : [
+ {xtype: 'tbtext', text: 'Item 1'} // or simply 'Item 1'
+ ]
+});
+</code></pre>
+ * @constructor
+ * Creates a new TextItem
+ * @param {String/Object} text A text string, or a config object containing a <tt>text</tt> property
+ * @xtype tbtext
+ */
+T.TextItem = Ext.extend(T.Item, {
+ /**
+ * @cfg {String} text The text to be used as innerHTML (html tags are accepted)
+ */
+
+ constructor: function(config){
+ T.TextItem.superclass.constructor.call(this, Ext.isString(config) ? {text: config} : config);
+ },
+
+ // private
+ onRender : function(ct, position) {
+ this.autoEl = {cls: 'xtb-text', html: this.text || ''};
+ T.TextItem.superclass.onRender.call(this, ct, position);
+ },
+
+ /**
+ * Updates this item's text, setting the text to be used as innerHTML.
+ * @param {String} t The text to display (html accepted).
+ */
+ setText : function(t) {
+ if(this.rendered){
+ this.el.update(t);
+ }else{
+ this.text = t;
+ }
+ }
+});
+Ext.reg('tbtext', T.TextItem);
+
+// backwards compat
+T.Button = Ext.extend(Ext.Button, {});
+T.SplitButton = Ext.extend(Ext.SplitButton, {});
+Ext.reg('tbbutton', T.Button);
+Ext.reg('tbsplit', T.SplitButton);
+
+})();
+/**
+ * @class Ext.ButtonGroup
+ * @extends Ext.Panel
+ * Container for a group of buttons. Example usage:
+ * <pre><code>
+var p = new Ext.Panel({
+ title: 'Panel with Button Group',
+ width: 300,
+ height:200,
+ renderTo: document.body,
+ html: 'whatever',
+ tbar: [{
+ xtype: 'buttongroup',
+ {@link #columns}: 3,
+ title: 'Clipboard',
+ items: [{
+ text: 'Paste',
+ scale: 'large',
+ rowspan: 3, iconCls: 'add',
+ iconAlign: 'top',
+ cls: 'x-btn-as-arrow'
+ },{
+ xtype:'splitbutton',
+ text: 'Menu Button',
+ scale: 'large',
+ rowspan: 3,
+ iconCls: 'add',
+ iconAlign: 'top',
+ arrowAlign:'bottom',
+ menu: [{text: 'Menu Item 1'}]
+ },{
+ xtype:'splitbutton', text: 'Cut', iconCls: 'add16', menu: [{text: 'Cut Menu Item'}]
+ },{
+ text: 'Copy', iconCls: 'add16'
+ },{
+ text: 'Format', iconCls: 'add16'
+ }]
+ }]
+});
+ * </code></pre>
+ * @constructor
+ * Create a new ButtonGroup.
+ * @param {Object} config The config object
+ * @xtype buttongroup
+ */
+Ext.ButtonGroup = Ext.extend(Ext.Panel, {
+ /**
+ * @cfg {Number} columns The <tt>columns</tt> configuration property passed to the
+ * {@link #layout configured layout manager}. See {@link Ext.layout.TableLayout#columns}.
+ */
+ /**
+ * @cfg {String} baseCls Defaults to <tt>'x-btn-group'</tt>. See {@link Ext.Panel#baseCls}.
+ */
+ baseCls: 'x-btn-group',
+ /**
+ * @cfg {String} layout Defaults to <tt>'table'</tt>. See {@link Ext.Container#layout}.
+ */
+ layout:'table',
+ defaultType: 'button',
+ /**
+ * @cfg {Boolean} frame Defaults to <tt>true</tt>. See {@link Ext.Panel#frame}.
+ */
+ frame: true,
+ internalDefaults: {removeMode: 'container', hideParent: true},
+
+ initComponent : function(){
+ this.layoutConfig = this.layoutConfig || {};
+ Ext.applyIf(this.layoutConfig, {
+ columns : this.columns
+ });
+ if(!this.title){
+ this.addClass('x-btn-group-notitle');
+ }
+ this.on('afterlayout', this.onAfterLayout, this);
+ Ext.ButtonGroup.superclass.initComponent.call(this);
+ },
+
+ applyDefaults : function(c){
+ c = Ext.ButtonGroup.superclass.applyDefaults.call(this, c);
+ var d = this.internalDefaults;
+ if(c.events){
+ Ext.applyIf(c.initialConfig, d);
+ Ext.apply(c, d);
+ }else{
+ Ext.applyIf(c, d);
+ }
+ return c;
+ },
+
+ onAfterLayout : function(){
+ var bodyWidth = this.body.getFrameWidth('lr') + this.body.dom.firstChild.offsetWidth;
+ this.body.setWidth(bodyWidth);
+ this.el.setWidth(bodyWidth + this.getFrameWidth());
+ }
+ /**
+ * @cfg {Array} tools @hide
+ */
+});
+
+Ext.reg('buttongroup', Ext.ButtonGroup);