2
* Ext JS Library 3.0 RC2
3
* Copyright(c) 2006-2009, 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},
59
initComponent : function(){
60
Ext.Tip.superclass.initComponent.call(this);
61
if(this.closable && !this.title){
62
this.elements += ',header';
67
afterRender : function(){
68
Ext.Tip.superclass.afterRender.call(this);
72
handler: this[this.closeAction],
79
* Shows this tip at the specified XY position. Example usage:
81
// Show the tip at x:50 and y:100
84
* @param {Array} xy An array containing the x and y coordinates
86
showAt : function(xy){
87
Ext.Tip.superclass.show.call(this);
88
if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
91
if(this.constrainPosition){
92
xy = this.el.adjustForConstraints(xy);
94
this.setPagePosition(xy[0], xy[1]);
98
doAutoWidth : function(){
99
var bw = this.body.getTextWidth();
101
bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
103
bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr");
104
this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
106
// IE7 repaint bug on initial show
107
if(Ext.isIE7 && !this.repainted){
109
this.repainted = true;
114
* <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
115
* anchor position value. Example usage:
117
// Show the tip at the default position ('tl-br?')
120
// Show the tip's top-left corner anchored to the element's top-right corner
121
tip.showBy('my-el', 'tl-tr');
123
* @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
124
* @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
125
* {@link #defaultAlign} if specified).
127
showBy : function(el, pos){
129
this.render(Ext.getBody());
131
this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
134
initDraggable : function(){
135
this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
136
this.header.addClass('x-tip-draggable');
140
// private - custom Tip DD implementation
141
Ext.Tip.DD = function(tip, config){
142
Ext.apply(this, config);
144
Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
145
this.setHandleElId(tip.header.id);
149
Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
152
headerOffsets:[100, 25],
153
startDrag : function(){
154
this.tip.el.disableShadow();
156
endDrag : function(e){
157
this.tip.el.enableShadow(true);
b'\\ No newline at end of file'