📄 tooltip.js
字号:
}
this.tipAnchor = m[1].charAt(0);
}
switch(this.tipAnchor){
case 't': return 'top';
case 'b': return 'bottom';
case 'r': return 'right';
}
return 'left';
},
// private
getAnchorAlign : function(){
switch(this.anchor){
case 'top' : return 'tl-bl';
case 'left' : return 'tl-tr';
case 'right': return 'tr-tl';
default : return 'bl-tl';
}
},
// private
getOffsets: function(){
var offsets, ap = this.getAnchorPosition().charAt(0);
if(this.anchorToTarget && !this.trackMouse){
switch(ap){
case 't':
offsets = [0, 9];
break;
case 'b':
offsets = [0, -13];
break;
case 'r':
offsets = [-13, 0];
break;
default:
offsets = [9, 0];
break;
}
}else{
switch(ap){
case 't':
offsets = [-15-this.anchorOffset, 30];
break;
case 'b':
offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];
break;
case 'r':
offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];
break;
default:
offsets = [25, -13-this.anchorOffset];
break;
}
}
var mouseOffset = this.getMouseOffset();
offsets[0] += mouseOffset[0];
offsets[1] += mouseOffset[1];
return offsets;
},
// private
onTargetOver : function(e){
if(this.disabled || e.within(this.target.dom, true)){
return;
}
var t = e.getTarget(this.delegate);
if (t) {
this.triggerElement = t;
this.clearTimer('hide');
this.targetXY = e.getXY();
this.delayShow();
}
},
// private
delayShow : function(){
if(this.hidden && !this.showTimer){
if(this.lastActive.getElapsed() < this.quickShowInterval){
this.show();
}else{
this.showTimer = this.show.defer(this.showDelay, this);
}
}else if(!this.hidden && this.autoHide !== false){
this.show();
}
},
// private
onTargetOut : function(e){
if(this.disabled || e.within(this.target.dom, true)){
return;
}
this.clearTimer('show');
if(this.autoHide !== false){
this.delayHide();
}
},
// private
delayHide : function(){
if(!this.hidden && !this.hideTimer){
this.hideTimer = this.hide.defer(this.hideDelay, this);
}
},
/**
* Hides this tooltip if visible.
*/
hide: function(){
this.clearTimer('dismiss');
this.lastActive = new Date();
delete this.triggerElement;
if(this.anchorEl){
this.anchorEl.hide();
}
Ext.ToolTip.superclass.hide.call(this);
},
/**
* Shows this tooltip at the current event target XY position.
*/
show : function(){
if(this.anchor){
// pre-show it off screen so that the el will have dimensions
// for positioning calcs when getting xy next
this.showAt([-1000,-1000]);
this.origConstrainPosition = this.constrainPosition;
this.constrainPosition = false;
this.anchor = this.origAnchor;
}
this.showAt(this.getTargetXY());
if(this.anchor){
this.syncAnchor();
this.anchorEl.show();
this.constrainPosition = this.origConstrainPosition;
}else{
this.anchorEl.hide();
}
},
// inherit docs
showAt : function(xy){
this.lastActive = new Date();
this.clearTimers();
Ext.ToolTip.superclass.showAt.call(this, xy);
if(this.dismissDelay && this.autoHide !== false){
this.dismissTimer = this.hide.defer(this.dismissDelay, this);
}
},
// private
syncAnchor : function(){
var anchorPos, targetPos, offset;
switch(this.tipAnchor.charAt(0)){
case 't':
anchorPos = 'b';
targetPos = 'tl';
offset = [20+this.anchorOffset, 2];
break;
case 'r':
anchorPos = 'l';
targetPos = 'tr';
offset = [-2, 11+this.anchorOffset];
break;
case 'b':
anchorPos = 't';
targetPos = 'bl';
offset = [20+this.anchorOffset, -2];
break;
default:
anchorPos = 'r';
targetPos = 'tl';
offset = [2, 11+this.anchorOffset];
break;
}
this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);
},
// private
setPagePosition : function(x, y){
Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
if(this.anchor){
this.syncAnchor();
}
},
// private
clearTimer : function(name){
name = name + 'Timer';
clearTimeout(this[name]);
delete this[name];
},
// private
clearTimers : function(){
this.clearTimer('show');
this.clearTimer('dismiss');
this.clearTimer('hide');
},
// private
onShow : function(){
Ext.ToolTip.superclass.onShow.call(this);
Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
},
// private
onHide : function(){
Ext.ToolTip.superclass.onHide.call(this);
Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
},
// private
onDocMouseDown : function(e){
if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){
this.disable();
this.enable.defer(100, this);
}
},
// private
onDisable : function(){
this.clearTimers();
this.hide();
},
// private
adjustPosition : function(x, y){
if(this.contstrainPosition){
var ay = this.targetXY[1], h = this.getSize().height;
if(y <= ay && (y+h) >= ay){
y = ay-h-5;
}
}
return {x : x, y: y};
},
// private
onDestroy : function(){
Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
Ext.ToolTip.superclass.onDestroy.call(this);
}
});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -