/*!
- * Ext JS Library 3.0.0
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.1.1
+ * Copyright(c) 2006-2010 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
* @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
/**\r
- * When a Tooltip is configured with the {@link #delegate} option to cause selected child elements of the {@link #target}\r
- * Element to each trigger a seperate show event, this property is set to the DOM element which triggered the show.\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
/**\r
- * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to monitor for mouseover events to trigger\r
- * showing this ToolTip.\r
+ * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to monitor\r
+ * for mouseover events to trigger showing this ToolTip.\r
*/\r
/**\r
- * @cfg {Boolean} autoHide True to automatically hide the tooltip after the mouse exits the target element\r
- * or after the {@link #dismissDelay} has expired if set (defaults to true). If {@link closable} = true a close\r
- * tool button will be rendered into the tooltip header.\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
/**\r
- * @cfg {Number} showDelay Delay in milliseconds before the tooltip displays after the mouse enters the\r
- * target element (defaults to 500)\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
+ showDelay : 500,\r
/**\r
- * @cfg {Number} hideDelay Delay in milliseconds after the mouse exits the target element but before the\r
- * tooltip actually hides (defaults to 200). Set to 0 for the tooltip to hide immediately.\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
+ hideDelay : 200,\r
/**\r
- * @cfg {Number} dismissDelay Delay in milliseconds before the tooltip automatically hides (defaults to 5000).\r
- * To disable automatic hiding, set dismissDelay = 0.\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
+ dismissDelay : 5000,\r
/**\r
- * @cfg {Array} mouseOffset An XY offset from the mouse position where the tooltip should be shown (defaults to [15,18]).\r
+ * @cfg {Array} mouseOffset An XY offset from the mouse position where the\r
+ * tooltip should be shown (defaults to [15,18]).\r
*/\r
/**\r
- * @cfg {Boolean} trackMouse True to have the tooltip follow the mouse as it moves over the target element (defaults to false).\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
/**\r
- * @cfg {Boolean} anchorToTarget True to anchor the tooltip to the target element, false to\r
- * anchor it relative to the mouse coordinates (defaults to true). When anchorToTarget is\r
- * true, use {@link #defaultAlign} to control tooltip alignment to the target element. When\r
- * anchorToTarget is false, use {@link #anchorPosition} instead to control alignment.\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
+ anchorToTarget : true,\r
/**\r
- * @cfg {Number} anchorOffset A numeric pixel value used to offset the default position of the\r
- * anchor arrow (defaults to 0). When the anchor position is on the top or bottom of the tooltip,\r
- * anchorOffset will be used as a horizontal offset. Likewise, when the anchor position is on the\r
- * left or right side, anchorOffset will be used as a vertical offset.\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
+ anchorOffset : 0,\r
/**\r
- * @cfg {String} delegate <p>Optional. A {@link Ext.DomQuery DomQuery} selector which allows selection of individual elements\r
- * within the {@link #target} element to trigger showing and hiding the ToolTip as the mouse moves within the target.</p>\r
- * <p>When specified, the child element of the target which caused a show event is placed into the {@link #triggerElement} property\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 in it, each of which need a Tooltip which contains\r
- * information specific to that element. For example:</p><pre><code>\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
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 referenced prior to the first show.\r
- listeners: { // Change content dynamically depending on which element triggered the show.\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
+ tip.body.dom.innerHTML = 'Over Record ID ' + store.getAt(rowIndex).id;\r
}\r
}\r
});\r
-});</code></pre>\r
+});\r
+ *</code></pre>\r
*/\r
\r
// private\r
- targetCounter: 0,\r
+ targetCounter : 0,\r
\r
- constrainPosition: false,\r
+ constrainPosition : false,\r
\r
// private\r
- initComponent: function(){\r
+ initComponent : function(){\r
Ext.ToolTip.superclass.initComponent.call(this);\r
this.lastActive = new Date();\r
this.initTarget(this.target);\r
var t;\r
if((t = Ext.get(target))){\r
if(this.target){\r
- this.target = Ext.get(this.target);\r
- this.target.un('mouseover', this.onTargetOver, this);\r
- this.target.un('mouseout', this.onTargetOut, this);\r
- this.target.un('mousemove', this.onMouseMove, this);\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
\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
- var xy = (this.anchorToTarget && !this.trackMouse) ?\r
- this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) :\r
- this.targetXY;\r
-\r
- var dw = Ext.lib.Dom.getViewWidth()-5;\r
- var dh = Ext.lib.Dom.getViewHeight()-5;\r
- var scrollX = (document.documentElement.scrollLeft || document.body.scrollLeft || 0)+5;\r
- var scrollY = (document.documentElement.scrollTop || document.body.scrollTop || 0)+5;\r
-\r
- var axy = [xy[0] + offsets[0], xy[1] + offsets[1]];\r
- var sz = this.getSize();\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
}else{\r
var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);\r
if(!m){\r
- throw "AnchorTip.defaultAlign is invalid";\r
+ throw 'AnchorTip.defaultAlign is invalid';\r
}\r
this.tipAnchor = m[1].charAt(0);\r
}\r
},\r
\r
// private\r
- getOffsets: function(){\r
- var offsets, ap = this.getAnchorPosition().charAt(0);\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
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
}\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
-});
\ No newline at end of file
+});\r
+\r
+Ext.reg('tooltip', Ext.ToolTip);
\ No newline at end of file