3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.QuickTip"></div>/**
\r
15 * @class Ext.QuickTip
\r
16 * @extends Ext.ToolTip
\r
18 * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
\r
19 * {@link Ext.QuickTips} instance. See the QuickTips class header for additional usage details and examples.
\r
22 * @param {Object} config The configuration options
\r
24 Ext.QuickTip = Ext.extend(Ext.ToolTip, {
\r
25 <div id="cfg-Ext.QuickTip-target"></div>/**
\r
26 * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this quicktip (defaults to the document).
\r
28 <div id="cfg-Ext.QuickTip-interceptTitles"></div>/**
\r
29 * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
\r
31 interceptTitles : false,
\r
47 initComponent : function(){
\r
48 this.target = this.target || Ext.getDoc();
\r
49 this.targets = this.targets || {};
\r
50 Ext.QuickTip.superclass.initComponent.call(this);
\r
53 <div id="method-Ext.QuickTip-register"></div>/**
\r
54 * Configures a new quick tip instance and assigns it to a target element. The following config values are
\r
55 * supported (for example usage, see the {@link Ext.QuickTips} class header):
\r
56 * <div class="mdetail-params"><ul>
\r
59 * <li>dismissDelay (overrides the singleton value)</li>
\r
60 * <li>target (required)</li>
\r
61 * <li>text (required)</li>
\r
63 * <li>width</li></ul></div>
\r
64 * @param {Object} config The config object
\r
66 register : function(config){
\r
67 var cs = Ext.isArray(config) ? config : arguments;
\r
68 for(var i = 0, len = cs.length; i < len; i++){
\r
70 var target = c.target;
\r
72 if(Ext.isArray(target)){
\r
73 for(var j = 0, jlen = target.length; j < jlen; j++){
\r
74 this.targets[Ext.id(target[j])] = c;
\r
77 this.targets[Ext.id(target)] = c;
\r
83 <div id="method-Ext.QuickTip-unregister"></div>/**
\r
84 * Removes this quick tip from its element and destroys it.
\r
85 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
\r
87 unregister : function(el){
\r
88 delete this.targets[Ext.id(el)];
\r
91 <div id="method-Ext.QuickTip-cancelShow"></div>/**
\r
92 * Hides a visible tip or cancels an impending show for a particular element.
\r
93 * @param {String/HTMLElement/Element} el The element that is the target of the tip.
\r
95 cancelShow: function(el){
\r
96 var at = this.activeTarget;
\r
97 el = Ext.get(el).dom;
\r
98 if(this.isVisible()){
\r
99 if(at && at.el == el){
\r
102 }else if(at && at.el == el){
\r
103 this.clearTimer('show');
\r
108 getTipCfg: function(e) {
\r
109 var t = e.getTarget(),
\r
112 if(this.interceptTitles && t.title){
\r
115 t.removeAttribute("title");
\r
116 e.preventDefault();
\r
118 cfg = this.tagConfig;
\r
119 ttp = t.qtip || Ext.fly(t).getAttribute(cfg.attribute, cfg.namespace);
\r
125 onTargetOver : function(e){
\r
129 this.targetXY = e.getXY();
\r
130 var t = e.getTarget();
\r
131 if(!t || t.nodeType !== 1 || t == document || t == document.body){
\r
134 if(this.activeTarget && ((t == this.activeTarget.el) || Ext.fly(this.activeTarget.el).contains(t))){
\r
135 this.clearTimer('hide');
\r
139 if(t && this.targets[t.id]){
\r
140 this.activeTarget = this.targets[t.id];
\r
141 this.activeTarget.el = t;
\r
142 this.anchor = this.activeTarget.anchor;
\r
144 this.anchorTarget = t;
\r
149 var ttp, et = Ext.fly(t), cfg = this.tagConfig, ns = cfg.namespace;
\r
150 if(ttp = this.getTipCfg(e)){
\r
151 var autoHide = et.getAttribute(cfg.hide, ns);
\r
152 this.activeTarget = {
\r
155 width: et.getAttribute(cfg.width, ns),
\r
156 autoHide: autoHide != "user" && autoHide !== 'false',
\r
157 title: et.getAttribute(cfg.title, ns),
\r
158 cls: et.getAttribute(cfg.cls, ns),
\r
159 align: et.getAttribute(cfg.align, ns)
\r
162 this.anchor = et.getAttribute(cfg.anchor, ns);
\r
164 this.anchorTarget = t;
\r
171 onTargetOut : function(e){
\r
173 // If moving within the current target, and it does not have a new tip, ignore the mouseout
\r
174 if (this.activeTarget && e.within(this.activeTarget.el) && !this.getTipCfg(e)) {
\r
178 this.clearTimer('show');
\r
179 if(this.autoHide !== false){
\r
185 showAt : function(xy){
\r
186 var t = this.activeTarget;
\r
188 if(!this.rendered){
\r
189 this.render(Ext.getBody());
\r
190 this.activeTarget = t;
\r
193 this.setWidth(t.width);
\r
194 this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
\r
195 this.measureWidth = false;
\r
197 this.measureWidth = true;
\r
199 this.setTitle(t.title || '');
\r
200 this.body.update(t.text);
\r
201 this.autoHide = t.autoHide;
\r
202 this.dismissDelay = t.dismissDelay || this.dismissDelay;
\r
204 this.el.removeClass(this.lastCls);
\r
205 delete this.lastCls;
\r
208 this.el.addClass(t.cls);
\r
209 this.lastCls = t.cls;
\r
212 this.constrainPosition = false;
\r
213 }else if(t.align){ // TODO: this doesn't seem to work consistently
\r
214 xy = this.el.getAlignToXY(t.el, t.align);
\r
215 this.constrainPosition = false;
\r
217 this.constrainPosition = true;
\r
220 Ext.QuickTip.superclass.showAt.call(this, xy);
\r
225 delete this.activeTarget;
\r
226 Ext.QuickTip.superclass.hide.call(this);
\r
229 Ext.reg('quicktip', Ext.QuickTip);</pre>