3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.0
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.Tip"></div>/**
19 * This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and
20 * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
21 * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
24 * @param {Object} config The configuration options
26 Ext.Tip = Ext.extend(Ext.Panel, {
27 <div id="cfg-Ext.Tip-closable"></div>/**
28 * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
30 <div id="cfg-Ext.Tip-width"></div>/**
32 * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
33 * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
35 <div id="cfg-Ext.Tip-minWidth"></div>/**
36 * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
39 <div id="cfg-Ext.Tip-maxWidth"></div>/**
40 * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
43 <div id="cfg-Ext.Tip-shadow"></div>/**
44 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"
45 * for bottom-right shadow (defaults to "sides").
48 <div id="cfg-Ext.Tip-defaultAlign"></div>/**
49 * @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value
50 * for this tip relative to its element of origin (defaults to "tl-bl?").
52 defaultAlign : "tl-bl?",
54 quickShowInterval : 250,
56 // private panel overrides
60 floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
66 initComponent : function(){
67 Ext.Tip.superclass.initComponent.call(this);
68 if(this.closable && !this.title){
69 this.elements += ',header';
74 afterRender : function(){
75 Ext.Tip.superclass.afterRender.call(this);
79 handler: this[this.closeAction],
85 <div id="method-Ext.Tip-showAt"></div>/**
86 * Shows this tip at the specified XY position. Example usage:
88 // Show the tip at x:50 and y:100
91 * @param {Array} xy An array containing the x and y coordinates
93 showAt : function(xy){
94 Ext.Tip.superclass.show.call(this);
95 if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
98 if(this.constrainPosition){
99 xy = this.el.adjustForConstraints(xy);
101 this.setPagePosition(xy[0], xy[1]);
105 doAutoWidth : function(adjust){
106 adjust = adjust || 0;
107 var bw = this.body.getTextWidth();
109 bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
111 bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr") + adjust;
112 this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
114 // IE7 repaint bug on initial show
115 if(Ext.isIE7 && !this.repainted){
117 this.repainted = true;
121 <div id="method-Ext.Tip-showBy"></div>/**
122 * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
123 * anchor position value. Example usage:
125 // Show the tip at the default position ('tl-br?')
128 // Show the tip's top-left corner anchored to the element's top-right corner
129 tip.showBy('my-el', 'tl-tr');
131 * @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
132 * @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
133 * {@link #defaultAlign} if specified).
135 showBy : function(el, pos){
137 this.render(Ext.getBody());
139 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
142 initDraggable : function(){
143 this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
144 this.header.addClass('x-tip-draggable');
148 Ext.reg('tip', Ext.Tip);
150 // private - custom Tip DD implementation
151 Ext.Tip.DD = function(tip, config){
152 Ext.apply(this, config);
154 Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
155 this.setHandleElId(tip.header.id);
159 Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
162 headerOffsets:[100, 25],
163 startDrag : function(){
164 this.tip.el.disableShadow();
166 endDrag : function(e){
167 this.tip.el.enableShadow(true);