3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.Tip"></div>/**
\r
11 * @extends Ext.Panel
\r
13 * This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and
\r
14 * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
\r
15 * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
\r
18 * @param {Object} config The configuration options
\r
20 Ext.Tip = Ext.extend(Ext.Panel, {
\r
21 <div id="cfg-Ext.Tip-closable"></div>/**
\r
22 * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
\r
24 <div id="cfg-Ext.Tip-width"></div>/**
\r
25 * @cfg {Number} width
\r
26 * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
\r
27 * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
\r
29 <div id="cfg-Ext.Tip-minWidth"></div>/**
\r
30 * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
\r
33 <div id="cfg-Ext.Tip-maxWidth"></div>/**
\r
34 * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
\r
37 <div id="cfg-Ext.Tip-shadow"></div>/**
\r
38 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"
\r
39 * for bottom-right shadow (defaults to "sides").
\r
42 <div id="cfg-Ext.Tip-defaultAlign"></div>/**
\r
43 * @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value
\r
44 * for this tip relative to its element of origin (defaults to "tl-bl?").
\r
46 defaultAlign : "tl-bl?",
\r
48 quickShowInterval : 250,
\r
50 // private panel overrides
\r
54 floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
\r
57 closeAction: 'hide',
\r
60 initComponent : function(){
\r
61 Ext.Tip.superclass.initComponent.call(this);
\r
62 if(this.closable && !this.title){
\r
63 this.elements += ',header';
\r
68 afterRender : function(){
\r
69 Ext.Tip.superclass.afterRender.call(this);
\r
73 handler: this[this.closeAction],
\r
79 <div id="method-Ext.Tip-showAt"></div>/**
\r
80 * Shows this tip at the specified XY position. Example usage:
\r
82 // Show the tip at x:50 and y:100
\r
83 tip.showAt([50,100]);
\r
85 * @param {Array} xy An array containing the x and y coordinates
\r
87 showAt : function(xy){
\r
88 Ext.Tip.superclass.show.call(this);
\r
89 if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
\r
92 if(this.constrainPosition){
\r
93 xy = this.el.adjustForConstraints(xy);
\r
95 this.setPagePosition(xy[0], xy[1]);
\r
99 doAutoWidth : function(adjust){
\r
100 adjust = adjust || 0;
\r
101 var bw = this.body.getTextWidth();
\r
103 bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
\r
105 bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr") + adjust;
\r
106 this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
\r
108 // IE7 repaint bug on initial show
\r
109 if(Ext.isIE7 && !this.repainted){
\r
111 this.repainted = true;
\r
115 <div id="method-Ext.Tip-showBy"></div>/**
\r
116 * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
\r
117 * anchor position value. Example usage:
\r
119 // Show the tip at the default position ('tl-br?')
\r
120 tip.showBy('my-el');
\r
122 // Show the tip's top-left corner anchored to the element's top-right corner
\r
123 tip.showBy('my-el', 'tl-tr');
\r
125 * @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
\r
126 * @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
\r
127 * {@link #defaultAlign} if specified).
\r
129 showBy : function(el, pos){
\r
130 if(!this.rendered){
\r
131 this.render(Ext.getBody());
\r
133 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
\r
136 initDraggable : function(){
\r
137 this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
\r
138 this.header.addClass('x-tip-draggable');
\r
142 Ext.reg('tip', Ext.Tip);
\r
144 // private - custom Tip DD implementation
\r
145 Ext.Tip.DD = function(tip, config){
\r
146 Ext.apply(this, config);
\r
148 Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
\r
149 this.setHandleElId(tip.header.id);
\r
150 this.scroll = false;
\r
153 Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
\r
156 headerOffsets:[100, 25],
\r
157 startDrag : function(){
\r
158 this.tip.el.disableShadow();
\r
160 endDrag : function(e){
\r
161 this.tip.el.enableShadow(true);
\r