1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-tip.QuickTip-method-constructor'><span id='Ext-tip.QuickTip'>/**
2 </span></span> * @class Ext.tip.QuickTip
3 * @extends Ext.tip.ToolTip
4 * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
5 * {@link Ext.tip.QuickTipManager} instance. See the QuickTipManager class header for additional usage details and examples.
8 * @param {Object} config The configuration options
11 Ext.define('Ext.tip.QuickTip', {
12 extend: 'Ext.tip.ToolTip',
13 alternateClassName: 'Ext.QuickTip',
14 <span id='Ext-tip.QuickTip-cfg-target'> /**
15 </span> * @cfg {Mixed} target The target HTMLElement, Ext.core.Element or id to associate with this Quicktip (defaults to the document).
17 <span id='Ext-tip.QuickTip-cfg-interceptTitles'> /**
18 </span> * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
20 interceptTitles : false,
22 // Force creation of header Component
27 namespace : "data-",
28 attribute : "qtip",
29 width : "qwidth",
30 target : "target",
31 title : "qtitle",
32 hide : "hide",
33 cls : "qclass",
34 align : "qalign",
35 anchor : "anchor"
39 initComponent : function(){
42 me.target = me.target || Ext.getDoc();
43 me.targets = me.targets || {};
47 <span id='Ext-tip.QuickTip-method-register'> /**
48 </span> * Configures a new quick tip instance and assigns it to a target element. The following config values are
49 * supported (for example usage, see the {@link Ext.tip.QuickTipManager} class header):
50 * <div class="mdetail-params"><ul>
51 * <li>autoHide</li>
52 * <li>cls</li>
53 * <li>dismissDelay (overrides the singleton value)</li>
54 * <li>target (required)</li>
55 * <li>text (required)</li>
56 * <li>title</li>
57 * <li>width</li></ul></div>
58 * @param {Object} config The config object
60 register : function(config){
61 var configs = Ext.isArray(config) ? config : arguments,
66 for (; i < len; i++) {
68 target = config.target;
70 if (Ext.isArray(target)) {
71 for (j = 0, targetLen = target.length; j < targetLen; j++) {
72 this.targets[Ext.id(target[j])] = config;
75 this.targets[Ext.id(target)] = config;
81 <span id='Ext-tip.QuickTip-method-unregister'> /**
82 </span> * Removes this quick tip from its element and destroys it.
83 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
85 unregister : function(el){
86 delete this.targets[Ext.id(el)];
89 <span id='Ext-tip.QuickTip-method-cancelShow'> /**
90 </span> * Hides a visible tip or cancels an impending show for a particular element.
91 * @param {String/HTMLElement/Element} el The element that is the target of the tip.
93 cancelShow: function(el){
95 activeTarget = me.activeTarget;
99 if (activeTarget && activeTarget.el == el) {
102 } else if (activeTarget && activeTarget.el == el) {
103 me.clearTimer('show');
107 getTipCfg: function(e) {
108 var t = e.getTarget(),
112 if(this.interceptTitles && t.title && Ext.isString(t.title)){
115 t.removeAttribute("title");
119 cfg = this.tagConfig;
120 t = e.getTarget('[' + cfg.namespace + cfg.attribute + ']');
122 ttp = t.getAttribute(cfg.namespace + cfg.attribute);
129 onTargetOver : function(e){
131 target = e.getTarget(),
142 // TODO - this causes "e" to be recycled in IE6/7 (EXTJSIV-1608) so ToolTip#setTarget
143 // was changed to include freezeEvent. The issue seems to be a nested 'resize' event
144 // that smashed Ext.EventObject.
145 me.targetXY = e.getXY();
147 if(!target || target.nodeType !== 1 || target == document || target == document.body){
151 if (me.activeTarget && ((target == me.activeTarget.el) || Ext.fly(me.activeTarget.el).contains(target))) {
152 me.clearTimer('hide');
158 Ext.Object.each(me.targets, function(key, value) {
159 var targetEl = Ext.fly(value.target);
160 if (targetEl && (targetEl.dom === target || targetEl.contains(target))) {
161 elTarget = targetEl.dom;
166 me.activeTarget = me.targets[elTarget.id];
167 me.activeTarget.el = target;
168 me.anchor = me.activeTarget.anchor;
170 me.anchorTarget = target;
177 elTarget = Ext.get(target);
180 ttp = me.getTipCfg(e);
183 autoHide = elTarget.getAttribute(ns + cfg.hide);
188 width: +elTarget.getAttribute(ns + cfg.width) || null,
189 autoHide: autoHide != "user" && autoHide !== 'false',
190 title: elTarget.getAttribute(ns + cfg.title),
191 cls: elTarget.getAttribute(ns + cfg.cls),
192 align: elTarget.getAttribute(ns + cfg.align)
195 me.anchor = elTarget.getAttribute(ns + cfg.anchor);
197 me.anchorTarget = target;
204 onTargetOut : function(e){
207 // If moving within the current target, and it does not have a new tip, ignore the mouseout
208 if (me.activeTarget && e.within(me.activeTarget.el) && !me.getTipCfg(e)) {
212 me.clearTimer('show');
213 if (me.autoHide !== false) {
219 showAt : function(xy){
221 target = me.activeTarget;
225 me.render(Ext.getBody());
226 me.activeTarget = target;
229 me.setTitle(target.title || '');
234 me.body.update(target.text);
235 me.autoHide = target.autoHide;
236 me.dismissDelay = target.dismissDelay || me.dismissDelay;
238 me.el.removeCls(me.lastCls);
242 me.el.addCls(target.cls);
243 me.lastCls = target.cls;
246 me.setWidth(target.width);
249 me.constrainPosition = false;
250 } else if (target.align) { // TODO: this doesn't seem to work consistently
251 xy = me.el.getAlignToXY(target.el, target.align);
252 me.constrainPosition = false;
254 me.constrainPosition = true;
262 delete this.activeTarget;
266 </pre></pre></body></html>