Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / src / tip / Tip.js
index 8961cf6..089081e 100644 (file)
@@ -1,12 +1,23 @@
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+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.
+
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
 /**
  * @class Ext.tip.Tip
  * @extends Ext.panel.Panel
  * This is the base class for {@link Ext.tip.QuickTip} and {@link Ext.tip.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
  * @xtype tip
  */
 Ext.define('Ext.tip.Tip', {
@@ -14,7 +25,8 @@ Ext.define('Ext.tip.Tip', {
     requires: [ 'Ext.layout.component.Tip' ],
     alternateClassName: 'Ext.Tip',
     /**
-     * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
+     * @cfg {Boolean} [closable=false]
+     * True to render a close tool button into the tooltip header.
      */
     /**
      * @cfg {Number} width
@@ -22,33 +34,32 @@ Ext.define('Ext.tip.Tip', {
      * {@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).
+     * @cfg {Number} minWidth The minimum width of the tip in pixels.
      */
     minWidth : 40,
     /**
-     * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300).  The maximum supported value is 500.
+     * @cfg {Number} maxWidth The maximum width of the tip in pixels.  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").
+     * for bottom-right shadow.
      */
     shadow : "sides",
 
     /**
-     * @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.core.Element#alignTo} anchor position value
-     * for this tip relative to its element of origin (defaults to "tl-bl?").
+     * @cfg {String} defaultAlign
+     * <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value for this tip relative
+     * to its element of origin.
      */
     defaultAlign : "tl-bl?",
     /**
-     * @cfg {Boolean} constrainPosition If true, then the tooltip will be automatically constrained to stay within
-     * the browser viewport. Defaults to false.
+     * @cfg {Boolean} constrainPosition
+     * If true, then the tooltip will be automatically constrained to stay within the browser viewport.
      */
     constrainPosition : true,
 
-    /**
-     * @inherited
-     */
+    // @inherited
     frame: false,
 
     // private panel overrides
@@ -63,15 +74,35 @@ Ext.define('Ext.tip.Tip', {
     focusOnToFront: false,
     componentLayout: 'tip',
 
+    /**
+     * @cfg {String} closeAction
+     * <p>The action to take when the close header tool is clicked:
+     * <div class="mdetail-params"><ul>
+     * <li><b><code>'{@link #destroy}'</code></b> : <div class="sub-desc">
+     * {@link #destroy remove} the window from the DOM and {@link Ext.Component#destroy destroy}
+     * it and all descendant Components. The window will <b>not</b> be available to be
+     * redisplayed via the {@link #show} method.
+     * </div></li>
+     * <li><b><code>'{@link #hide}'</code></b> : <b>Default</b><div class="sub-desc">
+     * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
+     * The window will be available to be redisplayed via the {@link #show} method.
+     * </div></li>
+     * </ul></div>
+     * <p><b>Note:</b> This behavior has changed! setting *does* affect the {@link #close} method
+     * which will invoke the approriate closeAction.
+     */
     closeAction: 'hide',
 
     ariaRole: 'tooltip',
 
     initComponent: function() {
-        this.callParent(arguments);
+        var me = this;
+
+        me.floating = Ext.apply({}, {shadow: me.shadow}, me.self.prototype.floating);
+        me.callParent(arguments);
 
         // Or in the deprecated config. Floating.doConstrain only constrains if the constrain property is truthy.
-        this.constrain = this.constrain || this.constrainPosition;
+        me.constrain = me.constrain || me.constrainPosition;
     },
 
     /**
@@ -80,11 +111,11 @@ Ext.define('Ext.tip.Tip', {
 // 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
+     * @param {Number[]} xy An array containing the x and y coordinates
      */
     showAt : function(xy){
         var me = this;
-        this.callParent();
+        this.callParent(arguments);
         // Show may have been vetoed.
         if (me.isVisible()) {
             me.setPagePosition(xy[0], xy[1]);
@@ -96,7 +127,7 @@ tip.showAt([50,100]);
     },
 
     /**
-     * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.core.Element#alignTo}
+     * <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?')
@@ -105,8 +136,8 @@ 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.core.Element or string id of the target element to align to
-     * @param {String} position (optional) A valid {@link Ext.core.Element#alignTo} anchor position (defaults to 'tl-br?' or
+     * @param {String/HTMLElement/Ext.Element} el An HTMLElement, Ext.Element or string id of the target element to align to
+     * @param {String} [position] A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
      * {@link #defaultAlign} if specified).
      */
     showBy : function(el, pos) {
@@ -124,7 +155,7 @@ tip.showBy('my-el', 'tl-tr');
             el: me.getDragEl(),
             delegate: me.header.el,
             constrain: me,
-            constrainTo: me.el.dom.parentNode
+            constrainTo: me.el.getScopeParent()
         };
         // Important: Bypass Panel's initDraggable. Call direct to Component's implementation.
         Ext.Component.prototype.initDraggable.call(me);
@@ -134,3 +165,4 @@ tip.showBy('my-el', 'tl-tr');
     ghost: undefined,
     unghost: undefined
 });
+