📄 panel.js
字号:
}
if(this.bodyBorder === false){
this.body.addClass(this.bodyCls + '-noborder');
}
this.bwrap.enableDisplayMode('block');
if(this.header){
this.header.unselectable();
// for tools, we need to wrap any existing header markup
if(this.headerAsText){
this.header.dom.innerHTML =
'<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>';
if(this.iconCls){
this.setIconClass(this.iconCls);
}
}
}
if(this.floating){
this.makeFloating(this.floating);
}
if(this.collapsible){
this.tools = this.tools ? this.tools.slice(0) : [];
if(!this.hideCollapseTool){
this.tools[this.collapseFirst?'unshift':'push']({
id: 'toggle',
handler : this.toggleCollapse,
scope: this
});
}
if(this.titleCollapse && this.header){
this.header.on('click', this.toggleCollapse, this);
this.header.setStyle('cursor', 'pointer');
}
}
if(this.tools){
var ts = this.tools;
this.tools = {};
this.addTool.apply(this, ts);
}else{
this.tools = {};
}
if(this.buttons && this.buttons.length > 0){
// tables are required to maintain order and for correct IE layout
var tb = this.footer.createChild({cls:'x-panel-btns-ct', cn: {
cls:"x-panel-btns x-panel-btns-"+this.buttonAlign,
html:'<table cellspacing="0"><tbody><tr></tr></tbody></table><div class="x-clear"></div>'
}}, null, true);
var tr = tb.getElementsByTagName('tr')[0];
for(var i = 0, len = this.buttons.length; i < len; i++) {
var b = this.buttons[i];
var td = document.createElement('td');
td.className = 'x-panel-btn-td';
b.render(tr.appendChild(td));
}
}
if(this.tbar && this.topToolbar){
if(Ext.isArray(this.topToolbar)){
this.topToolbar = new Ext.Toolbar(this.topToolbar);
}
this.topToolbar.render(this.tbar);
this.topToolbar.ownerCt = this;
}
if(this.bbar && this.bottomToolbar){
if(Ext.isArray(this.bottomToolbar)){
this.bottomToolbar = new Ext.Toolbar(this.bottomToolbar);
}
this.bottomToolbar.render(this.bbar);
this.bottomToolbar.ownerCt = this;
}
},
/**
* Sets the CSS class that provides the icon image for this panel. This method will replace any existing
* icon class if one has already been set.
* @param {String} cls The new CSS class name
*/
setIconClass : function(cls){
var old = this.iconCls;
this.iconCls = cls;
if(this.rendered && this.header){
if(this.frame){
this.header.addClass('x-panel-icon');
this.header.replaceClass(old, this.iconCls);
}else{
var hd = this.header.dom;
var img = hd.firstChild && String(hd.firstChild.tagName).toLowerCase() == 'img' ? hd.firstChild : null;
if(img){
Ext.fly(img).replaceClass(old, this.iconCls);
}else{
Ext.DomHelper.insertBefore(hd.firstChild, {
tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
});
}
}
}
this.fireEvent('iconchange', this, cls, old);
},
// private
makeFloating : function(cfg){
this.floating = true;
this.el = new Ext.Layer(
typeof cfg == 'object' ? cfg : {
shadow: this.shadow !== undefined ? this.shadow : 'sides',
shadowOffset: this.shadowOffset,
constrain:false,
shim: this.shim === false ? false : undefined
}, this.el
);
},
/**
* Returns the toolbar from the top (tbar) section of the panel.
* @return {Ext.Toolbar} The toolbar
*/
getTopToolbar : function(){
return this.topToolbar;
},
/**
* Returns the toolbar from the bottom (bbar) section of the panel.
* @return {Ext.Toolbar} The toolbar
*/
getBottomToolbar : function(){
return this.bottomToolbar;
},
/**
* Adds a button to this panel. Note that this method must be called prior to rendering. The preferred
* approach is to add buttons via the {@link #buttons} config.
* @param {String/Object} config A valid {@link Ext.Button} config. A string will become the text for a default
* button config, an object will be treated as a button config object.
* @param {Function} handler The function to be called on button {@link Ext.Button#click}
* @param {Object} scope The scope to use for the button handler function
* @return {Ext.Button} The button that was added
*/
addButton : function(config, handler, scope){
var bc = {
handler: handler,
scope: scope,
minWidth: this.minButtonWidth,
hideParent:true
};
if(typeof config == "string"){
bc.text = config;
}else{
Ext.apply(bc, config);
}
var btn = new Ext.Button(bc);
btn.ownerCt = this;
if(!this.buttons){
this.buttons = [];
}
this.buttons.push(btn);
return btn;
},
// private
addTool : function(){
if(!this[this.toolTarget]) { // no where to render tools!
return;
}
if(!this.toolTemplate){
// initialize the global tool template on first use
var tt = new Ext.Template(
'<div class="x-tool x-tool-{id}"> </div>'
);
tt.disableFormats = true;
tt.compile();
Ext.Panel.prototype.toolTemplate = tt;
}
for(var i = 0, a = arguments, len = a.length; i < len; i++) {
var tc = a[i];
if(!this.tools[tc.id]){
var overCls = 'x-tool-'+tc.id+'-over';
var t = this.toolTemplate.insertFirst((tc.align !== 'left') ? this[this.toolTarget] : this[this.toolTarget].child('span'), tc, true);
this.tools[tc.id] = t;
t.enableDisplayMode('block');
t.on('click', this.createToolHandler(t, tc, overCls, this));
if(tc.on){
t.on(tc.on);
}
if(tc.hidden){
t.hide();
}
if(tc.qtip){
if(typeof tc.qtip == 'object'){
Ext.QuickTips.register(Ext.apply({
target: t.id
}, tc.qtip));
} else {
t.dom.qtip = tc.qtip;
}
}
t.addClassOnOver(overCls);
}
}
},
// private
onShow : function(){
if(this.floating){
return this.el.show();
}
Ext.Panel.superclass.onShow.call(this);
},
// private
onHide : function(){
if(this.floating){
return this.el.hide();
}
Ext.Panel.superclass.onHide.call(this);
},
// private
createToolHandler : function(t, tc, overCls, panel){
return function(e){
t.removeClass(overCls);
e.stopEvent();
if(tc.handler){
tc.handler.call(tc.scope || t, e, t, panel);
}
};
},
// private
afterRender : function(){
if(this.fromMarkup && this.height === undefined && !this.autoHeight){
this.height = this.el.getHeight();
}
if(this.floating && !this.hidden && !this.initHidden){
this.el.show();
}
if(this.title){
this.setTitle(this.title);
}
this.setAutoScroll();
if(this.html){
this.body.update(typeof this.html == 'object' ?
Ext.DomHelper.markup(this.html) :
this.html);
delete this.html;
}
if(this.contentEl){
var ce = Ext.getDom(this.contentEl);
Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
this.body.dom.appendChild(ce);
}
if(this.collapsed){
this.collapsed = false;
this.collapse(false);
}
Ext.Panel.superclass.afterRender.call(this); // do sizing calcs last
this.initEvents();
},
// private
setAutoScroll : function(){
if(this.rendered && this.autoScroll){
var el = this.body || this.el;
if(el){
el.setOverflow('auto');
}
}
},
// private
getKeyMap : function(){
if(!this.keyMap){
this.keyMap = new Ext.KeyMap(this.el, this.keys);
}
return this.keyMap;
},
// private
initEvents : function(){
if(this.keys){
this.getKeyMap();
}
if(this.draggable){
this.initDraggable();
}
},
// private
initDraggable : function(){
/**
* <p>If this Panel is configured {@link #draggable}, this property will contain
* an instance of {@link Ext.dd.DragSource} which handles dragging the Panel.</p>
* The developer must provide implementations of the abstract methods of {@link Ext.dd.DragSource}
* in order to supply behaviour for each stage of the drag/drop process. See {@link #draggable}.
* @type Ext.dd.DragSource.
* @property dd
*/
this.dd = new Ext.Panel.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
},
// private
beforeEffect : function(){
if(this.floating){
this.el.beforeAction();
}
this.el.addClass('x-panel-animated');
},
// private
afterEffect : function(){
this.syncShadow();
this.el.removeClass('x-panel-animated');
},
// private - wraps up an animation param with internal callbacks
createEffect : function(a, cb, scope){
var o = {
scope:scope,
block:true
};
if(a === true){
o.callback = cb;
return o;
}else if(!a.callback){
o.callback = cb;
}else { // wrap it up
o.callback = function(){
cb.call(scope);
Ext.callback(a.callback, a.scope);
};
}
return Ext.applyIf(o, a);
},
/**
* Collapses the panel body so that it becomes hidden. Fires the {@link #beforecollapse} event which will
* cancel the collapse action if it returns false.
* @param {Boolean} animate True to animate the transition, else false (defaults to the value of the
* {@link #animCollapse} panel config)
* @return {Ext.Panel} this
*/
collapse : function(animate){
if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
return;
}
var doAnim = animate === true || (animate !== false && this.animCollapse);
this.beforeEffect();
this.onCollapse(doAnim, animate);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -