Upgrade to ExtJS 3.3.1 - Released 11/30/2010
[extjs.git] / docs / source / ToolTip.html
index 2f45fd9..664f0e8 100644 (file)
-<html>\r
-<head>\r
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js"><div id="cls-Ext.ToolTip"></div>/**\r
- * @class Ext.ToolTip\r
- * @extends Ext.Tip\r
- * A standard tooltip implementation for providing additional information when hovering over a target element.\r
- * @xtype tooltip\r
- * @constructor\r
- * Create a new Tooltip\r
- * @param {Object} config The configuration options\r
- */\r
-Ext.ToolTip = Ext.extend(Ext.Tip, {\r
-    <div id="prop-Ext.ToolTip-triggerElement"></div>/**\r
-     * When a Tooltip is configured with the <code>{@link #delegate}</code>\r
-     * option to cause selected child elements of the <code>{@link #target}</code>\r
-     * Element to each trigger a seperate show event, this property is set to\r
-     * the DOM element which triggered the show.\r
-     * @type DOMElement\r
-     * @property triggerElement\r
-     */\r
-    <div id="cfg-Ext.ToolTip-target"></div>/**\r
-     * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to monitor\r
-     * for mouseover events to trigger showing this ToolTip.\r
-     */\r
-    <div id="cfg-Ext.ToolTip-autoHide"></div>/**\r
-     * @cfg {Boolean} autoHide True to automatically hide the tooltip after the\r
-     * mouse exits the target element or after the <code>{@link #dismissDelay}</code>\r
-     * has expired if set (defaults to true).  If <code>{@link closable} = true</code>\r
-     * a close tool button will be rendered into the tooltip header.\r
-     */\r
-    <div id="cfg-Ext.ToolTip-showDelay"></div>/**\r
-     * @cfg {Number} showDelay Delay in milliseconds before the tooltip displays\r
-     * after the mouse enters the target element (defaults to 500)\r
-     */\r
-    showDelay : 500,\r
-    <div id="cfg-Ext.ToolTip-hideDelay"></div>/**\r
-     * @cfg {Number} hideDelay Delay in milliseconds after the mouse exits the\r
-     * target element but before the tooltip actually hides (defaults to 200).\r
-     * Set to 0 for the tooltip to hide immediately.\r
-     */\r
-    hideDelay : 200,\r
-    <div id="cfg-Ext.ToolTip-dismissDelay"></div>/**\r
-     * @cfg {Number} dismissDelay Delay in milliseconds before the tooltip\r
-     * automatically hides (defaults to 5000). To disable automatic hiding, set\r
-     * dismissDelay = 0.\r
-     */\r
-    dismissDelay : 5000,\r
-    <div id="cfg-Ext.ToolTip-mouseOffset"></div>/**\r
-     * @cfg {Array} mouseOffset An XY offset from the mouse position where the\r
-     * tooltip should be shown (defaults to [15,18]).\r
-     */\r
-    <div id="cfg-Ext.ToolTip-trackMouse"></div>/**\r
-     * @cfg {Boolean} trackMouse True to have the tooltip follow the mouse as it\r
-     * moves over the target element (defaults to false).\r
-     */\r
-    trackMouse : false,\r
-    <div id="cfg-Ext.ToolTip-anchorToTarget"></div>/**\r
-     * @cfg {Boolean} anchorToTarget True to anchor the tooltip to the target\r
-     * element, false to anchor it relative to the mouse coordinates (defaults\r
-     * to true).  When <code>anchorToTarget</code> is true, use\r
-     * <code>{@link #defaultAlign}</code> to control tooltip alignment to the\r
-     * target element.  When <code>anchorToTarget</code> is false, use\r
-     * <code>{@link #anchorPosition}</code> instead to control alignment.\r
-     */\r
-    anchorToTarget : true,\r
-    <div id="cfg-Ext.ToolTip-anchorOffset"></div>/**\r
-     * @cfg {Number} anchorOffset A numeric pixel value used to offset the\r
-     * default position of the anchor arrow (defaults to 0).  When the anchor\r
-     * position is on the top or bottom of the tooltip, <code>anchorOffset</code>\r
-     * will be used as a horizontal offset.  Likewise, when the anchor position\r
-     * is on the left or right side, <code>anchorOffset</code> will be used as\r
-     * a vertical offset.\r
-     */\r
-    anchorOffset : 0,\r
-    <div id="cfg-Ext.ToolTip-delegate"></div>/**\r
-     * @cfg {String} delegate <p>Optional. A {@link Ext.DomQuery DomQuery}\r
-     * selector which allows selection of individual elements within the\r
-     * <code>{@link #target}</code> element to trigger showing and hiding the\r
-     * ToolTip as the mouse moves within the target.</p>\r
-     * <p>When specified, the child element of the target which caused a show\r
-     * event is placed into the <code>{@link #triggerElement}</code> property\r
-     * before the ToolTip is shown.</p>\r
-     * <p>This may be useful when a Component has regular, repeating elements\r
-     * in it, each of which need a Tooltip which contains information specific\r
-     * to that element. For example:</p><pre><code>\r
-var myGrid = new Ext.grid.gridPanel(gridConfig);\r
-myGrid.on('render', function(grid) {\r
-    var store = grid.getStore();  // Capture the Store.\r
-    var view = grid.getView();    // Capture the GridView.\r
-    myGrid.tip = new Ext.ToolTip({\r
-        target: view.mainBody,    // The overall target element.\r
-        delegate: '.x-grid3-row', // Each grid row causes its own seperate show and hide.\r
-        trackMouse: true,         // Moving within the row should not hide the tip.\r
-        renderTo: document.body,  // Render immediately so that tip.body can be\r
-                                  //  referenced prior to the first show.\r
-        listeners: {              // Change content dynamically depending on which element\r
-                                  //  triggered the show.\r
-            beforeshow: function updateTipBody(tip) {\r
-                var rowIndex = view.findRowIndex(tip.triggerElement);\r
-                tip.body.dom.innerHTML = 'Over Record ID ' + store.getAt(rowIndex).id;\r
-            }\r
-        }\r
-    });\r
-});\r
-     *</code></pre>\r
-     */\r
-\r
-    // private\r
-    targetCounter : 0,\r
-\r
-    constrainPosition : false,\r
-\r
-    // private\r
-    initComponent : function(){\r
-        Ext.ToolTip.superclass.initComponent.call(this);\r
-        this.lastActive = new Date();\r
-        this.initTarget(this.target);\r
-        this.origAnchor = this.anchor;\r
-    },\r
-\r
-    // private\r
-    onRender : function(ct, position){\r
-        Ext.ToolTip.superclass.onRender.call(this, ct, position);\r
-        this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();\r
-        this.anchorEl = this.el.createChild({\r
-            cls: 'x-tip-anchor ' + this.anchorCls\r
-        });\r
-    },\r
-\r
-    // private\r
-    afterRender : function(){\r
-        Ext.ToolTip.superclass.afterRender.call(this);\r
-        this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1);\r
-    },\r
-\r
-    <div id="method-Ext.ToolTip-initTarget"></div>/**\r
-     * Binds this ToolTip to the specified element. The tooltip will be displayed when the mouse moves over the element.\r
-     * @param {Mixed} t The Element, HtmlElement, or ID of an element to bind to\r
-     */\r
-    initTarget : function(target){\r
-        var t;\r
-        if((t = Ext.get(target))){\r
-            if(this.target){\r
-                var tg = Ext.get(this.target);\r
-                this.mun(tg, 'mouseover', this.onTargetOver, this);\r
-                this.mun(tg, 'mouseout', this.onTargetOut, this);\r
-                this.mun(tg, 'mousemove', this.onMouseMove, this);\r
-            }\r
-            this.mon(t, {\r
-                mouseover: this.onTargetOver,\r
-                mouseout: this.onTargetOut,\r
-                mousemove: this.onMouseMove,\r
-                scope: this\r
-            });\r
-            this.target = t;\r
-        }\r
-        if(this.anchor){\r
-            this.anchorTarget = this.target;\r
-        }\r
-    },\r
-\r
-    // private\r
-    onMouseMove : function(e){\r
-        var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;\r
-        if (t) {\r
-            this.targetXY = e.getXY();\r
-            if (t === this.triggerElement) {\r
-                if(!this.hidden && this.trackMouse){\r
-                    this.setPagePosition(this.getTargetXY());\r
-                }\r
-            } else {\r
-                this.hide();\r
-                this.lastActive = new Date(0);\r
-                this.onTargetOver(e);\r
-            }\r
-        } else if (!this.closable && this.isVisible()) {\r
-            this.hide();\r
-        }\r
-    },\r
-\r
-    // private\r
-    getTargetXY : function(){\r
-        if(this.delegate){\r
-            this.anchorTarget = this.triggerElement;\r
-        }\r
-        if(this.anchor){\r
-            this.targetCounter++;\r
-            var offsets = this.getOffsets(),\r
-                xy = (this.anchorToTarget && !this.trackMouse) ? this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) : this.targetXY,\r
-                dw = Ext.lib.Dom.getViewWidth() - 5,\r
-                dh = Ext.lib.Dom.getViewHeight() - 5,\r
-                de = document.documentElement,\r
-                bd = document.body,\r
-                scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5,\r
-                scrollY = (de.scrollTop || bd.scrollTop || 0) + 5,\r
-                axy = [xy[0] + offsets[0], xy[1] + offsets[1]]\r
-                sz = this.getSize();\r
-                \r
-            this.anchorEl.removeClass(this.anchorCls);\r
-\r
-            if(this.targetCounter < 2){\r
-                if(axy[0] < scrollX){\r
-                    if(this.anchorToTarget){\r
-                        this.defaultAlign = 'l-r';\r
-                        if(this.mouseOffset){this.mouseOffset[0] *= -1;}\r
-                    }\r
-                    this.anchor = 'left';\r
-                    return this.getTargetXY();\r
-                }\r
-                if(axy[0]+sz.width > dw){\r
-                    if(this.anchorToTarget){\r
-                        this.defaultAlign = 'r-l';\r
-                        if(this.mouseOffset){this.mouseOffset[0] *= -1;}\r
-                    }\r
-                    this.anchor = 'right';\r
-                    return this.getTargetXY();\r
-                }\r
-                if(axy[1] < scrollY){\r
-                    if(this.anchorToTarget){\r
-                        this.defaultAlign = 't-b';\r
-                        if(this.mouseOffset){this.mouseOffset[1] *= -1;}\r
-                    }\r
-                    this.anchor = 'top';\r
-                    return this.getTargetXY();\r
-                }\r
-                if(axy[1]+sz.height > dh){\r
-                    if(this.anchorToTarget){\r
-                        this.defaultAlign = 'b-t';\r
-                        if(this.mouseOffset){this.mouseOffset[1] *= -1;}\r
-                    }\r
-                    this.anchor = 'bottom';\r
-                    return this.getTargetXY();\r
-                }\r
-            }\r
-\r
-            this.anchorCls = 'x-tip-anchor-'+this.getAnchorPosition();\r
-            this.anchorEl.addClass(this.anchorCls);\r
-            this.targetCounter = 0;\r
-            return axy;\r
-        }else{\r
-            var mouseOffset = this.getMouseOffset();\r
-            return [this.targetXY[0]+mouseOffset[0], this.targetXY[1]+mouseOffset[1]];\r
-        }\r
-    },\r
-\r
-    getMouseOffset : function(){\r
-        var offset = this.anchor ? [0,0] : [15,18];\r
-        if(this.mouseOffset){\r
-            offset[0] += this.mouseOffset[0];\r
-            offset[1] += this.mouseOffset[1];\r
-        }\r
-        return offset;\r
-    },\r
-\r
-    // private\r
-    getAnchorPosition : function(){\r
-        if(this.anchor){\r
-            this.tipAnchor = this.anchor.charAt(0);\r
-        }else{\r
-            var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);\r
-            if(!m){\r
-               throw 'AnchorTip.defaultAlign is invalid';\r
-            }\r
-            this.tipAnchor = m[1].charAt(0);\r
-        }\r
-\r
-        switch(this.tipAnchor){\r
-            case 't': return 'top';\r
-            case 'b': return 'bottom';\r
-            case 'r': return 'right';\r
-        }\r
-        return 'left';\r
-    },\r
-\r
-    // private\r
-    getAnchorAlign : function(){\r
-        switch(this.anchor){\r
-            case 'top'  : return 'tl-bl';\r
-            case 'left' : return 'tl-tr';\r
-            case 'right': return 'tr-tl';\r
-            default     : return 'bl-tl';\r
-        }\r
-    },\r
-\r
-    // private\r
-    getOffsets : function(){\r
-        var offsets, \r
-            ap = this.getAnchorPosition().charAt(0);\r
-        if(this.anchorToTarget && !this.trackMouse){\r
-            switch(ap){\r
-                case 't':\r
-                    offsets = [0, 9];\r
-                    break;\r
-                case 'b':\r
-                    offsets = [0, -13];\r
-                    break;\r
-                case 'r':\r
-                    offsets = [-13, 0];\r
-                    break;\r
-                default:\r
-                    offsets = [9, 0];\r
-                    break;\r
-            }\r
-        }else{\r
-            switch(ap){\r
-                case 't':\r
-                    offsets = [-15-this.anchorOffset, 30];\r
-                    break;\r
-                case 'b':\r
-                    offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];\r
-                    break;\r
-                case 'r':\r
-                    offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];\r
-                    break;\r
-                default:\r
-                    offsets = [25, -13-this.anchorOffset];\r
-                    break;\r
-            }\r
-        }\r
-        var mouseOffset = this.getMouseOffset();\r
-        offsets[0] += mouseOffset[0];\r
-        offsets[1] += mouseOffset[1];\r
-\r
-        return offsets;\r
-    },\r
-\r
-    // private\r
-    onTargetOver : function(e){\r
-        if(this.disabled || e.within(this.target.dom, true)){\r
-            return;\r
-        }\r
-        var t = e.getTarget(this.delegate);\r
-        if (t) {\r
-            this.triggerElement = t;\r
-            this.clearTimer('hide');\r
-            this.targetXY = e.getXY();\r
-            this.delayShow();\r
-        }\r
-    },\r
-\r
-    // private\r
-    delayShow : function(){\r
-        if(this.hidden && !this.showTimer){\r
-            if(this.lastActive.getElapsed() < this.quickShowInterval){\r
-                this.show();\r
-            }else{\r
-                this.showTimer = this.show.defer(this.showDelay, this);\r
-            }\r
-        }else if(!this.hidden && this.autoHide !== false){\r
-            this.show();\r
-        }\r
-    },\r
-\r
-    // private\r
-    onTargetOut : function(e){\r
-        if(this.disabled || e.within(this.target.dom, true)){\r
-            return;\r
-        }\r
-        this.clearTimer('show');\r
-        if(this.autoHide !== false){\r
-            this.delayHide();\r
-        }\r
-    },\r
-\r
-    // private\r
-    delayHide : function(){\r
-        if(!this.hidden && !this.hideTimer){\r
-            this.hideTimer = this.hide.defer(this.hideDelay, this);\r
-        }\r
-    },\r
-\r
-    <div id="method-Ext.ToolTip-hide"></div>/**\r
-     * Hides this tooltip if visible.\r
-     */\r
-    hide: function(){\r
-        this.clearTimer('dismiss');\r
-        this.lastActive = new Date();\r
-        if(this.anchorEl){\r
-            this.anchorEl.hide();\r
-        }\r
-        Ext.ToolTip.superclass.hide.call(this);\r
-        delete this.triggerElement;\r
-    },\r
-\r
-    <div id="method-Ext.ToolTip-show"></div>/**\r
-     * Shows this tooltip at the current event target XY position.\r
-     */\r
-    show : function(){\r
-        if(this.anchor){\r
-            // pre-show it off screen so that the el will have dimensions\r
-            // for positioning calcs when getting xy next\r
-            this.showAt([-1000,-1000]);\r
-            this.origConstrainPosition = this.constrainPosition;\r
-            this.constrainPosition = false;\r
-            this.anchor = this.origAnchor;\r
-        }\r
-        this.showAt(this.getTargetXY());\r
-\r
-        if(this.anchor){\r
-            this.syncAnchor();\r
-            this.anchorEl.show();\r
-            this.constrainPosition = this.origConstrainPosition;\r
-        }else{\r
-            this.anchorEl.hide();\r
-        }\r
-    },\r
-\r
-    // inherit docs\r
-    showAt : function(xy){\r
-        this.lastActive = new Date();\r
-        this.clearTimers();\r
-        Ext.ToolTip.superclass.showAt.call(this, xy);\r
-        if(this.dismissDelay && this.autoHide !== false){\r
-            this.dismissTimer = this.hide.defer(this.dismissDelay, this);\r
-        }\r
-        if(this.anchor && !this.anchorEl.isVisible()){\r
-            this.syncAnchor();\r
-            this.anchorEl.show();\r
-        }\r
-    },\r
-\r
-    // private\r
-    syncAnchor : function(){\r
-        var anchorPos, targetPos, offset;\r
-        switch(this.tipAnchor.charAt(0)){\r
-            case 't':\r
-                anchorPos = 'b';\r
-                targetPos = 'tl';\r
-                offset = [20+this.anchorOffset, 2];\r
-                break;\r
-            case 'r':\r
-                anchorPos = 'l';\r
-                targetPos = 'tr';\r
-                offset = [-2, 11+this.anchorOffset];\r
-                break;\r
-            case 'b':\r
-                anchorPos = 't';\r
-                targetPos = 'bl';\r
-                offset = [20+this.anchorOffset, -2];\r
-                break;\r
-            default:\r
-                anchorPos = 'r';\r
-                targetPos = 'tl';\r
-                offset = [2, 11+this.anchorOffset];\r
-                break;\r
-        }\r
-        this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);\r
-    },\r
-\r
-    // private\r
-    setPagePosition : function(x, y){\r
-        Ext.ToolTip.superclass.setPagePosition.call(this, x, y);\r
-        if(this.anchor){\r
-            this.syncAnchor();\r
-        }\r
-    },\r
-\r
-    // private\r
-    clearTimer : function(name){\r
-        name = name + 'Timer';\r
-        clearTimeout(this[name]);\r
-        delete this[name];\r
-    },\r
-\r
-    // private\r
-    clearTimers : function(){\r
-        this.clearTimer('show');\r
-        this.clearTimer('dismiss');\r
-        this.clearTimer('hide');\r
-    },\r
-\r
-    // private\r
-    onShow : function(){\r
-        Ext.ToolTip.superclass.onShow.call(this);\r
-        Ext.getDoc().on('mousedown', this.onDocMouseDown, this);\r
-    },\r
-\r
-    // private\r
-    onHide : function(){\r
-        Ext.ToolTip.superclass.onHide.call(this);\r
-        Ext.getDoc().un('mousedown', this.onDocMouseDown, this);\r
-    },\r
-\r
-    // private\r
-    onDocMouseDown : function(e){\r
-        if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){\r
-            this.disable();\r
-            this.enable.defer(100, this);\r
-        }\r
-    },\r
-\r
-    // private\r
-    onDisable : function(){\r
-        this.clearTimers();\r
-        this.hide();\r
-    },\r
-\r
-    // private\r
-    adjustPosition : function(x, y){\r
-        if(this.contstrainPosition){\r
-            var ay = this.targetXY[1], h = this.getSize().height;\r
-            if(y <= ay && (y+h) >= ay){\r
-                y = ay-h-5;\r
-            }\r
-        }\r
-        return {x : x, y: y};\r
-    },\r
-    \r
-    beforeDestroy : function(){\r
-        this.clearTimers();\r
-        Ext.destroy(this.anchorEl);\r
-        delete this.anchorEl;\r
-        delete this.target;\r
-        delete this.anchorTarget;\r
-        delete this.triggerElement;\r
-        Ext.ToolTip.superclass.beforeDestroy.call(this);    \r
-    },\r
-\r
-    // private\r
-    onDestroy : function(){\r
-        Ext.getDoc().un('mousedown', this.onDocMouseDown, this);\r
-        Ext.ToolTip.superclass.onDestroy.call(this);\r
-    }\r
-});\r
-\r
-Ext.reg('tooltip', Ext.ToolTip);</pre>    \r
-</body>\r
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <title>The source code</title>
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
+ */
+<div id="cls-Ext.ToolTip"></div>/**
+ * @class Ext.ToolTip
+ * @extends Ext.Tip
+ * A standard tooltip implementation for providing additional information when hovering over a target element.
+ * @xtype tooltip
+ * @constructor
+ * Create a new Tooltip
+ * @param {Object} config The configuration options
+ */
+Ext.ToolTip = Ext.extend(Ext.Tip, {
+    <div id="prop-Ext.ToolTip-triggerElement"></div>/**
+     * When a Tooltip is configured with the <code>{@link #delegate}</code>
+     * option to cause selected child elements of the <code>{@link #target}</code>
+     * Element to each trigger a seperate show event, this property is set to
+     * the DOM element which triggered the show.
+     * @type DOMElement
+     * @property triggerElement
+     */
+    <div id="cfg-Ext.ToolTip-target"></div>/**
+     * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to monitor
+     * for mouseover events to trigger showing this ToolTip.
+     */
+    <div id="cfg-Ext.ToolTip-autoHide"></div>/**
+     * @cfg {Boolean} autoHide True to automatically hide the tooltip after the
+     * mouse exits the target element or after the <code>{@link #dismissDelay}</code>
+     * has expired if set (defaults to true).  If <code>{@link closable} = true</code>
+     * a close tool button will be rendered into the tooltip header.
+     */
+    <div id="cfg-Ext.ToolTip-showDelay"></div>/**
+     * @cfg {Number} showDelay Delay in milliseconds before the tooltip displays
+     * after the mouse enters the target element (defaults to 500)
+     */
+    showDelay : 500,
+    <div id="cfg-Ext.ToolTip-hideDelay"></div>/**
+     * @cfg {Number} hideDelay Delay in milliseconds after the mouse exits the
+     * target element but before the tooltip actually hides (defaults to 200).
+     * Set to 0 for the tooltip to hide immediately.
+     */
+    hideDelay : 200,
+    <div id="cfg-Ext.ToolTip-dismissDelay"></div>/**
+     * @cfg {Number} dismissDelay Delay in milliseconds before the tooltip
+     * automatically hides (defaults to 5000). To disable automatic hiding, set
+     * dismissDelay = 0.
+     */
+    dismissDelay : 5000,
+    <div id="cfg-Ext.ToolTip-mouseOffset"></div>/**
+     * @cfg {Array} mouseOffset An XY offset from the mouse position where the
+     * tooltip should be shown (defaults to [15,18]).
+     */
+    <div id="cfg-Ext.ToolTip-trackMouse"></div>/**
+     * @cfg {Boolean} trackMouse True to have the tooltip follow the mouse as it
+     * moves over the target element (defaults to false).
+     */
+    trackMouse : false,
+    <div id="cfg-Ext.ToolTip-anchorToTarget"></div>/**
+     * @cfg {Boolean} anchorToTarget True to anchor the tooltip to the target
+     * element, false to anchor it relative to the mouse coordinates (defaults
+     * to true).  When <code>anchorToTarget</code> is true, use
+     * <code>{@link #defaultAlign}</code> to control tooltip alignment to the
+     * target element.  When <code>anchorToTarget</code> is false, use
+     * <code>{@link #anchorPosition}</code> instead to control alignment.
+     */
+    anchorToTarget : true,
+    <div id="cfg-Ext.ToolTip-anchorOffset"></div>/**
+     * @cfg {Number} anchorOffset A numeric pixel value used to offset the
+     * default position of the anchor arrow (defaults to 0).  When the anchor
+     * position is on the top or bottom of the tooltip, <code>anchorOffset</code>
+     * will be used as a horizontal offset.  Likewise, when the anchor position
+     * is on the left or right side, <code>anchorOffset</code> will be used as
+     * a vertical offset.
+     */
+    anchorOffset : 0,
+    <div id="cfg-Ext.ToolTip-delegate"></div>/**
+     * @cfg {String} delegate <p>Optional. A {@link Ext.DomQuery DomQuery}
+     * selector which allows selection of individual elements within the
+     * <code>{@link #target}</code> element to trigger showing and hiding the
+     * ToolTip as the mouse moves within the target.</p>
+     * <p>When specified, the child element of the target which caused a show
+     * event is placed into the <code>{@link #triggerElement}</code> property
+     * before the ToolTip is shown.</p>
+     * <p>This may be useful when a Component has regular, repeating elements
+     * in it, each of which need a Tooltip which contains information specific
+     * to that element. For example:</p><pre><code>
+var myGrid = new Ext.grid.gridPanel(gridConfig);
+myGrid.on('render', function(grid) {
+    var store = grid.getStore();  // Capture the Store.
+    var view = grid.getView();    // Capture the GridView.
+    myGrid.tip = new Ext.ToolTip({
+        target: view.mainBody,    // The overall target element.
+        delegate: '.x-grid3-row', // Each grid row causes its own seperate show and hide.
+        trackMouse: true,         // Moving within the row should not hide the tip.
+        renderTo: document.body,  // Render immediately so that tip.body can be
+                                  //  referenced prior to the first show.
+        listeners: {              // Change content dynamically depending on which element
+                                  //  triggered the show.
+            beforeshow: function updateTipBody(tip) {
+                var rowIndex = view.findRowIndex(tip.triggerElement);
+                tip.body.dom.innerHTML = 'Over Record ID ' + store.getAt(rowIndex).id;
+            }
+        }
+    });
+});
+     *</code></pre>
+     */
+
+    // private
+    targetCounter : 0,
+
+    constrainPosition : false,
+
+    // private
+    initComponent : function(){
+        Ext.ToolTip.superclass.initComponent.call(this);
+        this.lastActive = new Date();
+        this.initTarget(this.target);
+        this.origAnchor = this.anchor;
+    },
+
+    // private
+    onRender : function(ct, position){
+        Ext.ToolTip.superclass.onRender.call(this, ct, position);
+        this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();
+        this.anchorEl = this.el.createChild({
+            cls: 'x-tip-anchor ' + this.anchorCls
+        });
+    },
+
+    // private
+    afterRender : function(){
+        Ext.ToolTip.superclass.afterRender.call(this);
+        this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1).setVisibilityMode(Ext.Element.DISPLAY);
+    },
+
+    <div id="method-Ext.ToolTip-initTarget"></div>/**
+     * Binds this ToolTip to the specified element. The tooltip will be displayed when the mouse moves over the element.
+     * @param {Mixed} t The Element, HtmlElement, or ID of an element to bind to
+     */
+    initTarget : function(target){
+        var t;
+        if((t = Ext.get(target))){
+            if(this.target){
+                var tg = Ext.get(this.target);
+                this.mun(tg, 'mouseover', this.onTargetOver, this);
+                this.mun(tg, 'mouseout', this.onTargetOut, this);
+                this.mun(tg, 'mousemove', this.onMouseMove, this);
+            }
+            this.mon(t, {
+                mouseover: this.onTargetOver,
+                mouseout: this.onTargetOut,
+                mousemove: this.onMouseMove,
+                scope: this
+            });
+            this.target = t;
+        }
+        if(this.anchor){
+            this.anchorTarget = this.target;
+        }
+    },
+
+    // private
+    onMouseMove : function(e){
+        var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;
+        if (t) {
+            this.targetXY = e.getXY();
+            if (t === this.triggerElement) {
+                if(!this.hidden && this.trackMouse){
+                    this.setPagePosition(this.getTargetXY());
+                }
+            } else {
+                this.hide();
+                this.lastActive = new Date(0);
+                this.onTargetOver(e);
+            }
+        } else if (!this.closable && this.isVisible()) {
+            this.hide();
+        }
+    },
+
+    // private
+    getTargetXY : function(){
+        if(this.delegate){
+            this.anchorTarget = this.triggerElement;
+        }
+        if(this.anchor){
+            this.targetCounter++;
+            var offsets = this.getOffsets(),
+                xy = (this.anchorToTarget && !this.trackMouse) ? this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) : this.targetXY,
+                dw = Ext.lib.Dom.getViewWidth() - 5,
+                dh = Ext.lib.Dom.getViewHeight() - 5,
+                de = document.documentElement,
+                bd = document.body,
+                scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5,
+                scrollY = (de.scrollTop || bd.scrollTop || 0) + 5,
+                axy = [xy[0] + offsets[0], xy[1] + offsets[1]],
+                sz = this.getSize();
+                
+            this.anchorEl.removeClass(this.anchorCls);
+
+            if(this.targetCounter < 2){
+                if(axy[0] < scrollX){
+                    if(this.anchorToTarget){
+                        this.defaultAlign = 'l-r';
+                        if(this.mouseOffset){this.mouseOffset[0] *= -1;}
+                    }
+                    this.anchor = 'left';
+                    return this.getTargetXY();
+                }
+                if(axy[0]+sz.width > dw){
+                    if(this.anchorToTarget){
+                        this.defaultAlign = 'r-l';
+                        if(this.mouseOffset){this.mouseOffset[0] *= -1;}
+                    }
+                    this.anchor = 'right';
+                    return this.getTargetXY();
+                }
+                if(axy[1] < scrollY){
+                    if(this.anchorToTarget){
+                        this.defaultAlign = 't-b';
+                        if(this.mouseOffset){this.mouseOffset[1] *= -1;}
+                    }
+                    this.anchor = 'top';
+                    return this.getTargetXY();
+                }
+                if(axy[1]+sz.height > dh){
+                    if(this.anchorToTarget){
+                        this.defaultAlign = 'b-t';
+                        if(this.mouseOffset){this.mouseOffset[1] *= -1;}
+                    }
+                    this.anchor = 'bottom';
+                    return this.getTargetXY();
+                }
+            }
+
+            this.anchorCls = 'x-tip-anchor-'+this.getAnchorPosition();
+            this.anchorEl.addClass(this.anchorCls);
+            this.targetCounter = 0;
+            return axy;
+        }else{
+            var mouseOffset = this.getMouseOffset();
+            return [this.targetXY[0]+mouseOffset[0], this.targetXY[1]+mouseOffset[1]];
+        }
+    },
+
+    getMouseOffset : function(){
+        var offset = this.anchor ? [0,0] : [15,18];
+        if(this.mouseOffset){
+            offset[0] += this.mouseOffset[0];
+            offset[1] += this.mouseOffset[1];
+        }
+        return offset;
+    },
+
+    // private
+    getAnchorPosition : function(){
+        if(this.anchor){
+            this.tipAnchor = this.anchor.charAt(0);
+        }else{
+            var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);
+            if(!m){
+               throw 'AnchorTip.defaultAlign is invalid';
+            }
+            this.tipAnchor = m[1].charAt(0);
+        }
+
+        switch(this.tipAnchor){
+            case 't': return 'top';
+            case 'b': return 'bottom';
+            case 'r': return 'right';
+        }
+        return 'left';
+    },
+
+    // private
+    getAnchorAlign : function(){
+        switch(this.anchor){
+            case 'top'  : return 'tl-bl';
+            case 'left' : return 'tl-tr';
+            case 'right': return 'tr-tl';
+            default     : return 'bl-tl';
+        }
+    },
+
+    // private
+    getOffsets : function(){
+        var offsets, 
+            ap = this.getAnchorPosition().charAt(0);
+        if(this.anchorToTarget && !this.trackMouse){
+            switch(ap){
+                case 't':
+                    offsets = [0, 9];
+                    break;
+                case 'b':
+                    offsets = [0, -13];
+                    break;
+                case 'r':
+                    offsets = [-13, 0];
+                    break;
+                default:
+                    offsets = [9, 0];
+                    break;
+            }
+        }else{
+            switch(ap){
+                case 't':
+                    offsets = [-15-this.anchorOffset, 30];
+                    break;
+                case 'b':
+                    offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];
+                    break;
+                case 'r':
+                    offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];
+                    break;
+                default:
+                    offsets = [25, -13-this.anchorOffset];
+                    break;
+            }
+        }
+        var mouseOffset = this.getMouseOffset();
+        offsets[0] += mouseOffset[0];
+        offsets[1] += mouseOffset[1];
+
+        return offsets;
+    },
+
+    // private
+    onTargetOver : function(e){
+        if(this.disabled || e.within(this.target.dom, true)){
+            return;
+        }
+        var t = e.getTarget(this.delegate);
+        if (t) {
+            this.triggerElement = t;
+            this.clearTimer('hide');
+            this.targetXY = e.getXY();
+            this.delayShow();
+        }
+    },
+
+    // private
+    delayShow : function(){
+        if(this.hidden && !this.showTimer){
+            if(this.lastActive.getElapsed() < this.quickShowInterval){
+                this.show();
+            }else{
+                this.showTimer = this.show.defer(this.showDelay, this);
+            }
+        }else if(!this.hidden && this.autoHide !== false){
+            this.show();
+        }
+    },
+
+    // private
+    onTargetOut : function(e){
+        if(this.disabled || e.within(this.target.dom, true)){
+            return;
+        }
+        this.clearTimer('show');
+        if(this.autoHide !== false){
+            this.delayHide();
+        }
+    },
+
+    // private
+    delayHide : function(){
+        if(!this.hidden && !this.hideTimer){
+            this.hideTimer = this.hide.defer(this.hideDelay, this);
+        }
+    },
+
+    <div id="method-Ext.ToolTip-hide"></div>/**
+     * Hides this tooltip if visible.
+     */
+    hide: function(){
+        this.clearTimer('dismiss');
+        this.lastActive = new Date();
+        if(this.anchorEl){
+            this.anchorEl.hide();
+        }
+        Ext.ToolTip.superclass.hide.call(this);
+        delete this.triggerElement;
+    },
+
+    <div id="method-Ext.ToolTip-show"></div>/**
+     * Shows this tooltip at the current event target XY position.
+     */
+    show : function(){
+        if(this.anchor){
+            // pre-show it off screen so that the el will have dimensions
+            // for positioning calcs when getting xy next
+            this.showAt([-1000,-1000]);
+            this.origConstrainPosition = this.constrainPosition;
+            this.constrainPosition = false;
+            this.anchor = this.origAnchor;
+        }
+        this.showAt(this.getTargetXY());
+
+        if(this.anchor){
+            this.anchorEl.show();
+            this.syncAnchor();
+            this.constrainPosition = this.origConstrainPosition;
+        }else{
+            this.anchorEl.hide();
+        }
+    },
+
+    // inherit docs
+    showAt : function(xy){
+        this.lastActive = new Date();
+        this.clearTimers();
+        Ext.ToolTip.superclass.showAt.call(this, xy);
+        if(this.dismissDelay && this.autoHide !== false){
+            this.dismissTimer = this.hide.defer(this.dismissDelay, this);
+        }
+        if(this.anchor && !this.anchorEl.isVisible()){
+            this.syncAnchor();
+            this.anchorEl.show();
+        }else{
+            this.anchorEl.hide();
+        }
+    },
+
+    // private
+    syncAnchor : function(){
+        var anchorPos, targetPos, offset;
+        switch(this.tipAnchor.charAt(0)){
+            case 't':
+                anchorPos = 'b';
+                targetPos = 'tl';
+                offset = [20+this.anchorOffset, 2];
+                break;
+            case 'r':
+                anchorPos = 'l';
+                targetPos = 'tr';
+                offset = [-2, 11+this.anchorOffset];
+                break;
+            case 'b':
+                anchorPos = 't';
+                targetPos = 'bl';
+                offset = [20+this.anchorOffset, -2];
+                break;
+            default:
+                anchorPos = 'r';
+                targetPos = 'tl';
+                offset = [2, 11+this.anchorOffset];
+                break;
+        }
+        this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);
+    },
+
+    // private
+    setPagePosition : function(x, y){
+        Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
+        if(this.anchor){
+            this.syncAnchor();
+        }
+    },
+
+    // private
+    clearTimer : function(name){
+        name = name + 'Timer';
+        clearTimeout(this[name]);
+        delete this[name];
+    },
+
+    // private
+    clearTimers : function(){
+        this.clearTimer('show');
+        this.clearTimer('dismiss');
+        this.clearTimer('hide');
+    },
+
+    // private
+    onShow : function(){
+        Ext.ToolTip.superclass.onShow.call(this);
+        Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
+    },
+
+    // private
+    onHide : function(){
+        Ext.ToolTip.superclass.onHide.call(this);
+        Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
+    },
+
+    // private
+    onDocMouseDown : function(e){
+        if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){
+            this.disable();
+            this.doEnable.defer(100, this);
+        }
+    },
+    
+    // private
+    doEnable : function(){
+        if(!this.isDestroyed){
+            this.enable();
+        }
+    },
+
+    // private
+    onDisable : function(){
+        this.clearTimers();
+        this.hide();
+    },
+
+    // private
+    adjustPosition : function(x, y){
+        if(this.contstrainPosition){
+            var ay = this.targetXY[1], h = this.getSize().height;
+            if(y <= ay && (y+h) >= ay){
+                y = ay-h-5;
+            }
+        }
+        return {x : x, y: y};
+    },
+    
+    beforeDestroy : function(){
+        this.clearTimers();
+        Ext.destroy(this.anchorEl);
+        delete this.anchorEl;
+        delete this.target;
+        delete this.anchorTarget;
+        delete this.triggerElement;
+        Ext.ToolTip.superclass.beforeDestroy.call(this);    
+    },
+
+    // private
+    onDestroy : function(){
+        Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
+        Ext.ToolTip.superclass.onDestroy.call(this);
+    }
+});
+
+Ext.reg('tooltip', Ext.ToolTip);</pre>    
+</body>
 </html>
\ No newline at end of file