tvheadend/vendor/ext-3.4.1/docs/source/Toolbar.html
Adam Sutton bafcfff42d webui: restructure webui/extjs source files
I want to keep the 3rd-party packages away from the main source
where possible.
2013-06-03 17:11:01 +01:00

599 lines
21 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js"><span id='Ext-Toolbar-method-constructor'><span id='Ext-Toolbar'>/**
</span></span> * @class Ext.Toolbar
* @extends Ext.Container
* &lt;p&gt;Basic Toolbar class. Although the &lt;tt&gt;{@link Ext.Container#defaultType defaultType}&lt;/tt&gt; for Toolbar
* is &lt;tt&gt;{@link Ext.Button button}&lt;/tt&gt;, 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 &lt;tt&gt;{@link #add}&lt;/tt&gt;ed dynamically.&lt;/p&gt;
* &lt;p&gt;Some items have shortcut strings for creation:&lt;/p&gt;
* &lt;pre&gt;
&lt;u&gt;Shortcut&lt;/u&gt; &lt;u&gt;xtype&lt;/u&gt; &lt;u&gt;Class&lt;/u&gt; &lt;u&gt;Description&lt;/u&gt;
'-&gt;' '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
* &lt;/pre&gt;
*
* Example usage of various elements:
* &lt;pre&gt;&lt;code&gt;
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
'-&gt;', // 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'
]
});
* &lt;/code&gt;&lt;/pre&gt;
* Example adding a ComboBox within a menu of a button:
* &lt;pre&gt;&lt;code&gt;
// 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();
* &lt;/code&gt;&lt;/pre&gt;
* @constructor
* Creates a new Toolbar
* @param {Object/Array} config A config object or an array of buttons to &lt;tt&gt;{@link #add}&lt;/tt&gt;
* @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',
<span id='Ext-Toolbar-cfg-layout'> /**
</span> * @cfg {String/Object} layout
* This class assigns a default layout (&lt;code&gt;layout:'&lt;b&gt;toolbar&lt;/b&gt;'&lt;/code&gt;).
* Developers &lt;i&gt;may&lt;/i&gt; 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,
<span id='Ext-Toolbar-cfg-enableOverflow'> /**
</span> * @cfg {Boolean} enableOverflow
* Defaults to false. Configure &lt;tt&gt;true&lt;/tt&gt; to make the toolbar provide a button
* which activates a dropdown Menu to show items which overflow the Toolbar's width.
*/
<span id='Ext-Toolbar-cfg-buttonAlign'> /**
</span> * @cfg {String} buttonAlign
* &lt;p&gt;The default position at which to align child items. Defaults to &lt;code&gt;&quot;left&quot;&lt;/code&gt;&lt;/p&gt;
* &lt;p&gt;May be specified as &lt;code&gt;&quot;center&quot;&lt;/code&gt; to cause items added before a Fill (A &lt;code&gt;&quot;-&gt;&quot;&lt;/code&gt;) item
* to be centered in the Toolbar. Items added after a Fill are still right-aligned.&lt;/p&gt;
* &lt;p&gt;Specify as &lt;code&gt;&quot;right&quot;&lt;/code&gt; to right align all child items.&lt;/p&gt;
*/
trackMenus : true,
internalDefaults: {removeMode: 'container', hideParent: true},
toolbarCls: 'x-toolbar',
initComponent : function(){
T.superclass.initComponent.call(this);
<span id='Ext-Toolbar-event-overflowchange'> /**
</span> * @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);
}
},
<span id='Ext-Toolbar-method-add'> /**
</span> * &lt;p&gt;Adds element(s) to the toolbar -- this function takes a variable number of
* arguments of mixed type and adds them to the toolbar.&lt;/p&gt;
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @param {Mixed} arg1 The following types of arguments are all valid:&lt;br /&gt;
* &lt;ul&gt;
* &lt;li&gt;{@link Ext.Button} config: A valid button config object (equivalent to {@link #addButton})&lt;/li&gt;
* &lt;li&gt;HtmlElement: Any standard HTML element (equivalent to {@link #addElement})&lt;/li&gt;
* &lt;li&gt;Field: Any form field (equivalent to {@link #addField})&lt;/li&gt;
* &lt;li&gt;Item: Any subclass of {@link Ext.Toolbar.Item} (equivalent to {@link #addItem})&lt;/li&gt;
* &lt;li&gt;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.&lt;/li&gt;
* &lt;li&gt;'-': Creates a separator element (equivalent to {@link #addSeparator})&lt;/li&gt;
* &lt;li&gt;' ': Creates a spacer element (equivalent to {@link #addSpacer})&lt;/li&gt;
* &lt;li&gt;'-&gt;': Creates a fill element (equivalent to {@link #addFill})&lt;/li&gt;
* &lt;/ul&gt;
* @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 == '-&gt;'){
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;
},
<span id='Ext-Toolbar-method-addSeparator'> /**
</span> * Adds a separator
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @return {Ext.Toolbar.Item} The separator {@link Ext.Toolbar.Item item}
*/
addSeparator : function(){
return this.add(new T.Separator());
},
<span id='Ext-Toolbar-method-addSpacer'> /**
</span> * Adds a spacer element
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @return {Ext.Toolbar.Spacer} The spacer item
*/
addSpacer : function(){
return this.add(new T.Spacer());
},
<span id='Ext-Toolbar-method-addFill'> /**
</span> * Forces subsequent additions into the float:right toolbar
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
*/
addFill : function(){
this.add(new T.Fill());
},
<span id='Ext-Toolbar-method-addElement'> /**
</span> * Adds any standard HTML element to the toolbar
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @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}));
},
<span id='Ext-Toolbar-method-addItem'> /**
</span> * Adds any Toolbar.Item or subclass
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @param {Ext.Toolbar.Item} item
* @return {Ext.Toolbar.Item} The item
*/
addItem : function(item){
return this.add.apply(this, arguments);
},
<span id='Ext-Toolbar-method-addButton'> /**
</span> * Adds a button (or buttons). See {@link Ext.Button} for more info on the config.
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @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 &lt; len; i++) {
buttons.push(this.addButton(config[i]));
}
return buttons;
}
return this.add(this.constructButton(config));
},
<span id='Ext-Toolbar-method-addText'> /**
</span> * Adds text to the toolbar
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @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));
},
<span id='Ext-Toolbar-method-addDom'> /**
</span> * Adds a new element to the toolbar from the passed {@link Ext.DomHelper} config
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @param {Object} config
* @return {Ext.Toolbar.Item} The element's item
*/
addDom : function(config){
return this.add(new T.Item({autoEl: config}));
},
<span id='Ext-Toolbar-method-addField'> /**
</span> * 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}.
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @param {Ext.form.Field} field
* @return {Ext.Toolbar.Item}
*/
addField : function(field){
return this.add(field);
},
<span id='Ext-Toolbar-method-insertButton'> /**
</span> * Inserts any {@link Ext.Toolbar.Item}/{@link Ext.Button} at the specified index.
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: See the notes within {@link Ext.Container#add}.&lt;/p&gt;
* @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 &lt; 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 &amp;&amp; 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 &amp;&amp; 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);
<span id='Ext-Toolbar-Item-method-constructor'><span id='Ext-Toolbar-Item'>/**
</span></span> * @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, {
<span id='Ext-Toolbar-Item-method-enable'><span id='Ext-Toolbar-Item-cfg-hideParent'> hideParent: true, // Hiding a Toolbar.Item hides its containing TD
</span></span> enable:Ext.emptyFn,
<span id='Ext-Toolbar-Item-method-disable'> disable:Ext.emptyFn,
</span><span id='Ext-Toolbar-Item-method-focus'> focus:Ext.emptyFn
</span><span id='Ext-Toolbar-Item-cfg-overflowText'> /**
</span> * @cfg {String} overflowText Text to be used for the menu if the item is overflowed.
*/
});
Ext.reg('tbitem', T.Item);
<span id='Ext-Toolbar-Separator-method-constructor'><span id='Ext-Toolbar-Separator'>/**
</span></span> * @class Ext.Toolbar.Separator
* @extends Ext.Toolbar.Item
* A simple class that adds a vertical separator bar between toolbar items
* (css class:&lt;tt&gt;'xtb-sep'&lt;/tt&gt;). Example usage:
* &lt;pre&gt;&lt;code&gt;
new Ext.Panel({
tbar : [
'Item 1',
{xtype: 'tbseparator'}, // or '-'
'Item 2'
]
});
&lt;/code&gt;&lt;/pre&gt;
* @constructor
* Creates a new Separator
* @xtype tbseparator
*/
T.Separator = Ext.extend(T.Item, {
<span id='Ext-Toolbar-Separator-method-onRender'> onRender : function(ct, position){
</span> this.el = ct.createChild({tag:'span', cls:'xtb-sep'}, position);
}
});
Ext.reg('tbseparator', T.Separator);
<span id='Ext-Toolbar-Spacer-method-constructor'><span id='Ext-Toolbar-Spacer'>/**
</span></span> * @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:&lt;pre&gt;&lt;code&gt;
.x-toolbar .xtb-spacer {
width:2px;
}
* &lt;/code&gt;&lt;/pre&gt;
* &lt;p&gt;Example usage:&lt;/p&gt;
* &lt;pre&gt;&lt;code&gt;
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'
]
});
&lt;/code&gt;&lt;/pre&gt;
* @constructor
* Creates a new Spacer
* @xtype tbspacer
*/
T.Spacer = Ext.extend(T.Item, {
<span id='Ext-Toolbar-Spacer-cfg-width'> /**
</span> * @cfg {Number} width
* The width of the spacer in pixels (defaults to 2px via css style &lt;tt&gt;.x-toolbar .xtb-spacer&lt;/tt&gt;).
*/
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);
<span id='Ext-Toolbar-Fill-method-constructor'><span id='Ext-Toolbar-Fill'>/**
</span></span> * @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.
* &lt;pre&gt;&lt;code&gt;
new Ext.Panel({
tbar : [
'Item 1',
{xtype: 'tbfill'}, // or '-&gt;'
'Item 2'
]
});
&lt;/code&gt;&lt;/pre&gt;
* @constructor
* Creates a new Fill
* @xtype tbfill
*/
T.Fill = Ext.extend(T.Item, {
<span id='Ext-Toolbar-Fill-method-render'> // private
</span> render : Ext.emptyFn,
<span id='Ext-Toolbar-Fill-property-isFill'> isFill : true
</span>});
Ext.reg('tbfill', T.Fill);
<span id='Ext-Toolbar-TextItem-method-constructor'><span id='Ext-Toolbar-TextItem'>/**
</span></span> * @class Ext.Toolbar.TextItem
* @extends Ext.Toolbar.Item
* A simple class that renders text directly into a toolbar
* (with css class:&lt;tt&gt;'xtb-text'&lt;/tt&gt;). Example usage:
* &lt;pre&gt;&lt;code&gt;
new Ext.Panel({
tbar : [
{xtype: 'tbtext', text: 'Item 1'} // or simply 'Item 1'
]
});
&lt;/code&gt;&lt;/pre&gt;
* @constructor
* Creates a new TextItem
* @param {String/Object} text A text string, or a config object containing a &lt;tt&gt;text&lt;/tt&gt; property
* @xtype tbtext
*/
T.TextItem = Ext.extend(T.Item, {
<span id='Ext-Toolbar-TextItem-cfg-text'> /**
</span> * @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);
},
<span id='Ext-Toolbar-TextItem-method-onRender'> // private
</span> onRender : function(ct, position) {
this.autoEl = {cls: 'xtb-text', html: this.text || ''};
T.TextItem.superclass.onRender.call(this, ct, position);
},
<span id='Ext-Toolbar-TextItem-method-setText'> /**
</span> * 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);
})();
</pre>
</body>
</html>