X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..6b044c28b5f26fb99c86c237ffad19741c0f7f3d:/pkgs/pkg-toolbars-debug.js diff --git a/pkgs/pkg-toolbars-debug.js b/pkgs/pkg-toolbars-debug.js index 5daf84c5..8354914c 100644 --- a/pkgs/pkg-toolbars-debug.js +++ b/pkgs/pkg-toolbars-debug.js @@ -1,881 +1,688 @@ /*! - * Ext JS Library 3.0.0 - * Copyright(c) 2006-2009 Ext JS, LLC - * licensing@extjs.com - * http://www.extjs.com/license + * Ext JS Library 3.3.1 + * Copyright(c) 2006-2010 Sencha Inc. + * licensing@sencha.com + * http://www.sencha.com/license */ -/** - * @class Ext.layout.ToolbarLayout - * @extends Ext.layout.ContainerLayout - * Layout manager implicitly used by Ext.Toolbar. - */ -Ext.layout.ToolbarLayout = Ext.extend(Ext.layout.ContainerLayout, { - monitorResize : true, - triggerWidth : 18, - lastOverflow : false, - - noItemsMenuText : '
', - // private - onLayout : function(ct, target){ - if(!this.leftTr){ - target.addClass('x-toolbar-layout-ct'); - target.insertHtml('beforeEnd', - 'Basic Toolbar class. Although the {@link Ext.Container#defaultType defaultType} for Toolbar - * is {@link Ext.Button button}, 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 {@link #add}ed dynamically.
- *Some items have shortcut strings for creation:
- *-Shortcut xtype Class Description -'->' '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 - *- * - * Example usage of various elements: - *
-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'
- ]
-});
- *
- * Example adding a ComboBox within a menu of a button:
- *
-// 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();
- *
- * @constructor
- * Creates a new Toolbar
- * @param {Object/Array} config A config object or an array of buttons to {@link #add}
- * @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',
-
- 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);
- }
- },
-
- /**
- * Adds element(s) to the toolbar -- this function takes a variable number of
- * arguments of mixed type and adds them to the toolbar.
- * @param {Mixed} arg1 The following types of arguments are all valid:
-new Ext.Panel({
- tbar : [
- 'Item 1',
- {xtype: 'tbseparator'}, // or '-'
- 'Item 2'
- ]
-});
-
- * @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:
-.x-toolbar .xtb-spacer {
- width:2px;
-}
- *
- * Example usage:
- *
-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'
- ]
-});
-
- * @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 .x-toolbar .xtb-spacer).
- */
-
- 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.
- *
-new Ext.Panel({
- tbar : [
- 'Item 1',
- {xtype: 'tbfill'}, // or '->'
- 'Item 2'
- ]
-});
-
- * @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:'xtb-text'). Example usage:
- *
-new Ext.Panel({
- tbar : [
- {xtype: 'tbtext', text: 'Item 1'} // or simply 'Item 1'
- ]
-});
-
- * @constructor
- * Creates a new TextItem
- * @param {String/Object} text A text string, or a config object containing a text property
- * @xtype tbtext
- */
-T.TextItem = Ext.extend(T.Item, {
- constructor: function(config){
- if (Ext.isString(config)) {
- config = { autoEl: {cls: 'xtb-text', html: config }};
- } else {
- config.autoEl = {cls: 'xtb-text', html: config.text || ''};
- }
- T.TextItem.superclass.constructor.call(this, config);
- },
- /**
- * 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.dom.innerHTML = t;
- } else {
- this.autoEl.html = 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:
- *
-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'
- }]
- }]
-});
- *
- * @xtype buttongroup
- */
-Ext.ButtonGroup = Ext.extend(Ext.Panel, {
- /**
- * @cfg {Number} columns The columns configuration property passed to the
- * {@link #layout configured layout manager}. See {@link Ext.layout.TableLayout#columns}.
- */
- /**
- * @cfg {String} baseCls Defaults to 'x-btn-group'. See {@link Ext.Panel#baseCls}.
- */
- baseCls: 'x-btn-group',
- /**
- * @cfg {String} layout Defaults to 'table'. See {@link Ext.Container#layout}.
- */
- layout:'table',
- defaultType: 'button',
- /**
- * @cfg {Boolean} frame Defaults to true. 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);
+/**
+ * @class Ext.Toolbar
+ * @extends Ext.Container
+ * Basic Toolbar class. Although the {@link Ext.Container#defaultType defaultType} for Toolbar + * is {@link Ext.Button button}, 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 {@link #add}ed dynamically.
+ *Some items have shortcut strings for creation:
+ *+Shortcut xtype Class Description +'->' '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 + *+ * + * Example usage of various elements: + *
+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'
+ ]
+});
+ *
+ * Example adding a ComboBox within a menu of a button:
+ *
+// 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();
+ *
+ * @constructor
+ * Creates a new Toolbar
+ * @param {Object/Array} config A config object or an array of buttons to {@link #add}
+ * @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 (layout:'toolbar'
).
+ * Developers may 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 true to make the toolbar provide a button
+ * which activates a dropdown Menu to show items which overflow the Toolbar's width.
+ */
+ /**
+ * @cfg {String} buttonAlign
+ * The default position at which to align child items. Defaults to "left"
May be specified as "center"
to cause items added before a Fill (A "->"
) item
+ * to be centered in the Toolbar. Items added after a Fill are still right-aligned.
Specify as "right"
to right align all child items.
Adds element(s) to the toolbar -- this function takes a variable number of + * arguments of mixed type and adds them to the toolbar.
+ *Note: See the notes within {@link Ext.Container#add}.
+ * @param {Mixed} arg1 The following types of arguments are all valid:Note: See the notes within {@link Ext.Container#add}.
+ * @return {Ext.Toolbar.Item} The separator {@link Ext.Toolbar.Item item} + */ + addSeparator : function(){ + return this.add(new T.Separator()); + }, + + /** + * Adds a spacer element + *Note: See the notes within {@link Ext.Container#add}.
+ * @return {Ext.Toolbar.Spacer} The spacer item + */ + addSpacer : function(){ + return this.add(new T.Spacer()); + }, + + /** + * Forces subsequent additions into the float:right toolbar + *Note: See the notes within {@link Ext.Container#add}.
+ */ + addFill : function(){ + this.add(new T.Fill()); + }, + + /** + * Adds any standard HTML element to the toolbar + *Note: See the notes within {@link Ext.Container#add}.
+ * @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 + *Note: See the notes within {@link Ext.Container#add}.
+ * @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. + *Note: See the notes within {@link Ext.Container#add}.
+ * @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 + *Note: See the notes within {@link Ext.Container#add}.
+ * @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 + *Note: See the notes within {@link Ext.Container#add}.
+ * @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}. + *Note: See the notes within {@link Ext.Container#add}.
+ * @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. + *Note: See the notes within {@link Ext.Container#add}.
+ * @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); + if (c == this.activeMenuBtn) { + delete this.activeMenuBtn; + } + 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:'xtb-sep'). Example usage: + *
+new Ext.Panel({
+ tbar : [
+ 'Item 1',
+ {xtype: 'tbseparator'}, // or '-'
+ 'Item 2'
+ ]
+});
+
+ * @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:
+.x-toolbar .xtb-spacer {
+ width:2px;
+}
+ *
+ * Example usage:
+ *
+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'
+ ]
+});
+
+ * @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 .x-toolbar .xtb-spacer).
+ */
+
+ 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.
+ *
+new Ext.Panel({
+ tbar : [
+ 'Item 1',
+ {xtype: 'tbfill'}, // or '->'
+ 'Item 2'
+ ]
+});
+
+ * @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:'xtb-text'). Example usage:
+ *
+new Ext.Panel({
+ tbar : [
+ {xtype: 'tbtext', text: 'Item 1'} // or simply 'Item 1'
+ ]
+});
+
+ * @constructor
+ * Creates a new TextItem
+ * @param {String/Object} text A text string, or a config object containing a text 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:
+ *
+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'
+ }]
+ }]
+});
+ *
+ * @constructor
+ * Create a new ButtonGroup.
+ * @param {Object} config The config object
+ * @xtype buttongroup
+ */
+Ext.ButtonGroup = Ext.extend(Ext.Panel, {
+ /**
+ * @cfg {Number} columns The columns configuration property passed to the
+ * {@link #layout configured layout manager}. See {@link Ext.layout.TableLayout#columns}.
+ */
+ /**
+ * @cfg {String} baseCls Defaults to 'x-btn-group'. See {@link Ext.Panel#baseCls}.
+ */
+ baseCls: 'x-btn-group',
+ /**
+ * @cfg {String} layout Defaults to 'table'. See {@link Ext.Container#layout}.
+ */
+ layout:'table',
+ defaultType: 'button',
+ /**
+ * @cfg {Boolean} frame Defaults to true. 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);
/**
* @class Ext.PagingToolbar
* @extends Ext.Toolbar
@@ -895,10 +702,14 @@ Ext.reg('buttongroup', Ext.ButtonGroup);
Ext.QuickTips.init(); // to display button quicktips
var myStore = new Ext.data.Store({
+ reader: new Ext.data.JsonReader({
+ {@link Ext.data.JsonReader#totalProperty totalProperty}: 'results',
+ ...
+ }),
...
});
-var myPageSize = 25; // server script should only send back 25 items
+var myPageSize = 25; // server script should only send back 25 items at a time
var grid = new Ext.grid.GridPanel({
...
@@ -919,20 +730,43 @@ var grid = new Ext.grid.GridPanel({
*
store.load({
params: {
- start: 0, // specify params for the first page load if using paging
+ // specify params for the first page load if using paging
+ start: 0,
limit: myPageSize,
+ // other params
foo: 'bar'
}
});
+ *
+ *
+ * If using {@link Ext.data.Store#autoLoad store's autoLoad} configuration:
+ *
+var myStore = new Ext.data.Store({
+ {@link Ext.data.Store#autoLoad autoLoad}: {params:{start: 0, limit: 25}},
+ ...
+});
+ *
+ *
+ * The packet sent back from the server would have this form:
+ *
+{
+ "success": true,
+ "results": 2000,
+ "rows": [ // *Note: this must be an Array
+ { "id": 1, "name": "Bill", "occupation": "Gardener" },
+ { "id": 2, "name": "Ben", "occupation": "Horticulturalist" },
+ ...
+ { "id": 25, "name": "Sue", "occupation": "Botanist" }
+ ]
+}
*
* Paging with Local Data
*Paging can also be accomplished with local data using extensions:
*Deprecated. paramNames
should be set in the data store
+ * (see {@link Ext.data.Store#paramNames}).
Object mapping of parameter names used for load calls, initially set to:
*{start: 'start', limit: 'limit'}+ * @type Object + * @property paramNames + * @deprecated */ /** @@ -1061,6 +898,7 @@ Ext.PagingToolbar = Ext.extend(Ext.Toolbar, { allowNegative: false, enableKeyEvents: true, selectOnFocus: true, + submitValue: false, listeners: { scope: this, keydown: this.onPagingKeyDown, @@ -1086,7 +924,7 @@ Ext.PagingToolbar = Ext.extend(Ext.Toolbar, { tooltip: this.refreshText, overflowText: this.refreshText, iconCls: 'x-tbar-loading', - handler: this.refresh, + handler: this.doRefresh, scope: this })]; @@ -1136,7 +974,7 @@ Ext.PagingToolbar = Ext.extend(Ext.Toolbar, { ); this.on('afterlayout', this.onFirstLayout, this, {single: true}); this.cursor = 0; - this.bindStore(this.store); + this.bindStore(this.store, true); }, // private @@ -1312,7 +1150,7 @@ Ext.PagingToolbar = Ext.extend(Ext.Toolbar, { /** * Refresh the current page, has the same effect as clicking the 'refresh' button. */ - refresh : function(){ + doRefresh : function(){ this.doLoad(this.cursor); }, @@ -1324,11 +1162,15 @@ Ext.PagingToolbar = Ext.extend(Ext.Toolbar, { bindStore : function(store, initial){ var doLoad; if(!initial && this.store){ - this.store.un('beforeload', this.beforeLoad, this); - this.store.un('load', this.onLoad, this); - this.store.un('exception', this.onLoadError, this); if(store !== this.store && this.store.autoDestroy){ this.store.destroy(); + }else{ + this.store.un('beforeload', this.beforeLoad, this); + this.store.un('load', this.onLoad, this); + this.store.un('exception', this.onLoadError, this); + } + if(!store){ + this.store = null; } } if(store){ @@ -1339,7 +1181,7 @@ Ext.PagingToolbar = Ext.extend(Ext.Toolbar, { load: this.onLoad, exception: this.onLoadError }); - doLoad = store.getCount() > 0; + doLoad = true; } this.store = store; if(doLoad){