📄 button-debug.js
字号:
hideMenu : function(){ if(this.menu){ this.menu.hide(); } return this; }, hasVisibleMenu : function(){ return this.menu && this.menu.isVisible(); }, // private onClick : function(e){ if(e){ e.preventDefault(); } if(e.button != 0){ return; } if(!this.disabled){ if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){ this.toggle(); } if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){ this.showMenu(); } this.fireEvent("click", this, e); if(this.handler){ //this.el.removeClass("x-btn-over"); this.handler.call(this.scope || this, this, e); } } }, // private isMenuTriggerOver : function(e, internal){ return this.menu && !internal; }, // private isMenuTriggerOut : function(e, internal){ return this.menu && !internal; }, // private onMouseOver : function(e){ if(!this.disabled){ var internal = e.within(this.el, true); if(!internal){ this.el.addClass("x-btn-over"); if(!this.monitoringMouseOver){ Ext.getDoc().on('mouseover', this.monitorMouseOver, this); this.monitoringMouseOver = true; } this.fireEvent('mouseover', this, e); } if(this.isMenuTriggerOver(e, internal)){ this.fireEvent('menutriggerover', this, this.menu, e); } } }, // private monitorMouseOver : function(e){ if(e.target != this.el.dom && !e.within(this.el)){ if(this.monitoringMouseOver){ Ext.getDoc().un('mouseover', this.monitorMouseOver, this); this.monitoringMouseOver = false; } this.onMouseOut(e); } }, // private onMouseOut : function(e){ var internal = e.within(this.el) && e.target != this.el.dom; this.el.removeClass("x-btn-over"); this.fireEvent('mouseout', this, e); if(this.isMenuTriggerOut(e, internal)){ this.fireEvent('menutriggerout', this, this.menu, e); } }, // private onFocus : function(e){ if(!this.disabled){ this.el.addClass("x-btn-focus"); } }, // private onBlur : function(e){ this.el.removeClass("x-btn-focus"); }, // private getClickEl : function(e, isUp){ return this.el; }, // private onMouseDown : function(e){ if(!this.disabled && e.button == 0){ this.getClickEl(e).addClass("x-btn-click"); Ext.getDoc().on('mouseup', this.onMouseUp, this); } }, // private onMouseUp : function(e){ if(e.button == 0){ this.getClickEl(e, true).removeClass("x-btn-click"); Ext.getDoc().un('mouseup', this.onMouseUp, this); } }, // private onMenuShow : function(e){ this.ignoreNextClick = 0; this.el.addClass("x-btn-menu-active"); this.fireEvent('menushow', this, this.menu); }, // private onMenuHide : function(e){ this.el.removeClass("x-btn-menu-active"); this.ignoreNextClick = this.restoreClick.defer(250, this); this.fireEvent('menuhide', this, this.menu); }, // private restoreClick : function(){ this.ignoreNextClick = 0; } });Ext.reg('button', Ext.Button);// Private utility class used by ButtonExt.ButtonToggleMgr = function(){ var groups = {}; function toggleGroup(btn, state){ if(state){ var g = groups[btn.toggleGroup]; for(var i = 0, l = g.length; i < l; i++){ if(g[i] != btn){ g[i].toggle(false); } } } } return { register : function(btn){ if(!btn.toggleGroup){ return; } var g = groups[btn.toggleGroup]; if(!g){ g = groups[btn.toggleGroup] = []; } g.push(btn); btn.on("toggle", toggleGroup); }, unregister : function(btn){ if(!btn.toggleGroup){ return; } var g = groups[btn.toggleGroup]; if(g){ g.remove(btn); btn.un("toggle", toggleGroup); } } };}();
Ext.SplitButton = Ext.extend(Ext.Button, {
// private
arrowSelector : 'button:last',
// private
initComponent : function(){
Ext.SplitButton.superclass.initComponent.call(this);
this.addEvents("arrowclick");
},
// private
onRender : function(ct, position){
// this is one sweet looking template!
var tpl = new Ext.Template(
'<table cellspacing="0" class="x-btn-menu-wrap x-btn"><tr><td>',
'<table cellspacing="0" class="x-btn-wrap x-btn-menu-text-wrap"><tbody>',
'<tr><td class="x-btn-left"><i> </i></td><td class="x-btn-center"><button class="x-btn-text" type="{1}">{0}</button></td></tr>',
"</tbody></table></td><td>",
'<table cellspacing="0" class="x-btn-wrap x-btn-menu-arrow-wrap"><tbody>',
'<tr><td class="x-btn-center"><button class="x-btn-menu-arrow-el" type="button"> </button></td><td class="x-btn-right"><i> </i></td></tr>',
"</tbody></table></td></tr></table>"
);
var btn, targs = [this.text || ' ', this.type];
if(position){
btn = tpl.insertBefore(position, targs, true);
}else{
btn = tpl.append(ct, targs, true);
}
var btnEl = this.btnEl = btn.child(this.buttonSelector);
this.initButtonEl(btn, btnEl);
this.arrowBtnTable = btn.child("table:last");
this.arrowEl = btn.child(this.arrowSelector);
if(this.arrowTooltip){
this.arrowEl.dom[this.tooltipType] = this.arrowTooltip;
}
},
// private
autoWidth : function(){
if(this.el){
var tbl = this.el.child("table:first");
var tbl2 = this.el.child("table:last");
this.el.setWidth("auto");
tbl.setWidth("auto");
if(Ext.isIE7 && Ext.isStrict){
var ib = this.btnEl;
if(ib && ib.getWidth() > 20){
ib.clip();
ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
}
}
if(this.minWidth){
if((tbl.getWidth()+tbl2.getWidth()) < this.minWidth){
tbl.setWidth(this.minWidth-tbl2.getWidth());
}
}
this.el.setWidth(tbl.getWidth()+tbl2.getWidth());
}
},
setArrowHandler : function(handler, scope){
this.arrowHandler = handler;
this.scope = scope;
},
// private
onClick : function(e){
e.preventDefault();
if(!this.disabled){
if(e.getTarget(".x-btn-menu-arrow-wrap")){
if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
this.showMenu();
}
this.fireEvent("arrowclick", this, e);
if(this.arrowHandler){
this.arrowHandler.call(this.scope || this, this, e);
}
}else{
if(this.enableToggle){
this.toggle();
}
this.fireEvent("click", this, e);
if(this.handler){
this.handler.call(this.scope || this, this, e);
}
}
}
},
// private
getClickEl : function(e, isUp){
if(!isUp){
return (this.lastClickEl = e.getTarget("table", 10, true));
}
return this.lastClickEl;
},
onDisableChange: function(disabled){
Ext.SplitButton.superclass.onDisableChange.call(this, disabled);
if(this.arrowEl){
this.arrowEl.dom.disabled = disabled;
}
},
// private
isMenuTriggerOver : function(e){
return this.menu && e.within(this.arrowBtnTable) && !e.within(this.arrowBtnTable, true);
},
// private
isMenuTriggerOut : function(e, internal){
return this.menu && !e.within(this.arrowBtnTable);
},
// private
onDestroy : function(){
Ext.destroy(this.arrowBtnTable);
Ext.SplitButton.superclass.onDestroy.call(this);
}
});
// backwards compat
Ext.MenuButton = Ext.SplitButton;
Ext.reg('splitbutton', Ext.SplitButton);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -