3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.QuickTip"></div>/**
\r
9 * @class Ext.QuickTip
\r
10 * @extends Ext.ToolTip
\r
11 * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
\r
12 * {@link Ext.QuickTips} instance. See the QuickTips class header for additional usage details and examples.
\r
15 * @param {Object} config The configuration options
\r
17 Ext.QuickTip = Ext.extend(Ext.ToolTip, {
\r
18 <div id="cfg-Ext.QuickTip-target"></div>/**
\r
19 * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this quicktip (defaults to the document).
\r
21 <div id="cfg-Ext.QuickTip-interceptTitles"></div>/**
\r
22 * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
\r
24 interceptTitles : false,
\r
40 initComponent : function(){
\r
41 this.target = this.target || Ext.getDoc();
\r
42 this.targets = this.targets || {};
\r
43 Ext.QuickTip.superclass.initComponent.call(this);
\r
46 <div id="method-Ext.QuickTip-register"></div>/**
\r
47 * Configures a new quick tip instance and assigns it to a target element. The following config values are
\r
48 * supported (for example usage, see the {@link Ext.QuickTips} class header):
\r
49 * <div class="mdetail-params"><ul>
\r
52 * <li>dismissDelay (overrides the singleton value)</li>
\r
53 * <li>target (required)</li>
\r
54 * <li>text (required)</li>
\r
56 * <li>width</li></ul></div>
\r
57 * @param {Object} config The config object
\r
59 register : function(config){
\r
60 var cs = Ext.isArray(config) ? config : arguments;
\r
61 for(var i = 0, len = cs.length; i < len; i++){
\r
63 var target = c.target;
\r
65 if(Ext.isArray(target)){
\r
66 for(var j = 0, jlen = target.length; j < jlen; j++){
\r
67 this.targets[Ext.id(target[j])] = c;
\r
70 this.targets[Ext.id(target)] = c;
\r
76 <div id="method-Ext.QuickTip-unregister"></div>/**
\r
77 * Removes this quick tip from its element and destroys it.
\r
78 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
\r
80 unregister : function(el){
\r
81 delete this.targets[Ext.id(el)];
\r
84 <div id="method-Ext.QuickTip-cancelShow"></div>/**
\r
85 * Hides a visible tip or cancels an impending show for a particular element.
\r
86 * @param {String/HTMLElement/Element} el The element that is the target of the tip.
\r
88 cancelShow: function(el){
\r
89 var at = this.activeTarget;
\r
90 el = Ext.get(el).dom;
\r
91 if(this.isVisible()){
\r
92 if(at && at.el == el){
\r
95 }else if(at && at.el == el){
\r
96 this.clearTimer('show');
\r
101 onTargetOver : function(e){
\r
105 this.targetXY = e.getXY();
\r
106 var t = e.getTarget();
\r
107 if(!t || t.nodeType !== 1 || t == document || t == document.body){
\r
110 if(this.activeTarget && t == this.activeTarget.el){
\r
111 this.clearTimer('hide');
\r
115 if(t && this.targets[t.id]){
\r
116 this.activeTarget = this.targets[t.id];
\r
117 this.activeTarget.el = t;
\r
118 this.anchor = this.activeTarget.anchor;
\r
120 this.anchorTarget = t;
\r
126 var ttp, et = Ext.fly(t), cfg = this.tagConfig;
\r
127 var ns = cfg.namespace;
\r
128 if(this.interceptTitles && t.title){
\r
131 t.removeAttribute("title");
\r
132 e.preventDefault();
\r
134 ttp = t.qtip || et.getAttribute(cfg.attribute, ns);
\r
137 var autoHide = et.getAttribute(cfg.hide, ns);
\r
138 this.activeTarget = {
\r
141 width: et.getAttribute(cfg.width, ns),
\r
142 autoHide: autoHide != "user" && autoHide !== 'false',
\r
143 title: et.getAttribute(cfg.title, ns),
\r
144 cls: et.getAttribute(cfg.cls, ns),
\r
145 align: et.getAttribute(cfg.align, ns)
\r
148 this.anchor = et.getAttribute(cfg.anchor, ns);
\r
150 this.anchorTarget = t;
\r
157 onTargetOut : function(e){
\r
158 this.clearTimer('show');
\r
159 if(this.autoHide !== false){
\r
165 showAt : function(xy){
\r
166 var t = this.activeTarget;
\r
168 if(!this.rendered){
\r
169 this.render(Ext.getBody());
\r
170 this.activeTarget = t;
\r
173 this.setWidth(t.width);
\r
174 this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
\r
175 this.measureWidth = false;
\r
177 this.measureWidth = true;
\r
179 this.setTitle(t.title || '');
\r
180 this.body.update(t.text);
\r
181 this.autoHide = t.autoHide;
\r
182 this.dismissDelay = t.dismissDelay || this.dismissDelay;
\r
184 this.el.removeClass(this.lastCls);
\r
185 delete this.lastCls;
\r
188 this.el.addClass(t.cls);
\r
189 this.lastCls = t.cls;
\r
192 this.constrainPosition = false;
\r
193 }else if(t.align){ // TODO: this doesn't seem to work consistently
\r
194 xy = this.el.getAlignToXY(t.el, t.align);
\r
195 this.constrainPosition = false;
\r
197 this.constrainPosition = true;
\r
200 Ext.QuickTip.superclass.showAt.call(this, xy);
\r
205 delete this.activeTarget;
\r
206 Ext.QuickTip.superclass.hide.call(this);
\r