Tip_wev8.js
4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* Ext JS Library 2.0.2
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
/**
* @class Ext.Tip
* @extends Ext.Panel
* This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and
* positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
* tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
* @constructor
* Create a new Tip
* @param {Object} config The configuration options
*/
Ext.Tip = Ext.extend(Ext.Panel, {
/**
* @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
*/
/**
* @cfg {Number} width
* Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
* {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
*/
/**
* @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
*/
minWidth : 40,
/**
* @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
*/
maxWidth : 300,
/**
* @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"
* for bottom-right shadow (defaults to "sides").
*/
shadow : "sides",
/**
* @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value
* for this tip relative to its element of origin (defaults to "tl-bl?").
*/
defaultAlign : "tl-bl?",
autoRender: true,
quickShowInterval : 250,
// private panel overrides
frame:true,
hidden:true,
baseCls: 'x-tip',
floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
autoHeight:true,
// private
initComponent : function(){
Ext.Tip.superclass.initComponent.call(this);
if(this.closable && !this.title){
this.elements += ',header';
}
},
// private
afterRender : function(){
Ext.Tip.superclass.afterRender.call(this);
if(this.closable){
this.addTool({
id: 'close',
handler: this.hide,
scope: this
});
}
},
/**
* Shows this tip at the specified XY position. Example usage:
* <pre><code>
// Show the tip at x:50 and y:100
tip.showAt([50,100]);
</code></pre>
* @param {Array} xy An array containing the x and y coordinates
*/
showAt : function(xy){
Ext.Tip.superclass.show.call(this);
if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
var bw = this.body.getTextWidth();
if(this.title){
bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
}
bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr");
this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
}
if(this.constrainPosition){
xy = this.el.adjustForConstraints(xy);
}
this.setPagePosition(xy[0], xy[1]);
},
/**
* <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
* anchor position value. Example usage:
* <pre><code>
// Show the tip at the default position ('tl-br?')
tip.showBy('my-el');
// Show the tip's top-left corner anchored to the element's top-right corner
tip.showBy('my-el', 'tl-tr');
</code></pre>
* @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
* @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
* {@link #defaultAlign} if specified).
*/
showBy : function(el, pos){
if(!this.rendered){
this.render(Ext.getBody());
}
this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
},
initDraggable : function(){
this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
this.header.addClass('x-tip-draggable');
}
});
// private - custom Tip DD implementation
Ext.Tip.DD = function(tip, config){
Ext.apply(this, config);
this.tip = tip;
Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
this.setHandleElId(tip.header.id);
this.scroll = false;
};
Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
moveOnly:true,
scroll:false,
headerOffsets:[100, 25],
startDrag : function(){
this.tip.el.disableShadow();
},
endDrag : function(e){
this.tip.el.enableShadow(true);
}
});