3 * Copyright(c) 2006-2010 Ext JS, LLC
5 * http://www.extjs.com/license
11 * This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and
\r
12 * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned
\r
13 * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.
\r
16 * @param {Object} config The configuration options
\r
18 Ext.Tip = Ext.extend(Ext.Panel, {
\r
20 * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).
\r
23 * @cfg {Number} width
\r
24 * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of
\r
25 * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.
\r
28 * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).
\r
32 * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.
\r
36 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"
\r
37 * for bottom-right shadow (defaults to "sides").
\r
41 * @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value
\r
42 * for this tip relative to its element of origin (defaults to "tl-bl?").
\r
44 defaultAlign : "tl-bl?",
\r
46 quickShowInterval : 250,
\r
48 // private panel overrides
\r
52 floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
\r
55 closeAction: 'hide',
\r
58 initComponent : function(){
\r
59 Ext.Tip.superclass.initComponent.call(this);
\r
60 if(this.closable && !this.title){
\r
61 this.elements += ',header';
\r
66 afterRender : function(){
\r
67 Ext.Tip.superclass.afterRender.call(this);
\r
71 handler: this[this.closeAction],
\r
78 * Shows this tip at the specified XY position. Example usage:
\r
80 // Show the tip at x:50 and y:100
\r
81 tip.showAt([50,100]);
\r
83 * @param {Array} xy An array containing the x and y coordinates
\r
85 showAt : function(xy){
\r
86 Ext.Tip.superclass.show.call(this);
\r
87 if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
\r
90 if(this.constrainPosition){
\r
91 xy = this.el.adjustForConstraints(xy);
\r
93 this.setPagePosition(xy[0], xy[1]);
\r
97 doAutoWidth : function(adjust){
\r
98 adjust = adjust || 0;
\r
99 var bw = this.body.getTextWidth();
\r
101 bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
\r
103 bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr") + adjust;
\r
104 this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
\r
106 // IE7 repaint bug on initial show
\r
107 if(Ext.isIE7 && !this.repainted){
\r
109 this.repainted = true;
\r
114 * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
\r
115 * anchor position value. Example usage:
\r
117 // Show the tip at the default position ('tl-br?')
\r
118 tip.showBy('my-el');
\r
120 // Show the tip's top-left corner anchored to the element's top-right corner
\r
121 tip.showBy('my-el', 'tl-tr');
\r
123 * @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
\r
124 * @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
\r
125 * {@link #defaultAlign} if specified).
\r
127 showBy : function(el, pos){
\r
128 if(!this.rendered){
\r
129 this.render(Ext.getBody());
\r
131 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
\r
134 initDraggable : function(){
\r
135 this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
\r
136 this.header.addClass('x-tip-draggable');
\r
140 Ext.reg('tip', Ext.Tip);
\r
142 // private - custom Tip DD implementation
\r
143 Ext.Tip.DD = function(tip, config){
\r
144 Ext.apply(this, config);
\r
146 Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
\r
147 this.setHandleElId(tip.header.id);
\r
148 this.scroll = false;
\r
151 Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
\r
154 headerOffsets:[100, 25],
\r
155 startDrag : function(){
\r
156 this.tip.el.disableShadow();
\r
158 endDrag : function(e){
\r
159 this.tip.el.enableShadow(true);
\r
162 * @class Ext.ToolTip
\r
164 * A standard tooltip implementation for providing additional information when hovering over a target element.
\r
167 * Create a new Tooltip
\r
168 * @param {Object} config The configuration options
\r
170 Ext.ToolTip = Ext.extend(Ext.Tip, {
\r
172 * When a Tooltip is configured with the <code>{@link #delegate}</code>
\r
173 * option to cause selected child elements of the <code>{@link #target}</code>
\r
174 * Element to each trigger a seperate show event, this property is set to
\r
175 * the DOM element which triggered the show.
\r
177 * @property triggerElement
\r
180 * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to monitor
\r
181 * for mouseover events to trigger showing this ToolTip.
\r
184 * @cfg {Boolean} autoHide True to automatically hide the tooltip after the
\r
185 * mouse exits the target element or after the <code>{@link #dismissDelay}</code>
\r
186 * has expired if set (defaults to true). If <code>{@link closable} = true</code>
\r
187 * a close tool button will be rendered into the tooltip header.
\r
190 * @cfg {Number} showDelay Delay in milliseconds before the tooltip displays
\r
191 * after the mouse enters the target element (defaults to 500)
\r
195 * @cfg {Number} hideDelay Delay in milliseconds after the mouse exits the
\r
196 * target element but before the tooltip actually hides (defaults to 200).
\r
197 * Set to 0 for the tooltip to hide immediately.
\r
201 * @cfg {Number} dismissDelay Delay in milliseconds before the tooltip
\r
202 * automatically hides (defaults to 5000). To disable automatic hiding, set
\r
203 * dismissDelay = 0.
\r
205 dismissDelay : 5000,
\r
207 * @cfg {Array} mouseOffset An XY offset from the mouse position where the
\r
208 * tooltip should be shown (defaults to [15,18]).
\r
211 * @cfg {Boolean} trackMouse True to have the tooltip follow the mouse as it
\r
212 * moves over the target element (defaults to false).
\r
214 trackMouse : false,
\r
216 * @cfg {Boolean} anchorToTarget True to anchor the tooltip to the target
\r
217 * element, false to anchor it relative to the mouse coordinates (defaults
\r
218 * to true). When <code>anchorToTarget</code> is true, use
\r
219 * <code>{@link #defaultAlign}</code> to control tooltip alignment to the
\r
220 * target element. When <code>anchorToTarget</code> is false, use
\r
221 * <code>{@link #anchorPosition}</code> instead to control alignment.
\r
223 anchorToTarget : true,
\r
225 * @cfg {Number} anchorOffset A numeric pixel value used to offset the
\r
226 * default position of the anchor arrow (defaults to 0). When the anchor
\r
227 * position is on the top or bottom of the tooltip, <code>anchorOffset</code>
\r
228 * will be used as a horizontal offset. Likewise, when the anchor position
\r
229 * is on the left or right side, <code>anchorOffset</code> will be used as
\r
230 * a vertical offset.
\r
234 * @cfg {String} delegate <p>Optional. A {@link Ext.DomQuery DomQuery}
\r
235 * selector which allows selection of individual elements within the
\r
236 * <code>{@link #target}</code> element to trigger showing and hiding the
\r
237 * ToolTip as the mouse moves within the target.</p>
\r
238 * <p>When specified, the child element of the target which caused a show
\r
239 * event is placed into the <code>{@link #triggerElement}</code> property
\r
240 * before the ToolTip is shown.</p>
\r
241 * <p>This may be useful when a Component has regular, repeating elements
\r
242 * in it, each of which need a Tooltip which contains information specific
\r
243 * to that element. For example:</p><pre><code>
\r
244 var myGrid = new Ext.grid.gridPanel(gridConfig);
\r
245 myGrid.on('render', function(grid) {
\r
246 var store = grid.getStore(); // Capture the Store.
\r
247 var view = grid.getView(); // Capture the GridView.
\r
248 myGrid.tip = new Ext.ToolTip({
\r
249 target: view.mainBody, // The overall target element.
\r
250 delegate: '.x-grid3-row', // Each grid row causes its own seperate show and hide.
\r
251 trackMouse: true, // Moving within the row should not hide the tip.
\r
252 renderTo: document.body, // Render immediately so that tip.body can be
\r
253 // referenced prior to the first show.
\r
254 listeners: { // Change content dynamically depending on which element
\r
255 // triggered the show.
\r
256 beforeshow: function updateTipBody(tip) {
\r
257 var rowIndex = view.findRowIndex(tip.triggerElement);
\r
258 tip.body.dom.innerHTML = 'Over Record ID ' + store.getAt(rowIndex).id;
\r
269 constrainPosition : false,
\r
272 initComponent : function(){
\r
273 Ext.ToolTip.superclass.initComponent.call(this);
\r
274 this.lastActive = new Date();
\r
275 this.initTarget(this.target);
\r
276 this.origAnchor = this.anchor;
\r
280 onRender : function(ct, position){
\r
281 Ext.ToolTip.superclass.onRender.call(this, ct, position);
\r
282 this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();
\r
283 this.anchorEl = this.el.createChild({
\r
284 cls: 'x-tip-anchor ' + this.anchorCls
\r
289 afterRender : function(){
\r
290 Ext.ToolTip.superclass.afterRender.call(this);
\r
291 this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1);
\r
295 * Binds this ToolTip to the specified element. The tooltip will be displayed when the mouse moves over the element.
\r
296 * @param {Mixed} t The Element, HtmlElement, or ID of an element to bind to
\r
298 initTarget : function(target){
\r
300 if((t = Ext.get(target))){
\r
302 var tg = Ext.get(this.target);
\r
303 this.mun(tg, 'mouseover', this.onTargetOver, this);
\r
304 this.mun(tg, 'mouseout', this.onTargetOut, this);
\r
305 this.mun(tg, 'mousemove', this.onMouseMove, this);
\r
308 mouseover: this.onTargetOver,
\r
309 mouseout: this.onTargetOut,
\r
310 mousemove: this.onMouseMove,
\r
316 this.anchorTarget = this.target;
\r
321 onMouseMove : function(e){
\r
322 var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;
\r
324 this.targetXY = e.getXY();
\r
325 if (t === this.triggerElement) {
\r
326 if(!this.hidden && this.trackMouse){
\r
327 this.setPagePosition(this.getTargetXY());
\r
331 this.lastActive = new Date(0);
\r
332 this.onTargetOver(e);
\r
334 } else if (!this.closable && this.isVisible()) {
\r
340 getTargetXY : function(){
\r
342 this.anchorTarget = this.triggerElement;
\r
345 this.targetCounter++;
\r
346 var offsets = this.getOffsets(),
\r
347 xy = (this.anchorToTarget && !this.trackMouse) ? this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) : this.targetXY,
\r
348 dw = Ext.lib.Dom.getViewWidth() - 5,
\r
349 dh = Ext.lib.Dom.getViewHeight() - 5,
\r
350 de = document.documentElement,
\r
351 bd = document.body,
\r
352 scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5,
\r
353 scrollY = (de.scrollTop || bd.scrollTop || 0) + 5,
\r
354 axy = [xy[0] + offsets[0], xy[1] + offsets[1]],
\r
355 sz = this.getSize();
\r
357 this.anchorEl.removeClass(this.anchorCls);
\r
359 if(this.targetCounter < 2){
\r
360 if(axy[0] < scrollX){
\r
361 if(this.anchorToTarget){
\r
362 this.defaultAlign = 'l-r';
\r
363 if(this.mouseOffset){this.mouseOffset[0] *= -1;}
\r
365 this.anchor = 'left';
\r
366 return this.getTargetXY();
\r
368 if(axy[0]+sz.width > dw){
\r
369 if(this.anchorToTarget){
\r
370 this.defaultAlign = 'r-l';
\r
371 if(this.mouseOffset){this.mouseOffset[0] *= -1;}
\r
373 this.anchor = 'right';
\r
374 return this.getTargetXY();
\r
376 if(axy[1] < scrollY){
\r
377 if(this.anchorToTarget){
\r
378 this.defaultAlign = 't-b';
\r
379 if(this.mouseOffset){this.mouseOffset[1] *= -1;}
\r
381 this.anchor = 'top';
\r
382 return this.getTargetXY();
\r
384 if(axy[1]+sz.height > dh){
\r
385 if(this.anchorToTarget){
\r
386 this.defaultAlign = 'b-t';
\r
387 if(this.mouseOffset){this.mouseOffset[1] *= -1;}
\r
389 this.anchor = 'bottom';
\r
390 return this.getTargetXY();
\r
394 this.anchorCls = 'x-tip-anchor-'+this.getAnchorPosition();
\r
395 this.anchorEl.addClass(this.anchorCls);
\r
396 this.targetCounter = 0;
\r
399 var mouseOffset = this.getMouseOffset();
\r
400 return [this.targetXY[0]+mouseOffset[0], this.targetXY[1]+mouseOffset[1]];
\r
404 getMouseOffset : function(){
\r
405 var offset = this.anchor ? [0,0] : [15,18];
\r
406 if(this.mouseOffset){
\r
407 offset[0] += this.mouseOffset[0];
\r
408 offset[1] += this.mouseOffset[1];
\r
414 getAnchorPosition : function(){
\r
416 this.tipAnchor = this.anchor.charAt(0);
\r
418 var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);
\r
420 throw 'AnchorTip.defaultAlign is invalid';
\r
422 this.tipAnchor = m[1].charAt(0);
\r
425 switch(this.tipAnchor){
\r
426 case 't': return 'top';
\r
427 case 'b': return 'bottom';
\r
428 case 'r': return 'right';
\r
434 getAnchorAlign : function(){
\r
435 switch(this.anchor){
\r
436 case 'top' : return 'tl-bl';
\r
437 case 'left' : return 'tl-tr';
\r
438 case 'right': return 'tr-tl';
\r
439 default : return 'bl-tl';
\r
444 getOffsets : function(){
\r
446 ap = this.getAnchorPosition().charAt(0);
\r
447 if(this.anchorToTarget && !this.trackMouse){
\r
453 offsets = [0, -13];
\r
456 offsets = [-13, 0];
\r
465 offsets = [-15-this.anchorOffset, 30];
\r
468 offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];
\r
471 offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];
\r
474 offsets = [25, -13-this.anchorOffset];
\r
478 var mouseOffset = this.getMouseOffset();
\r
479 offsets[0] += mouseOffset[0];
\r
480 offsets[1] += mouseOffset[1];
\r
486 onTargetOver : function(e){
\r
487 if(this.disabled || e.within(this.target.dom, true)){
\r
490 var t = e.getTarget(this.delegate);
\r
492 this.triggerElement = t;
\r
493 this.clearTimer('hide');
\r
494 this.targetXY = e.getXY();
\r
500 delayShow : function(){
\r
501 if(this.hidden && !this.showTimer){
\r
502 if(this.lastActive.getElapsed() < this.quickShowInterval){
\r
505 this.showTimer = this.show.defer(this.showDelay, this);
\r
507 }else if(!this.hidden && this.autoHide !== false){
\r
513 onTargetOut : function(e){
\r
514 if(this.disabled || e.within(this.target.dom, true)){
\r
517 this.clearTimer('show');
\r
518 if(this.autoHide !== false){
\r
524 delayHide : function(){
\r
525 if(!this.hidden && !this.hideTimer){
\r
526 this.hideTimer = this.hide.defer(this.hideDelay, this);
\r
531 * Hides this tooltip if visible.
\r
534 this.clearTimer('dismiss');
\r
535 this.lastActive = new Date();
\r
537 this.anchorEl.hide();
\r
539 Ext.ToolTip.superclass.hide.call(this);
\r
540 delete this.triggerElement;
\r
544 * Shows this tooltip at the current event target XY position.
\r
548 // pre-show it off screen so that the el will have dimensions
\r
549 // for positioning calcs when getting xy next
\r
550 this.showAt([-1000,-1000]);
\r
551 this.origConstrainPosition = this.constrainPosition;
\r
552 this.constrainPosition = false;
\r
553 this.anchor = this.origAnchor;
\r
555 this.showAt(this.getTargetXY());
\r
559 this.anchorEl.show();
\r
560 this.constrainPosition = this.origConstrainPosition;
\r
562 this.anchorEl.hide();
\r
567 showAt : function(xy){
\r
568 this.lastActive = new Date();
\r
569 this.clearTimers();
\r
570 Ext.ToolTip.superclass.showAt.call(this, xy);
\r
571 if(this.dismissDelay && this.autoHide !== false){
\r
572 this.dismissTimer = this.hide.defer(this.dismissDelay, this);
\r
574 if(this.anchor && !this.anchorEl.isVisible()){
\r
576 this.anchorEl.show();
\r
581 syncAnchor : function(){
\r
582 var anchorPos, targetPos, offset;
\r
583 switch(this.tipAnchor.charAt(0)){
\r
587 offset = [20+this.anchorOffset, 2];
\r
592 offset = [-2, 11+this.anchorOffset];
\r
597 offset = [20+this.anchorOffset, -2];
\r
602 offset = [2, 11+this.anchorOffset];
\r
605 this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);
\r
609 setPagePosition : function(x, y){
\r
610 Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
\r
617 clearTimer : function(name){
\r
618 name = name + 'Timer';
\r
619 clearTimeout(this[name]);
\r
624 clearTimers : function(){
\r
625 this.clearTimer('show');
\r
626 this.clearTimer('dismiss');
\r
627 this.clearTimer('hide');
\r
631 onShow : function(){
\r
632 Ext.ToolTip.superclass.onShow.call(this);
\r
633 Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
\r
637 onHide : function(){
\r
638 Ext.ToolTip.superclass.onHide.call(this);
\r
639 Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
\r
643 onDocMouseDown : function(e){
\r
644 if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){
\r
646 this.enable.defer(100, this);
\r
651 onDisable : function(){
\r
652 this.clearTimers();
\r
657 adjustPosition : function(x, y){
\r
658 if(this.contstrainPosition){
\r
659 var ay = this.targetXY[1], h = this.getSize().height;
\r
660 if(y <= ay && (y+h) >= ay){
\r
664 return {x : x, y: y};
\r
667 beforeDestroy : function(){
\r
668 this.clearTimers();
\r
669 Ext.destroy(this.anchorEl);
\r
670 delete this.anchorEl;
\r
671 delete this.target;
\r
672 delete this.anchorTarget;
\r
673 delete this.triggerElement;
\r
674 Ext.ToolTip.superclass.beforeDestroy.call(this);
\r
678 onDestroy : function(){
\r
679 Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
\r
680 Ext.ToolTip.superclass.onDestroy.call(this);
\r
684 Ext.reg('tooltip', Ext.ToolTip);/**
\r
685 * @class Ext.QuickTip
\r
686 * @extends Ext.ToolTip
\r
688 * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
\r
689 * {@link Ext.QuickTips} instance. See the QuickTips class header for additional usage details and examples.
\r
692 * @param {Object} config The configuration options
\r
694 Ext.QuickTip = Ext.extend(Ext.ToolTip, {
\r
696 * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this quicktip (defaults to the document).
\r
699 * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
\r
701 interceptTitles : false,
\r
706 attribute : "qtip",
\r
717 initComponent : function(){
\r
718 this.target = this.target || Ext.getDoc();
\r
719 this.targets = this.targets || {};
\r
720 Ext.QuickTip.superclass.initComponent.call(this);
\r
724 * Configures a new quick tip instance and assigns it to a target element. The following config values are
\r
725 * supported (for example usage, see the {@link Ext.QuickTips} class header):
\r
726 * <div class="mdetail-params"><ul>
\r
727 * <li>autoHide</li>
\r
729 * <li>dismissDelay (overrides the singleton value)</li>
\r
730 * <li>target (required)</li>
\r
731 * <li>text (required)</li>
\r
733 * <li>width</li></ul></div>
\r
734 * @param {Object} config The config object
\r
736 register : function(config){
\r
737 var cs = Ext.isArray(config) ? config : arguments;
\r
738 for(var i = 0, len = cs.length; i < len; i++){
\r
740 var target = c.target;
\r
742 if(Ext.isArray(target)){
\r
743 for(var j = 0, jlen = target.length; j < jlen; j++){
\r
744 this.targets[Ext.id(target[j])] = c;
\r
747 this.targets[Ext.id(target)] = c;
\r
754 * Removes this quick tip from its element and destroys it.
\r
755 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
\r
757 unregister : function(el){
\r
758 delete this.targets[Ext.id(el)];
\r
762 * Hides a visible tip or cancels an impending show for a particular element.
\r
763 * @param {String/HTMLElement/Element} el The element that is the target of the tip.
\r
765 cancelShow: function(el){
\r
766 var at = this.activeTarget;
\r
767 el = Ext.get(el).dom;
\r
768 if(this.isVisible()){
\r
769 if(at && at.el == el){
\r
772 }else if(at && at.el == el){
\r
773 this.clearTimer('show');
\r
777 getTipCfg: function(e) {
\r
778 var t = e.getTarget(),
\r
781 if(this.interceptTitles && t.title && Ext.isString(t.title)){
\r
784 t.removeAttribute("title");
\r
785 e.preventDefault();
\r
787 cfg = this.tagConfig;
\r
788 ttp = t.qtip || Ext.fly(t).getAttribute(cfg.attribute, cfg.namespace);
\r
794 onTargetOver : function(e){
\r
798 this.targetXY = e.getXY();
\r
799 var t = e.getTarget();
\r
800 if(!t || t.nodeType !== 1 || t == document || t == document.body){
\r
803 if(this.activeTarget && ((t == this.activeTarget.el) || Ext.fly(this.activeTarget.el).contains(t))){
\r
804 this.clearTimer('hide');
\r
808 if(t && this.targets[t.id]){
\r
809 this.activeTarget = this.targets[t.id];
\r
810 this.activeTarget.el = t;
\r
811 this.anchor = this.activeTarget.anchor;
\r
813 this.anchorTarget = t;
\r
818 var ttp, et = Ext.fly(t), cfg = this.tagConfig, ns = cfg.namespace;
\r
819 if(ttp = this.getTipCfg(e)){
\r
820 var autoHide = et.getAttribute(cfg.hide, ns);
\r
821 this.activeTarget = {
\r
824 width: et.getAttribute(cfg.width, ns),
\r
825 autoHide: autoHide != "user" && autoHide !== 'false',
\r
826 title: et.getAttribute(cfg.title, ns),
\r
827 cls: et.getAttribute(cfg.cls, ns),
\r
828 align: et.getAttribute(cfg.align, ns)
\r
831 this.anchor = et.getAttribute(cfg.anchor, ns);
\r
833 this.anchorTarget = t;
\r
840 onTargetOut : function(e){
\r
842 // If moving within the current target, and it does not have a new tip, ignore the mouseout
\r
843 if (this.activeTarget && e.within(this.activeTarget.el) && !this.getTipCfg(e)) {
\r
847 this.clearTimer('show');
\r
848 if(this.autoHide !== false){
\r
854 showAt : function(xy){
\r
855 var t = this.activeTarget;
\r
857 if(!this.rendered){
\r
858 this.render(Ext.getBody());
\r
859 this.activeTarget = t;
\r
862 this.setWidth(t.width);
\r
863 this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
\r
864 this.measureWidth = false;
\r
866 this.measureWidth = true;
\r
868 this.setTitle(t.title || '');
\r
869 this.body.update(t.text);
\r
870 this.autoHide = t.autoHide;
\r
871 this.dismissDelay = t.dismissDelay || this.dismissDelay;
\r
873 this.el.removeClass(this.lastCls);
\r
874 delete this.lastCls;
\r
877 this.el.addClass(t.cls);
\r
878 this.lastCls = t.cls;
\r
881 this.constrainPosition = false;
\r
882 }else if(t.align){ // TODO: this doesn't seem to work consistently
\r
883 xy = this.el.getAlignToXY(t.el, t.align);
\r
884 this.constrainPosition = false;
\r
886 this.constrainPosition = true;
\r
889 Ext.QuickTip.superclass.showAt.call(this, xy);
\r
894 delete this.activeTarget;
\r
895 Ext.QuickTip.superclass.hide.call(this);
\r
898 Ext.reg('quicktip', Ext.QuickTip);/**
\r
899 * @class Ext.QuickTips
\r
900 * <p>Provides attractive and customizable tooltips for any element. The QuickTips
\r
901 * singleton is used to configure and manage tooltips globally for multiple elements
\r
902 * in a generic manner. To create individual tooltips with maximum customizability,
\r
903 * you should consider either {@link Ext.Tip} or {@link Ext.ToolTip}.</p>
\r
904 * <p>Quicktips can be configured via tag attributes directly in markup, or by
\r
905 * registering quick tips programmatically via the {@link #register} method.</p>
\r
906 * <p>The singleton's instance of {@link Ext.QuickTip} is available via
\r
907 * {@link #getQuickTip}, and supports all the methods, and all the all the
\r
908 * configuration properties of Ext.QuickTip. These settings will apply to all
\r
909 * tooltips shown by the singleton.</p>
\r
910 * <p>Below is the summary of the configuration properties which can be used.
\r
911 * For detailed descriptions see {@link #getQuickTip}</p>
\r
912 * <p><b>QuickTips singleton configs (all are optional)</b></p>
\r
913 * <div class="mdetail-params"><ul><li>dismissDelay</li>
\r
914 * <li>hideDelay</li>
\r
915 * <li>maxWidth</li>
\r
916 * <li>minWidth</li>
\r
917 * <li>showDelay</li>
\r
918 * <li>trackMouse</li></ul></div>
\r
919 * <p><b>Target element configs (optional unless otherwise noted)</b></p>
\r
920 * <div class="mdetail-params"><ul><li>autoHide</li>
\r
922 * <li>dismissDelay (overrides singleton value)</li>
\r
923 * <li>target (required)</li>
\r
924 * <li>text (required)</li>
\r
926 * <li>width</li></ul></div>
\r
927 * <p>Here is an example showing how some of these config options could be used:</p>
\r
929 // Init the singleton. Any tag-based quick tips will start working.
\r
930 Ext.QuickTips.init();
\r
932 // Apply a set of config properties to the singleton
\r
933 Ext.apply(Ext.QuickTips.getQuickTip(), {
\r
940 // Manually register a quick tip for a specific element
\r
941 Ext.QuickTips.register({
\r
943 title: 'My Tooltip',
\r
944 text: 'This tooltip was added in code',
\r
949 * <p>To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with
\r
950 * the <b>ext:</b> namespace. The HTML element itself is automatically set as the quick tip target. Here is the summary
\r
951 * of supported attributes (optional unless otherwise noted):</p>
\r
952 * <ul><li><b>hide</b>: Specifying "user" is equivalent to setting autoHide = false. Any other value will be the
\r
953 * same as autoHide = true.</li>
\r
954 * <li><b>qclass</b>: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).</li>
\r
955 * <li><b>qtip (required)</b>: The quick tip text (equivalent to the 'text' target element config).</li>
\r
956 * <li><b>qtitle</b>: The quick tip title (equivalent to the 'title' target element config).</li>
\r
957 * <li><b>qwidth</b>: The quick tip width (equivalent to the 'width' target element config).</li></ul>
\r
958 * <p>Here is an example of configuring an HTML element to display a tooltip from markup:</p>
\r
960 // Add a quick tip to an HTML button
\r
961 <input type="button" value="OK" ext:qtitle="OK Button" ext:qwidth="100"
\r
962 ext:qtip="This is a quick tip from markup!"></input>
\r
966 Ext.QuickTips = function(){
\r
967 var tip, locks = [];
\r
970 * Initialize the global QuickTips instance and prepare any quick tips.
\r
971 * @param {Boolean} autoRender True to render the QuickTips container immediately to preload images. (Defaults to true)
\r
973 init : function(autoRender){
\r
976 Ext.onReady(function(){
\r
977 Ext.QuickTips.init(autoRender);
\r
981 tip = new Ext.QuickTip({elements:'header,body'});
\r
982 if(autoRender !== false){
\r
983 tip.render(Ext.getBody());
\r
989 * Enable quick tips globally.
\r
991 enable : function(){
\r
994 if(locks.length < 1){
\r
1001 * Disable quick tips globally.
\r
1003 disable : function(){
\r
1011 * Returns true if quick tips are enabled, else false.
\r
1012 * @return {Boolean}
\r
1014 isEnabled : function(){
\r
1015 return tip !== undefined && !tip.disabled;
\r
1019 * Gets the global QuickTips instance.
\r
1021 getQuickTip : function(){
\r
1026 * Configures a new quick tip instance and assigns it to a target element. See
\r
1027 * {@link Ext.QuickTip#register} for details.
\r
1028 * @param {Object} config The config object
\r
1030 register : function(){
\r
1031 tip.register.apply(tip, arguments);
\r
1035 * Removes any registered quick tip from the target element and destroys it.
\r
1036 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
\r
1038 unregister : function(){
\r
1039 tip.unregister.apply(tip, arguments);
\r
1043 * Alias of {@link #register}.
\r
1044 * @param {Object} config The config object
\r
1047 tip.register.apply(tip, arguments);
\r