3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
12
* A standard tooltip implementation for providing additional information when hovering over a target element.
14
* Create a new Tooltip
15
* @param {Object} config The configuration options
17
Ext.ToolTip = Ext.extend(Ext.Tip, {
19
* @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this tooltip.
22
* @cfg {Boolean} autoHide True to automatically hide the tooltip after the mouse exits the target element
23
* or after the {@link #dismissDelay} has expired if set (defaults to true). If {@link closable} = true a close
24
* tool button will be rendered into the tooltip header.
27
* @cfg {Number} showDelay Delay in milliseconds before the tooltip displays after the mouse enters the
28
* target element (defaults to 500)
32
* @cfg {Number} hideDelay Delay in milliseconds after the mouse exits the target element but before the
33
* tooltip actually hides (defaults to 200). Set to 0 for the tooltip to hide immediately.
37
* @cfg {Number} dismissDelay Delay in milliseconds before the tooltip automatically hides (defaults to 5000).
38
* To disable automatic hiding, set dismissDelay = 0.
42
* @cfg {Array} mouseOffset An XY offset from the mouse position where the tooltip should be shown (defaults to [15,18]).
46
* @cfg {Boolean} trackMouse True to have the tooltip follow the mouse as it moves over the target element (defaults to false).
49
constrainPosition: true,
52
initComponent: function(){
53
Ext.ToolTip.superclass.initComponent.call(this);
54
this.lastActive = new Date();
59
initTarget : function(){
61
this.target = Ext.get(this.target);
62
this.target.on('mouseover', this.onTargetOver, this);
63
this.target.on('mouseout', this.onTargetOut, this);
64
this.target.on('mousemove', this.onMouseMove, this);
69
onMouseMove : function(e){
70
this.targetXY = e.getXY();
71
if(!this.hidden && this.trackMouse){
72
this.setPagePosition(this.getTargetXY());
77
getTargetXY : function(){
78
return [this.targetXY[0]+this.mouseOffset[0], this.targetXY[1]+this.mouseOffset[1]];
82
onTargetOver : function(e){
83
if(this.disabled || e.within(this.target.dom, true)){
86
this.clearTimer('hide');
87
this.targetXY = e.getXY();
92
delayShow : function(){
93
if(this.hidden && !this.showTimer){
94
if(this.lastActive.getElapsed() < this.quickShowInterval){
97
this.showTimer = this.show.defer(this.showDelay, this);
99
}else if(!this.hidden && this.autoHide !== false){
105
onTargetOut : function(e){
106
if(this.disabled || e.within(this.target.dom, true)){
109
this.clearTimer('show');
110
if(this.autoHide !== false){
116
delayHide : function(){
117
if(!this.hidden && !this.hideTimer){
118
this.hideTimer = this.hide.defer(this.hideDelay, this);
123
* Hides this tooltip if visible.
126
this.clearTimer('dismiss');
127
this.lastActive = new Date();
128
Ext.ToolTip.superclass.hide.call(this);
132
* Shows this tooltip at the current event target XY position.
135
this.showAt(this.getTargetXY());
139
showAt : function(xy){
140
this.lastActive = new Date();
142
Ext.ToolTip.superclass.showAt.call(this, xy);
143
if(this.dismissDelay && this.autoHide !== false){
144
this.dismissTimer = this.hide.defer(this.dismissDelay, this);
149
clearTimer : function(name){
150
name = name + 'Timer';
151
clearTimeout(this[name]);
156
clearTimers : function(){
157
this.clearTimer('show');
158
this.clearTimer('dismiss');
159
this.clearTimer('hide');
164
Ext.ToolTip.superclass.onShow.call(this);
165
Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
170
Ext.ToolTip.superclass.onHide.call(this);
171
Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
175
onDocMouseDown : function(e){
176
if(this.autoHide !== false && !e.within(this.el.dom)){
178
this.enable.defer(100, this);
183
onDisable : function(){
189
adjustPosition : function(x, y){
190
// keep the position from being under the mouse
191
var ay = this.targetXY[1], h = this.getSize().height;
192
if(this.constrainPosition && y <= ay && (y+h) >= ay){
195
return {x : x, y: y};
199
onDestroy : function(){
200
Ext.ToolTip.superclass.onDestroy.call(this);
202
this.target.un('mouseover', this.onTargetOver, this);
203
this.target.un('mouseout', this.onTargetOut, this);
204
this.target.un('mousemove', this.onMouseMove, this);
b'\\ No newline at end of file'