📄 toolbar.js
字号:
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;
}
/**
* @cfg {String} autoEl @hide
*/
});
Ext.reg('toolbar', Ext.Toolbar);
/**
* @class Ext.Toolbar.Item
* The base class that other classes should extend in order to get some basic common toolbar item functionality.
* @constructor
* Creates a new Item
* @param {HTMLElement} el
*/
T.Item = function(el){
this.el = Ext.getDom(el);
this.id = Ext.id(this.el);
this.hidden = false;
};
T.Item.prototype = {
/**
* Get this item's HTML Element
* @return {HTMLElement}
*/
getEl : function(){
return this.el;
},
// private
render : function(td){
this.td = td;
td.appendChild(this.el);
},
/**
* Removes and destroys this item.
*/
destroy : function(){
if(this.el){
var el = Ext.get(this.el);
Ext.destroy(el);
}
Ext.removeNode(this.td);
},
/**
* Shows this item.
*/
show: function(){
this.hidden = false;
this.td.style.display = "";
},
/**
* Hides this item.
*/
hide: function(){
this.hidden = true;
this.td.style.display = "none";
},
/**
* Convenience function for boolean show/hide.
* @param {Boolean} visible true to show/false to hide
*/
setVisible: function(visible){
if(visible) {
this.show();
}else{
this.hide();
}
},
/**
* Try to focus this item
*/
focus : function(){
Ext.fly(this.el).focus();
},
/**
* Disables this item.
*/
disable : function(){
Ext.fly(this.td).addClass("x-item-disabled");
this.disabled = true;
this.el.disabled = true;
},
/**
* Enables this item.
*/
enable : function(){
Ext.fly(this.td).removeClass("x-item-disabled");
this.disabled = false;
this.el.disabled = false;
}
};
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. Example usage:
* <pre><code>
new Ext.Panel({
tbar : [
'Item 1',
{xtype: 'tbseparator'}, // or '-'
'Item 2'
]
});
</code></pre>
* @constructor
* Creates a new Separator
*/
T.Separator = function(){
var s = document.createElement("span");
s.className = "ytb-sep";
T.Separator.superclass.constructor.call(this, s);
};
Ext.extend(T.Separator, T.Item, {
enable:Ext.emptyFn,
disable:Ext.emptyFn,
focus:Ext.emptyFn
});
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.
* <pre><code>
new Ext.Panel({
tbar : [
'Item 1',
{xtype: 'tbspacer'}, // or ' '
'Item 2'
]
});
</code></pre>
* @constructor
* Creates a new Spacer
*/
T.Spacer = function(){
var s = document.createElement("div");
s.className = "ytb-spacer";
T.Spacer.superclass.constructor.call(this, s);
};
Ext.extend(T.Spacer, T.Item, {
enable:Ext.emptyFn,
disable:Ext.emptyFn,
focus:Ext.emptyFn
});
Ext.reg('tbspacer', T.Spacer);
/**
* @class Ext.Toolbar.Fill
* @extends Ext.Toolbar.Spacer
* A simple element that adds a greedy (100% width) horizontal space between items in a toolbar.
* <pre><code>
new Ext.Panel({
tbar : [
'Item 1',
{xtype: 'tbfill'}, // or '->'
'Item 2'
]
});
</code></pre>
* @constructor
* Creates a new Spacer
*/
T.Fill = Ext.extend(T.Spacer, {
// private
render : function(td){
td.style.width = '100%';
T.Fill.superclass.render.call(this, td);
}
});
Ext.reg('tbfill', T.Fill);
/**
* @class Ext.Toolbar.TextItem
* @extends Ext.Toolbar.Item
* A simple class that renders text directly into a toolbar.
* <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
*/
T.TextItem = function(t){
var s = document.createElement("span");
s.className = "ytb-text";
s.innerHTML = t.text ? t.text : t;
T.TextItem.superclass.constructor.call(this, s);
};
Ext.extend(T.TextItem, T.Item, {
enable:Ext.emptyFn,
disable:Ext.emptyFn,
focus:Ext.emptyFn
});
Ext.reg('tbtext', T.TextItem);
/**
* @class Ext.Toolbar.Button
* @extends Ext.Button
* A button that renders into a toolbar. Use the <tt>handler</tt> config to specify a callback function
* to handle the button's click event.
* <pre><code>
new Ext.Panel({
tbar : [
{text: 'OK', handler: okHandler} // tbbutton is the default xtype if not specified
]
});
</code></pre>
* @constructor
* Creates a new Button
* @param {Object} config A standard {@link Ext.Button} config object
*/
T.Button = Ext.extend(Ext.Button, {
hideParent : true,
onDestroy : function(){
T.Button.superclass.onDestroy.call(this);
if(this.container){
this.container.remove();
}
}
});
Ext.reg('tbbutton', T.Button);
/**
* @class Ext.Toolbar.SplitButton
* @extends Ext.SplitButton
* A split button that renders into a toolbar.
* <pre><code>
new Ext.Panel({
tbar : [
{
xtype: 'tbsplit',
text: 'Options',
handler: optionsHandler, // handle a click on the button itself
menu: new Ext.menu.Menu({
items: [
// These items will display in a dropdown menu when the split arrow is clicked
{text: 'Item 1', handler: item1Handler},
{text: 'Item 2', handler: item2Handler}
]
})
}
]
});
</code></pre>
* @constructor
* Creates a new SplitButton
* @param {Object} config A standard {@link Ext.SplitButton} config object
*/
T.SplitButton = Ext.extend(Ext.SplitButton, {
hideParent : true,
onDestroy : function(){
T.SplitButton.superclass.onDestroy.call(this);
if(this.container){
this.container.remove();
}
}
});
Ext.reg('tbsplit', T.SplitButton);
// backwards compat
T.MenuButton = T.SplitButton;
})();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -