3 * Copyright(c) 2006-2009 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(){
\r
98 var bw = this.body.getTextWidth();
\r
100 bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
\r
102 bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr");
\r
103 this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
\r
105 // IE7 repaint bug on initial show
\r
106 if(Ext.isIE7 && !this.repainted){
\r
108 this.repainted = true;
\r
113 * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}
\r
114 * anchor position value. Example usage:
\r
116 // Show the tip at the default position ('tl-br?')
\r
117 tip.showBy('my-el');
\r
119 // Show the tip's top-left corner anchored to the element's top-right corner
\r
120 tip.showBy('my-el', 'tl-tr');
\r
122 * @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to
\r
123 * @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or
\r
124 * {@link #defaultAlign} if specified).
\r
126 showBy : function(el, pos){
\r
127 if(!this.rendered){
\r
128 this.render(Ext.getBody());
\r
130 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
\r
133 initDraggable : function(){
\r
134 this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
\r
135 this.header.addClass('x-tip-draggable');
\r
139 Ext.reg('tip', Ext.Tip);
\r
141 // private - custom Tip DD implementation
\r
142 Ext.Tip.DD = function(tip, config){
\r
143 Ext.apply(this, config);
\r
145 Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
\r
146 this.setHandleElId(tip.header.id);
\r
147 this.scroll = false;
\r
150 Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
\r
153 headerOffsets:[100, 25],
\r
154 startDrag : function(){
\r
155 this.tip.el.disableShadow();
\r
157 endDrag : function(e){
\r
158 this.tip.el.enableShadow(true);
\r
161 * @class Ext.ToolTip
\r
163 * A standard tooltip implementation for providing additional information when hovering over a target element.
\r
166 * Create a new Tooltip
\r
167 * @param {Object} config The configuration options
\r
169 Ext.ToolTip = Ext.extend(Ext.Tip, {
\r
171 * When a Tooltip is configured with the <code>{@link #delegate}</code>
\r
172 * option to cause selected child elements of the <code>{@link #target}</code>
\r
173 * Element to each trigger a seperate show event, this property is set to
\r
174 * the DOM element which triggered the show.
\r
176 * @property triggerElement
\r
179 * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to monitor
\r
180 * for mouseover events to trigger showing this ToolTip.
\r
183 * @cfg {Boolean} autoHide True to automatically hide the tooltip after the
\r
184 * mouse exits the target element or after the <code>{@link #dismissDelay}</code>
\r
185 * has expired if set (defaults to true). If <code>{@link closable} = true</code>
\r
186 * a close tool button will be rendered into the tooltip header.
\r
189 * @cfg {Number} showDelay Delay in milliseconds before the tooltip displays
\r
190 * after the mouse enters the target element (defaults to 500)
\r
194 * @cfg {Number} hideDelay Delay in milliseconds after the mouse exits the
\r
195 * target element but before the tooltip actually hides (defaults to 200).
\r
196 * Set to 0 for the tooltip to hide immediately.
\r
200 * @cfg {Number} dismissDelay Delay in milliseconds before the tooltip
\r
201 * automatically hides (defaults to 5000). To disable automatic hiding, set
\r
202 * dismissDelay = 0.
\r
204 dismissDelay : 5000,
\r
206 * @cfg {Array} mouseOffset An XY offset from the mouse position where the
\r
207 * tooltip should be shown (defaults to [15,18]).
\r
210 * @cfg {Boolean} trackMouse True to have the tooltip follow the mouse as it
\r
211 * moves over the target element (defaults to false).
\r
213 trackMouse : false,
\r
215 * @cfg {Boolean} anchorToTarget True to anchor the tooltip to the target
\r
216 * element, false to anchor it relative to the mouse coordinates (defaults
\r
217 * to true). When <code>anchorToTarget</code> is true, use
\r
218 * <code>{@link #defaultAlign}</code> to control tooltip alignment to the
\r
219 * target element. When <code>anchorToTarget</code> is false, use
\r
220 * <code>{@link #anchorPosition}</code> instead to control alignment.
\r
222 anchorToTarget : true,
\r
224 * @cfg {Number} anchorOffset A numeric pixel value used to offset the
\r
225 * default position of the anchor arrow (defaults to 0). When the anchor
\r
226 * position is on the top or bottom of the tooltip, <code>anchorOffset</code>
\r
227 * will be used as a horizontal offset. Likewise, when the anchor position
\r
228 * is on the left or right side, <code>anchorOffset</code> will be used as
\r
229 * a vertical offset.
\r
233 * @cfg {String} delegate <p>Optional. A {@link Ext.DomQuery DomQuery}
\r
234 * selector which allows selection of individual elements within the
\r
235 * <code>{@link #target}</code> element to trigger showing and hiding the
\r
236 * ToolTip as the mouse moves within the target.</p>
\r
237 * <p>When specified, the child element of the target which caused a show
\r
238 * event is placed into the <code>{@link #triggerElement}</code> property
\r
239 * before the ToolTip is shown.</p>
\r
240 * <p>This may be useful when a Component has regular, repeating elements
\r
241 * in it, each of which need a Tooltip which contains information specific
\r
242 * to that element. For example:</p><pre><code>
\r
243 var myGrid = new Ext.grid.gridPanel(gridConfig);
\r
244 myGrid.on('render', function(grid) {
\r
245 var store = grid.getStore(); // Capture the Store.
\r
246 var view = grid.getView(); // Capture the GridView.
\r
247 myGrid.tip = new Ext.ToolTip({
\r
248 target: view.mainBody, // The overall target element.
\r
249 delegate: '.x-grid3-row', // Each grid row causes its own seperate show and hide.
\r
250 trackMouse: true, // Moving within the row should not hide the tip.
\r
251 renderTo: document.body, // Render immediately so that tip.body can be
\r
252 // referenced prior to the first show.
\r
253 listeners: { // Change content dynamically depending on which element
\r
254 // triggered the show.
\r
255 beforeshow: function updateTipBody(tip) {
\r
256 var rowIndex = view.findRowIndex(tip.triggerElement);
\r
257 tip.body.dom.innerHTML = 'Over Record ID ' + store.getAt(rowIndex).id;
\r
268 constrainPosition : false,
\r
271 initComponent : function(){
\r
272 Ext.ToolTip.superclass.initComponent.call(this);
\r
273 this.lastActive = new Date();
\r
274 this.initTarget(this.target);
\r
275 this.origAnchor = this.anchor;
\r
279 onRender : function(ct, position){
\r
280 Ext.ToolTip.superclass.onRender.call(this, ct, position);
\r
281 this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();
\r
282 this.anchorEl = this.el.createChild({
\r
283 cls: 'x-tip-anchor ' + this.anchorCls
\r
288 afterRender : function(){
\r
289 Ext.ToolTip.superclass.afterRender.call(this);
\r
290 this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1);
\r
294 * Binds this ToolTip to the specified element. The tooltip will be displayed when the mouse moves over the element.
\r
295 * @param {Mixed} t The Element, HtmlElement, or ID of an element to bind to
\r
297 initTarget : function(target){
\r
299 if((t = Ext.get(target))){
\r
301 var tg = Ext.get(this.target);
\r
302 this.mun(tg, 'mouseover', this.onTargetOver, this);
\r
303 this.mun(tg, 'mouseout', this.onTargetOut, this);
\r
304 this.mun(tg, 'mousemove', this.onMouseMove, this);
\r
307 mouseover: this.onTargetOver,
\r
308 mouseout: this.onTargetOut,
\r
309 mousemove: this.onMouseMove,
\r
315 this.anchorTarget = this.target;
\r
320 onMouseMove : function(e){
\r
321 var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;
\r
323 this.targetXY = e.getXY();
\r
324 if (t === this.triggerElement) {
\r
325 if(!this.hidden && this.trackMouse){
\r
326 this.setPagePosition(this.getTargetXY());
\r
330 this.lastActive = new Date(0);
\r
331 this.onTargetOver(e);
\r
333 } else if (!this.closable && this.isVisible()) {
\r
339 getTargetXY : function(){
\r
341 this.anchorTarget = this.triggerElement;
\r
344 this.targetCounter++;
\r
345 var offsets = this.getOffsets();
\r
346 var xy = (this.anchorToTarget && !this.trackMouse) ?
\r
347 this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) :
\r
350 var dw = Ext.lib.Dom.getViewWidth()-5;
\r
351 var dh = Ext.lib.Dom.getViewHeight()-5;
\r
352 var scrollX = (document.documentElement.scrollLeft || document.body.scrollLeft || 0)+5;
\r
353 var scrollY = (document.documentElement.scrollTop || document.body.scrollTop || 0)+5;
\r
355 var axy = [xy[0] + offsets[0], xy[1] + offsets[1]];
\r
356 var 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
445 var offsets, ap = this.getAnchorPosition().charAt(0);
\r
446 if(this.anchorToTarget && !this.trackMouse){
\r
452 offsets = [0, -13];
\r
455 offsets = [-13, 0];
\r
464 offsets = [-15-this.anchorOffset, 30];
\r
467 offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];
\r
470 offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];
\r
473 offsets = [25, -13-this.anchorOffset];
\r
477 var mouseOffset = this.getMouseOffset();
\r
478 offsets[0] += mouseOffset[0];
\r
479 offsets[1] += mouseOffset[1];
\r
485 onTargetOver : function(e){
\r
486 if(this.disabled || e.within(this.target.dom, true)){
\r
489 var t = e.getTarget(this.delegate);
\r
491 this.triggerElement = t;
\r
492 this.clearTimer('hide');
\r
493 this.targetXY = e.getXY();
\r
499 delayShow : function(){
\r
500 if(this.hidden && !this.showTimer){
\r
501 if(this.lastActive.getElapsed() < this.quickShowInterval){
\r
504 this.showTimer = this.show.defer(this.showDelay, this);
\r
506 }else if(!this.hidden && this.autoHide !== false){
\r
512 onTargetOut : function(e){
\r
513 if(this.disabled || e.within(this.target.dom, true)){
\r
516 this.clearTimer('show');
\r
517 if(this.autoHide !== false){
\r
523 delayHide : function(){
\r
524 if(!this.hidden && !this.hideTimer){
\r
525 this.hideTimer = this.hide.defer(this.hideDelay, this);
\r
530 * Hides this tooltip if visible.
\r
533 this.clearTimer('dismiss');
\r
534 this.lastActive = new Date();
\r
536 this.anchorEl.hide();
\r
538 Ext.ToolTip.superclass.hide.call(this);
\r
539 delete this.triggerElement;
\r
543 * Shows this tooltip at the current event target XY position.
\r
547 // pre-show it off screen so that the el will have dimensions
\r
548 // for positioning calcs when getting xy next
\r
549 this.showAt([-1000,-1000]);
\r
550 this.origConstrainPosition = this.constrainPosition;
\r
551 this.constrainPosition = false;
\r
552 this.anchor = this.origAnchor;
\r
554 this.showAt(this.getTargetXY());
\r
558 this.anchorEl.show();
\r
559 this.constrainPosition = this.origConstrainPosition;
\r
561 this.anchorEl.hide();
\r
566 showAt : function(xy){
\r
567 this.lastActive = new Date();
\r
568 this.clearTimers();
\r
569 Ext.ToolTip.superclass.showAt.call(this, xy);
\r
570 if(this.dismissDelay && this.autoHide !== false){
\r
571 this.dismissTimer = this.hide.defer(this.dismissDelay, this);
\r
573 if(this.anchor && !this.anchorEl.isVisible()){
\r
575 this.anchorEl.show();
\r
580 syncAnchor : function(){
\r
581 var anchorPos, targetPos, offset;
\r
582 switch(this.tipAnchor.charAt(0)){
\r
586 offset = [20+this.anchorOffset, 2];
\r
591 offset = [-2, 11+this.anchorOffset];
\r
596 offset = [20+this.anchorOffset, -2];
\r
601 offset = [2, 11+this.anchorOffset];
\r
604 this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);
\r
608 setPagePosition : function(x, y){
\r
609 Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
\r
616 clearTimer : function(name){
\r
617 name = name + 'Timer';
\r
618 clearTimeout(this[name]);
\r
623 clearTimers : function(){
\r
624 this.clearTimer('show');
\r
625 this.clearTimer('dismiss');
\r
626 this.clearTimer('hide');
\r
630 onShow : function(){
\r
631 Ext.ToolTip.superclass.onShow.call(this);
\r
632 Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
\r
636 onHide : function(){
\r
637 Ext.ToolTip.superclass.onHide.call(this);
\r
638 Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
\r
642 onDocMouseDown : function(e){
\r
643 if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){
\r
645 this.enable.defer(100, this);
\r
650 onDisable : function(){
\r
651 this.clearTimers();
\r
656 adjustPosition : function(x, y){
\r
657 if(this.contstrainPosition){
\r
658 var ay = this.targetXY[1], h = this.getSize().height;
\r
659 if(y <= ay && (y+h) >= ay){
\r
663 return {x : x, y: y};
\r
667 onDestroy : function(){
\r
668 Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
\r
669 Ext.ToolTip.superclass.onDestroy.call(this);
\r
673 Ext.reg('tooltip', Ext.ToolTip);/**
\r
674 * @class Ext.QuickTip
\r
675 * @extends Ext.ToolTip
\r
677 * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
\r
678 * {@link Ext.QuickTips} instance. See the QuickTips class header for additional usage details and examples.
\r
681 * @param {Object} config The configuration options
\r
683 Ext.QuickTip = Ext.extend(Ext.ToolTip, {
\r
685 * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this quicktip (defaults to the document).
\r
688 * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
\r
690 interceptTitles : false,
\r
695 attribute : "qtip",
\r
706 initComponent : function(){
\r
707 this.target = this.target || Ext.getDoc();
\r
708 this.targets = this.targets || {};
\r
709 Ext.QuickTip.superclass.initComponent.call(this);
\r
713 * Configures a new quick tip instance and assigns it to a target element. The following config values are
\r
714 * supported (for example usage, see the {@link Ext.QuickTips} class header):
\r
715 * <div class="mdetail-params"><ul>
\r
716 * <li>autoHide</li>
\r
718 * <li>dismissDelay (overrides the singleton value)</li>
\r
719 * <li>target (required)</li>
\r
720 * <li>text (required)</li>
\r
722 * <li>width</li></ul></div>
\r
723 * @param {Object} config The config object
\r
725 register : function(config){
\r
726 var cs = Ext.isArray(config) ? config : arguments;
\r
727 for(var i = 0, len = cs.length; i < len; i++){
\r
729 var target = c.target;
\r
731 if(Ext.isArray(target)){
\r
732 for(var j = 0, jlen = target.length; j < jlen; j++){
\r
733 this.targets[Ext.id(target[j])] = c;
\r
736 this.targets[Ext.id(target)] = c;
\r
743 * Removes this quick tip from its element and destroys it.
\r
744 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
\r
746 unregister : function(el){
\r
747 delete this.targets[Ext.id(el)];
\r
751 * Hides a visible tip or cancels an impending show for a particular element.
\r
752 * @param {String/HTMLElement/Element} el The element that is the target of the tip.
\r
754 cancelShow: function(el){
\r
755 var at = this.activeTarget;
\r
756 el = Ext.get(el).dom;
\r
757 if(this.isVisible()){
\r
758 if(at && at.el == el){
\r
761 }else if(at && at.el == el){
\r
762 this.clearTimer('show');
\r
767 getTipCfg: function(e) {
\r
768 var t = e.getTarget(),
\r
771 if(this.interceptTitles && t.title){
\r
774 t.removeAttribute("title");
\r
775 e.preventDefault();
\r
777 cfg = this.tagConfig;
\r
778 ttp = t.qtip || Ext.fly(t).getAttribute(cfg.attribute, cfg.namespace);
\r
784 onTargetOver : function(e){
\r
788 this.targetXY = e.getXY();
\r
789 var t = e.getTarget();
\r
790 if(!t || t.nodeType !== 1 || t == document || t == document.body){
\r
793 if(this.activeTarget && ((t == this.activeTarget.el) || Ext.fly(this.activeTarget.el).contains(t))){
\r
794 this.clearTimer('hide');
\r
798 if(t && this.targets[t.id]){
\r
799 this.activeTarget = this.targets[t.id];
\r
800 this.activeTarget.el = t;
\r
801 this.anchor = this.activeTarget.anchor;
\r
803 this.anchorTarget = t;
\r
808 var ttp, et = Ext.fly(t), cfg = this.tagConfig, ns = cfg.namespace;
\r
809 if(ttp = this.getTipCfg(e)){
\r
810 var autoHide = et.getAttribute(cfg.hide, ns);
\r
811 this.activeTarget = {
\r
814 width: et.getAttribute(cfg.width, ns),
\r
815 autoHide: autoHide != "user" && autoHide !== 'false',
\r
816 title: et.getAttribute(cfg.title, ns),
\r
817 cls: et.getAttribute(cfg.cls, ns),
\r
818 align: et.getAttribute(cfg.align, ns)
\r
821 this.anchor = et.getAttribute(cfg.anchor, ns);
\r
823 this.anchorTarget = t;
\r
830 onTargetOut : function(e){
\r
832 // If moving within the current target, and it does not have a new tip, ignore the mouseout
\r
833 if (this.activeTarget && e.within(this.activeTarget.el) && !this.getTipCfg(e)) {
\r
837 this.clearTimer('show');
\r
838 if(this.autoHide !== false){
\r
844 showAt : function(xy){
\r
845 var t = this.activeTarget;
\r
847 if(!this.rendered){
\r
848 this.render(Ext.getBody());
\r
849 this.activeTarget = t;
\r
852 this.setWidth(t.width);
\r
853 this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
\r
854 this.measureWidth = false;
\r
856 this.measureWidth = true;
\r
858 this.setTitle(t.title || '');
\r
859 this.body.update(t.text);
\r
860 this.autoHide = t.autoHide;
\r
861 this.dismissDelay = t.dismissDelay || this.dismissDelay;
\r
863 this.el.removeClass(this.lastCls);
\r
864 delete this.lastCls;
\r
867 this.el.addClass(t.cls);
\r
868 this.lastCls = t.cls;
\r
871 this.constrainPosition = false;
\r
872 }else if(t.align){ // TODO: this doesn't seem to work consistently
\r
873 xy = this.el.getAlignToXY(t.el, t.align);
\r
874 this.constrainPosition = false;
\r
876 this.constrainPosition = true;
\r
879 Ext.QuickTip.superclass.showAt.call(this, xy);
\r
884 delete this.activeTarget;
\r
885 Ext.QuickTip.superclass.hide.call(this);
\r
888 Ext.reg('quicktip', Ext.QuickTip);/**
\r
889 * @class Ext.QuickTips
\r
890 * <p>Provides attractive and customizable tooltips for any element. The QuickTips
\r
891 * singleton is used to configure and manage tooltips globally for multiple elements
\r
892 * in a generic manner. To create individual tooltips with maximum customizability,
\r
893 * you should consider either {@link Ext.Tip} or {@link Ext.ToolTip}.</p>
\r
894 * <p>Quicktips can be configured via tag attributes directly in markup, or by
\r
895 * registering quick tips programmatically via the {@link #register} method.</p>
\r
896 * <p>The singleton's instance of {@link Ext.QuickTip} is available via
\r
897 * {@link #getQuickTip}, and supports all the methods, and all the all the
\r
898 * configuration properties of Ext.QuickTip. These settings will apply to all
\r
899 * tooltips shown by the singleton.</p>
\r
900 * <p>Below is the summary of the configuration properties which can be used.
\r
901 * For detailed descriptions see {@link #getQuickTip}</p>
\r
902 * <p><b>QuickTips singleton configs (all are optional)</b></p>
\r
903 * <div class="mdetail-params"><ul><li>dismissDelay</li>
\r
904 * <li>hideDelay</li>
\r
905 * <li>maxWidth</li>
\r
906 * <li>minWidth</li>
\r
907 * <li>showDelay</li>
\r
908 * <li>trackMouse</li></ul></div>
\r
909 * <p><b>Target element configs (optional unless otherwise noted)</b></p>
\r
910 * <div class="mdetail-params"><ul><li>autoHide</li>
\r
912 * <li>dismissDelay (overrides singleton value)</li>
\r
913 * <li>target (required)</li>
\r
914 * <li>text (required)</li>
\r
916 * <li>width</li></ul></div>
\r
917 * <p>Here is an example showing how some of these config options could be used:</p>
\r
919 // Init the singleton. Any tag-based quick tips will start working.
\r
920 Ext.QuickTips.init();
\r
922 // Apply a set of config properties to the singleton
\r
923 Ext.apply(Ext.QuickTips.getQuickTip(), {
\r
930 // Manually register a quick tip for a specific element
\r
931 Ext.QuickTips.register({
\r
933 title: 'My Tooltip',
\r
934 text: 'This tooltip was added in code',
\r
939 * <p>To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with
\r
940 * the <b>ext:</b> namespace. The HTML element itself is automatically set as the quick tip target. Here is the summary
\r
941 * of supported attributes (optional unless otherwise noted):</p>
\r
942 * <ul><li><b>hide</b>: Specifying "user" is equivalent to setting autoHide = false. Any other value will be the
\r
943 * same as autoHide = true.</li>
\r
944 * <li><b>qclass</b>: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).</li>
\r
945 * <li><b>qtip (required)</b>: The quick tip text (equivalent to the 'text' target element config).</li>
\r
946 * <li><b>qtitle</b>: The quick tip title (equivalent to the 'title' target element config).</li>
\r
947 * <li><b>qwidth</b>: The quick tip width (equivalent to the 'width' target element config).</li></ul>
\r
948 * <p>Here is an example of configuring an HTML element to display a tooltip from markup:</p>
\r
950 // Add a quick tip to an HTML button
\r
951 <input type="button" value="OK" ext:qtitle="OK Button" ext:qwidth="100"
\r
952 ext:qtip="This is a quick tip from markup!"></input>
\r
956 Ext.QuickTips = function(){
\r
957 var tip, locks = [];
\r
960 * Initialize the global QuickTips instance and prepare any quick tips.
\r
961 * @param {Boolean} autoRender True to render the QuickTips container immediately to preload images. (Defaults to true)
\r
963 init : function(autoRender){
\r
966 Ext.onReady(function(){
\r
967 Ext.QuickTips.init(autoRender);
\r
971 tip = new Ext.QuickTip({elements:'header,body'});
\r
972 if(autoRender !== false){
\r
973 tip.render(Ext.getBody());
\r
979 * Enable quick tips globally.
\r
981 enable : function(){
\r
984 if(locks.length < 1){
\r
991 * Disable quick tips globally.
\r
993 disable : function(){
\r
1001 * Returns true if quick tips are enabled, else false.
\r
1002 * @return {Boolean}
\r
1004 isEnabled : function(){
\r
1005 return tip !== undefined && !tip.disabled;
\r
1009 * Gets the global QuickTips instance.
\r
1011 getQuickTip : function(){
\r
1016 * Configures a new quick tip instance and assigns it to a target element. See
\r
1017 * {@link Ext.QuickTip#register} for details.
\r
1018 * @param {Object} config The config object
\r
1020 register : function(){
\r
1021 tip.register.apply(tip, arguments);
\r
1025 * Removes any registered quick tip from the target element and destroys it.
\r
1026 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
\r
1028 unregister : function(){
\r
1029 tip.unregister.apply(tip, arguments);
\r
1033 * Alias of {@link #register}.
\r
1034 * @param {Object} config The config object
\r
1037 tip.register.apply(tip, arguments);
\r