4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-tip-QuickTip-method-constructor'><span id='Ext-tip-QuickTip'>/**
19 </span></span> * @class Ext.tip.QuickTip
20 * @extends Ext.tip.ToolTip
21 * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global
22 * {@link Ext.tip.QuickTipManager} instance. See the QuickTipManager class header for additional usage details and examples.
25 * @param {Object} config The configuration options
28 Ext.define('Ext.tip.QuickTip', {
29 extend: 'Ext.tip.ToolTip',
30 alternateClassName: 'Ext.QuickTip',
31 <span id='Ext-tip-QuickTip-cfg-target'> /**
32 </span> * @cfg {Mixed} target The target HTMLElement, Ext.core.Element or id to associate with this Quicktip (defaults to the document).
34 <span id='Ext-tip-QuickTip-cfg-interceptTitles'> /**
35 </span> * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).
37 interceptTitles : false,
39 // Force creation of header Component
44 namespace : "data-",
45 attribute : "qtip",
46 width : "qwidth",
47 target : "target",
48 title : "qtitle",
49 hide : "hide",
50 cls : "qclass",
51 align : "qalign",
52 anchor : "anchor"
56 initComponent : function(){
59 me.target = me.target || Ext.getDoc();
60 me.targets = me.targets || {};
64 <span id='Ext-tip-QuickTip-method-register'> /**
65 </span> * Configures a new quick tip instance and assigns it to a target element. The following config values are
66 * supported (for example usage, see the {@link Ext.tip.QuickTipManager} class header):
67 * <div class="mdetail-params"><ul>
68 * <li>autoHide</li>
69 * <li>cls</li>
70 * <li>dismissDelay (overrides the singleton value)</li>
71 * <li>target (required)</li>
72 * <li>text (required)</li>
73 * <li>title</li>
74 * <li>width</li></ul></div>
75 * @param {Object} config The config object
77 register : function(config){
78 var configs = Ext.isArray(config) ? config : arguments,
83 for (; i < len; i++) {
85 target = config.target;
87 if (Ext.isArray(target)) {
88 for (j = 0, targetLen = target.length; j < targetLen; j++) {
89 this.targets[Ext.id(target[j])] = config;
92 this.targets[Ext.id(target)] = config;
98 <span id='Ext-tip-QuickTip-method-unregister'> /**
99 </span> * Removes this quick tip from its element and destroys it.
100 * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.
102 unregister : function(el){
103 delete this.targets[Ext.id(el)];
106 <span id='Ext-tip-QuickTip-method-cancelShow'> /**
107 </span> * Hides a visible tip or cancels an impending show for a particular element.
108 * @param {String/HTMLElement/Element} el The element that is the target of the tip.
110 cancelShow: function(el){
112 activeTarget = me.activeTarget;
114 el = Ext.get(el).dom;
115 if (me.isVisible()) {
116 if (activeTarget && activeTarget.el == el) {
119 } else if (activeTarget && activeTarget.el == el) {
120 me.clearTimer('show');
124 getTipCfg: function(e) {
125 var t = e.getTarget(),
129 if(this.interceptTitles && t.title && Ext.isString(t.title)){
132 t.removeAttribute("title");
136 cfg = this.tagConfig;
137 t = e.getTarget('[' + cfg.namespace + cfg.attribute + ']');
139 ttp = t.getAttribute(cfg.namespace + cfg.attribute);
146 onTargetOver : function(e){
148 target = e.getTarget(),
159 // TODO - this causes "e" to be recycled in IE6/7 (EXTJSIV-1608) so ToolTip#setTarget
160 // was changed to include freezeEvent. The issue seems to be a nested 'resize' event
161 // that smashed Ext.EventObject.
162 me.targetXY = e.getXY();
164 if(!target || target.nodeType !== 1 || target == document || target == document.body){
168 if (me.activeTarget && ((target == me.activeTarget.el) || Ext.fly(me.activeTarget.el).contains(target))) {
169 me.clearTimer('hide');
175 Ext.Object.each(me.targets, function(key, value) {
176 var targetEl = Ext.fly(value.target);
177 if (targetEl && (targetEl.dom === target || targetEl.contains(target))) {
178 elTarget = targetEl.dom;
183 me.activeTarget = me.targets[elTarget.id];
184 me.activeTarget.el = target;
185 me.anchor = me.activeTarget.anchor;
187 me.anchorTarget = target;
194 elTarget = Ext.get(target);
197 ttp = me.getTipCfg(e);
200 autoHide = elTarget.getAttribute(ns + cfg.hide);
205 width: +elTarget.getAttribute(ns + cfg.width) || null,
206 autoHide: autoHide != "user" && autoHide !== 'false',
207 title: elTarget.getAttribute(ns + cfg.title),
208 cls: elTarget.getAttribute(ns + cfg.cls),
209 align: elTarget.getAttribute(ns + cfg.align)
212 me.anchor = elTarget.getAttribute(ns + cfg.anchor);
214 me.anchorTarget = target;
221 onTargetOut : function(e){
224 // If moving within the current target, and it does not have a new tip, ignore the mouseout
225 if (me.activeTarget && e.within(me.activeTarget.el) && !me.getTipCfg(e)) {
229 me.clearTimer('show');
230 if (me.autoHide !== false) {
236 showAt : function(xy){
238 target = me.activeTarget;
242 me.render(Ext.getBody());
243 me.activeTarget = target;
246 me.setTitle(target.title || '');
251 me.body.update(target.text);
252 me.autoHide = target.autoHide;
253 me.dismissDelay = target.dismissDelay || me.dismissDelay;
255 me.el.removeCls(me.lastCls);
259 me.el.addCls(target.cls);
260 me.lastCls = target.cls;
263 me.setWidth(target.width);
266 me.constrainPosition = false;
267 } else if (target.align) { // TODO: this doesn't seem to work consistently
268 xy = me.el.getAlignToXY(target.el, target.align);
269 me.constrainPosition = false;
271 me.constrainPosition = true;
279 delete this.activeTarget;