3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
17 * @extends Ext.panel.Panel
18 * This is the base class for {@link Ext.tip.QuickTip} and {@link Ext.tip.ToolTip} that provides the basic layout and
19 * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
20 * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
23 Ext.define('Ext.tip.Tip', {
24 extend: 'Ext.panel.Panel',
25 requires: [ 'Ext.layout.component.Tip' ],
26 alternateClassName: 'Ext.Tip',
28 * @cfg {Boolean} [closable=false]
29 * True to render a close tool button into the tooltip header.
33 * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
34 * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
37 * @cfg {Number} minWidth The minimum width of the tip in pixels.
41 * @cfg {Number} maxWidth The maximum width of the tip in pixels. The maximum supported value is 500.
45 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"
46 * for bottom-right shadow.
51 * @cfg {String} defaultAlign
52 * <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value for this tip relative
53 * to its element of origin.
55 defaultAlign : "tl-bl?",
57 * @cfg {Boolean} constrainPosition
58 * If true, then the tooltip will be automatically constrained to stay within the browser viewport.
60 constrainPosition : true,
65 // private panel overrides
68 baseCls: Ext.baseCSSPrefix + 'tip',
74 focusOnToFront: false,
75 componentLayout: 'tip',
78 * @cfg {String} closeAction
79 * <p>The action to take when the close header tool is clicked:
80 * <div class="mdetail-params"><ul>
81 * <li><b><code>'{@link #destroy}'</code></b> : <div class="sub-desc">
82 * {@link #destroy remove} the window from the DOM and {@link Ext.Component#destroy destroy}
83 * it and all descendant Components. The window will <b>not</b> be available to be
84 * redisplayed via the {@link #show} method.
86 * <li><b><code>'{@link #hide}'</code></b> : <b>Default</b><div class="sub-desc">
87 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
88 * The window will be available to be redisplayed via the {@link #show} method.
91 * <p><b>Note:</b> This behavior has changed! setting *does* affect the {@link #close} method
92 * which will invoke the approriate closeAction.
98 initComponent: function() {
101 me.floating = Ext.apply({}, {shadow: me.shadow}, me.self.prototype.floating);
102 me.callParent(arguments);
104 // Or in the deprecated config. Floating.doConstrain only constrains if the constrain property is truthy.
105 me.constrain = me.constrain || me.constrainPosition;
109 * Shows this tip at the specified XY position. Example usage:
111 // Show the tip at x:50 and y:100
112 tip.showAt([50,100]);
114 * @param {Number[]} xy An array containing the x and y coordinates
116 showAt : function(xy){
118 this.callParent(arguments);
119 // Show may have been vetoed.
120 if (me.isVisible()) {
121 me.setPagePosition(xy[0], xy[1]);
122 if (me.constrainPosition || me.constrain) {
130 * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
131 * anchor position value. Example usage:
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');
139 * @param {String/HTMLElement/Ext.Element} el An HTMLElement, Ext.Element or string id of the target element to align to
140 * @param {String} [position] A valid {@link Ext.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));
150 * Set Tip draggable using base Component's draggability
152 initDraggable : function(){
156 delegate: me.header.el,
158 constrainTo: me.el.getScopeParent()
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"