4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-tip-Tip'>/**
19 </span> * @class Ext.tip.Tip
20 * @extends Ext.panel.Panel
21 * This is the base class for {@link Ext.tip.QuickTip} and {@link Ext.tip.ToolTip} that provides the basic layout and
22 * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
23 * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
26 Ext.define('Ext.tip.Tip', {
27 extend: 'Ext.panel.Panel',
28 requires: [ 'Ext.layout.component.Tip' ],
29 alternateClassName: 'Ext.Tip',
30 <span id='Ext-tip-Tip-cfg-closable'> /**
31 </span> * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
33 <span id='Ext-tip-Tip-cfg-width'> /**
34 </span> * @cfg {Number} width
35 * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
36 * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
38 <span id='Ext-tip-Tip-cfg-minWidth'> /**
39 </span> * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
42 <span id='Ext-tip-Tip-cfg-maxWidth'> /**
43 </span> * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
46 <span id='Ext-tip-Tip-cfg-shadow'> /**
47 </span> * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"
48 * for bottom-right shadow (defaults to "sides").
50 shadow : "sides",
52 <span id='Ext-tip-Tip-cfg-defaultAlign'> /**
53 </span> * @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.core.Element#alignTo} anchor position value
54 * for this tip relative to its element of origin (defaults to "tl-bl?").
56 defaultAlign : "tl-bl?",
57 <span id='Ext-tip-Tip-cfg-constrainPosition'> /**
58 </span> * @cfg {Boolean} constrainPosition If true, then the tooltip will be automatically constrained to stay within
59 * the browser viewport. Defaults to false.
61 constrainPosition : true,
63 <span id='Ext-tip-Tip-property-frame'> /**
68 // private panel overrides
71 baseCls: Ext.baseCSSPrefix + 'tip',
77 focusOnToFront: false,
78 componentLayout: 'tip',
80 <span id='Ext-tip-Tip-cfg-closeAction'> /**
81 </span> * @cfg {String} closeAction
82 * <p>The action to take when the close header tool is clicked:
83 * <div class="mdetail-params"><ul>
84 * <li><b><code>'{@link #destroy}'</code></b> : <div class="sub-desc">
85 * {@link #destroy remove} the window from the DOM and {@link Ext.Component#destroy destroy}
86 * it and all descendant Components. The window will <b>not</b> be available to be
87 * redisplayed via the {@link #show} method.
88 * </div></li>
89 * <li><b><code>'{@link #hide}'</code></b> : <b>Default</b><div class="sub-desc">
90 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
91 * The window will be available to be redisplayed via the {@link #show} method.
92 * </div></li>
93 * </ul></div>
94 * <p><b>Note:</b> This behavior has changed! setting *does* affect the {@link #close} method
95 * which will invoke the approriate closeAction.
101 initComponent: function() {
102 this.callParent(arguments);
104 // Or in the deprecated config. Floating.doConstrain only constrains if the constrain property is truthy.
105 this.constrain = this.constrain || this.constrainPosition;
108 <span id='Ext-tip-Tip-method-showAt'> /**
109 </span> * Shows this tip at the specified XY position. Example usage:
110 * <pre><code>
111 // Show the tip at x:50 and y:100
112 tip.showAt([50,100]);
113 </code></pre>
114 * @param {Array} xy An array containing the x and y coordinates
116 showAt : function(xy){
119 // Show may have been vetoed.
120 if (me.isVisible()) {
121 me.setPagePosition(xy[0], xy[1]);
122 if (me.constrainPosition || me.constrain) {
129 <span id='Ext-tip-Tip-method-showBy'> /**
130 </span> * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.core.Element#alignTo}
131 * anchor position value. Example usage:
132 * <pre><code>
133 // Show the tip at the default position ('tl-br?')
136 // Show the tip's top-left corner anchored to the element's top-right corner
137 tip.showBy('my-el', 'tl-tr');
138 </code></pre>
139 * @param {Mixed} el An HTMLElement, Ext.core.Element or string id of the target element to align to
140 * @param {String} position (optional) A valid {@link Ext.core.Element#alignTo} anchor position (defaults to 'tl-br?' or
141 * {@link #defaultAlign} if specified).
143 showBy : function(el, pos) {
144 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
147 <span id='Ext-tip-Tip-method-initDraggable'> /**
150 * Set Tip draggable using base Component's draggability
152 initDraggable : function(){
156 delegate: me.header.el,
158 constrainTo: me.el.dom.parentNode
160 // Important: Bypass Panel's initDraggable. Call direct to Component's implementation.
161 Ext.Component.prototype.initDraggable.call(me);
164 // Tip does not ghost. Drag is "live"