3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
12
* This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and
13
* positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
14
* tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
17
* @param {Object} config The configuration options
19
Ext.Tip = Ext.extend(Ext.Panel, {
21
* @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
25
* Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
26
* {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
29
* @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
33
* @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
37
* @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"
38
* for bottom-right shadow (defaults to "sides").
42
* @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value
43
* for this tip relative to its element of origin (defaults to "tl-bl?").
45
defaultAlign : "tl-bl?",
47
quickShowInterval : 250,
49
// private panel overrides
53
floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
57
initComponent : function(){
58
Ext.Tip.superclass.initComponent.call(this);
59
if(this.closable && !this.title){
60
this.elements += ',header';
65
afterRender : function(){
66
Ext.Tip.superclass.afterRender.call(this);
77
* Shows this tip at the specified XY position. Example usage:
79
// Show the tip at x:50 and y:100
82
* @param {Array} xy An array containing the x and y coordinates
84
showAt : function(xy){
85
Ext.Tip.superclass.show.call(this);
86
if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
89
if(this.constrainPosition){
90
xy = this.el.adjustForConstraints(xy);
92
this.setPagePosition(xy[0], xy[1]);
96
doAutoWidth : function(){
97
var bw = this.body.getTextWidth();
99
bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
101
bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr");
102
this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
104
// IE7 repaint bug on initial show
105
if(Ext.isIE7 && !this.repainted){
107
this.repainted = true;
112
* <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
113
* anchor position value. Example usage:
115
// Show the tip at the default position ('tl-br?')
118
// Show the tip's top-left corner anchored to the element's top-right corner
119
tip.showBy('my-el', 'tl-tr');
121
* @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
122
* @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
123
* {@link #defaultAlign} if specified).
125
showBy : function(el, pos){
127
this.render(Ext.getBody());
129
this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
132
initDraggable : function(){
133
this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
134
this.header.addClass('x-tip-draggable');
138
// private - custom Tip DD implementation
139
Ext.Tip.DD = function(tip, config){
140
Ext.apply(this, config);
142
Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
143
this.setHandleElId(tip.header.id);
147
Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
150
headerOffsets:[100, 25],
151
startDrag : function(){
152
this.tip.el.disableShadow();
154
endDrag : function(e){
155
this.tip.el.enableShadow(true);
b'\\ No newline at end of file'